Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
shooting game
Old
robertcolberg
Guest
 
Status:
Posts: n/a
Angry shooting game - 12-03-2009, 01:55 PM

how do i make a gun (revolver) aim at zombies? like when you turn it automatically aims at them like in resident penguin? and so that they turn a certain color when they are pointed at? please help thank you
   
Reply With Quote
Old
x2495iiii
Super Moderator
 
x2495iiii's Avatar
 
Status: Offline
Posts: 3,508
Join Date: Dec 2008
Location: Somewhere in the Continental U.S.
Default 12-03-2009, 02:30 PM

Warning, this one's complicated!

I used two cones I called leftmark and rightmark positioned to the left and right of the penguin, vehicled to him, and oriented to the penguin, but turned inward slightly (so the left cone was turned slightly right and the right turned slightly left), then used a series of if/else ifs which checked to see if each zombie was

-to the left of rightmark
-to the right of leftmark
-in front of penguin (otherwise it would work if you were facing directly away from the zombie as well)
-isShowing (so as not to target already dead zombies)

And if all four of those things are true, it would set the target variable to the number of the zombie's placement on an enemies list I'd made which included all of the zombies.

Check inside the targetCheck method (or whatever I called it, it's called by the event "when a number changes" and the method I called "not for the faint of heart" in my comments in the very first method, gameStuff) to see what I mean.

Glad you liked the game, by the way. Hope you can learn from it.


(')>
   
Reply With Quote
Reply

Tags
gun shooting game

Thread Tools
Display Modes

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 Jump



Copyright ©2024, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.