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

#1 2012-04-12 18:59:06

yan95
New Scratcher
Registered: 2012-04-12
Posts: 2

How i make bullets comeout from my gun

What i mean to say, im doing a game like contra, i want to shoot bullets from my gun. I only have the sprites of shooting, but not the bullets coming out. If you can help me, im really going to appreciate that. Thanks!

Offline

 

#2 2012-04-12 20:43:48

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

Re: How i make bullets comeout from my gun

It's a little bit complicated, but my Tanks project has some scripts for that. Just download it and take a look. It's got scripts for you shooting, and enemies shooting as well. If its too complicated and jumbles together for you, the next level has a simpler script for the same thing. Hope this helps:).


Why are the secret organizations getting all the attention?  mad

Offline

 

#3 2012-04-12 21:23:26

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: How i make bullets comeout from my gun

Scripting just one (reusable) bullet is the easiest, but makes rapid fire basically impossible.  On the other hand, one can use multiple bullet sprites to achieve a "machine-gun" type of fire, but it is more complicated.  For single-bullet fire, use this script in the bullet sprite:

when gf clicked
hide
forever if<mouse down?>
show
go to [gun v]
point towards [mouse pointer v]
repeat until <<touching [edge v]?> or <touching [enemy v]?>>
move (10) steps
end
hide
if<touching [enemy v]?>
broadcast [kill enemy v]
end

Last edited by MoreGamesNow (2012-04-12 21:23:55)


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#4 2012-04-12 21:37:57

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

Re: How i make bullets comeout from my gun

First of all, his script is simpler than the first Tanks level, so for times sake, you should probably use that. Secondly, I forgot about rapid fire. To do that, you would just make copies of the bullet sprite, and then, in between forever if, and show, you would put wait any amount of seconds. Depending on how rapid the fire rate is. In between the wait block and the show block, put an if block that says, if not mouse down, stop script. To prevent all the bullet from flying regardless of if you want to stop shooting.


Why are the secret organizations getting all the attention?  mad

Offline

 

#5 2012-04-12 23:21:53

yan95
New Scratcher
Registered: 2012-04-12
Posts: 2

Re: How i make bullets comeout from my gun

thanks, but, im not doing an FPS, what im doing is a platform. It s just horizontal bullets, but my true problem is to repeat the bullets and doing it with ammo. When ammo reach zero, i reload, but when i start again, the images of bullets dont come out again. I dont know why, but the action of shooting is ok. The problem is just for the bullet sprite. Thanks!

Offline

 

#6 2012-04-13 08:59:40

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: How i make bullets comeout from my gun

when gf clicked
hide
forever if<<mouse down?> and <(ammo) > [0]>>
change [ammo v] by (-1)
show
go to [gun v]
repeat until <<touching [edge v]?> or <touching [enemy v]?>>
change x by (10)
end
hide
if<touching [enemy v]?>
broadcast [kill enemy v]
end


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#7 2012-04-13 10:35:43

THAWKK
New Scratcher
Registered: 2012-02-27
Posts: 37

Re: How i make bullets comeout from my gun

You are gonna have to make a bullet sprite

Offline

 

Board footer