View Full Version : A.i
Webpest_Gold
October 19th, 2002, 09:32 PM
I have kind of been driven by this once or twice but never givin enough info.
I am making a game how this guy walks around. But there are enemies! When you get close enough to the enemy it will see you. How can I do something how when you get close enough. The enemy will start shooting at you!:o
lostinbeta
October 19th, 2002, 10:11 PM
I don't know how to do this, but here is a theory on how it might be done...
take x,y position of player
take x,y coords of enemy
subtract them from eachother and if either the x or y distance gets below a certain number, then your enemy starts firing.
Again, just theory.... I have never tried this.
bcogswell11
October 19th, 2002, 10:18 PM
Yap, that's it Lost. Webpest, it would be done similiarily to the way I showed you for the guy reaching the computer.
-brad-:cowboy:
Scootman
October 19th, 2002, 11:13 PM
is it a side scroller? or is it like a top view rpg type thing... or is it like an up and down scroller... that depends on the distance you gotta check... if its just the x, just the y, or the x and y...
if its side scroller do
distance = Math.abs(guyX - badguX);
if its top scroller do
distance = Math.abs(guyY - badguyY);
and if its like anywhere on the stage its the distance formula (thanks geometry) hehe had to look this up btw... didnt remember from last year haha
distance = Math.sqrt Math.pow((guyX - badguyX),2) + Math.pow((guyY - badguyY),2));
i think... haha
if i got that wrong the formula is
d = sqrt( (x2 - x1)^2 + (y2 - y1)^2)
lostinbeta
October 19th, 2002, 11:17 PM
Wow, that is some useful info scoot. I am about to start my own game just to try those out :P
Haha, just kidding, but thanks for that anyways. Let us hope it helps out Webpest.
Webpest_Gold
October 19th, 2002, 11:29 PM
Yes, it is side scroller view. But where would I put that actionscript and what would I put under the Math?!?!?
I am confused:elderly: my stupid 11 year old mind can't handle this, lol.
lostinbeta
October 19th, 2002, 11:33 PM
11 years old!??!?!?!
Dude, I think you may be a bit ambitious. Not to put you down because of age, but you haven't even learned geometry and physics yet which is what you need to know in a situation like this. You will also have the know about x and y coords and mathematical equations to determine distance and such.
You at least have to have a basic knowledge of whats going on and why before you can do this project.
Scootman
October 19th, 2002, 11:59 PM
ya... i havent even taken physics yet... im in chem 2 (for some stupid reason)... i shoulda took physics this year but im takin it next year... anyway i rememberd that formula from geometry last year... so i hope it helps you out man...
o ya... Math. just calls math functions... it allows you to do powers, square roots, trig stuff (sine, cosine, tangent), rounding off, absolute value... and more! (sound like an advertisement?) haha...
actionscript is sorta hard to learn at first too... im pretty much self taught from tutorials(from here) and this forum... cuz my multimedia 1 class just taught about tweens and shape morphs...but anyway my learning is off the subject... and i think sbeener and ilyas and flex and other people smarter than me would be the ones to ask for help...
o ya for the side and top scrollers im not sure if the math.abs() is necessary... thats just so you dont get a negative answer in case you wanted to check a positive range
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.