Moving an enemy image towards the player

Creating Games? Developing something for fun?

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
antn18
Posts: 10
Joined: Fri Feb 26, 2016 6:48 pm

Moving an enemy image towards the player

Post by antn18 » Wed Mar 16, 2016 10:46 am

So, i have the enemy following the player using

on opencard
set movespeed to 10
move image "Skeleton gif" to the loc of image "Grado gif" in 1 second
move image "Skeleton gif 2" to the loc of image "Grado gif" in 1 second
end opencard

grado is the name of my player by the way ;) anyways, once the 1 second passes, they follow but stop at the point where Grado started and stay there and stop following, how do i make it so they follow me constantly until i kill them

Ant

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1964
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria
Contact:

Re: Moving an enemy image towards the player

Post by richmond62 » Wed Mar 16, 2016 5:42 pm

I think you need to explain a bit more.

Could you upload your stack here, as a ZIP file ?

AndyP
Posts: 298
Joined: Wed Aug 27, 2008 12:57 pm
Location: Seeheim, Germany (ex UK)
Contact:

Re: Moving an enemy image towards the player

Post by AndyP » Thu Mar 17, 2016 8:27 am

You're only requesting the move happens once.

Try this.

on opencard
moveGrado
end opencard

on moveGrado
put 10 into movespeed
move image "Skeleton gif" to the loc of image "Grado gif"
move image "Skeleton gif 2" to the loc of image "Grado gif"
send moveGrado to me in 1 second
end moveGrado

You may also want to put the movespeed value into a global so you can access and change it at any time from any card or script.

add this to your openStack script

global gmovespeed
put 10 into gmovespeed

https://livecode.com/resources/api/#liv ... cript/send

https://livecode.com/resources/api/#liv ... ipt/global
Andy Piddock

http://2108.co.uk/tinyide/ - TinyIDE gives you more space to develop your ideas

http://2108.co.uk/script-editor-themer/ Script Editor Themer - Your code has never looked so good

My software never has bugs. It just develops random features

antn18
Posts: 10
Joined: Fri Feb 26, 2016 6:48 pm

Re: Moving an enemy image towards the player

Post by antn18 » Fri Mar 18, 2016 12:54 pm

i think you have misunderstood,

i want the enemy skeletons to continue to follow Grado throughout the level.

Ant

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3977
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Moving an enemy image towards the player

Post by jacque » Fri Mar 18, 2016 9:15 pm

i want the enemy skeletons to continue to follow Grado throughout the level.
That's what the script does. Every time moveGrado executes, it sends a command to itself to do it again in one second.

Technically, the command name should be in quotes though:

Code: Select all

send "moveGrado" to me in 1 second
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply

Return to “Creating Games”