Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 07-08-2010, 07:40 PM   #1
Registered User
Join Date: Feb 2007
Posts: 3
Talking [AS3] Hit test and depth

hello there. i'm new to as3 code and creating games but i have a simple game in mind that i would like to create and it involves a simple "shooter" type of game where like, the mouse on the stage is moving a pistol or bb gun and like 15 feet away are some random appearing targets and when you press the left mouse, the pistol fires a bullet and if it hits one of the targets then a sound is played and the score is added up etc etc...

much of this i understand how to do but one thing i want to simulate is depth and gravity. from the guns perspective, the targets in the background will visually look like they are several feet away (15 or so) and i don't want the bullet to just travel in a straight line. based on the velocity of the bullet i want some gravity to "pull" the bullet down some when it's fired....making the game more difficult. and i only want the "hit" to count against the target when the bullet has reached the distance in order to actually hit the target. does this make sense?

i was wondering if anyone could show some example code to demonstrate this sort of thing in AS3. visually, my plan was to have it appear as though you were standing behind the shooter maybe a foot behind them. so my gun will end up being like a translucent gun that perhaps flashes real quick
linuxbox is offline   Reply With Quote
Old 07-08-2010, 07:48 PM   #2
Senior Member
Join Date: Feb 2006
Location: Washington, DC
Posts: 2,812
Send a message via AIM to abeall

Well in Flash 10 you actually have a .z property that if you increment linerally it will create the appearance of depth.

You could also use a little mathematical perspective to get the effect:

Aaron Beall | Flash portfolio | Fireworks extensions | Twitter
abeall is offline   Reply With Quote
Old 07-08-2010, 08:27 PM   #3
Registered User
Join Date: Feb 2007
Posts: 3

abeall, that's interesting. what i was thinking about was having two layers of targets...one lower and one higher and simply instead of having the mouse move the gun, keep the gun in a fixed position except have the barrell angle itself a bit according to the x position of the mouse which would be on the target. the targets dont stay on screen but for a second or so and you would have several appearing on those two levels at once.

if the mouse was placed higher than the bottom of the upper level targets then a hit would only apply for the upper level of targets and wouldn't matter if the bullet crossed the plane of the lower level targets. it sounds quite complicated to me actually.
linuxbox is offline   Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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

All times are GMT. The time now is 02:34 AM.

Follow actionscriptorg on Twitter


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.