Sign in to follow this  
Zanx

Movement

Recommended Posts

So I've drawn a guy. I'm going to name him Bob. I've already finished with his walking animation and all that, but I'm clueless as to how to get him moving around with the WASD keys. I'm using c++. So I have several questions: How do I make it so when you hit 'w' you go up, 's' down, etc? How do I make it so he uses the right animation when he's walking in that direction? How do I make him stop moving/stop the animation? I thought that for a start, I'd at least get something moving around on a screen that I'd drawn in paint. But how? If you could get me a link to a good tut for this, or just write it here, that would be cool. Thank you in advance!

Share this post


Link to post
Share on other sites
I don't think you realise just how large the answers to your questions are going to be!

First, it might help if you tell us what operating system you're using and if your model is a) 2D or 3D and b) whether your game is 2D or 3D. That will go a long way to helping answer the other questions.

Even so, the short and simple answer is you respond to WM_KEYDOWN iirc, and either change your characters x,y coord for 2D, or set the transform of the world matrix for a 3D character.

I'll let you provide some more info before we even try to answer the other questions.

Share this post


Link to post
Share on other sites
I'm using Vista Home Premium. Right now the game is 2D, but if I'm not terribly mistaken (actually I probably am) can't you use 2D figures to represent 3D models? Sorry if I'm talking gibberish, I just migrated from Game Maker to c++. But for now, due to my heavily limited knowledge of c++, I think its going to be 2D.

Share this post


Link to post
Share on other sites
Quote:
Original post by Zanx
I'm using Vista Home Premium. Right now the game is 2D, but if I'm not terribly mistaken (actually I probably am) can't you use 2D figures to represent 3D models? Sorry if I'm talking gibberish, I just migrated from Game Maker to c++. But for now, due to my heavily limited knowledge of c++, I think its going to be 2D.


Ok, so I assume that you're not using and kind of game engine or libraries, just starting from scratch in C++. Are you targetting DirectX, OpenGL, or are you trying to use MFC or straight Win32 through GDI?

Share this post


Link to post
Share on other sites
Well, I have downloaded the Irrlicht engine. It looked pretty good. I also got OGRE, but I have no clue how to set it up. I think Irrlicht supports DirectX, so I'll go with that.

Share this post


Link to post
Share on other sites
Quote:
Original post by Zanx
Well, I have downloaded the Irrlicht engine. It looked pretty good. I also got OGRE, but I have no clue how to set it up. I think Irrlicht supports DirectX, so I'll go with that.
I think there are a few questions worth asking here:

1. What's your end goal? Is it to make a game? Or to learn C++?

2. What type of game(s) do you want to make? 2-d? 2-d? Any particular genre or level of complexity?

3. Is there any particular reason you moved from Game Maker to C++?

4. Is there any particular reason you chose C++ as a programming language?

I don't know that Irrlicht/C++ would be the best choice for what you're wanting to do (based on what you've described so far, at least). If the goal is to learn C++, there are probably some other libraries you could use (such as SFML) that would be a little more light-weight and easier to get off the ground with. If the goal is simply to learn to program, then you might consider developing in a language other than C++ (many people recommend Python+Pygame and C#+XNA). If your goal is specifically to make games, then you might reconsider your move from Game Maker. My understanding is that you can do quite a bit with Game Maker via the scripting system, and I imagine you could get quite a ways with it before reaching its limitations (whatever they are). Or, if you need a bit more flexibility, you could try Unity.

The point is that there are quite a few options available here, so don't feel like the only way to do what you're wanting is to write your game from scratch in C++ (because it's not).

Share this post


Link to post
Share on other sites
The main purpose was to get at least a basic understanding of c++. I'm still going to use GM, but I really do want to know c++. And for now, I want to see if I can get an animated guy walking around (2D).

Share this post


Link to post
Share on other sites
Quote:
Original post by Zanx
The main purpose was to get at least a basic understanding of c++. I'm still going to use GM, but I really do want to know c++. And for now, I want to see if I can get an animated guy walking around (2D).
In that case, you might give something like SFML a try. I haven't used Irrlicht myself, but it seems like it might be a little more than what you need at this point. In terms of just getting a basic application up and running with some entities moving around in 2-d, something like SDL or SFML might be a better choice. (If you want to give SDL a try, check out the 'Lazy Foo' SDL tutorials - they cover just about everything you'd need to know to do what you're describing. As for SFML, I imagine there are probably some tutorials and/or example projects available on the SFML website.)

Share this post


Link to post
Share on other sites
Quote:
Original post by Zanx
The main purpose was to get at least a basic understanding of c++. I'm still going to use GM, but I really do want to know c++. And for now, I want to see if I can get an animated guy walking around (2D).


If your goal is to get a basic understanding of C++ then you're better off getting a "C++ for Beginners" type book or looking for some web tutorials that will take you through the language and have you write console programs. Attempting to write a game requires extra knowledge such as the Win32 API and DirectX. Those APIs aren't requirements of knowing the basics of C++ and will only serve to confuse you while you try and sort out what C++ actually is.

Share this post


Link to post
Share on other sites
Well I have been reading a book on it. I can do pretty much everything simple in a console application. And I actually meant to say that the purpose was to understand how to make a simple game with c++. Well, I'll start with SDL and get some images up and stuff. Thanks for helping me!

Share this post


Link to post
Share on other sites

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