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

#1 2012-03-11 16:01:19

MeTwo
Scratcher
Registered: 2010-11-29
Posts: 14

How to make a bullet set-up

ok, this is a bullet set-up i made by myself but it is a little complicated with variables and lists. if you are not an experienced scratcher, turn back now.

THIS SCRIPT ALLOWS YOU TO HAVE MULTIPLE BULLETS OUT ON THE FIELD.

  So, you are going to have 2 to 7 sprites depending on how many bullets you want on the project. one sprite is going to be the player and the others are going to projectiles.

  Here is the script for the player:

when gf clicked
forever if <mouse down?>
  broadcast [shoot v]
  wait until <not<mouse down?>>
Also for the player (separate):

when I receive [shoot v]
set [counter v] to [1]
set [found open v] to [0]
repeat until (found open) = [1]
  if <(item (counter) of [bullets v]) = [0]>
     set [broadcast v] to (counter)
     set [found open v] to [1]
  else
     change [counter v] by [1]
broadcast (broadcast)
(connect that^)
now for each bullet:

when I receive [1 v]
show
go to [player v]
replace item [1 v] of [bullets v] with [1]
point towards [mouse-pointer v]
repeat until <touching edge v>
  move [10] steps
hide
replace item [1 v] of [bullets v] with [0]
note that if you are making more than one bullet, you must change the number you are to replace in the list and also note that you CAN pit a variable representative in a broadcast. make a broadcast for each bullet such as 1 for your first bullet and 2 for your second and so on.

I hope you are getting my script because it's a really great way to shoot multiple bullets.

Last edited by MeTwo (2012-03-11 16:04:17)

Offline

 

Board footer