delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/07/28/09:04:31

Message-ID: <000b01bff895$2a351280$387a5a8f@dynabook>
From: "Rogerio Mazakina" <dway AT designer DOT mailbr DOT com DOT br>
To: <djgpp AT delorie DOT com>
Subject: Game
Date: Fri, 28 Jul 2000 22:10:11 +0900
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 5.00.2314.1300
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300
Reply-To: djgpp AT delorie DOT com

hello.

Im building a game with allegro/djgpp

i have 2 functions, but my program is slow to get the keys
(up, left, right and left)

///  KEYS  ///
int a_key;
int s_key;
int d_key;

int z_key;
int x_key;
int c_key;

int left_key;
int right_key;
int up_key;
int down_key;

int esc_key;
int enter_key;

int selected = 0;
int selected_x;
int selected_y;

int key_pressed;
int arrow_pressed;

void get_move(void)
{
  if (key[KEY_ENTER]) {enter_key++;  key_pressed = 1; selected = 1;}
  if (key[KEY_ESC])   exit_game = 1;

  if (key[KEY_UP])         {up_key++; arrow_pressed = 1;}
  if (key[KEY_DOWN])  {down_key++; arrow_pressed = 1;}
  if (key[KEY_LEFT])     {left_key++; arrow_pressed = 1;}
  if (key[KEY_RIGHT])   {right_key++; arrow_pressed = 1;}

  if (key[KEY_A])   {a_key++;   key_pressed = 1; selected = 1;}
  if (key[KEY_S])   {s_key++;   key_pressed = 1;}
  if (key[KEY_D])   {d_key++;   key_pressed = 1;}

  if (key[KEY_Z])    {z_key++;   key_pressed = 1;}
  if (key[KEY_X])   {x_key++;   key_pressed = 1;}
  if (key[KEY_C])   {c_key++;   key_pressed = 1;}

  if      (up_key           > 0) selected_y--;
  else if (down_key   > 0) selected_y++;
  if      (left_key          > 0) selected_x--;
  else if (right_key    > 0) selected_x++;
}

and play_sample(...);   // if key is pressed

void menu(void)
{
  int done = 0;

  while (!done)
  {
    get_move();
    clear(buffer);
    //  do some thing with selected_x or y
    blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
    play_fx();
    unpress_all_key();
  }
}

but in my game, if i press any arrow key, the play_sample is called but the
cursor is not
moved.

someone can to tell me what i need to change.
or send me an example
maybe is because i use 24bit color and 640x480 resolution

obs: My english is not good... :-(

[]s
Rogerio



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019