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)
Offline
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
Offline
Ok, thanks. It may be better to download it to actually see the scripts.
Offline
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
Do you want the phhysics, like a cannonball? If you do, you can look at my projects, and learn how to create an arc.
Offline
What I need is the projectile pointing a certain way, staying pointed, and moving a couple of steps. No grav.
Offline
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.
Offline
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
Are the shots fired by the player, or by an A.I. system?
Offline
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
Offline
Sorry, I posted the link to the project on the other thread. Here it is: Air Raid (with pause function)
Offline
Great! Thanks for helping me. Is it possible to make the missiles stop moving?
Last edited by Firedrake969 (2012-05-13 19:16:00)
Offline