delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/06/23/07:45:40

From: "DeepBlack \(Murray Evans\)" <deepblack AT dial DOT pipex DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Keyboard (?) problems, Allegro............ PLEASE HELP.
Date: Fri, 23 Jun 2000 12:42:32 +0100
Organization: UUNET WorldCom server (post doesn't reflect views of UUNET WorldCom
Lines: 83
Message-ID: <8ivift$rtv$1@lure.pipex.net>
NNTP-Posting-Host: usercr17.uk.uudial.com
X-Trace: lure.pipex.net 961760573 28607 62.188.156.244 (23 Jun 2000 11:42:53 GMT)
X-Complaints-To: abuse AT uk DOT uu DOT net
NNTP-Posting-Date: 23 Jun 2000 11:42:53 GMT
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2919.6600
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Right, I'm currently mucking about with allegro, with the goal of creating a
little game like one I used to have on ancient 5 1/4 disks, called Space-War
(an overhead shooty thing on one screen, one player against the other, with
the option of sticking a planet in the middle... it's really old,
anyway...). My problem is that the program (which follows) does not seem to
want to read from the keyboard. In fact, after a few button presses, the
computer starts bleeping at me in an annoyed manner.... here's the code (it
compiles fine...):


#include <stdio.h>

#include <allegro.h>
#include <duel.h>



int main()
 {


  int angle;
  BITMAP *buffer; /*for double buffer*/
  /* BITMAP *player; /*for player sprite*/
  BITMAP *enemy; /*for comp, player 2 sprite*/
  RGB pal[255];  /*for palette*/

  allegro_init;   /*load allegro*/
  install_timer;  /*allegro timer*/
  install_keyboard; /*allegro keyboard routines */

  set_color_depth(16);
  set_gfx_mode(GFX_VESA3,640,480,0,0);  /* set gfx mode, 640*480, no
'virtual'*/


  /*load the graphics files*/
    /*ships*/

      /*player = load_bitmap("green.bmp",pal); not suing this just yet, only
testing stuff */
      enemy = load_bitmap("orange.bmp", pal);

            /*to do later, once everything else works:
              make a sprite selection screen*/

    /*other graphics*/
     /*none as yet*/
  /*set palette to that of graphics files*/
  set_palette(pal);

    /* create and clear double buffer */
   buffer = create_bitmap(640,480);
   clear(buffer);
   clear(screen);

  /*main loop*/

  clear_keybuf;
  angle=0;
  do
  {
   if(key[KEY_RIGHT]) angle++;
   if(key[KEY_LEFT]) angle--;
   if(angle>255) angle=0;
   if(angle<0) angle=254;
   clear(buffer);
   rotate_sprite(buffer, enemy, 310,230, itofix(angle));
   blit(buffer,screen,0,0,0,0,640,480);
  }while (!key[KEY_ESC]);


  /*destroy_bitmap(player);*/
  destroy_bitmap(enemy);
  destroy_bitmap(buffer);
  exit(0);

}


am I doing something wrong? missing something?


- Raw text -


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