Skip to content

Commit

Permalink
no message
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielMcAssey committed Jan 10, 2014
1 parent 4a7a430 commit 639caec
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public Enemy_MercBot(uint id, ContentManager virtualContent, Vector2 position)
this.animation.Origin = new Vector2((tmpTexture.Width / 3f) / 2f, (tmpTexture.Height / 3f) / 2f);
this.animation.Scale = 1.5f;
this.animation.CurrentAnimation = "idle";
this.animation.Loop = true;

this.Health = 100;
this.Speed = 1f;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,7 @@ public void moveLeft()
if (playerAnimation != null)
{
if (isJumping == false)
{
moveDirection = MoveDirection.Left;
}

position.X -= moveSpeed;
playerAnimation.CurrentAnimation = "left";
Expand All @@ -96,9 +94,7 @@ public void moveRight()
if (playerAnimation != null)
{
if (isJumping == false && isOnTop == false)
{
moveDirection = MoveDirection.Right;
}

position.X += moveSpeed;
playerAnimation.CurrentAnimation = "right";
Expand Down Expand Up @@ -135,7 +131,7 @@ public void jump()

public override void Update(GameTime gameTime)
{
if (isJumping == true)
if (isJumping)
{
jumpDistance = (float)gameTime.ElapsedGameTime.TotalSeconds * jumpSpeed;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public PowerUp_Crate(uint id, ContentManager virtualContent, Vector2 position)
this.animation.CurrentAnimation = "idle";
this.Score = 10;
this.type = PowerUpType.Crate;
this.animation.Loop = true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public PowerUp_Crystal(uint id, ContentManager virtualContent, Vector2 position)
this.animation.Origin = new Vector2((tmpTexture.Width / 12f) / 2f, tmpTexture.Height / 2f);
this.animation.Scale = 0.5f;
this.animation.CurrentAnimation = "idle";
this.animation.Loop = true;
this.Score = 10;
this.type = PowerUpType.Crystal;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public PowerUp_Dynamite(uint id, ContentManager virtualContent, Vector2 position
this.animation.CurrentAnimation = "idle";
this.Score = -10;
this.type = PowerUpType.Dynamite;
this.animation.Loop = true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public PowerUp_EnergyBall(uint id, ContentManager virtualContent, Vector2 positi
this.animation.CurrentAnimation = "idle";
this.Score = 10;
this.type = PowerUpType.EnergyBall;
this.animation.Loop = true;
}
}
}
10 changes: 10 additions & 0 deletions SolarFusion/SolarFusion/SolarFusion/Core/Input/InputManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ public InputManager()

this.AddGamePadInput("GLOBAL_START", SysConfig.INPUT_GAMEPAD_START, false);

this.AddGamePadInput("PLAY_MOVE_LEFT", SysConfig.INPUT_GAMEPAD_LEFT_DPAD, false);
this.AddGamePadInput("PLAY_MOVE_LEFT", SysConfig.INPUT_GAMEPAD_LEFT_STICK, false);
this.AddGamePadInput("PLAY_MOVE_RIGHT", SysConfig.INPUT_GAMEPAD_RIGHT_DPAD, false);
this.AddGamePadInput("PLAY_MOVE_RIGHT", SysConfig.INPUT_GAMEPAD_RIGHT_STICK, false);
this.AddGamePadInput("PLAY_MOVE_JUMP", SysConfig.INPUT_GAMEPAD_JUMP, false);

//Add Keyboard Input
this.AddKeyboardInput("NAV_UP", SysConfig.INPUT_KEYBOARD_UP, true);
this.AddKeyboardInput("NAV_DOWN", SysConfig.INPUT_KEYBOARD_DOWN, true);
Expand All @@ -42,6 +48,10 @@ public InputManager()
this.AddKeyboardInput("NAV_CANCEL", SysConfig.INPUT_KEYBOARD_CANCEL, true);

this.AddKeyboardInput("GLOBAL_START", SysConfig.INPUT_KEYBOARD_START, false);

this.AddKeyboardInput("PLAY_MOVE_LEFT", SysConfig.INPUT_KEYBOARD_LEFT, false);
this.AddKeyboardInput("PLAY_MOVE_RIGHT", SysConfig.INPUT_KEYBOARD_RIGHT, false);
this.AddKeyboardInput("PLAY_MOVE_JUMP", SysConfig.INPUT_KEYBOARD_JUMP, false);
}

public InputHelper NewInput(string action)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void LoadLevel(uint _LevelID, Player _activePlayer, EntityManager _objMan
switch (goData.entCategory) //Swtich by object category.
{
case "PlayerStart":
Vector2 newPos = new Vector2(position.X, position.Y + ((player.Height / 2) / 2));
Vector2 newPos = new Vector2(position.X, (position.Y - ((player.Height / 2) / 2)));
player.Position = newPos;
player.floorHeight = position.Y + ((player.Height / 2) / 2);
player.isSingleplayer = true;
Expand Down Expand Up @@ -166,11 +166,12 @@ public void Update(GameTime _gameTime)
}
}
}

go.Update(_gameTime); //Updates the object.
this._obj_entitymanager.UpdateGameObject(goID); //Updates the object within the object manager.
}
}

