Post by Jonathan Cauldwell on Apr 10, 2012 15:44:22 GMT -5
This won't work for versions up to and including v2.7.
Put a couple of lines at the end of your player sprite type:
LET O = X LET P = Y
Then use the following code to hunt the player. The line IF PARAMA > 1 can be adjusted to alter the speed of the pursuer.
ADD 1 TO PARAMA IF PARAMA > 1 LET PARAMA = 0 IF Y > P IF CANGOLEFT SPRITELEFT ENDIF ELSE IF Y <> P IF CANGORIGHT SPRITERIGHT ENDIF ENDIF ENDIF IF X > O IF CANGOUP SPRITEUP ENDIF ELSE IF X <> O IF CANGODOWN SPRITEDOWN ENDIF ENDIF ENDIF ENDIF
Does any of this code differ for version 4.5?,I was planning to use this follow player code for baddies which spawn in certain screens when the player has been playing for X amount of time,I have the o=x p=y in my initialise sprite as it is used to respawn player at location of death and are begining to think that it might be interfering with the follow code. Anyway I have followed instructions above and inserted let o=x p=y In player code and inserted the second block of code in my new enemy sprite 5 and are getting odd effects,The enemy on screen one starts ontop of player killing him and all other enemies on other screens start on upper top left of screen,I have also tried changing the o,p varable to something different like m n
Last Edit: Mar 27, 2014 14:10:29 GMT -5 by jammajup
Last night I decided to load my more recent file and again sit down with it and the chase code was working!that is twice I have switched off frustrated with new code inserted not working and next session the game has been fine lol,must be some sort of over written code in memory type thingy (no I don't actually know).