[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4762: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4764: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4765: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4766: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
Sean O'Connor's Games • View topic - Programming Question

Programming Question

Command a squadron of spaceships

Programming Question

Postby Sketchy » Fri Apr 10, 2009 1:24 am

Image
Sketchy
 
Posts: 73
Joined: Thu Nov 06, 2008 4:39 pm

Re: Programming Question

Postby Legacy » Fri Apr 10, 2009 1:57 am

"Every man is my superior in that I may learn from him."

Don't take life too seriously, you won't make it out alive!
User avatar
Legacy
 
Posts: 664
Joined: Thu Feb 17, 2005 4:34 pm
Location: Wellsboro, PA, USA

Postby umeboshi110 » Fri Apr 10, 2009 2:52 am

(\ /)
(O.o)
(> <)
umeboshi110
 
Posts: 139
Joined: Tue Oct 11, 2005 1:37 pm
Location: NY

Postby Sketchy » Fri Apr 10, 2009 3:40 am

Thanks for the help - I'm going to take some time to digest it, and see what I can come up with.

As for the radar...

I'm pretty sure the range calculation uses the straight-line "euclidean" distance, but the radar components on each side cover just a 45 degree arc.

Should result in something like this:
Image

And yes, the radar coverage is continuously updated in realtime.
However, the first time you spot an enemy ship, if you then lose contact with it again by the end of the turn, the siren won't sound - so early in a mission be sure to check your radar at the end of every turn.
Image
Sketchy
 
Posts: 73
Joined: Thu Nov 06, 2008 4:39 pm

Postby Fusion_power » Fri Apr 10, 2009 5:35 am

http://en.wikipedia.org/wiki/B%C3%A9zier_curve

You will find a few answers there.

DarJones
User avatar
Fusion_power
 
Posts: 322
Joined: Fri Sep 03, 2004 2:34 pm

Postby Sketchy » Fri Apr 10, 2009 12:13 pm

Thanks for the suggestion guys :)

I understand how to move the ships, once I know the thrust and turning.
The problem is trying to figure out how much thrust and turning are actually needed.

Critical Mass seems to be the only game that calculates thrust & turning from a destination - other similar games, such as FlightCommander2, OverTheReich, and AchtungSpitfire, all require you to enter them directly (using an onscreen joystick & throttle) and then show you the resulting flight path.

It's no use finding the distance between the ship and the mouse - the actual distance travelled will vary depending on the rate of turning, as a straight line is going to be shorter than a curve. The same applies to the ships angle - they can't be treated as if they are independent of one another.

Also, it isn't enough to just pass through the destination - it must be reached after a precise amount of time (ie. the end of the turn).

Again, I can see how Bezier curves are useful for plotting specific points along the ships flightpath, but I don't see how you could extract thrust & turning from one.

If P0 = start, and P2 = target, how do you know P1?
Presumably, it would need to be a very high-order curve too, as a quadratic curve couldn't account for acceleration?
Image
Sketchy
 
Posts: 73
Joined: Thu Nov 06, 2008 4:39 pm

Postby Fusion_power » Sat Apr 11, 2009 4:03 am

Bezier curves account for the full curve expression including turning, acceleration, and distance traveled. It is a lot easier to explain in polar coordinates. Go back and read the wiki and hone your math skills.

DarJones
User avatar
Fusion_power
 
Posts: 322
Joined: Fri Sep 03, 2004 2:34 pm

Postby Sketchy » Sat Apr 11, 2009 12:41 pm

I've read that page (and others on B?zier Curves) many times, and given the 3 or more points, I understand how to draw a curve.

The problem is that I only know 2 points - P0 and P2. How do I find P1?
Image

Is P1 just the point you'd end up at without any rotation or acceleration? If so, I already got as far as drawing that curve.
Even having got a curve though, I don't understand how you can find acceleration & turning from it.

I thought maybe (if I have 50 frames per turn):
* P0 = start point
* P2 = end point (mouse)
* P1 = end point if turning & accel. = 0
* Q0 = 1/50th of the way from P0 to P1
* Q1 = 1/50th of the way from P1 to P2
* B = 1/50th of the way from Q0 to Q1
* Accel. = distance from P0 to B, minus original speed
* Turning = angle from P0 to B, minus original angle

