Gotoxy

This is a discussion on Gotoxy within the C++ Programming forums, part of the General Programming Boards category; I know how to use gotoxy, but how might I use that to create a wall. Heres the scenario: I've ...

  1. #1
    Student drdroid's Avatar
    Join Date
    Feb 2002
    Location
    Montreal, Quebec
    Posts
    669

    Question Gotoxy

    I know how to use gotoxy, but how might I use that to create a wall. Heres the scenario: I've created a program where you move an asterisk around the screen. Well I want to turn that in to a maze program. How might I go about making walls?

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    you could use #.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  3. #3
    Student drdroid's Avatar
    Join Date
    Feb 2002
    Location
    Montreal, Quebec
    Posts
    669

    Reply

    I don't mean it like that... How would I make the wall actually stop the asterisk?

  4. #4
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    if ( asterix_current_square +1 == '#') // do whatever to stop asterix moving to square.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  5. #5
    Registered User
    Join Date
    Feb 2002
    Posts
    4

    YAAAWWNNN

    im bored

  6. #6
    Student drdroid's Avatar
    Join Date
    Feb 2002
    Location
    Montreal, Quebec
    Posts
    669

    Question Reply

    I tried that statement but I don't know what kind of equation can keep it from going... like an equation that can block it all together...

  7. #7
    Student drdroid's Avatar
    Join Date
    Feb 2002
    Location
    Montreal, Quebec
    Posts
    669

    Talking Never Mind

    Nevermind I got it...

  8. #8
    Unregistered
    Guest

    Reply

    I don't mean it like that... How would I make the wall actually stop the asterisk?

  9. #9
    Budding Synth Programmer samGwilliam's Avatar
    Join Date
    Feb 2002
    Location
    Trefforest
    Posts
    368
    Instead of #, use char 219. It's a solid block.

    If your game 'arena' is an array of [80] [24] then the following will work:

    Code:
    .
    .
    .
    char inkey;
    
    while (1)
    {
       if (kbhit ())
          inkey = getch ();
    
       if ((inkey == '6') && (arena [x + 1] [y] != 219))
       {
          x++;
          gotoxy (x - 1, y);
          printf (" ");
       }
    
       if ((inkey == '4') && (arena [x - 1] [y] != 219))
       {
          x--;
          gotoxy (x + 1, y);
          printf (" ");
       }
       
       if ((inkey == '2') && (arena [x] [y + 1] != 219))
       {
          y++;
          gotoxy (x, y - 1);
          printf (" ");
       }
    
       if ((inkey == '8') && (arena [x] [y - 1] != 219))
       {
          y--;
          gotoxy (x, y + 1);
          printf (" ");
       }
    }
    MSVC++ 6.0

  10. #10
    Student drdroid's Avatar
    Join Date
    Feb 2002
    Location
    Montreal, Quebec
    Posts
    669

    Question Reply

    Could you be a little specific to what some of the things do, I'm kind'a a newbie... could you use // to comment on what does what?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. What is gotoxy??
    By Beachblue in forum C Programming
    Replies: 6
    Last Post: 11-23-2008, 12:24 AM
  2. Tic Tac Toe movement
    By $l4xklynx in forum Game Programming
    Replies: 4
    Last Post: 11-06-2008, 06:22 PM
  3. gotoxy(); help!!
    By clique in forum C Programming
    Replies: 2
    Last Post: 10-07-2008, 04:08 AM
  4. Want to see if I am using gotoxy the right way ...
    By o0obruceleeo0o in forum C++ Programming
    Replies: 5
    Last Post: 04-22-2003, 04:17 PM
  5. Is gotoxy ansi?
    By MeneLaus in forum C Programming
    Replies: 2
    Last Post: 05-18-2002, 02:48 PM

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