![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Feb 2006
Posts: 3
Rep Power: 0
![]() |
Move through keyboard
hii all,
i wanted to know the code to move a point or line using the arrow keys of the keyboard. is that possible? i m trying to make the game 'snake'. plz help. hope u understand wat i m trying to say. thanx Last edited by InsaneXterminator; Feb 4th, 2006 at 1:43 AM. |
|
|
|
|
|
#2 |
|
Professional Programmer
Join Date: Sep 2005
Location: serbia & montenegro
Posts: 484
Rep Power: 3
![]() |
Depends if it will console or graphical application.
|
|
|
|
|
|
#3 |
|
Newbie
Join Date: Sep 2005
Posts: 28
Rep Power: 0
![]() |
If you are using sdl or opengl, they have functions to handle events such as keyboard or mouse input. If you are writing you own app from scratch, you just need to write a funtion that gets one char at a time from stdin and depending on what key was pressed do the appropriate action. Here you can find the keyboard codes for most keys and here there is an application written for a *nix command line that outputs all keyboard input back to the shell. It's not what you want, but this will help you grasp the idea.
Hope this helps...0
__________________
The geeks shall inherit the earth. |
|
|
|
|
|
#4 | |
|
Game engine designer
Join Date: May 2005
Location: Sweden
Posts: 297
Rep Power: 4
![]() |
Quote:
|
|
|
|
|
|
|
#5 |
|
Newbie
Join Date: Feb 2006
Posts: 3
Rep Power: 0
![]() |
can u please show me a sample code, i cant really get what u r saying.
|
|
|
|
|
|
#6 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Can you understand code written in English, instead of as "u r" doing it?
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#7 | |
|
Expert Programmer
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4
![]() |
Quote:
|
|
|
|
|
|
|
#8 |
|
Newbie
Join Date: Feb 2006
Posts: 3
Rep Power: 0
![]() |
i just want a particular character, for eg a * (asterix) to be able to move with the help of the cursor keys on the keyboard.
|
|
|
|
|
|
#9 |
|
Hobbyist Programmer
Join Date: Jan 2006
Location: Menidi, Athens, Greece
Posts: 239
Rep Power: 3
![]() |
First of all you need to specify what you intend to do.
So, you must tell us if you need instructions about building such a thing as a console application, or using OpenGL. Finally, what operating system are you using?
__________________
Project::Soulstorm (personal homepage) |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|