|
Post by Jonathan Cauldwell on Apr 10, 2012 20:44:22 GMT
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
|
|
|
Post by lukebord1 on Dec 9, 2013 0:47:38 GMT
Just checked for my current AGD game, works like a charm! Thanks Jonathan... That code deserves its specific category inside the sprite events!
|
|
jammajup
Abandoned Uranium Working

Posts: 18
|
Post by jammajup on Mar 27, 2014 19:06:10 GMT
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
|
|
|
Post by Jonathan Cauldwell on Mar 29, 2014 16:06:52 GMT
This code should still work in version 4.5.
Reading your post, I'm just wondering if you forgot to use a separate LET for each variable? Either that or perhaps you have used one or both of these variables elsewhere.
|
|
jammajup
Abandoned Uranium Working

Posts: 18
|
Post by jammajup on Mar 31, 2014 13:00:09 GMT
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).
|
|