Re: A83: A problem with my game...


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

Re: A83: A problem with my game...




They probably aren't moving every loop...they're moving 2/3 of the time.  
>From what I see, there's no way for you to know how many loops it skips, and 
I'm guessing you assumed it was doing every loop because it was faster than 
before and you thought it would be going slower.

In order to make it only loop 1/3 of the time, you need to change your 
function so that it will not move most of the time instead of moving most of 
the time.  Two is a special numer..any other number can be used the way you 
want to use it.

I recommend changing the jr z,no_move_aliens into jr nz,no_move_aliens.  This 
will still work and give you the 1:x ratio for AI:loops that you wanted 
instead of the (x-1):x ratio that you currently have.

> 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...