Archived

This topic is now archived and is closed to further replies.

making something move in 2d

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

I''m a beginner in game programming. What is the simplest way to make an image (of a person) move around the screen depending on which arrow keys the user presses? What is the syntax? Can anyone help me? any help you can give me would be greatly appreciated. P.S. Once again, I am a beginner, so please explain to me what''s going on.

Share this post


Link to post
Share on other sites
There are 3 main parts of this you''ll need to know how to program.

* The movement logic (easy - just store the position on screen as X&Y coordinates).

* The graphics (harder - you''ll probably need to learn DirectDraw).

* The input (easyish - you''ll probably need to learn DirectInput).

If you have a good grip on your programming language of choice, then move on to following the tutorials in the DirectX SDK.

The SDK is available on the Microsoft site, and comes with Visual C++ as part of MSDN.


Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions

Share this post


Link to post
Share on other sites
For graphics, don''t necessarily rule out OpenGL as well. While DirectX is fairly necessary for all the other aspects, graphics can be done in a somewhat simpler syntax. Of course, I don''t have any experience with DirectX, and I should probably start. Then again, I am also a Linux fan, and cross-platform support is important for me. I should also learn SDL. Darn lack of knowledge! B-)

Share this post


Link to post
Share on other sites
I think you will have to do this steps:
1. Set up everything to be able to draw at all (one can even use win API for this)
2. Load your graphics
3. Prepare for getting user input (Direct Input or WinAPI)
4. Enter a loop which does the following:
a) Fetch user input
b) if(left) x--; if(right) x++; if(up) y--; if(down) y++;
c) Draw the image at (x|y)


Im Anfang war die Tat...
Faust

Share this post


Link to post
Share on other sites
I have a couple questions for ya there lemonstix.

a) Do you plan to be programming this for Windows?
b) What language do you plan to program this in, C++ or Java?
c) Do you know anything about Windows programming?

let me know. I need to take a break from the stuff I''ve been programming on, so I might write ya a tutorial and link it up to my website.

Lucas

Share this post


Link to post
Share on other sites
quote:
Original post by lukeyes
I have a couple questions for ya there lemonstix.

a) Do you plan to be programming this for Windows?
b) What language do you plan to program this in, C++ or Java?
c) Do you know anything about Windows programming?

let me know. I need to take a break from the stuff I''ve been programming on, so I might write ya a tutorial and link it up to my website.

Lucas


Hi, this is lemonstix

In case you dont remember,I wrote to a forum on GameDev regarding how to make a character move using the keyboard. You wanted to know how much I knew. I don''t know that much actually, I use C++. I know some Windows programming, but I was provided with a game engine that someone else wrote. Would you like to see it? I can try to attach it later.

A tutorial would be great, could you do that? Any information you need I can send, i think. I also want to know how to make it so the character doesn''t bump into any walls on a map i drew. Thanks so much..
also, i tried emailing you directly, but it says your inbox is full...
lemonstix

Share this post


Link to post
Share on other sites
sorry about that buddy, seems like I don''t even have a spam filter anymore.

yeah, the inbox was full. but send me the email again. And yes, I will write a tutorial for you. I eventually want to get into teaching, so I might as well start working on teaching what I know.

lukeyes@hotmail.com

Lucas

Share this post


Link to post
Share on other sites