Colliding With Collision Yet Again
So I tried to optimise collision for non-player objects, and the results weren’t really that different. I ended up reverting to what I already had and optimising it a bit.
I also added a draw and update zone within a certian proximity to the player. Anything outside the zone isn’t being drawn or updated. I was going to do this later on, but as I ran into performance issues when spawning hundreds of collidable objects with physics on each other, I thought it best to just do it now.
I’ve updated the editor so I can do basic edits to levels again. I think it’s a laugh that the level editor was one of the first things I added, but it hadn’t been touched for months while I worked on the platforming mechanics… The frustrating thing about the editor is needing a GUI for editing the properties of objects. Fortunately I already created the GUI framework, but it’s still a bit of a hassle.
There’s a Raylib GUI library but I haven’t really looked at it, and at this point I’ll stick with what I have as the UI will be quite customised, and made with clay like the rest of the game.
I’ve also added crouching in, finally.
Next up I’d like to add some dust animations behind the player when running, buttons/switches to trigger things, projectile firing enemies and hazards and climbable objects.
The concepts for the main characters are basically done, and a lot of fun. I’ll keep them under wraps for now, though.
20FPS is ok, right?
I’ve made it so hazards can be attached to objects, e.g. a moving platform, or even an enemy.
I’ve added “spawners” that can spawn different objects. Watching enemies popping out every few seconds is just funny.
However, I did start to see a drop from 60fps at around 80-100 collidable objects colliding. I’ll have to optimise my engine, as that’s not great at all. Although it’s not really affecting the CPU or memory much from what I can tell…
Right now every object uses the same collision checking as the player character, which is overkill. I’ll start with something more lightweight and iterate from there.
They’re also bouncing around a lot, which is funny to watch but not intended. This is when the foot position is too close to the edge of the thing it’s standing on (most objects just have collision points in a diamond shape at the moment). Got to fix that too.
Do enemies need collision with each other? It’s not really something you see in classic platformers. Although even if I turn that off, there’s the ground collision to check for, and when I upped it to over 300 enemies it wasn’t good. I thought about just using box collision for the enemies, but because of the uneven ground I can’t really do that. I’m going to have to experiment a bit.
I’ll only update/draw objects within a certain range of the player anyway, but I’d still really like to have good performance with this relatively small number of objects on the screen.
Hazards Ahead
Sporadic progress this week.
I’ve added “hazards”, with the basic one I’m testing with being some spikes. Touch the spikes, die. Pretty standard stuff.
I’ve fixed an issue that was causing jittering and screen tearing, especially in full screen. The game looks and feels smooth as butter now!
I also tweaked the camera movement so it can smooth out subtle movements, whereas before it was tracking every slight movement of the player.
The most exciting thing happening at the moment is working with a concept artist to come up with the look and feel of the game.
I can’t wait to see how it turns out!
Throwing weight around
So I saw a need to refactor my collision system, completely breaking it in the process. However, now it’s back and better than ever!
I’ve also fixed the annoying stepping behaviour when walking down a slope, which was something I was putting off for ages. Adding onto that, I made objects slide/roll down slopes, depending on the angle and the weight of the object.
I also had another happy accident with throwing doodads around, with them now colliding and moving each other. They can keep their momentum and bounce now too, depending on their weight.
As sick of my test level as I am, I’m adding new mechanics every day which keeps it fun.
Next up I need to revisit burrowing through platforms, and then I’ll implement environmental hazards and effects, like spiky floors, falling objects, air drafts and whatnot.
Might look into water/mud as well.
Push, Pickup, Projectile
Got “pushable” doodads in there now. Combined with picking up and throwing at enemies it’s proving to be pretty fun :)
Pick Me Up
I spent a bit of time getting “grabbable” items in the game. I’m calling these doodads, which will cover any object the player can interact with, but that isn’t a collectible.
I tweaked the action button to work for a tap (melee), and a hold (grab). A doodad can be picked up with a hold, dropped with a tap and thrown if dropped with momentum.
Onion can’t hold things (no arms), so the object is dropped when switching characters.
There’s a fun, unintentional effect where the doodad can be thrown at an enemy, pushing the enemy through the map if it lands on top. The doodads also work with moving and disappearing platforms. I’m pretty happy with my collision system!
Although, I had a “game development is painful” moment tonight. There were some collision issues that took longer to resolve than they should have. Fortunately they were legitimate bugs that would’ve broken things down the track, so it’s good to iron them out now.
As you can see from the gif it’s not pretty at all, but it’s a good start!