View Full Version : Making a character MOVE!
unknownUser
05-17-2002, 06:40 PM
I am witing a program for school and I was gonna write it in windows but i was like "heck no! LINUX is the BEST!" so.... I am a newb at C++ but I need to know how to make it so i can use the arrow keys to move a letter around like "X" or sumthing I know it would have sumthing to do with updating the screen everytime the letter moved but i dont think i have sufficient coding skills..... :)
unknownUser
05-17-2002, 06:41 PM
#include <stdlib.h>
#include <stdio.h>
void main()
{
printf("+---------------------------------+");
printf("| Hello this is the UBER program. |");
printf("+---------------------------------+");
printf("\n\n\n\n");
printf("Eventually this program will move a letter...");
system ("exit");
}
Commander
05-17-2002, 08:34 PM
here's something for ya
int main ( void )
{
int k=0, x=1, y=1;
printf("\n\nPRESS 2 TO EXIT\n\n");
gotoxy( x, y );
printf ( "*(%d,%d)", x,y);
for(;k!=2;){
k=getch();
switch (k)
{
case 72: (--y); break; //up
case 75: (--x); break; //left
case 80: (++y); break; //down
case 77: (++x); break; //right
}
clrscr();
gotoxy( x, y );
printf ( "*(%d,%d)", x,y);
}
}
Commander
05-17-2002, 08:36 PM
by the way, that prog moves a * accross the screen and beside it, prints it's current coordinates in this format (x,y)
WebmasterMattD
05-17-2002, 11:05 PM
If you want to get into the manipulating the window, then I would suggest using NCurses.
There is a greate document explaining how this is done over at the Linux Documentation Project
click this link (http://www.tldp.org).
At least you are starting to realise the evilness of Microsoft while you are still at school, as there are many so called seasoned programmers that have been brainwashed by the pocket book of Microsoft.
Long live Linux!!
later,
unknownUser
05-19-2002, 04:42 PM
Thank you for your help... and yes LONG LIVE LINUX!
vBulletin® v3.7.0, Copyright ©2000-2009, Jelsoft Enterprises Ltd.