|
-
Sep 6th, 2004, 03:11 AM
#1
Thread Starter
PowerPoster
Move Multiple Directions
This has to do with direct input.
Now, I notice in some amatuer source code, or if the game works fine with this method, some people just go
(typing this in english, not code)
if button=left
else if button = right
else if button = left
ect
Now this leaves little for play, and one cannot move on diangols...
So A few if then statements would be nice, no else...the only else there should be on each if statement is to make sure the button is up.
Now how would one go about getting multiple directions. I have chosen a method, and seen a few others.
Here is my method, using c++ string
Direction is a string
The player pressed a button
if button = left then
Direction += Direction + "left"
if button = right then
Direction += Direction + "right"
Then we the motion is carried out I just
if (Direction.find("left",0) != string:npos)
move the stuff
Now I have also seen it done with ints, but an int representing a direcetion can get confusing to other programmers looking at yer stuff. I have seen individual key BOOLS for each key, which is consuming...Anyone have any nice methods they wish to explain.
Note: in my game I use north, south, east, west, up, down.
"From what was there, and was meant to be, but not of that was faded away." - - Steve Damm
"The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm
"When you do things right, people won't be sure if you did anything at all." - - God from Futurama
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|