This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2013-01-02 08:09:25

Willpower
Scratcher
Registered: 2012-01-26
Posts: 1000+

Changing direction while moving (if that makes any sense :P )

Hi there, i am making a project at the moment which has the player use magic to stop any enemies touching them.

One of the spells is Wind, which theoretically should blast the enemies backwards but the enemy is already gliding 5 seconds to the player's position and it does this instead of being blasted backwards.

Is there any way to stop this from happening?

I will appreciate any help, even if it is "give up now"  tongue

~Willpower

Last edited by Willpower (2013-01-02 08:09:45)


http://i49.tinypic.com/e84kdj.png

Offline

 

#2 2013-01-02 09:41:49

Ideas
Scratcher
Registered: 2012-10-07
Posts: 100+

Re: Changing direction while moving (if that makes any sense :P )

I would like to help so, could you either type out the magician's scripts as well as the enemies scripts in or upload the project - that would help.
<                                  >
The main problem I can 'see' from my 'view' is to replace the

glide to x (x position) y (y position) for (0) secs
. Rather let your enemy
point towards [player v]
move(your amount) steps
wait (wanted delay time) secs//to calculate how long it will take to get at the sprite simply do this ((distance to player / steps moved)* time delay)
For your player:
when gf clicked
forever
set x to (your x position)
set y to (your y position)
if <(mouse down?)>
broadcast [attack v] and wait 
end
end
Then when you attack in the enemy's scripts
when i recieve [attack v]
if <([abs v] of (distance to [player v])) < (desired range)>
point towards [player v]
move((desired range)*[-1]) steps
end
Hope this helps

Last edited by Ideas (2013-01-02 10:02:58)


http://img685.imageshack.us/img685/2010/screenshot20121110at132.pngI think that you must CLICK above

Offline

 

#3 2013-01-02 10:21:04

Willpower
Scratcher
Registered: 2012-01-26
Posts: 1000+

Re: Changing direction while moving (if that makes any sense :P )

Magicians Scripts- basically the spell which you type in is the spell that is cast- the magician does not move at the moment unless you cast the "Teleport" spell

http://i49.tinypic.com/20qgefk.gif


The enemy "Skeleton" scripts
http://i47.tinypic.com/wbb1mt.gif

I know roughly what you are saying and i thought the glide was the problem but the desired range is confusing me and since the skeleton can start from 8 different positions i think your solution will not work. I should of put these scripts up to start with  sad


http://i49.tinypic.com/e84kdj.png

Offline

 

#4 2013-01-02 13:34:36

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: Changing direction while moving (if that makes any sense :P )

Willpower wrote:

Magicians Scripts- basically the spell which you type in is the spell that is cast- the magician does not move at the moment unless you cast the "Teleport" spell

http://i49.tinypic.com/20qgefk.gif


The enemy "Skeleton" scripts
http://i47.tinypic.com/wbb1mt.gif

I know roughly what you are saying and i thought the glide was the problem but the desired range is confusing me and since the skeleton can start from 8 different positions i think your solution will not work. I should of put these scripts up to start with  sad

Actually, you didn't need to put all of those scripts because this doesn't involve all of them. And the first half of what Ideas proposed will actually work; just put it after your placement script. The only thing he forgot is a repeat loop around the movement part of the script or else it'll run once and end. So what you'd need is:

point towards [player v]
repeat until (Dead?)
 if (Allowed to move?)//Not needed.
  move(your amount) steps
  wait (wanted delay time) secs//to calculate how long it will take to get at the sprite simply do this ((distance to player / steps moved)* time delay)
 end
end

Moving on, the only option you have that keeps your glide block is to use broadcasts, though it can get messy. So, you'll have to broadcast this whenever you want to start or stop movement, but not when you want to check to see if you should be moving or not:

when I receive [recheck v]
if (Should be moving?)//Replace with conditional.
 glide (5) secs to x: (89) y: (89)
else
 Whatever scripts you want...
end

I hope that this helps!

Last edited by ErnieParke (2013-01-02 13:34:48)


http://i46.tinypic.com/35ismmc.png

Offline

 

#5 2013-01-02 14:39:22

Willpower
Scratcher
Registered: 2012-01-26
Posts: 1000+

Re: Changing direction while moving (if that makes any sense :P )

Thank you very much, from your help i have created this script which means it can not move when it is hit by an Iceshard and it gets blasted back when it touches Wind or a Windshield

http://i46.tinypic.com/t4teuf.jpg

Requesting to be closed  big_smile

Last edited by Willpower (2013-01-02 14:39:46)


http://i49.tinypic.com/e84kdj.png

Offline

 

#6 2013-01-02 15:15:42

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: Changing direction while moving (if that makes any sense :P )

Closed by request of the topic owner.


http://i39.tinypic.com/2nav6o7.gif

Offline

 

Board footer