player.Update(_gameTime);
}

public void Draw(SpriteBatch spriteBatch)
Expand Down Expand Up @@ -219,6 +220,8 @@ public void Draw(SpriteBatch spriteBatch)
go.Draw(spriteBatch); //Draws The Object.
}

player.Draw(spriteBatch);

spriteBatch.End();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ public override void loadContent()

//!Debug!
AnimatedSprite _tmpPlayerAnim = new AnimatedSprite(this._local_content.Load<Texture2D>("Sprites/Characters/Jumpista/spritesheet"), 5, 3);
_tmpPlayerAnim.AddAnimation("right", 0, 5, 7);
_tmpPlayerAnim.AddAnimation("left", 1, 5, 7);
_tmpPlayerAnim.AddAnimation("idle", 2, 3, 5);
_tmpPlayerAnim.AddAnimation("right", 1, 5, 7);
_tmpPlayerAnim.AddAnimation("left", 2, 5, 7);
_tmpPlayerAnim.AddAnimation("idle", 3, 3, 5);
_tmpPlayerAnim.mCurrentAnimation = "idle";
_tmpPlayerAnim.Loop = true;
//!Debug!

this._obj_activeplayer = new Player(this._obj_entitymanager.NextID(), _tmpPlayerAnim, Vector2.Zero, 1.8f, 100, 280, this._obj_entitymanager);
Expand All @@ -54,8 +56,18 @@ public override void update() //Update per frame
GameTime _gameTimer = this.GlobalGameTimer;
TimeSpan _elapsedTime = _gameTimer.ElapsedGameTime;
TimeSpan _totalTime = _gameTimer.TotalGameTime;


this._obj_levelmanager.Update(_gameTimer);

if (this.GlobalInput.IsPressed("PLAY_MOVE_LEFT", this.ControllingPlayer)) //If player presses cancel button (Escape/B)
this._obj_activeplayer.moveLeft();
else if (this.GlobalInput.IsPressed("PLAY_MOVE_RIGHT", this.ControllingPlayer)) //If player presses cancel button (Escape/B)
this._obj_activeplayer.moveRight();
else
this._obj_activeplayer.moveIdle();

if (this.GlobalInput.IsPressed("PLAY_MOVE_JUMP", this.ControllingPlayer)) //If player presses cancel button (Escape/B)
this._obj_activeplayer.jump();

base.update();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public AnimatedBGEntity(Texture2D spriteTexture, int frameCount, int animCount,
baseAnimation.AddAnimation("DEFAULT", 1, frameCount, fps);
baseAnimation.Frame = initFrame;
baseAnimation.mCurrentAnimation = "DEFAULT";
baseAnimation.IsLoopAnimation = true;
baseAnimation.Loop = true;
}

public float GetSpeedX
Expand Down
22 changes: 10 additions & 12 deletions SolarFusion/SolarFusion/SolarFusion/Core/Sprites/AnimatedSprite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@ namespace SolarFusion.Core
public class AnimatedSprite : Sprite
{
private float mTimeElapsed;
public bool IsLoopAnimation = false;
private bool IsLoopAnimation = false;
private float mTimeToUpdate = 0.05f;

public bool Loop
{
get { return this.IsLoopAnimation; }
set { this.IsLoopAnimation = value; }
}

public int FramesPerSecond
{
set { mTimeToUpdate = (1f / value); }
Expand All @@ -35,27 +41,19 @@ public void Update(GameTime gameTime)
{
mTimeElapsed -= mTimeToUpdate;

if (IsAnimation == true)
if (IsAnimation)
{
if (mFrameIndex < (mSpriteFramesCount[mCurrentAnimation] - 1))
{
mFrameIndex++;
}
else if (IsLoopAnimation == true)
{
else if (IsLoopAnimation)
mFrameIndex = 0;
}
}
else
{
if (mFrameIndex < (mAnimationFrames - 1))
{
mFrameIndex++;
}
else if (IsLoopAnimation == true)
{
else if (IsLoopAnimation)
mFrameIndex = 0;
}
}
}
}
Expand Down
6 changes: 0 additions & 6 deletions SolarFusion/SolarFusion/SolarFusion/Core/Sprites/Sprite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,7 @@ public void AddAnimation(string animName, int animRow, int frameCount, int sprit
Rectangle[] tmpRectangles = new Rectangle[frameCount];

for (int i = 0; i < frameCount; i++)
{
tmpRectangles[i] = new Rectangle(i * AnimationWidth, (animRow - 1) * AnimationHeight, AnimationWidth, AnimationHeight);
}

mSpriteAnimations.Add(animName, tmpRectangles);
mSpriteFramesCount.Add(animName, frameCount);
Expand All @@ -132,16 +130,12 @@ public void Draw(SpriteBatch spriteBatch)
if (mFrameIndex > (mSpriteAnimations[mCurrentAnimation].Length - 1))
{
if (mSpriteTexture != null)
{
spriteBatch.Draw(mSpriteTexture, mSpritePosition, mSpriteAnimations[mCurrentAnimation][0], mSpriteColor, mSpriteRotation, mSpriteOrigin, mSpriteScale, mSpriteEffects, 0f);
}
}
else
{
if (mSpriteTexture != null)
{
spriteBatch.Draw(mSpriteTexture, mSpritePosition, mSpriteAnimations[mCurrentAnimation][mFrameIndex], mSpriteColor, mSpriteRotation, mSpriteOrigin, mSpriteScale, mSpriteEffects, 0f);
}
}
}
//!FUNCTIONS
Expand Down
4 changes: 4 additions & 0 deletions SolarFusion/SolarFusion/SolarFusion/Core/SysConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ public class SysConfig
public const Buttons INPUT_GAMEPAD_SELECT = Buttons.A;
public const Buttons INPUT_GAMEPAD_CANCEL = Buttons.B;

public const Buttons INPUT_GAMEPAD_JUMP = Buttons.A;

//Default Keyboard Controls
public const Keys INPUT_KEYBOARD_UP = Keys.Up;
public const Keys INPUT_KEYBOARD_DOWN = Keys.Down;
Expand All @@ -68,5 +70,7 @@ public class SysConfig
public const Keys INPUT_KEYBOARD_START = Keys.Escape;
public const Keys INPUT_KEYBOARD_SELECT = Keys.Enter;
public const Keys INPUT_KEYBOARD_CANCEL = Keys.Escape;

public const Keys INPUT_KEYBOARD_JUMP = Keys.Space;
}
}

0 comments on commit 639caec

Please sign in to comment.