Prev: CF14 Up: Map Next: CF68
CF22: The update routine for the spider that scuttles at random
Graphic 89: deadly both ways (MAKE_DEADLY), falling one unit a turn, and flipped on every other turn, which is its scuttle. It moves diagonally, four units a turn in both U and V; when it bumps into something in U or V, or has no step, it picks a new diagonal at random, U by bit 3 of RANDOM and V by bit 3 of R.
Input
IX the object record
SPIDER CF22 CALL DRAW_AT_L16_D8 the drawing nudge; deadly; fall one unit a turn
CF25 CALL MAKE_DEADLY
CF28 LD (IX+$0B),$00
CF2C CALL DEC_DZ_AND_UPDATE_UVZ
CF2F RES 6,(IX+$07) mirrored on odd turns
CF33 LD A,(TURNS)
CF36 AND $01
CF38 JR Z,SPIDER_0
CF3A SET 6,(IX+$07)
SPIDER_0 CF3E BIT 0,(IX+$0C) bumped in U or V, or still: a new direction
CF42 JR NZ,SPIDER_1
CF44 BIT 1,(IX+$0C)
CF48 JR NZ,SPIDER_1
CF4A LD A,(IX+$09)
CF4D OR (IX+$0A)
CF50 JR NZ,SPIDER_2
SPIDER_1 CF52 LD A,(RANDOM) four units either way in U, and in V
CF55 AND $08
CF57 SUB $04
CF59 LD (IX+$09),A
CF5C LD A,R
CF5E AND $08
CF60 SUB $04
CF62 LD (IX+$0A),A
SPIDER_2 CF65 JP SET_WIPE_AND_DRAW_FLAGS redraw
Prev: CF14 Up: Map Next: CF68