Jump to content
  • Advertisement

Esper S.

  • Content Count

  • Joined

  • Last visited

Community Reputation

124 Neutral

About Esper S.

  • Rank
  1. Esper S.

    Jumping - What did I do wrong?

    @Muzzy A   The code has been remade and re-posted   (see comment right before yours)
  2. Esper S.

    Jumping - What did I do wrong?

         I'm such an idiot! I should have defined the three bools in the header for this kind of operation. Also, BLM768 was spot on. Since the player will rise on button press, both rising and inAir should become 'true'. Furthermore, since rising and falling are (pretty much) opposites, only one was required. I believe this is what Iomateron was getting at. Here is the finished code for a basic jump  - who knows, someone might find it helpful: //remember to declare "bool inAir, rising;" in your header. On initialization, just set them to false; void Character::Jump(bool x){ if(m_pos.y != 0)inAir = true; if(x){ inAir = true; rising = true; } if(inAir){ if(m_pos.y >= 10)rising = false; if(rising)m_pos.y += 0.5; if(!rising)m_pos.y -= 0.5; if(m_pos.y == 0)inAir = false; } Nice work guys! (y)
  3. Esper S.

    Jumping - What did I do wrong?

    Oh, I thought I laid it out to be understandable enough  Well the whole thing is simply a jump function to execute on a camera. It is safe to assume that all other translations/rotations are already coded, so lets just focus on the 'jump' function. bool x is made true when the user presses a key (whichever one you want  ), and Jump(bool) is run every frame. In case it's the m_pos part that's worrying you, m_pos is a D3DXVECTOR3. Now, with all that out the way, I just want to restate that this is not in any way how I would code a jumping function; this is just something fun I wish to try out to see if it works. The goal is to make basic code that uses no timers, no acceleration, and no gravity: a basic jump function    Ah, one more thing: I am using DirectX10, if it helps. But since this is just practice code, the DirectX/OpenGL version used doesn't matter; only making it work with the constraints.
  4. I know it would be easy to use the windows timer, implement gravity and acceleration, and etc. but just as a test I tried making a primitive "jumping function". On run, the computer freezes; my guess is that I'm doing a useless loop of some sort. Here is the code; can anyone help figure out the problem? void Character::Jump(bool x){ bool inAir; bool rising; bool falling; if(m_pos.y != 0)inAir = true; if(x)inAir = true; if(inAir){ if(m_pos.y == 10 && !falling){ rising = false; falling = true; } if(rising)m_pos.y += 0.5; if(falling)m_pos.y -= 0.5; if(m_pos.y == 0){ inAir = false; } } } I've tried many ways, and this is my latest... I can't see why it shouldn't work
  5. I will do my best! btw, I've been using Rastertek tutorials. They're really good! 
  6. Whoa, that would be helpful! I have D3DXVECTOR3 position, but how would you make one for camera target? Where the camera is looking will change constantly due to mouse input. Also, what would I do to make the camera go forward in that direction?
  7. Thank you for taking the time to help me!
  8. I'm sorry! I've never used posts like this before. What other info would be required? The aim was for the camera to move relative to itself. So regardless of the camera's rotation, it still moves "forward" (into the screen?) instead of along the world's z-axis.
  9. Using DirectX10, I have made a camera that rotates and moves about just fine. The problem is that it seems to be moving relative to the world. Can someone please explain why the camera won't move correctly and the necessary steps to fix this? Thank you, everyone
  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!