Making a character MOVE!

This is a discussion on Making a character MOVE! within the Linux Programming forums, part of the Platform Specific Boards category; I am witing a program for school and I was gonna write it in windows but i was like "heck ...

  1. #1
    Registered User unknownUser's Avatar
    Join Date
    Apr 2002
    Posts
    14

    Unhappy Making a character MOVE!

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

  2. #2
    Registered User unknownUser's Avatar
    Join Date
    Apr 2002
    Posts
    14

    Oh ya here is the code I have so far....

    #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");
    }

  3. #3
    Registered User Commander's Avatar
    Join Date
    Sep 2001
    Posts
    804
    here's something for ya
    Code:
    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);
    
       }
    
    
    }
    oh i'm sorry! i didn;t realize my fist was rushing to meet ur face!

    MSN :: commander_android@hotmail.com []*[]

  4. #4
    Registered User Commander's Avatar
    Join Date
    Sep 2001
    Posts
    804
    by the way, that prog moves a * accross the screen and beside it, prints it's current coordinates in this format (x,y)
    oh i'm sorry! i didn;t realize my fist was rushing to meet ur face!

    MSN :: commander_android@hotmail.com []*[]

  5. #5
    Registered User
    Join Date
    Apr 2002
    Posts
    110
    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.

    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,
    WebmasterMattD
    WebmasterMattD.NET

  6. #6
    Registered User unknownUser's Avatar
    Join Date
    Apr 2002
    Posts
    14

    thank you

    Thank you for your help... and yes LONG LIVE LINUX!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Tic Tac Toe Comp Move help
    By swgh in forum C++ Programming
    Replies: 5
    Last Post: 09-24-2008, 12:05 PM
  2. pipe
    By smart girl in forum C Programming
    Replies: 4
    Last Post: 04-30-2006, 10:17 AM
  3. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  4. making camera move with mouse
    By Ti22 in forum Game Programming
    Replies: 13
    Last Post: 01-16-2005, 08:56 AM
  5. Replies: 5
    Last Post: 09-08-2001, 10:18 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21