Alice Community gun shooting

 gun shooting
 Rmorrissey1 Junior Member     Status: Offline Posts: 6 Join Date: Jan 2012 gun shooting - 01-29-2012, 03:31 PM How do I make a gun shoot and a bullet comming out 5 times like a revolver then reloading? Thanks for the help!
 Mr Kidnapper Senior Member   Status: Offline Posts: 442 Join Date: Feb 2011 01-29-2012, 04:45 PM I guess your teacher never taught you how to think like a robot. First you have to simplify what happens when a gun is shot into basic steps. Problem is, we don't do that whole physics flash powder exploding thing. No. That's not how it works, at least not with computers. Let's ignore the fact that you have a gun at all. Let's just say you're moving the bullet with your mind and the inner mechanics of that is "It's magic." What happens when a bullet gets shot? It moves forward. Now you're thinking like a robot. What if I want to shoot a lot of bullets? Well you're either going to have to make a lot of bullets or you're going to have to use the same bullet over and over again. Most modern video games just clone the bullet over and over again, but that's not really how it works in Alice 'cause we can't clone in the middle of the game. So move that bullet you just shot back to where it was before you shot it. You can make it move to a dummy that has its vehicle to the camera. At least that's what most people do. But what if I want it to run out of bullets? Well, first you need to think like a robot. Let Alice count how many bullets you have. You can do this with a number variable. Are you using a six-shot revolver? Make it six, or however many bullets your gun holds. Think like a robot again. What happens when a bullet gets shot? You have one less bullet. Now you're thinking like a robot. Subtract that variable by one whenever you shoot. What if you want to reload? Well, first off you're going to have to make an animation that looks like you're reloading. This is up to you. Some people don't even make the animation. After which you set the number variable back to 6, or however many bullets your gun holds. But what if you want something to get killed when it gets hit? Well that's where things get hard. This is called collision detection. Some of the newer members like to get the object under the mouse when it gets clicked. That's okay for now, you can make real collision detection later. But what if you want something to die when it gets killed? Well that's easy. Make an animation that looks like it's dying. I don't know, flip it 90º backwards and make it invisible or something. Last edited by Mr Kidnapper; 01-29-2012 at 04:49 PM.
 Rmorrissey1 Junior Member     Status: Offline Posts: 6 Join Date: Jan 2012 01-29-2012, 08:26 PM But when I have it shoot like five times in a row i have to wait for the bullet that I made to go and come back and after I push the button numerous times it still goes when I do not want it to go anymore.
 Mr Kidnapper Senior Member   Status: Offline Posts: 442 Join Date: Feb 2011 01-29-2012, 10:18 PM Alice is like that. A method has to finish before you start another one, which is why you might make six bullets beforehand instead of using the same one over and over again. Probably ought to have mentioned that beforehand but eh.
 Rmorrissey1 Junior Member     Status: Offline Posts: 6 Join Date: Jan 2012 01-30-2012, 07:44 PM But if I made six bullets woud I have to make a different button for each to shoot because if I made all of them go when lets say button "a" was pressed wouldn't they all go at the same time?
 Mr Kidnapper Senior Member   Status: Offline Posts: 442 Join Date: Feb 2011 01-30-2012, 09:58 PM That's where you use an IF function. IF bullet 1 has been shot, then shoot bullet 2. That sort of thing. The "has been shot" variable is a boolean variable that gets set to true when you use the shoot method, and all of them gets set to false when you reload.
 sfunk Senior Member     Status: Offline Posts: 1,112 Join Date: Mar 2011 Location: I don't know 01-31-2012, 06:40 AM to go off a little more on what kidnapper said, you might want to use a number variable to decide which bullet is being fired, while using your if/else function. so say if your variable "bullet==6" then that bullet would be fired and so on If you are stuck on a project, check out the tutorials I made here at this link: http://alice.org/community/showthread.php?p=36778#post36778 There are lots of tutorials on it so far, including some youtube videos, check it out Or.. Go to my youtube channel to check out my alice 2.2 tutorials I have there.. http://www.youtube.com/user/sfunk1992?feature=mhsn
AliceMaster00
Senior Member

Status: Offline
Posts: 167
Join Date: Oct 2011
Location: You know that gap between the bottom of your dresser and the floor? Yeah, there.
01-31-2012, 09:39 AM

Quote:
 Originally Posted by Rmorrissey1 How do I make a gun shoot and a bullet comming out 5 times like a revolver then reloading? Thanks for the help!
Just make one bullet come out then in really fast. Make a number variable called ''bullets'', then set it to 5. then place ''When mouse is clicked on anything do
Do Together
revolver turn backward .15 revolutions .5 seconds abruptly
bullet move foward 20 meters .2 seconds abruptly

Do Together
revolver turn foward .15 revolutions .5 seconds gently
bullet move backward 20 meters 0 seconds abruptly''

The reason why gently is because the shoot ting would be more realistic.

What a piece of work is a man? How noble in reason, how infinite in faculties, in form and in motion, how express and admirable how like an angel! What apprehension oh how like a god! The beauty of thee world, the paragon of animals, and yet- to me, what is this quintessence o' dust? Man delights, not me. Nor woman either, nor woman either.

Superdog
Junior Member

Status: Offline
Posts: 1
Join Date: Feb 2012
Location: Worcester
02-07-2012, 04:21 PM

Quote:
 Originally Posted by sfunk to go off a little more on what kidnapper said, you might want to use a number variable to decide which bullet is being fired, while using your if/else function. so say if your variable "bullet==6" then that bullet would be fired and so on
Cityville Hack

sfunk and Mr Kidnapper put it well, a simple if function should suffice.
It might even be a better solution to use an array rather than individual variables for each of the bullets, so you'd have Bullet(0), Bullet(1), Bullet(2), etc!

Microsoft Points Codes

Last edited by Superdog; 02-28-2012 at 10:06 AM.

 GameKid Senior Member     Status: Offline Posts: 467 Join Date: May 2011 Location: My magnificent castle 02-07-2012, 11:51 PM Actually, there's a simpler way to stop the methods from backing up like this. Just put the method block in the begin section of while a key is pressed instead of when a key is pressed, and the method shouldn't occur unless it's not already on. [COLOR=e4eaf2]Your text here[/COLOR] Come on, you know you want to try it.

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Announcements     Community News and Announcements Alice 3     How Do I?     Works In Progress     Share Your World     Share Custom Classes     Bugs and Trouble Shooting     Suggestion Box Alice 2     How do I...?     Works-In-Progress     Share Worlds     Share Objects     Bugs and Troubleshooting     Suggestion Box Educators     Teaching with Alice     Teaching Using Alice 3     Teaching Using Alice 2     CS Principles and Alice     AP CSA and Intro to Java and Alice     Workshops General Discussion     Questions and Comments     The Lounge