Posted: Sun Jan 25, 2004 2:37 am Post subject: [tutorial] movement (getch,keydown,mouse)
This tutorial is kind of a response to the on in:
http://www.compsci.ca/v2/viewtopic.php?t=3270 Getch
Getch is the command for "get char"...which waits until the user inputs(presses) a button (character) on the keyboard, then it saves it under a variable name. This can be used for buttons too, like (KEY_UP_ARROW), etc.
Input.KeyDown
This does similarly the same thing...except it can handle multiple characters (enabling 2+ player programs). These extra characters are held in a boolean array, thats why the variable is declared like so:
code:
var chars:array char of boolean
Mousewhere
The mouse is an uncommonly used tool for movement. There are easy ways this is done though, like 4 if statements, checking the mouses x and y co-ordinates relative to the players. Then if the player clicks, and (for example) the x and y are greater than the sprites x and y, the sprites x and y increase as a movement step.
I have included a program showing you how each of these movement types work.
Posted: Sun Jan 25, 2004 12:40 pm Post subject: (No subject)
simple and effective.. good job... (just delay the keydown a bit though)
DanShadow
Posted: Sun Jan 25, 2004 4:55 pm Post subject: (No subject)
tx...and it doesnt matter too much about the delay...im just giving an example, doesnt have to be perfect, heh
shorthair
Posted: Sun Jan 25, 2004 5:09 pm Post subject: (No subject)
Its good , well done , you have put alot of effor into making this ( that i can see ) , keep up the good code
Paul
Posted: Sun Feb 01, 2004 2:47 pm Post subject: (No subject)
Wow, that IS really well done, it taught a person like me to move stuff with keyboard and mouse in 2 minutes, thanks!
Cervantes
Posted: Sun Feb 01, 2004 2:54 pm Post subject: (No subject)
necessities for making a great game!
Paulbian make a game now and post it! be as creative as you can!
(well, if you want to )
Paul
Posted: Sun Feb 01, 2004 2:57 pm Post subject: (No subject)
ahem... does a moving circle which grows when you press enter and shrinks when you press backspace count as a game...
Cervantes
Posted: Sun Feb 01, 2004 3:04 pm Post subject: (No subject)
well that's certainly creative, wouldn't think its that much fun though.
don't post it yet, make it really good
Sponsor Sponsor
jonos
Posted: Sun Feb 01, 2004 3:57 pm Post subject: (No subject)
ill post a game cervantes, i just need to look at the tutr.l
Cervantes
Posted: Sun Feb 01, 2004 4:06 pm Post subject: (No subject)
did you know this stuff before? / have you already used this stuff?
jonos
Posted: Sun Feb 01, 2004 4:22 pm Post subject: (No subject)
never used it before, my class only learned stuff to arrays. im gonna learn it, i just need to learn collision detection then you wil have your gaem;
Cervantes
Posted: Sun Feb 01, 2004 4:30 pm Post subject: (No subject)
awesome. go for it
be creative!
Paul
Posted: Sun Feb 01, 2004 4:32 pm Post subject: (No subject)
Hey, you think I can use whatdotcolor for collision detection?
Cervantes
Posted: Sun Feb 01, 2004 4:45 pm Post subject: (No subject)
yes that's one way, ask dodge and its the only way
Andy
Posted: Sun Feb 01, 2004 4:55 pm Post subject: (No subject)
cervantes -5 bits to you...
of course u can use whatdotcolor! everybody should use whatdotcolor for the perfect collision detection... and i'm not kidding about perfect... if u think really hard about it, you'll get plus as a bonus you'll love whatdotcolor