From: mert0407 AT sable DOT ox DOT ac DOT uk (George Foot) Newsgroups: comp.os.msdos.djgpp Subject: Re: allegro problems (gfx + kb) Date: 13 Mar 1997 09:11:09 GMT Organization: Oxford University, England Message-ID: <5g8gbd$3d0@news.ox.ac.uk> References: <199703122105 DOT VAA01257 AT post DOT dialin DOT co DOT uk> NNTP-Posting-Host: sable.ox.ac.uk Lines: 63 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Lee Simons (lee AT dialin DOT co DOT uk) wrote: [...] : void draw() : { : putpixel(screen, pix.x, pix.y, 1); : textout(screen, font, frames, SCREEN_W/2, SCREEN_H/2, 1); : } No, this won't work; textout only prints strings. One way to rewrite this would be: void draw() { char s[10]; putpixel(screen, pix.x, pix.y, 1); sprintf(s,"%d",frames); // there are many functions which // work here; sprintf is slow but // very versatile textout(screen, font, s, SCREEN_W/2, SCREEN_H/2, 1); } [...] : void check_kb() : { : int key, i; : key = readkey(); I suggest that you shouldn't redefine the variable `key'; Allegro already uses this to reference an array. While this is not an error, it does mean you can't easily access the array from within this function. : if((readkey() >> 8) == KEY_UP && pix.y != 0) : { : for(i = 0; i < 2; i++) : pix.y--; : } [...] Change the `readkey()' in all the conditions like this one to whatever you change the `key variable to. Example: void check_kb() { int key_read,i; key_read=readkey(); if (((key_read>>8)==KEY_UP) && (pix.y != 200)) for (i=0; i<2; i++) pix.y++; if (((key_read>>8)==KEY_DOWN) && (pix.y != 200)) ... This way the program will only wait for one key to be pressed. -- George Foot Merton College, Oxford