I can not exactly type out a script for you at this moment as i am busy, but I suggest, if what you are after is a bouncing script, check out the script of the project in my signature, it might be helpful.
Offline
For each coin sprite, make a script like this:
when gf clicked hide when i receive [monster_dead v] show go to [monster v] set [yvel v] to (pick random (3) to (10)) set [xvel v] to (pick random (-10) to (10)) repeat until <touching [player v]?> change y by (yvel) change x by (xvel) if <touching [ground v]?> set [yvel v] to ((yvel) * (-1)) set [xvel v] to ((xvel) * (0.8)) else change [yvel v] by (-0.1) end end hideJust remember to make xvel and yvel "for this sprite only".
Offline
BirdByte wrote:
For each coin sprite, make a script like this:
when gf clicked hide when i receive [monster_dead v] show go to [monster v] set [yvel v] to (pick random (3) to (10)) set [xvel v] to (pick random (-10) to (10)) repeat until <touching [player v]?> change y by (yvel) change x by (xvel) if <touching [ground v]?> set [yvel v] to ((yvel) * (-1)) set [xvel v] to ((xvel) * (0.8)) else change [yvel v] by (-0.1) end end hideJust remember to make xvel and yvel "for this sprite only".
after he dies do you know how to make a store so you could buy more things?
Offline
lilyo11 wrote:
BirdByte wrote:
For each coin sprite, make a script like this:
when gf clicked hide when i receive [monster_dead v] show go to [monster v] set [yvel v] to (pick random (3) to (10)) set [xvel v] to (pick random (-10) to (10)) repeat until <touching [player v]?> change y by (yvel) change x by (xvel) if <touching [ground v]?> set [yvel v] to ((yvel) * (-1)) set [xvel v] to ((xvel) * (0.8)) else change [yvel v] by (-0.1) end end hideJust remember to make xvel and yvel "for this sprite only".after he dies do you know how to make a store so you could buy more things?
That's kinda unrelated to the topic; make a new one about it.
Offline
As an addition to BirdByte's script, you might want to add vertical friction (e.g. set [y-vel v] to ((0.95)*(y-vel))) and/or bouncing off of walls (if it isn't just a flat field).
Offline
MoreGamesNow wrote:
As an addition to BirdByte's script, you might want to add vertical friction (e.g. set [y-vel v] to ((0.95)*(y-vel)) and/or bouncing off of walls (if it isn't just a flat field).
Yeah, do that. XP But remember to make sure that the coin doesn't get stuck in the ground by adding "change y by 1" to the "set yvel to yvel*-1" script.
Offline
Here's the easiest change I could think of. It may even look better since it resolves the bounce in single frame:
when gf clicked hide when i receive [monster_dead v] show go to [monster v] set [yvel v] to (pick random (3) to (10)) set [xvel v] to (pick random (-10) to (10)) repeat until <touching [player v]?> change y by (yvel) change x by (xvel) if <touching [ground v]?> change y by ((-1)*(yvel)) set [yvel v] to ((yvel) * (-0.8)) set [xvel v] to ((xvel) * (0.8)) else change [yvel v] by (-0.1) end end hide
Offline
Oops, forgot walls. I'll leave the other script up in case you don't need them:
when gf clicked hide when i receive [monster_dead v] show go to [monster v] set [yvel v] to (pick random (3) to (10)) set [xvel v] to (pick random (-10) to (10)) repeat until <touching [player v]?> change [yvel v] by (-0.1) change y by (yvel) if<touching [wall/ground v]?> change y by ((-1)*(yvel)) set [yvel v] to ((-0.8)*(yvel)) set [xvel v] to ((0.8)*(xvel)) end change x by (xvel) if<touching [wall/ground v]?> change x by ((-1)*(xvel)) set [xvel v] to ((-0.8)*(xvel)) end end hideInstead of "set [xvel v] to (pick random (-10) to (10))", you can add the monster's x velocity to a random number (like below) if you want (assuming the monster is moving at a velocity).
set [xvel v] to ((monster_x_velocity)+(pick random (-4) to (4)))
Offline