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

#1 2010-08-14 13:47:49

Aloys1320
Scratcher
Registered: 2010-03-12
Posts: 23

Gun Clips.

I was wondering if there was a way to make it so a gun could have a clip, like you have to reload it after lets say, 7 shots. Does anyone know how to do this or have any ideas?

Offline

 

#2 2010-08-14 14:09:15

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: Gun Clips.

this belongs in "all about scratch as it's not an advanced topic... use a variable to count how many shots have been fired and when it reaches 7 don't let it fire again until reload is hit.


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#3 2010-08-14 14:17:54

Aloys1320
Scratcher
Registered: 2010-03-12
Posts: 23

Re: Gun Clips.

ok thanks ill try that. And i thought that it would fit in Advanced because it just seems that way to me. Sorry if i put it in the wrong spot.

Offline

 

#4 2010-08-14 14:25:09

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Gun Clips.

Anything about general Scratch programming goes in All About Scratch, no matter how 'advanced' the scripts needed may be. Advanced topics is reserved for more techical discussion such as modifications to the Scratch program, mesh, etc.

Anyway, here's a script to go along with what sparks said:

Code:

When green flag clicked
set ammo to (size of clip)
Forever
    If <key space pressed> and <ammo > 0>
        {shooting scripts}
        change ammo by -1
    EndIf
    If <key r pressed>
        wait (reload time) seconds
        set ammo to (size of clip)
    EndIf
EndForever

http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/OZn2RD3.png&amp;link2=http://i.imgur.com/duzaGTB.png&amp;link3=http://i.imgur.com/CrDGvvZ.png&amp;link4=http://i.imgur.com/POEpQyZ.png&amp;link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#5 2010-08-14 14:27:38

Aloys1320
Scratcher
Registered: 2010-03-12
Posts: 23

Re: Gun Clips.

ok thanks.

Offline

 

#6 2010-08-14 16:03:39

markyparky56
Scratcher
Registered: 2008-03-20
Posts: 1000+

Re: Gun Clips.

Well thats this solved... close?


http://j.mp/jgVnTq
Check out my game engine development site: NewDawn I'm a Level 171 Scratcher.I am http://bit.ly/nkvLNT

Offline

 

#7 2010-08-14 20:11:53

Chrischb
Scratcher
Registered: 2008-07-24
Posts: 1000+

Re: Gun Clips.

What if further assistance is needed?  hmm
Or I'm just paranoid. xP


I fall: It's a tragedy. You fall: It's comedy.
Hmph enjoy your fall - I get a lovely spring... without pans of new leaves.

Offline

 

#8 2010-08-15 10:36:52

Locomule
Scratcher
Registered: 2009-08-24
Posts: 500+

Re: Gun Clips.

Since it is not closed yet, I'll add a little something. When I was young and teaching myself to program, I had a difficult time because I got caught up in in the names of concepts. For example, I would think of gravity in the terms of real-world physics so the idea of incorporating that into a game seemed impossibly difficult to fathom. Velocity? Forget about it!

Now I realize that in fact, these concepts are usually coded into a game in a few simple lines of script that do nothing except alter numeric variables. The reason I mention this is because the op seems to be sharing a similar perception. I'm not saying that is a bad thing, just that scripting practice will break down that barrier which in turn frees you up as a programmer to add cool features to your project without the seemingly huge gap between "I want my game to do <this> but have no idea how to code it?"


aka Pain from DragonSpires, Delrith Online, BotBattle, Urban Dead etc etc lol

Offline

 

Board footer