Discuss Scratch

Xyyzzz
Scratcher
79 posts

Multiple attacking

Hey guys, I need some help on how to make multiple attacks occur. For example, http://scratch.mit.edu/projects/14165857/ in that game whenever you shoot somewhere and then quickly shoot somewhere else, the first attack disappears and gets replaced by the second one. I'd like to know how to make it so that when you use fast weapons, you can show more than just 1 attack.

All help would be appreciated!
ZorchyGroxFox
Scratcher
9 posts

Multiple attacking

I'm no expert in scratch 2.0 (or any scratch for that matter) but is there a way you could use the cloning feature to generate attack sprites under the cursor whenever it's clicked, rather than having to move the same sprite to the cursor over and over again? If you're looking to do this in 1.4, I've been trying for a while to do something similar and havent had any luck, so I guess I can't help much there. Anyway.
Xyyzzz
Scratcher
79 posts

Multiple attacking

Yes I've tried clones but they take a bit of time to generate, and in an action game like this one (well, in the future), lagg would be pretty bad. D:
scubajerry
Scratcher
1000+ posts

Multiple attacking

You can generate a bunch of clones and have them hidden until you need them. When they hit, don't delete, just hide and put it back in the inventory.

Last edited by scubajerry (Nov. 12, 2013 01:25:08)

Xyyzzz
Scratcher
79 posts

Multiple attacking

Thanks scuba, I'll try it out soon.

Also, I want to make it so that you don't have to press particular keys in order to switch weapons. I just want it so that you could press the right or left key and it'd scroll through the weapons you bought (for example if I bought weapons 1 and 3 I could press right and it'd go to weapon 3 if I'm wearing weapon 1). Would this be possible to code without having to put manual instructions for every instance?
scubajerry
Scratcher
1000+ posts

Multiple attacking

If I understand your question, you make a LIST that contains your available weapons. You make some variable that points to the one in the list that you are currently using. Increment that variable if you hit right arrow and decrement it if you hit left arrow

whenkeyleft arrowpressedifweaponindex=1thensetweapon indextolengthofweapon listelsechangeweapon indexby-1whenkeyright arrowpressedifweaponindex=lengthofweapon listthensetweapon indexto1elsechangeweapon indexby1

Last edited by scubajerry (Nov. 12, 2013 05:45:26)

Xyyzzz
Scratcher
79 posts

Multiple attacking

Oh I see, thanks for the advice. Also I'm fixing the multiple attacks but whenever you attack twice without waiting for the first clone to vanish, the next one stacks a clone on top of the first one. It only fixes if you wait for all the clones to vanish.

http://scratch.mit.edu/projects/14170446/

I want to fix it so that it doesn't stack.. any ideas?

Powered by DjangoBB