delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/11/14/20:51:09

Message-Id: <199811150003.AAA16294@remus.clara.net>
From: "Arthur" <arfa AT clara DOT net>
To: <djgpp AT delorie DOT com>
Subject: RE: Coding problems from an extreme C newbie...
Date: Sun, 15 Nov 1998 00:02:30 -0000
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook 8.5, Build 4.71.2173.0
Importance: Normal
In-Reply-To: <364dfa95.1416189@news.flash.net>
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
Reply-To: djgpp AT delorie DOT com

> Okay, I'm an extreme newbie when it comes to code (my usual speciality
> is graphics), and I'm using DJGPP and Allegro.  Here's my problems...
>
> 1. How can I use "readkey()" to check for more than one keypress?
> I.e.: If KEY-UP is pressed, the pointer will move up, and if KEY-DOWN
> is pressed, it will move down.  Hmm..maybe I've worded this wrong..not
> sure.

You can't use readkey, but if the keyboard handler's installed, an external
array is used to keep track of key presses. Try this:

if(key[KEY_UP]) move_up();
if(key[KEY_DOWN]) move_down();
...
and so on.

> 2. (a general coding question) How can I return back to a specific
> point in a function? (without using GOTO of course. :))

The only stylistically acceptable way of doing this is within a
for(...;...;...){} loop, a do{}while(); loop, or a while(){}; loop. Anything
else is generally put down to bad structure.

> and 3. (using Allegro) What's the best way to peoperly remove a sprite
> (not a bitmap) when I'm done with it?  Right now, I just call the
> original bitmap back from memory before it had any sprites plopped on
> it, but that's probably not good.

That's a perfectly valid method of doing it. The "dirty rectangles" method
is sometimes quicker, although it really does depend on what your game does.

James Arthur
jaa AT arfa DOT clara DOT net
ICQ#15054819


- Raw text -


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