Okay, I have a platformer, mouse to aim gun. But it only shoots in 32 directions, I'm using direction calculator and fastloop for instant hitting. I want 360 degrees! I've tried advanced direction object, but it doesn't seem to work. Maybe a trigonometry idea would be good, although I dont know how to make a bullet shoot at an angle.
If someone could make an example, or post a solution, I'd really appreciate it.
n/a
Assault Andy Administrator
I make other people create vaporware
Registered 29/07/2002
Points 5686
23rd November, 2003 at 22:53:51 -
You need maths mate:
always - bullet.x = bullet.x + cos(bullet.alt a) * 10
- bullet.y = bullet.y + cos(bullet.alt a) * 10
Now, you set the alt a of the bullet to it's angle, and the 10 at the end is the speed. I think that should work, but i don't really know trigonometry.
Pixelate #11 had a good one about trig stuff in games, mostly for c++ tho
Edited by the Author.
"If Darl McBride was in charge, he'd probably make marriage unconstitutional too, since clearly it de-emphasizes the commercial nature of normal human interaction, and probably is a major impediment to the commercial growth of prostitution."
-- Linus Torvalds, December 5th 2003.
(Darl McBride is CEO of The SCO Group)
this place sucks but don't tell anyone, it's our little secret, ok?
"Say you're hanging from a huge cliff at the top of mt. everest and a guy comes along and says he'll save you, and proceeds to throw religious pamphlets at you while simultaniously giving a sermon." - Dustin G
There's another, less mathtastic extension-happy way. Make it so that there's a thick line with hot spot at one end and action point at the other and rotate it. Then always set a small dots possition at the action point. Create another obzect on bounce ball movement ad make it so that when turning, it moves towards the dot, and when it touches the dot the line rotates around 1 unit in the right direction. The bounce ball (you'll probable want it slow) will then make a smooth 32 sided shape when rotating (basically, a circle). When you shoot then, you set value A of the bullet to the difference between the dot's X and the lines X and value B to the Y value difference. Then you use fastloop to reposition the bullets accordingly (X=X+valueA, Y=Y+valueB). This will in fact be more than 360 directions (although it'll need a little fiddling, but I'm sure you can handle that).
Why the hell am I on the computer at 1 in the morning? No, don't answer.
hey, man. I just wrote an article on 360 degree shooting formulas. I should note, in the article, that I was writing it as object 1 was the player and object 2 was the crosshair. Depending on what effect you want to accomplish - there may be easier ways to do it, skipping any asin()*(180/pi) functions. If you want to see an example of what I accomplished with this stuff, check out my tech demo for this game I'm making.
www.kimball-law.com/hg/games/deserted_tdv2.zip