Jump to content
  • Advertisement
Sign in to follow this  

2D Move along the ground?

This topic is 4291 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, to give you an idea of my experience I was teaching myself C++, when MS announced XNA. So now i've switched to C# and am working on a 2D, sidescroller. I can draw a character on screen. move it with controls make it collide with other sprites, make it animate appropriate to diffrent actions... but I'm hitting a huge brick wall. I dont know what method to start creating the ground and walls with. Using collision detection to stop the character from passing through walls seems fine. But when i combine a method for gravity and colision detection for the ground stuff starts getting really messy. My ambition is to use curved surfaces, like in Sonic games, so Is there a total other tree I'm supposed to be barking up. I'm really new but usually some source code and notes does me alot of good. I am suprised to have found absolutely nothing on this. Heres my code snipet for my Character class to give you an idea of my understanding of the language. public struct Character { public string m_Name; public string m_State; public bool airborne; public float m_Health; public int m_TopSpeed; public float m_AttackPower; public float m_DefensePower; public float m_Jump; public float m_HangTime; public int m_Drag; public Texture2D[,] m_AniFrame; public int i_framegroup; public int i_framenumber; public Rectangle m_HitBox; public int[] m_Velocity; public Color[] m_Color; public int i_colornumber; public void UpdateCharacter() { Move(); CheckState(); } public void Move() { m_HitBox.X += m_Velocity[0]; m_HitBox.Y += m_Velocity[1]; } public void CheckState() { switch (m_State) { case "standing": { airborne = false; i_framegroup = 0; } break; case "jumping": { airborne = true; i_framegroup = 2; } break; case "running": { airborne = false; i_framegroup = 1; } break; } } }

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!