Log In  

Ghost Rally

Cart #grally-0 | 2019-06-02 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
53

Game

The game is a race-against-yourself rally game. It features accurate rigid body physics and car handling.
Goal is to beat yourself every lap!

Enjoy racing as in the 80's, whith over powered cars very close to the public!
tip hitting any of the lil' dudes:
[0x0]
incurs a +5s time penalty :]

warning the game is complete yet the car handling is really picky - I am releasing it as is, as I can't tweak the gameplay without breaking the physic engine :/

Controls

  • left/right: turn
  • up/down: accelerate/brake
  • c: recover (when flipping over!)

Dev Log

Source code & tools: ghost-rally

Credits:

Sound effect code: taken from @tiagosr rally game
Trifill: @p01

Physic Engine

Physic engine was started from scratch following Barraf's 'classic' paper.
I quickly dropped this version as it relied too much on numeric convergence !

The current version uses part of Randy Gaul C++ physic library and underlying principles.
The key aspect to get stable collision is to resolve impacts only for the incident face, e.g. the plane most facing the ground:

This is obviously an heavily simplified version, limited to dynamic-to-static resolution.
Randy's engine architecture relies on very few magic constants and is extremely stable (well, as long as pico numbers don't get in the way!!).

The physic engine is designed as an extension a generic 3d actor class and can easily be taken out for other games.

Car Physic

The car is modeled using a front and rear tire. Each tire has lateral and longitudinal forces, as detailed in this article: The Racing Line - Combined Tyre Forces.
Other good readings:
Car Physics for Games
Box2d Top Down Racing Game

The gif above shows forces applied to the car and their application point:

  • G force (down)
  • read tyre pushing car (with a lateral component to counter slide)
  • front tyre and turning forces (again with a lateral component)

Slip angle and slip ratio curves are defined using SFX 4 and 5 - tweak them to see effect in game!

Terrain

The game started as a terrain renderer using marching squares.
Terrain height map is 64x64, displayed as a 128x128 grid to display marching square "diamond tiles":

Textured Car

The car is textured mapped, using a custom version of @p01 trifill.
The Blender model directly references an export of the cart spritesheet.

Toolchain

The game uses my usual Blender/Python export toolchain.
A custom terrain editor is available as a pico-8 cart (contact me if needed)

P#64950 2019-06-02 14:33 ( Edited 2019-06-04 20:11)

Well done !

Graphism are really good, even if it is difficult to recognize the car (colors help a lot if you know it) I like the top down view.

+1 for ghost on 2nd lap
shooting people should give extra time :D

It is really difficult to control the car, you don't ride, you fight your car !

Do you think you'll try to improve the physics engine ?

Thanks for the links, it is really interesting !

P#64953 2019-06-02 15:39 ( Edited 2019-06-02 19:16)

Do you think you'll try to improve the physics engine ?
Unlikely - I spent weeks tweaking the car physics and I am literaly running in circle :)

P#64954 2019-06-02 16:33 ( Edited 2019-06-02 16:33)
2

Would it be possible to use the other action button instead of up for accelerating? Personally I think it would make it easier to control the car!

P#64956 2019-06-02 18:07

maaaaybe if I can find a couple of tokens :/

P#64959 2019-06-02 19:14

The physics and rendering are really impressive. I'd love to hear more about how you're doing the texture mapping on the car. I haven't seen anyone do that with decent performance on Pico-8 before.

I guess I've gotten to used to modern racing games with analogue controls because I initially wanted to hold down the left/right keys to turn, but once I got used to just lightly tapping them the control felt pretty good. Then it just becomes a matter of anticipating the track to know when to slow down so you don't go sailing through the air off a steep hill.

I like the little touches of bumping objects around when you hit them and I had a little chuckle the first time I hit a spectator and a little angel floated up.

You tweeted a gif of a car selection screen, are you still intending to put that into the game or are you too limited for tokens?

P#64971 2019-06-03 11:58
1

@paranoidcactus: thanks but many other pico games used texture mapping before mine! (see @electrigryphon or @J-Fry work). My version is non-perspective correct (useless at this resolution) and uses the inner loop of @p01 trifill.

Pers. correct: left / Affine mapping: right (aka PS1 texture mapping :)

I am really short on tokens, the selection menu is definitely out - I misread the pico documentation and initially planned to have a loading screen cart, but it requires multicart :/

P#64977 2019-06-03 19:43 ( Edited 2019-06-03 20:01)

Super cool!

About the texture mapping, I would also like to know where I can read about it. The others may have done it first, but they didn't include links to papers :)

P#64993 2019-06-05 04:03 ( Edited 2019-06-05 04:07)
1

@Catatafish Thanks
You want papers? sigh ;)
This is a classic: Chris Hecker

Other than that:

  • w=1/z is linear in screen space, so is u/z (or u*w). Let that sink in and you should see the light :)
  • deconstruct @p01 trifill (really boils down to rendering 2 trapezes).

Now use that to feed trifill with additional texture parameters, eg (x,y, w,uw, vw) - they can all be linearly interpolated... - and you are done ;)

P#64999 2019-06-05 06:45 ( Edited 2019-06-05 21:08)

Hi @freds72,
Can you please tell me why you multiply the slip angle curve by the slip ratio curve? @ Line 490:

local sr_ratio=sa_ratio*apply_curve(sr_curve,abs(sr))

I'm trying to understand the tyre physics to make a racing game and I can't find an explanation about this equation on the internet.

Also, super cool game, thank you very much!

P#68250 2019-09-29 13:09 ( Edited 2019-09-29 13:19)

Hmm ... steering seems a little wonky but there's no denying the excellence and craftsmanship of this cart. You get my star.

Well done !!

P#68251 2019-09-29 16:25
1

@lusca - thanks
The slip angle * slip ratio makes the tire loose traction when loosing friction.
In the literature, it is usually done by limiting the norm of the (slip angle, slip ratio) vector (eg. limiting the total force the tire can generate).

P#68254 2019-09-29 16:39

Awesome

P#77653 2020-06-04 11:11

Really fun game, reminds me of my Rally-Sport races with my friends. Problems are game's lack of content, controls are terrible and there is no actual racing. Could use improvement a bit, but I don't know how hard it is to script with PICO. Anyway, really fun and exciting experience, really pushed the limits of PICO as far as I can tell. Good luck on the project! This was good game!

P#78265 2020-06-19 09:28

Thanks but so far no plans to come back to this game - I am not super happy of the control/feedback.

P#78274 2020-06-19 11:14

You may want to change the controls, so that the gas/brake is at both the O and X buttons respectively. Putting them on the directional pad is the last thing I could expect, and yould make control of the car impossible.

P#89835 2021-04-01 22:51

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-19 05:28:09 | 0.083s | Q:41