A83: A problem with my game...


[Prev][Next][Index][Thread]

A83: A problem with my game...




Hey everyone,
  I've got a problem with my game.. and I can't find out why it's happening! 
With my game Alien Breed II, I have an artificial intelligence routine. It's 
called from within the main game play loop. Now, the AI routine is at the 
moment only supposed to run every 2nd loop, and this is how I've set it up 
to do this:

main_loop:

  key press stuff
  more stuff
  call move_aliens     ; AI routine
  more stuff
  even more stuff
  jr main_loop         ; loop back to beginning

move_aliens:

  ld a,(aliencnt)      ; load count into A
  inc a                ; increment
  cp 2                 ; is it 2?
  jr z,no_move_aliens  ; if so, don't move aliens this loop
  ld (aliencnt),a
  ; the alien AI crap goes here
  ret

no_move_aliens:

  xor a                ; reset counter (A=0)
  ld (aliencnt),a      ; re-initialise variable
  ret                  ; back to main loop


Now, this works.. the problem is, when I change the "cp 2" to a different 
value, eg. "cp 3", the aliens don't move every 3rd loop, they move EVERY 
loop. Can anyone PLEASE tell me why??
Thanx,

James Vernon
jimbob_v@hotmail.com

PS: I hope I explained it properly...


______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com