Skip to content
Snippets Groups Projects
Commit 10c4bb5a authored by Susan Yuen's avatar Susan Yuen
Browse files

Merged animation branch

parents 9e4570ea 2bd80e26
No related branches found
No related tags found
No related merge requests found
Showing
with 119 additions and 36 deletions
......@@ -111,6 +111,7 @@
<Content Include="GameThumbnail.png">
<XnaPlatformSpecific>true</XnaPlatformSpecific>
</Content>
<None Include="Resources\warrior.png" />
<None Include="Resources\Warrior_Info.png" />
<None Include="Resources\warrior_stats.png" />
<None Include="Resources\Game_Map.jpg" />
......
......@@ -8,7 +8,8 @@ Content\items.xnb
Content\move.xnb
Content\wait.xnb
Content\warrior_art.xnb
Content\PixelFont.xnb
Content\warrior_stats.xnb
Content\Warrior_Info.xnb
Content\PixelFont.xnb
Content\PixelFontLarge.xnb
Content\warrior.xnb
......@@ -194,9 +194,14 @@ namespace Controller
// draws units for player 1
for (int i = 0; i < player1.getNumOfUnits(); i++)
{
<<<<<<< HEAD
Unit unit = player1.getUnits().ElementAt(i); // gets unit at i
spriteBatch.Draw(unit.getSpriteImage(), unit.getPixelCoordinates(),
null, Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.8f); // redraws char sprite
=======
Unit unit = player1.getUnits().ElementAt(i); //gets unit at i
spriteBatch.Draw(unit.getSpriteImage(), unit.getPixelCoordinates(), unit.getCurrentFrame(), Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.8f); // redraws char sprite
>>>>>>> origin/Animation
}
#endregion
......@@ -300,7 +305,7 @@ namespace Controller
if (unitType == UnitType.Warrior)
{
return new Warrior(Content.Load<Texture2D>("charSprite"), attackButton, moveButton,
return new Warrior(Content.Load<Texture2D>("warrior"), attackButton, moveButton,
itemButton, waitButton, Content.Load<Texture2D>("warrior_Info"), unitPosition);
}
return null;
......
......@@ -31,7 +31,6 @@
this.Start = new System.Windows.Forms.Button();
this.Instructions = new System.Windows.Forms.Button();
this.Exit = new System.Windows.Forms.Button();
this.titleLabel = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// Start
......@@ -41,6 +40,7 @@
this.Start.FlatAppearance.BorderSize = 0;
this.Start.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.Start.Font = new System.Drawing.Font("Lucida Console", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Start.ForeColor = System.Drawing.Color.White;
this.Start.Location = new System.Drawing.Point(264, 253);
this.Start.Name = "Start";
this.Start.Size = new System.Drawing.Size(168, 44);
......@@ -57,7 +57,7 @@
this.Instructions.FlatAppearance.BorderSize = 0;
this.Instructions.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.Instructions.Font = new System.Drawing.Font("Lucida Console", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Instructions.ForeColor = System.Drawing.Color.Transparent;
this.Instructions.ForeColor = System.Drawing.Color.White;
this.Instructions.Location = new System.Drawing.Point(264, 304);
this.Instructions.Name = "Instructions";
this.Instructions.Size = new System.Drawing.Size(168, 44);
......@@ -74,7 +74,7 @@
this.Exit.FlatAppearance.BorderSize = 0;
this.Exit.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.Exit.Font = new System.Drawing.Font("Lucida Console", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Exit.ForeColor = System.Drawing.SystemColors.ControlText;
this.Exit.ForeColor = System.Drawing.Color.White;
this.Exit.Location = new System.Drawing.Point(264, 353);
this.Exit.Name = "Exit";
this.Exit.Size = new System.Drawing.Size(168, 44);
......@@ -84,13 +84,6 @@
this.Exit.MouseLeave += new System.EventHandler(this.Exit_leaveHover);
this.Exit.MouseHover += new System.EventHandler(this.Exit_Hover);
//
// titleLabel
//
this.titleLabel.Location = new System.Drawing.Point(0, 0);
this.titleLabel.Name = "titleLabel";
this.titleLabel.Size = new System.Drawing.Size(100, 23);
this.titleLabel.TabIndex = 0;
//
// MainMenu
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
......@@ -99,7 +92,6 @@
this.BackgroundImage = global::Blaze_Brigade.Resource1.MenuImage;
this.ClientSize = new System.Drawing.Size(668, 478);
this.ControlBox = false;
this.Controls.Add(this.titleLabel);
this.Controls.Add(this.Exit);
this.Controls.Add(this.Instructions);
this.Controls.Add(this.Start);
......@@ -115,7 +107,6 @@
private System.Windows.Forms.Button Start;
private System.Windows.Forms.Button Instructions;
private System.Windows.Forms.Button Exit;
private System.Windows.Forms.Label titleLabel;
private System.Windows.Forms.Label infoLabel;
}
}
\ No newline at end of file
......@@ -152,12 +152,14 @@ namespace Controller
{
if (unit.getPixelCoordinates().X < nodePixelX)
{
unit.animate(2);
unit.setPixelCoordinates(new Vector2(unit.getPixelCoordinates().X + 4, unit.getPixelCoordinates().Y));
Game.Instance.Tick();
Thread.Sleep(40);
}
else
{
unit.animate(1);
unit.setPixelCoordinates(new Vector2(unit.getPixelCoordinates().X - 4, unit.getPixelCoordinates().Y));
Game.Instance.Tick();
Thread.Sleep(40);
......@@ -168,12 +170,14 @@ namespace Controller
{
if (unit.getPixelCoordinates().Y < nodePixelY)
{
unit.animate(0);
unit.setPixelCoordinates(new Vector2(unit.getPixelCoordinates().X, unit.getPixelCoordinates().Y + 4));
Game.Instance.Tick();
Thread.Sleep(40);
}
else
{
unit.animate(4);
unit.setPixelCoordinates(new Vector2(unit.getPixelCoordinates().X, unit.getPixelCoordinates().Y - 4));
Game.Instance.Tick();
Thread.Sleep(40);
......
......@@ -80,16 +80,6 @@ namespace Blaze_Brigade {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap charSprite {
get {
object obj = ResourceManager.GetObject("charSprite", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
......@@ -150,6 +140,16 @@ namespace Blaze_Brigade {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap warrior {
get {
object obj = ResourceManager.GetObject("warrior", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
......
......@@ -118,9 +118,6 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="charSprite" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\charSprite.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="MenuImage" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\MenuImage.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
......@@ -154,4 +151,7 @@
<data name="Warrior_Info" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\Warrior_Info.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="warrior" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\warrior.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
\ No newline at end of file
src/Blaze-Brigade/Blaze_Brigade/Resources/warrior.png

8.52 KiB

......@@ -37,6 +37,8 @@ namespace Model
void setEquippedWeapon(Weapon w); // sets the unit's currently equipped weapon
MenuButton[] getMenuButtons(); // returns the dropdown menu buttons of the unit
void setMenuButtonCoordinates(Vector2 pixelCoordinates); // sets the coordinates of menu buttons
Rectangle getCurrentFrame(); // returns the current sprite frame in animation sequence
void animate(int direction);
}
enum UnitType { Warrior, Archer, Mage }; //defines the possible classes of a unit
......
......@@ -6,6 +6,7 @@ using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using View;
using System.Diagnostics;
namespace Model
{
......@@ -31,6 +32,8 @@ namespace Model
private Texture2D charInfo;
private Boolean clickedOn = false;
private Boolean menuOpen = false;
private int currentFrame; //the current frame the sprite is on
private int direction; //direction the character is currently facing - 0=down, 1=left, 2=right, up=up
public Warrior(Texture2D spriteImage, MenuButton attackButton, MenuButton moveButton,
MenuButton itemButton, MenuButton waitButton, Texture2D charInfo, Vector2 coordinates)
......@@ -46,7 +49,7 @@ namespace Model
int positionX = (int)Math.Round(coordinates.X / 32);
int positionY = (int)Math.Round(coordinates.Y / 32);
position = new Tuple<int, int>(positionX, positionY);
currentFrame = 1;
setMenuButtonCoordinates(pixelCoordinates);
}
......@@ -229,9 +232,85 @@ namespace Model
}
}
public void Update(GameTime gameTime)
public Rectangle getCurrentFrame() //return current frame the sprite is on
{
Rectangle screenBounds = new Rectangle(currentFrame * 32, 0, 32, 32);
return screenBounds;
}
// animates the sprite by switching to the correct frame sequences
public void animate(int direction)
{
if (direction == 0) // for going down
{
if (currentFrame > 2) // if unit isnt already going down, set the sprite to default facing downwards
{
currentFrame = 1;
}
else
{
if (currentFrame == 2) // if unit has reached end of going down walk cycle, go back to beginning
{
currentFrame = 0;
}
else
{
currentFrame++; // increment through walk cycle
}
}
}else if(direction == 1) // for going left
{
if ((currentFrame < 3) || (currentFrame > 5)) // if unit isnt already going left, set the sprite to default facing left
{
currentFrame = 4;
}
else
{
if (currentFrame == 5) // if unit has reached end of going down walk cycle, go back to beginning
{
currentFrame = 3;
}
else
{
currentFrame++; //increment walk cycle
}
}
}else if (direction == 2) // for going right
{
if ((currentFrame < 6) || (currentFrame > 8)) // if unit isnt already going right, set the sprite to default facing right
{
currentFrame = 7;//increment walk cycle
}
else
{
if (currentFrame == 8)// if unit has reached end of going down walk cycle, go back to beginning
{
currentFrame = 6;
}
else
{
currentFrame++;
}
}
}
else if (direction == 3) // for going up
{
if (currentFrame < 9) // if unit isnt already going up, set the sprite to default facing upwards
{
currentFrame = 10;//increment walk cycle
}
else
{
if (currentFrame == 11)// if unit has reached end of going down walk cycle, go back to beginning
{
currentFrame = 9;//increment walk cycle
}
else
{
currentFrame++;
}
}
}
}
}
}
......@@ -29,13 +29,6 @@
<Reference Include="Microsoft.Xna.Framework.Content.Pipeline.AudioImporters, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=MSIL" />
<Reference Include="Microsoft.Xna.Framework.Content.Pipeline.VideoImporters, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=MSIL" />
</ItemGroup>
<ItemGroup>
<Compile Include="charSprite.png">
<Name>charSprite</Name>
<Importer>TextureImporter</Importer>
<Processor>TextureProcessor</Processor>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="Game_Map.jpg">
<Name>Game_Map</Name>
......@@ -128,6 +121,13 @@
<Processor>FontDescriptionProcessor</Processor>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="warrior.png">
<Name>warrior</Name>
<Importer>TextureImporter</Importer>
<Processor>TextureProcessor</Processor>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
......
src/Blaze-Brigade/Blaze_BrigadeContent/charSprite.png

1.11 KiB

src/Blaze-Brigade/Blaze_BrigadeContent/warrior.png

8.52 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment