Tank game(help)

NoMercy
02-07-2002, 11:38 PM
I am making a tank game wehre you pick an angle and choose a power. My problem is when shooting the bullet I found the slope of the barrel. but the bullet always went straight up until the slope was more .5 I think it is because it is round to 0. How can I get the bullet to move in the direction of the barrel?

wild wolf
02-08-2002, 12:50 AM
I am making a tank game wehre you pick an angle and choose a power. My problem is when shooting the bullet I found the slope of the barrel. but the bullet always went straight up until the slope was more .5 I think it is because it is round to 0. How can I get the bullet to move in the direction of the barrel?


iam really sorry but i din get what u meant, :o

Ad1
02-08-2002, 04:20 AM
you could try multiplying your slope by 10 so you would have 5 instead of 0.5, and then just alter your algorithm to adjust to that

Squirm
02-08-2002, 06:57 AM
Alternatively, use the Single or Double datatype instead of Long or Integer.

Teric
02-08-2002, 07:55 AM
Could you attach your code here so that we can take a look at it? I'd like to see what you're doing with the tank game anyway--Scorched Earth is a classic!

NoMercy
02-08-2002, 10:24 PM
yeah sure I iwll do it tomorrow. Mine is gonan be Almost a twin to scorched earth Just having a couple glitches

Waxycat
02-09-2002, 07:01 AM
well how about this, just take the angle and initial force, turn them into x and y velocities as so (F is force, A is angle): Xv = F * cos(A), Yv = F * sin(A). after that, X velocity should be pretty much constant throughout the path, unless you want air resistance/wind. Y velocity should have gravity decreased from it every frame, again, with a slight lift if there is to be air resistance or a terminal velocity. then X and Y possitions should be calcualated by adding X and Y velocities. make sure not only that you're using floating point numbers, but signed numbers.

the next part's the collision detection, which can differ depending on wheather you're using lines/polygons or height points/a topographical map.

andreww
02-14-2002, 05:49 AM
thats pretty simple


i made a game where u fire bullets at the direction of the gun..what i did was

the radius is like the turning circle of the barrel..or u could just remove it..i cant remember how much difference it would actually do as the bullet would be goining straight
anyway u are basically setting the angle of the bullet for each bullet fired


If FireButton=True then
Counter=Counter+1
Bullet(Counter).Angle= Player.Angle
Bullet(Counter).Active=True
End If

For i = 1 to Counter
If Bullet(i).Active=True then
Bullet(i).x=Bullet(i).x+ Cos(BUllet(i).angle)*Radius
Bullet(i).y=Bullet(i).y+ Sin(BUllet(i).angle)*Radius
End If



hey i was wondering if your doing it like scorched earth i was wondering how you are doing collision detection of the terrain, and if you are allowing the terrain to be deformed, what method are u using?

also you know how scorched earth did the falling dirt effect, u wouldnt possibly know how they did that either ? :)

Waxycat
02-14-2002, 02:29 PM
me? i'm not making anything like scorched earth (or at least i don't plan to yet). i'm not even entirely sure what scorched earth is, i don't remember, but if it's the game i'm thinking of, here's how i think they did it: they have an array of numbers each representing sequential equally spaced horizontal locations, each number represents the height at that point. so it's like a 2D topographical map. then, as the projectile is moveing through the air, with each step, the 2 horizontal points it is between and their heights are used to find a line that intersects them. then, the height of the projectile is compared to the height at that point on the line, and if it's below or equals it, it hit the ground; if it's above it, it's still moving. if it hit the ground, they probably just find the percentage across from one horizontal point to the other and multiply it by a constant (the total force, so maybe it's not a constant) and then lower the point by that much. then do the same with the remaining percentage for the other point. it might take it a little further, and use the angle of the force as well. furthermore, they might tapper off to the surrounding points outside of those 2. and if they took it a step further, they would probably be using intermediate calculus. but anyway, that was all a fairly good way of doing that.

Flyguy
02-14-2002, 04:06 PM
Can you please start using CAPITALS when starting a new sentence! Adding some linefeeds would be nice too.
Man your posts are so hard to read!

Waxycat
02-15-2002, 02:53 PM
Me? Sorry, I didn't realize it bothered anyone. But don't mistake my lazyness for gramatical ignorance.

Squirm
02-15-2002, 04:09 PM
Well your laziness means we have to spend extra time reading your posts and thus cant understand you so well or answer you so quick. Use a little sense and everything runs smoother....

Waxycat
02-15-2002, 04:29 PM
I didn't realize it was hard to read. You should see some of the terrible typing I've had to endure! I said i'm sorry, chill.

Kitaiko
02-15-2002, 06:51 PM
itwasntthathardtoread! Lol

Waxycat
02-16-2002, 06:58 AM
Kitaiko, you forgot to use BuMpYtExT!

wild wolf
02-16-2002, 08:47 AM
lets talk about something more sensible and stop wasting server space. Lets get to the original post again :mad:

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum