delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/05/04/20:35:45

Date: 5 MAY 97 10:13:09 AST
From: DBerry1 AT dca DOT gov DOT au
Subject: Check a range of numbers with case
To: djgpp AT delorie DOT com
MIME-Version: 1.0
Message-ID: <0000jjzjjbzl.0000iswkaeyu@dca.gov.au>

Morning all

I've slowly been working my way through learning C and DJGPP, and I was 
wondering if it's possible to use a Case statement to check for a range of 
numbers - not just one....

eg..

Switch (bullet_x)

  Case (alien1_x to alien1_x + 16)
	then alien_hit = 1
  Case (alien2_x to alien2_x + 16)
	then alien_hit = 2
  Default
	alien_hit = 0

I guess I'm trying to do a 'bounding box' (?) check to see if a player 
bullet has hit an alien sprite anywhere along it's width.  I'm doing a 
space invaders game where the players bullet just goes straight up the 
screen.

Thanks

David Berry
dberry1 AT dca DOT gov DOT au
-
As you grow up and leave the playground,
where you kissed your prince and found your frog,
remember the Jester who showed you tears.

- Raw text -


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