delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/10/15:19:48

Message-ID: <3324690C.3CA2@swipnet.se>
Date: Mon, 10 Mar 1997 21:03:24 +0100
From: Deltaman <deltaman AT swipnet DOT se>
Reply-To: deltaman AT swipnet DOT se
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Newbie need help

Hi!

I've got four functions in my program that blit a sprite in a specific 
direction. Is there any way to reuse this function to different
directions?
They are exactly the same except for the key that triggers the blitting, 
the direction (xpos, ypos) and sprite that I blit to the sprite buffer.

void walk_left () {
int counter;
counter = 0;
while (key[KEY_LEFT])
{
   if (counter > 3) counter = 0;
   if (counter == 0) blit (data[LEFT_2].dat,
sprite_buffer,0,0,0,0,32,64);
   if (counter == 1) blit (data[LEFT_3].dat,
sprite_buffer,0,0,0,0,32,64);
   if (counter == 2) blit (data[LEFT_2].dat,
sprite_buffer,0,0,0,0,32,64);
   if (counter == 3) blit (data[LEFT_1].dat,
sprite_buffer,0,0,0,0,32,64);
   my_update_function(); */ Does all the double-buffering and sprite
updating and more/*
   xpos--;
   counter++;
}
}

Also, I've read some tutorials and a newbie book and feel somewhat
comfortable
with c. Where can I learn more (there are a lot of tutorials but only a
few 'after the 
tutorials') and eventually begin with c++? 
------------------------------------------------------------------------
______  _______        _______ _______ _______ _______ __   _
 |     \ |______ |         |    |_____| |  |  | |_____| | \  |
 |_____/ |______ |_____    |    |     | |  |  | |     | |  \_|

- Raw text -


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