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

#1 2012-05-01 13:42:33

Firedrake969
Scratcher
Registered: 2011-11-24
Posts: 1000+

Projectile firing

On my game, Air Dodge, I need a script to fire a projectile.  It is a different one than just plain firing, though, so I'd like an experienced Scratcher.  Go on the link above to download and see what I mean.

EDIT:  The URL is now http://scratch.mit.edu/users/Firedrake969/2510629

Last edited by Firedrake969 (2012-05-02 18:50:09)


Click the sign.
https://s3.amazonaws.com/eterna/eterna2/logo2.png

Offline

 

#2 2012-05-01 15:42:20

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

Re: Projectile firing

Firedrake969 wrote:

On my game, Air Dodge, i need a script to fire a projectile.  It is a different one than just plain firing, though, so i'd like an experienced scratcher.  Go onn the link above to download and see what i mean.  sorry for bad grammar but i have little time.

Since i am reviewing your project tomorrow i will have a look, i'm not that experienced but pratically all my projects have some shooting in them


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

Offline

 

#3 2012-05-01 16:24:10

Firedrake969
Scratcher
Registered: 2011-11-24
Posts: 1000+

Re: Projectile firing

Ok, thanks.  It may be better to download it to actually see the scripts.


Click the sign.
https://s3.amazonaws.com/eterna/eterna2/logo2.png

Offline

 

#4 2012-05-01 16:36:28

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

Re: Projectile firing

Firedrake969 wrote:

Ok, thanks.  It may be better to download it to actually see the scripts.

I'll do that, check my review topic at about 5.00 pm UK time to see what i've found.


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

Offline

 

#5 2012-05-01 17:20:56

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: Projectile firing

I'm not completely certain what kind of projectile firing you want to deal with.  Do you want the bullets to be affected by gravity, or just to move straight?  How many bullets do you want the player to be able to fire? 

Typically, a project like this uses at least one bullet sprite that, when it receives the "shoot" command, goes to the appropriate source of the bullet, moves at a constant speed in a constant direction, until either it hits a target or the edge, and then hides again.  The main problem with this approach is that you can't fire again until the bullet reaches the edge of the screen (or some other obstacle). 

If you want to do multiple projectiles, on the other hand, it gets a little more complicated.  It's do-able, it just takes a bit more time to think about and implement. 

Anyway, reply to this post and I'll see if I can help.

Offline

 

#6 2012-05-01 18:05:04

Firedrake969
Scratcher
Registered: 2011-11-24
Posts: 1000+

Re: Projectile firing

Just look at my game if you need to. it's in my siggy.


Click the sign.
https://s3.amazonaws.com/eterna/eterna2/logo2.png

Offline

 

#7 2012-05-02 07:58:36

zammer990
Scratcher
Registered: 2012-01-22
Posts: 500+

Re: Projectile firing

Firedrake969 wrote:

Just look at my game if you need to. it's in my siggy.

No.... your game doesn't give any real clues as to what you want


http://i45.tinypic.com/2ynq7nn.jpg Play now!

Offline

 

#8 2012-05-02 18:27:12

Firedrake969
Scratcher
Registered: 2011-11-24
Posts: 1000+

Re: Projectile firing

Download it.


Click the sign.
https://s3.amazonaws.com/eterna/eterna2/logo2.png

Offline

 

#9 2012-05-03 01:00:00

AliensFTW
New Scratcher
Registered: 2012-05-01
Posts: 19

Re: Projectile firing

You could just try to make use of the "glide for _ sec to _ block. Just do something like
glide for (needed amount) sec to (x position) + (10000000)
That way it will glide pretty fast.

Offline

 

#10 2012-05-03 07:35:25

jontmy00
Scratcher
Registered: 2011-11-28
Posts: 1000+

Re: Projectile firing

Check the Scratch Wiki here  big_smile


FOR ALL THE NEWS ON UPDATES FOR SIMPLISTICRAFT, CLICK HERE.

Offline

 

#11 2012-05-03 10:15:26

mythbusteranimator
Scratcher
Registered: 2012-02-28
Posts: 1000+

Re: Projectile firing

