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

#1 2007-07-26 15:19:46

lubigor
Scratcher
Registered: 2007-07-24
Posts: 3

FOR ADVANCED PEOPLE

How can I make my Spite(Soldier)shot in 4 directions left,right,up,down and also move in the same?
I made 4 diferent Cosumes,for each direction(one for moving one for shoting) and I wont to combine costumes and direction of fire,so that I can shot and move up,down.left and right.

Offline

 

#2 2007-07-26 15:34:21

Graham
Scratcher
Registered: 2007-04-06
Posts: 53

Re: FOR ADVANCED PEOPLE

Well, make a variable called 'direction' and say 'forever set direction to sprite1's direction. if key space pressed broadcast shoot'. and for the bullet 'when I receive 'shoot' point in direction 'direction'. repeat until touching edge: move 5 steps' That might work.

Last edited by Graham (2007-07-27 19:43:00)


Mini Game heaven: http://scratch.mit.edu/projects/Graham/20856 Don't press the Button: http://scratch.mit.edu/projects/Graham/3167 and Army Ants: http://scratch.mit.edu/projects/Graham/1059

Offline

 

#3 2007-07-26 15:38:24

AngelEyra
Scratcher
Registered: 2007-07-19
Posts: 100+

Re: FOR ADVANCED PEOPLE

Graham wrote:

Well, make a variable called 'direction' and say 'forever set direction to sprite1's direction if key space pressed broadcast shoot' and for the bullet 'when I receive 'shoot' point in direction 'direction' repeat until touching edge move 5 steps' That might work.

Wha?

That took me about half a minute to process.

eyra

Last edited by AngelEyra (2007-07-26 15:38:52)


AngelEyra's . MyScratchR . Blog
Think with portals
Sorry, Companion Cube... I didn't mean to...

Offline

 

#4 2007-07-26 16:39:22

Sawman3
Scratcher
Registered: 2007-07-19
Posts: 97

Re: FOR ADVANCED PEOPLE

Actually, lubigor, another way to do this would be to have the arrow keys or the w, a, s, and d keys be for the soldier's movements and then have a sight for his gun that follows the mouse pointer.  That way you could aim anywhere, smoothly, and still be able to move.  Alternatively, you could set the soldier's movements to the arrow keys and the gun's aim to the w, a, s, and d keys or vice-versa, though with that settup the controls would be much clunkier.


"These are the old days, the glory days...they're back."

Offline

 

#5 2007-07-26 18:15:05

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: FOR ADVANCED PEOPLE

Put simply here it is:

Variables you need: direction

now on the player sprite put this.

When flag clicked
forever if {key right down}
change x by 3 ( or however many units you want to move him)

And repeat this and alter for each direction

Now the bullet sprite put this

When flag clicked
forever if {key right down}
set direction to 90

and again repeat for each direction

now for firing

when space (or any firing key) pressed
goto "player"
show
point in direction "direction" ("direction" is the variable)
repeat until touching edge or enemies
hide
move 3 ( or move however many you like)

Thats all  smile


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

Board footer