Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 [tutorial] movement (getch,keydown,mouse)
Index -> Programming, Turing -> Turing Tutorials
Goto page 1, 2, 3  Next
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
DanShadow




PostPosted: 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.



Movement Tutorial.t
 Description:
Dans Movement Example

Download
 Filename:  Movement Tutorial.t
 Filesize:  1.65 KB
 Downloaded:  3432 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
santabruzer




PostPosted: Sun Jan 25, 2004 12:40 pm   Post subject: (No subject)

simple and effective.. good job... (just delay the keydown a bit though)
DanShadow




PostPosted: 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 Laughing
shorthair




PostPosted: 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




PostPosted: 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




PostPosted: 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! Very Happy

(well, if you want to Eh)
Paul




PostPosted: 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... Embarassed
Cervantes




PostPosted: Sun Feb 01, 2004 3:04 pm   Post subject: (No subject)

well that's certainly creative, wouldn't think its that much fun though. Eh

don't post it yet, make it really good Smile
Sponsor
Sponsor
Sponsor
sponsor
jonos




PostPosted: 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




PostPosted: Sun Feb 01, 2004 4:06 pm   Post subject: (No subject)

did you know this stuff before? / have you already used this stuff?
jonos




PostPosted: 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




PostPosted: Sun Feb 01, 2004 4:30 pm   Post subject: (No subject)

awesome. go for it Smile

be creative!
Paul




PostPosted: Sun Feb 01, 2004 4:32 pm   Post subject: (No subject)

Hey, you think I can use whatdotcolor for collision detection?
Cervantes




PostPosted: Sun Feb 01, 2004 4:45 pm   Post subject: (No subject)

yes that's one way, ask dodge and its the only way Smile
Andy




PostPosted: 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
Display posts from previous:   
   Index -> Programming, Turing -> Turing Tutorials
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 3  [ 44 Posts ]
Goto page 1, 2, 3  Next
Jump to:   


Style:  
Search: