Mail Archives: djgpp/1997/03/13/05:08:36
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 <mert0407 AT sable DOT ox DOT ac DOT uk>
Merton College, Oxford
- Raw text -