Message-Id: <199811151151.LAA25454@remus.clara.net> From: "Arthur" To: Subject: RE: Coding problems from an extreme C newbie... Date: Sun, 15 Nov 1998 11:50:36 -0000 X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook 8.5, Build 4.71.2173.0 In-Reply-To: <364e3737.14360160@news.flash.net> X-MIMEOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Importance: Normal Reply-To: djgpp AT delorie DOT com > >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. > > Okay, so how would I define the array? (I told you I'm a newbie. :) You don't have to. It's defined in allegro.h. Just make sure you #include that. > >> 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. > > Sorry, misworded question on my part. It should have read: How can I > return back to a specific point in a function AFTER calling another > function? I.e. main() processes some stuff, calls temp(), then temp() > processes some more stuff, then returns to a point where it left off > in main(). That's the normal process: /* CODE BEGINS HERE */ void temp(void) { printf("Now I'm processing in temp()\n"); } int main(void) { printf("Processing in main()\n"); temp(); printf("Back in main() again\n"); return 0; } /* CODE ENDS HERE */ > >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. > > Allright. Now can you point me in the direction of some sample dirty > rectangles code? Have a look at the Allegro demo game. It's a bit complex. I think there are some tutorials on dirty rectangles somewhere, but I don't know where. Anyone? James Arthur jaa AT arfa DOT clara DOT net ICQ#15054819