A game by its cover - Pastel Riders

Hi all!

This is the tiny dev diary for my entry to the game jam A game by its cover (our version)

I didn’t really know if I was going to be able to put much effort into this, so I haven’t chosen a cover until now:

Edit: Cover by @gemsheldrake aka Petitecreme

I’m not sure what to make of the name on the cover (or the pink tiger?), so I’ll just take it down a notch by simply calling it Pastel Riders, which seems like something a little more manageable.

This project is also a way for me to tick off some items on my bucket list of things to do. Even though I’ve done racing games before, I haven’t done a 2D racing game, on my own :slight_smile:

My main mission is to learn more about what Defold can do, and have fun at the same time.

I will take a lot of inspiration and ideas from the awesome game Nitro, which I’ve played a lot.

I’ve come a (very) little way, and here are two screen shots to give you an idea of my scope/style of things:

Here I tried my first real interaction with the render script. I followed the advice of @sven gave on the topic here:

Since I’m a fairly new Defold user, the first goals have been to find a project setup and file structure that I’m comfortable with. And although I think I’m getting there now. I have struggled with a few things, that might be worth mentioning.

Physics Worlds
Earlier, my level was loaded via a collection proxy, and my player object was spawned in the main collection. This led to the two physics objects being part of two separate physics worlds.
The solution was to reorganize my structure a bit, so that the player object was part of the level.

Input Focus
In my main collection, I had my main script that acquired input focus. Problem became later, when I wanted to have input focus in my collection proxy (level). It turns out, the game object that holds the collection proxy, is the one that needs the focus, in order to pass the focus along. Thanks @sicher for pointing that out here.

Next up, I’ll be trying my luck adding ai cars, so that there’s something to compete against…

12 Likes

First use of the newly added collision checks: The treacherous oil spill!
If you turn when passing through, you’ll lose control of the car:

Fyi, the physics setup is exactly the same as in the physics tutorial. The only difference is I added more collision groups to my tilemap.

3 Likes

While reading up on various ways of doing 2d car ai, I figured I’d implement a way to get waypoints for the ai to use. They are basically outlining the middle of the road, so that the cars know if they deviate from the path.

Since defold doesn’t have a “path” notion, you have a few ways of doing this:

  1. Adding game objects to your collection. The way to get the waypoints would be to get them one by one, by name. The drawback is that if you wish to redraw the map, reorganizing the waypoints would be cumbersome.
  2. An alternative is to draw the waypoints in the tilemap. Then they’re structured spatially, and if you wish to redraw the map, you’d have less work to do. The main drawback is that the waypoints only can go in 8 directions.

Since I’m at early stages in testing, I expect myself to redraw my maps plenty of times, so I chose option 2.

To show you some results, here are some screenshots:

Do you use “paths” in your games? How do you create/use those?

4 Likes

Tiled has paths as an object entity option, and then would have to write a custom interpreter for their data when you export.

Are you using the system draw_line function for those lines?

Re your transitions - check out this video

6 Likes

@Pkeod Yes, I’m using the draw_line message for those lines.

And thanks for the video link, I knew I had seen that somewhere, but couldn’t find it again. We’ll see if I have the time to do some more transition work before the jam ends though…

After looking around for some ideas to base the ai on, I found a good link about autonomous agents.

It is a quite simple approach, and it should lend itself well to adaptations along the way.

Here’s a very first, unpolished, version:

Right now, the agent only looks at the waypoints and the distance from the center of the road.
And since it tries to go as fast as possible, it often overshoots the curves.

Next, I’m going to try to train the agent to find good velocities when approaching the curves and also a good racing line…

6 Likes

So, a week later, I have implemented a first workable version. And with that, I mean that the car should actually stay on the track (currently is does not avoid obstacles, that will come later)

The main work has been to be able to determine some good measurements as to what the relation is between the car and the track: velocity, curviness, predicted position, understeering etc.
The goal is to have as few rules as possible, and they should be as clear/understandable as possible.

I don’t feel I’m quite there yet, but at least I have a base version to work from now.
Here is a video of a lap:

As you can tell, the racing line is far from perfect, and I could probably spend many more hours finding new rules to make it better, but I’m not going to (not now anyways), because I want to get to the next stage of my bucket list: letting the AI incrementally find a better path, in terms of both speed and waypoints.

This is another thing I’ve wanted to write for a long time, ever since my old colleague wrote such a system in an old game we worked on.

Basically, I want to run the game for a lap, then check if the lap was successful or not, and change some values before the next test. Currently, the values I have in mind, are waypoints offsets and recommended speeds. IIrc, those were the two values that was generated in the old game.

Also, for debugging, I’d like to be able to view the data generated, so I can debug it. I imagine it somewhat like this, although not in realtime. I want to try to learn to run the engine headless, in order to generate the data extra fast. :slight_smile:

9 Likes

Running the game headless

Now, I’ve started adding some frameworks for testing my setup.

I’m using the dmengine_headless executable, which allows you to run the game without graphics. This has the added benefit that it can speed up simulation tremendously. A common use case is of course to do unit testing.

The process is very easy, here’s how you do it:

  • Download the version of dmengine_headless for the platform you want here
  • Open a terminal (or command prompt)
  • Navigate to the project folder
    • You can find the folder by either by right clicking game.project and choosing “Show in Finder/Explorer” or dragging the game.project to your terminal
  • Make the executable runnable
    • chmod +x ~/Downloads/dmengine_headless
  • Make sure you have built the project once before
    • E.g. with “Build and Launch”
    • Or with bob.jar
  • Execute the engine in the folder, possibly with arguments such as config settings:
    • ./dmengine_headless --config=trainer.enable=1 --config=trainer.level=level01

And here is some example output from a trainer session for my game:

(I won’t go into details about the actual test itself yet, maybe in the next post)

A handy side benefit is that this also lets me store the best results on disc (ready for check into git), and load them in as new defaults for a level. Quite handy!

6 Likes

Long time since last post. The project definitely slowed down and I didn’t quite make it in time for la grande jam finale, but I’m still developing it from time to time :slight_smile:

The other day I added some more cars, to see if the steering holds up. The cars can all progress through the laps quite fine.
I’m not entirely happy with the way the steering works though, it’s a bit difficult to make the cars avoid obstacles as it is now. As usual, I think a better approach is to hand craft the waypoints and the recommended speeds. (But that would have defeated my purpose of trying out some iterative improvements testing etc.)

I’ve uploaded current state of the “game” here: HTML5

The code is currently still in a very fluctuating state, so it makes little sense to share it yet. Soon though, I hope I can share it too.

10 Likes

hoo very nice and smmoth :wink:

1 Like

Nice! And I like the aesthetics of your Demos page.

1 Like

Heya!
I’m the artist of the famicase, Thank you so much for picking my work to inspire you to make a game!

I don’t know if you went on the site but here is the story for the cover:
Pastel Powder Keg
Crystal and Elvira got in trouble with the mafia! To pay back their debt they need to preform crazy jobs from robbing banks with rubber toys to driving pet tigers to keep them happy! Can they earn enough to stop the mafia or do they use their money to build their own gang? Play on your own or with a friend for crazy fun! 1-2 players.

It’s based of my girl gang series that takes steven universe pastel astestics but with hotline miami extreme violence.
you can see more art here

I also took inspiration from Saints Row, specially the mini game where you have to drive a tiger around town to stop it attacking you. XD

But thank you very much, please let me know when it’s finished! I look forward to play it!!

-Petitecreme
twitter.com/gemsheldrake

7 Likes

Hi @gemsheldrake!

It’s great to get some back story to that cool cover! Sounds brilliant!

I hope to pick up this game again soon and although it was originally a more straightforward racing game, I’m sure I’ll get a lot of inspiration by that synopsis!
I really do want to feature that pink tiger :slight_smile:

1 Like

Wow, thank you for getting in touch with us! I also considered doing a game around your cover, but ended up doing Lucky Fishing instead. I had a game similar to Retro City Rampage in mind for my Pastel Powder Keg game.

2 Likes

That sounds so cool! I’m really honoured my work inspired you!
Please let me know if you’ll be needing any more artwork/feedback.
(I’ve always wanted to get into game art, but I took my path to comics instead XD)

4 Likes

I decided to start fiddling with this project again, but also wanted to abandon some earlier ideas, so I figured I’d share the code in its current (very messy and not very playable) state before I make huge changes.

You’ll find the code here and you can also find it via my examples page. I don’t expect it will be terribly useful as a whole in this state, but perhaps it might help someone in some specific case so I’d rather share it now.

4 Likes

Thank you very much for sharing @Mathias_Westerdahl ! :thumbsup:

1 Like