Pages: 1
Topic closed
So i am making a game similar to metal slug, which is a game made on Scratch. It would be extremely helpful to play the game for a few seconds before answering. So basically the character does not change 'Y' position, but only 'X' position. (This means that the character only moves left to right on the screen, not up or down.) how do i make it so that multiple enemies will come out from each side and move towards the character? I have been thinking of using 'Glide', but my main question is how do i make multiple enemies that look exactly the same come out simultaneously?
Offline
OK, this might work; (sorry, it's a little complex - maybe too complex)
when gf clicked //x velocity is "for this sprite only" forever set [enemy count v] to [0] //"for this sprite only" repeat (length of [enemies v]) //basically check if I'm touching any enemies... change [enemy count v] by [1] if <touching (item (enemy count) of [enemies v])?> if <(x position) < ([x position v] of [player v])> //if I'm on the left of the enemy if <(x velocity) > [0]> //and I'm moving right (towards it) set [x velocity v] to [0] // stop end else //on my right? if <(x velocity) > [0]> //and I'm moving left (towards it) set [x velocity v] to [0] // stop end end end end if <(x position) < ([x position v] of [player v])> //if I'm on the left of the player set [x velocity v] to [4] // set my x speed to 4 (change it to adjust speed) else set [x velocity v] to [-4] //set my x speed to -4 (moves left) end change x by (x velocity) //change x by x speedTo add enemies, just use this:
add [SPRITE NAME OF ENEMY HERE] to [enemies v]was this what your looking for?
Offline
Splodgey wrote:
if <touching (item (enemy count) of [enemies v])?>
There are no lists of sprites, are there? So you can't script: touching variable.
I would make an enemy1 sprite that goes to one side of the screen and then something like this:
repeat until <touching [player v]?> point towards [player v] move (0.5) steps //change this to whatever speed you want endThan duplicate the sprite many times, make them appear from different places.
Offline
aryabtsev wrote:
Splodgey wrote:
if <touching (item (enemy count) of [enemies v])?>There are no lists of sprites, are there? So you can't script: touching variable.
*Facepalm* Your supposed to add all the enemy sprite names to the list. It's kinda like a "Sprite Class". If you see what I mean...
Also, mine makes enemies "bump" into each other.
aryabtsev wrote:
Splodgey wrote:
if <touching (item (enemy count) of [enemies v])?>
repeat until <touching [player v]?> point towards [player v] move (0.5) steps //change this to whatever speed you want endThen duplicate the sprite many times, make them appear from different places.
Scratch on!
It moves left/right. What if the enemies are a different height to the player?
if <(x position) < ([x position v] of [player v])> //if the player's on my right wait (0.5) secs //makes it more realistic, if you jump over something, it will take about 0.5 secs to realise what's point in direction [90 v] //happened (from above) else wait (0.5) secs point in direction [-90 v]
Last edited by Splodgey (2012-04-04 14:23:11)
Offline
Draw enemy
when gf clicked set (side) to (pick random 0 to 1) if <(side) = 1> set x to [240] else set x to [-240] end forever glide (x position of player) for (speed) secondsduplicate the sprite
Offline
Topic closed
Pages: 1