Do you want the phhysics, like a cannonball? If you do, you can look at my projects, and learn how to create an arc.


http://www.foxtrot.com/comics/2012-04-01-fdb37077.gif
clicky

Offline

 

#12 2012-05-03 19:34:32

Firedrake969
Scratcher
Registered: 2011-11-24
Posts: 1000+

Re: Projectile firing

What I need is the projectile pointing a certain way, staying pointed, and moving a couple of steps.  No grav.


Click the sign.
https://s3.amazonaws.com/eterna/eterna2/logo2.png

Offline

 

#13 2012-05-03 21:43:05

AtomicBawm3
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: Projectile firing

Firedrake969 wrote:

What I need is the projectile pointing a certain way, staying pointed, and moving a couple of steps.  No grav.

Why not just use the move block then?  Otherwise, you can use trig, which basically works out like this:

M=magnitude=total distance you want it to move
change x by M*sin(direction)
change y by M*cos(direction)

To add gravity, simply have to variables that are set to the beginning x and y velocities and then run a script that constantly changes the x and y positions by those and changes the y velocity by your gravity constant.


http://i50.tinypic.com/j0yw0p.jpg

Offline

 

#14 2012-05-06 16:47:25

Firedrake969
Scratcher
Registered: 2011-11-24
Posts: 1000+

Re: Projectile firing

I don't need gravity.  PLEASE READ THAT!


Click the sign.
https://s3.amazonaws.com/eterna/eterna2/logo2.png

Offline

 

#15 2012-05-06 17:33:35

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: Projectile firing

when gf clicked
forever
if<key [space v] pressed?>
set [bulletDirection v] to ([direction v] of [Plane v])
broadcast [Shoot v] and wait
end
end

when I receive [Shoot v]
go to [Plane v]
show
point in direction (bulletDirection)
repeat until <touching [edge v]?>
move (5) steps
end
hide

Last edited by amcerbu (2012-05-06 17:35:16)

Offline

 

#16 2012-05-07 18:42:29

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: Projectile firing

Firedrake969, does that answer your question?

Offline

 

#17 2012-05-10 03:43:33

sonicfan12p
Scratcher
Registered: 2011-11-16
Posts: 1000+

Re: Projectile firing

Are the shots fired by the player, or by an A.I. system?


Why are the secret organizations getting all the attention?  mad

Offline

 

#18 2012-05-10 18:37:44

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: Projectile firing

From what I understand, they're fired by the player.

Offline

 

#19 2012-05-12 01:43:46

sonicfan12p
Scratcher
Registered: 2011-11-16
Posts: 1000+

Re: Projectile firing

In that case, just download the sequel to my Tanks game, and look at the player's firing scripts. The link to the first game is in my signature. The sequel is in a link in a comment on that project. You'll need the code from the first one to access the second however. But that should solve your problem


Why are the secret organizations getting all the attention?  mad

Offline

 

#20 2012-05-13 11:31:36

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: Projectile firing

Firedrake: The remix on my test account fixes the bugs with shooting.

Offline

 

#21 2012-05-13 17:31:11

Firedrake969
Scratcher
Registered: 2011-11-24
Posts: 1000+

Re: Projectile firing

What Is your test acount?


Click the sign.
https://s3.amazonaws.com/eterna/eterna2/logo2.png

Offline

 

#22 2012-05-13 18:07:23

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: Projectile firing

Sorry, I posted the link to the project on the other thread.  Here it is: Air Raid (with pause function)

Offline

 

#23 2012-05-13 19:15:03

Firedrake969
Scratcher
Registered: 2011-11-24
Posts: 1000+

Re: Projectile firing

Great!  Thanks for helping me.  Is it possible to make the missiles stop moving?

Last edited by Firedrake969 (2012-05-13 19:16:00)


Click the sign.
https://s3.amazonaws.com/eterna/eterna2/logo2.png

Offline

 

#24 2012-05-13 19:18:55

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: Projectile firing

I'm still working on it.  The glide function can't be paused, so I've had to modify stuff a bit.  I'll probably finish it up on Monday or Tuesday (can't right now).

Offline

 

Board footer