Need a litte help...

Okay, so I was fooling around with this ‘car’ script. Everything is working fine so far, but I’ve come across a problem… I have two points. The front of the car, and the back of the car(indicated by circles). Each work somewhat independently of each other, so the problem is they can either begin to drift apart, or close in on each other. Since it’s a car and they need to be a fixed distance away from each other, I need help on being able to achieve that.

Anyone think they can help? Controls are: S to accel, D to break, left/right to turn. (and it’s the door.png that is the actual car script)

Ah, you have the circles fixed to the velocity of the car, instead of the length of the car, in a sense.

Also a bit odd you have the velocities separated and revolve around getangle a lot, when you could have it based on just a single velocity, sin & cos, and a radial direction.

[code]if(created) {
setimg door.png;
dontblock;
drawunderplayer;
disabledefmovement;
showstats 0;
playerx = x-.75;
playery = y-1.25;
this.maxspeed = 1;
this.turnspeed = pi/20; // 20 frames to turn 180’
this.dir = ((playerdir+1) * pi/2) % (pi*2);
}

if(playerenters || timeout) {
this.speed += (keydown(5)) * 0.2 - (!keydown(5)) * 0.05 - (keydown(4)) * 0.25;
if(this.speed < 0) this.speed = 0; else if(this.speed > this.maxspeed) this.speed = this.maxspeed;
if(this.speed > 0) this.dir += this.turnspeed*((keydown(1))-(keydown(3)));

playerx += sin(this.dir)*this.speed;
playery += cos(this.dir)*this.speed;

showimg2 200,wmace0.png,playerx+1.5+sin(this.dir)-4/16,playery+2+cos(this.dir)-4/16,playerz; // -4/16, to center the image to the point.
showimg2 201,wmace0.png,playerx+1.5-sin(this.dir)-4/16,playery+2-cos(this.dir)-4/16,playerz;

//Fancy Showpoly
showpoly 100,{playerx+1.5+sin(this.dir)*1.5,playery+2+cos(this.dir)*1.5,playerx+1.5-sin(this.dir-1),playery+2-cos(this.dir-1),playerx+1.5-sin(this.dir),playery+2-cos(this.dir),playerx+1.5-sin(this.dir+1),playery+2-cos(this.dir+1)};
changeimgvis 100,0;
timeout = 0.05;
}[/code]

Added a showpoly for the hell of it, and centered the chain links to the points where they were to be detecting (-4/16,-4/16)
Oh, and I changed the turning and accelerating variables a bit to revolve around binary flags to use a bit more math to compress the code.
(^- In case anyone reading this wonders what the hell I just did.)

*edit: And that was fun :open_mouth:
Also if you were trying to make a more “accurate car”, in where the front guides the back, acting separately while attached. Then this wouldn’t help you at all. lol

Ya, I was going for something a bit more realistic that just an angle, heh. I’m not sure if I actually accomplished this, though, because my math is pretty horrible.

Suppose technically you could get the “angle” of the front and back, then have it specifically draw the two chain links out from the center at a fixed radius. The body of the “car” would generally be a fixed shape anyway.

Fixed it :smiley:
It was simple, really. I just did a check AFTER calculations and movement was done of dist/angle and such. And if the distance from the back to front wasn’t 2, made the front = back + sin/cos of the angle between the two * 2.

Now I can start working on other things. Maybe put up a small go-kart server soon.

edit: added drifting(A button). Still working out the kinks, but I’m happy with it so far. Also added reversing(D).

Nice lil project :open_mouth:

Wow, that’s really smooth.

[QUOTE=Nalin;14085]I remember working on a Mario Kart type racing system back in the day. I may try to finish it. Might be tough without an NPC server, though.[/QUOTE]

I tried emulating Mode7 (Mario Kart SNES).
As as far as Graal using it goes, IT FUCKING LAGS. XD

[QUOTE=Nalin;14090]What is wrong with you?[/QUOTE]

Mode7 -^

Wasn’t going to have it as detailed, have it more crude as a “one color per-tile” basis.
Basically a crude ingame 3d engine, Lol. However calculating all of those vertexes, lagged to shit.

[QUOTE=Nalin;14085]I remember working on a Mario Kart type racing system back in the day.[/QUOTE]
–^ I was bored and felt in the mood for “Racers”.

And I didn’t feel like making this --v

But regardless, both of them would have required massive amounts of tiling.
http://www.vgmaps.com/Atlas/SuperNES/SuperMarioKart-SpecialCup-DonutPlains3.png


Not the prettiest thing, but I’ll have to worry about that later! I guess this is no longer a help thread, heh… though there’s still a lot more to do if anyone would like to throw out ideas, or actually help! You know, even with 36 sprites, it still looks jerky as hell, heh.

Already done:

physics are pretty much to my liking.
drifting was a big hope, and I finished it
terrain slowdown
car sprite (I suck at mechanical graphics, but it’ll do)
ramping

To-do:

lap and placement calculations. I have a pretty good idea how I want to do this, however. But if anyone would like to throw out ideas, please do!
wall detection
weaponry
if I make it a server, I need to somehow set up a nice system where you can join races and such.

[QUOTE=Shiny;14096]> lap and placement calculations. I have a pretty good idea how I want to do this, however. But if anyone would like to throw out ideas, please do![/QUOTE]

Placement calculations “could” be tricky, but as for Laps, I recommend putting down a few invisible setshape NPCs as “check points”, if you were to have them more frequent that could double as a placement NPC (or check the distance [a^2 + b^2 = c^2] of who ever is closer to their next check point, the check points [and laps] being further ahead being worth more).

Basically changing it from a distance calculator to some sort of hidden point scoreboard. O_o
Heh, yeah that should work out just fine, however without any real form of globalization (without GServer modding), I’d recommend each player in a race have their own server flag (for time & points), to prevent overwriting, then to wait atleast a second after the race has finished, for comparing points and times [to syncronize clientsided winners].

Edit: Sidenote, if you don’t mind “ripping”, could always grab some Super Mario Kart tiles from www.vgmaps.com haha.

That’s exactly what I was planning on doing, heh. In fact, that’s how I was going to do the placement method as well. Calculate overall ‘distance’ from the end of the race by calculating the distance from the next checkpoint, adding in checkpoints not passed, and laps not finished yet. That should give a rough overall distance from the end of the race, and then simply rank the players by that value.

Excellent.

I think I’m going to try something incredibly stupid.
A 2x Scale server with a ridable train that crosses levels.

As for the 2x Scale, think I’ll used a “fixed” player head, body, sword, shield image
No need to bloat things like I did with the platform server’s head. Thing about the 2x scale, everything will be snapped to the 2x grid. Should make the train more interesting as well.

(The fixed-props cheapens the effect, I know. But technically we should break away from all of the old images anyway).

Well, finished the lap calculation process(this will calculate the distance it will take the player to finish the race, therefor allowing me to rank and figure out player positions easily).

Another to-do:

special effects, mainly skidding.