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

#1 2009-12-20 18:39:36

CharlieAZ
Scratcher
Registered: 2008-12-24
Posts: 100+

###someone Help!###

Hey, I need help! I made a scrolling game using the basic scrolling script that you see a lot, Now how do I create enemies that walk on their own and will shoot at you when you are within a certain range? Keep in mind that this IS a working scroller.  See it at my profile.  Project name: Iron Man level 1

Offline

 

#2 2009-12-20 18:59:51

martianshark
Scratcher
Registered: 2008-03-24
Posts: 1000+

Re: ###someone Help!###

I only know how to make enemies that don't go anywhere, like in my Skywire Scroller. Example:

<when green flag clicked>
<forever>
<set x to( (( ( [X position] of [scroll5] ) <+> 30 ))
<end>

Last edited by martianshark (2009-12-20 19:00:12)


http://img.geocaching.com/stats/img.aspx?txt=martianshark&amp;uid=e6cdc2c8-2476-4abd-9994-27f857396579&amp;bg=1

Offline

 

#3 2009-12-20 20:09:42

CharlieAZ
Scratcher
Registered: 2008-12-24
Posts: 100+

Re: ###someone Help!###

martianshark wrote:

I only know how to make enemies that don't go anywhere, like in my Skywire Scroller. Example:

<when green flag clicked>
<forever>
<set x to( (( ( [X position] of [scroll5] ) <+> 30 ))
<end>

Love the Sky wire, and thanks, I was able to figure out that much by myself, but I need sprites that walk and shoot at you.  Thanks anyway  smile

Offline

 

#4 2009-12-21 00:08:13

martianshark
Scratcher
Registered: 2008-03-24
Posts: 1000+

Re: ###someone Help!###

Sorry, I don't know how to do that. Making something like that is really complicated.


http://img.geocaching.com/stats/img.aspx?txt=martianshark&amp;uid=e6cdc2c8-2476-4abd-9994-27f857396579&amp;bg=1

Offline

 

#5 2009-12-21 03:35:22

JSO
Community Moderator
Registered: 2007-06-23
Posts: 1000+

Re: ###someone Help!###

(I edited the tile slightly and removed some #'s)


http://oi48.tinypic.com/2v1q0e9.jpg

Offline

 

#6 2009-12-21 06:13:49

Dibbo222
Scratcher
Registered: 2007-11-03
Posts: 100+

Re: ###someone Help!###

My game, PikAdventure, does the above. You should be able to make an enemy that doesn't move, and be able to put it into a certain position on the screen before reading on (just add or take away a number to do this). What I did was make a new variable. This variable would change the "add or minus" number. So, instead of "adding 30" to an enemy's position, you "add variable". Now, either within the script or by making a new script (i think i made a new script), continually change this variable within the constraints you want. But wait, your not done, because the scrolling velocity is changing according to what keys the player is pressing, you must MINUS or ADD the scrolling velocity (should be a variable already). Just play around with it untill it looks better (one will look completely wrong and one will look right). This is so if the player moves left or right, the bullet doesn't seem to slow down or speed up.

That's the moving part done (if you're stuck, ask me). Now, to make the enemy shoot, follow the same sort of principle above. I always use a broadcast block to broadcast to the Bullet sprite that it needs to shoot. If you only want to shoot when the sprite is in range, just check if the distance to Player sprite is less then 100 before broadcasting, for example. When the Bullet sprite recieves the broadcast to shoot, tell it to go to the enemy. Now (bit tricky now), get it to move in a direction and remember to MINUS or TAKE the current scrolling velocity.

Have a look at the scripts in my PikAdventure game if you want.

Any problems, ask!


The biggest tower defense game on Scratch?
http://scratch.mit.edu/projects/Dibbo222/929092

Offline

 

#7 2009-12-21 06:17:15

Dibbo222
Scratcher
Registered: 2007-11-03
Posts: 100+

Re: ###someone Help!###

and i just had a look at ur scripts in your game. yeah, your using the same scrolling techniques as me, but, just a tip, try combining the terrain sprites into 2 if you can. (just think about how this would work and it should be do-able).


The biggest tower defense game on Scratch?
http://scratch.mit.edu/projects/Dibbo222/929092

Offline

 

#8 2009-12-21 12:36:07

CharlieAZ
Scratcher
Registered: 2008-12-24
Posts: 100+

Re: ###someone Help!###

Dibbo222 wrote:

My game, PikAdventure, does the above. You should be able to make an enemy that doesn't move, and be able to put it into a certain position on the screen before reading on (just add or take away a number to do this). What I did was make a new variable. This variable would change the "add or minus" number. So, instead of "adding 30" to an enemy's position, you "add variable". Now, either within the script or by making a new script (i think i made a new script), continually change this variable within the constraints you want. But wait, your not done, because the scrolling velocity is changing according to what keys the player is pressing, you must MINUS or ADD the scrolling velocity (should be a variable already). Just play around with it untill it looks better (one will look completely wrong and one will look right). This is so if the player moves left or right, the bullet doesn't seem to slow down or speed up.

That's the moving part done (if you're stuck, ask me). Now, to make the enemy shoot, follow the same sort of principle above. I always use a broadcast block to broadcast to the Bullet sprite that it needs to shoot. If you only want to shoot when the sprite is in range, just check if the distance to Player sprite is less then 100 before broadcasting, for example. When the Bullet sprite recieves the broadcast to shoot, tell it to go to the enemy. Now (bit tricky now), get it to move in a direction and remember to MINUS or TAKE the current scrolling velocity.
Have a look at the scripts in my PikAdventure game if you want.

Any problems, ask!

Thanks! I will try that soon, but thanks for even playing my Iron Man game!  BTW this is off topic, but did you like it?

Offline

 

Board footer