Where have I gone wrong (or is just all completely wrong)?
Image
Sketchy
 
Posts: 73
Joined: Thu Nov 06, 2008 4:39 pm

Postby the space predator » Sat Apr 11, 2009 3:19 pm

It appears to be good
the space predator
 
Posts: 442
Joined: Fri Feb 06, 2009 11:09 pm
Location: Montr?al

Postby Legacy » Sat Apr 11, 2009 6:16 pm

A little bit of fairly basic calculus should suffice...
"Every man is my superior in that I may learn from him."

Don't take life too seriously, you won't make it out alive!
User avatar
Legacy
 
Posts: 664
Joined: Thu Feb 17, 2005 4:34 pm
Location: Wellsboro, PA, USA

Postby Sketchy » Sat Apr 11, 2009 9:09 pm

I'm pretty sure there's no such thing as "fairly basic calculus" :(
Image
Sketchy
 
Posts: 73
Joined: Thu Nov 06, 2008 4:39 pm

Postby Legacy » Sun Apr 12, 2009 2:15 am

It's been a while, but taking derivatives isn't too bad.
"Every man is my superior in that I may learn from him."

Don't take life too seriously, you won't make it out alive!
User avatar
Legacy
 
Posts: 664
Joined: Thu Feb 17, 2005 4:34 pm
Location: Wellsboro, PA, USA

Postby umeboshi110 » Sun Apr 12, 2009 5:41 am

wow, so i was completely off (i just checked using a ruler on my screen too lol). however, i still believe that the turn is double the angle between the "no turn" line and the line between mouse and ship. just in case, i will mention that i'm pretty sure acceleration works instantaneously at the start of each turn and you will move each turn with a constant speed.

well, since you already know how to draw the curve figuring out the rest shouldn't be too hard. i can see that in the quadratic example there, P1 is most definitely not end point if turn/accel=0. it is basically the intersection between the line you would travel if turn=0 and the line you would be traveling in after the turn (extending backwards).
now, i am assuming you will want to approximate a circular arc as this is what it's like in CM as far as I can see. after some geometry/trig, the point P1 is a distance d=(r/2)/cos(θ) along the line of travel if turn=0, where θ = angle between line of travel if turn=0 and line between ship and mouse and r is distance from ship to mouse.

i'll add more stuff if i can figure it out
(\ /)
(O.o)
(> <)
umeboshi110
 
Posts: 139
Joined: Tue Oct 11, 2005 1:37 pm
Location: NY

Postby sorare31 » Sun Apr 12, 2009 7:27 am

how is it that a ship with a tighter turn radius than, say, an orik still manage to get hit by one if fired from behind?
sorare31
 
Posts: 9
Joined: Tue Apr 07, 2009 6:00 am

Postby Sketchy » Sun Apr 12, 2009 12:31 pm

Sorare31:
Missiles have a much higher top speed than ships, and rather than trying to follow the path the ship takes, they can "cut corners" (although they can't "lead their target"). I'm pretty sure a modern AAM couldn't out-turn something like an F-16, but it can fly at Mach4+ so it doesn't need to.
Oriks fired from close range are easy to avoid because they haven't had time to get up to speed yet. Once they've been in the air for a couple of turns though, they become really very annoying.

Umeboshi110:
Thankyou so much - this is just the kind of detailed help I was hoping for :)

You're absolutely right about acceleration being instant, and speed constant. I was convinced that wasn't the case before, but I did some tests, and there's no doubt about it. It seems like that ought to make things easier?

I'm going to put that formula of yours into my program and see how it looks.

I have another question though:
Any thoughts on the best way to make a ship reverse, rather than trying to just turn really tightly?
Image
Sketchy
 
Posts: 73
Joined: Thu Nov 06, 2008 4:39 pm

Next

Return to Critical Mass

Who is online

Users browsing this forum: No registered users and 1 guest

cron