Sign in to follow this  

2D Move along the ground?

This topic is 4075 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

This topic is 4075 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this