Super Freaks 1 Ultimate Edition (Pre-Alpha 5)

Subscribers:
334
Published on ● Video Link: https://www.youtube.com/watch?v=Ix25KgRX1GQ



Duration: 0:38
28 views
0


I've been recoding the engine from scratch, as the old one I had was super unoptimized. This iteration runs much faster and has a proper options menu (complete with button remapping) too. How did I speed it up so much? Let me elaborate:

The purple grid you see is what is known as a spatial hashmap. Anyone who has done game development knows collision checking is the most expensive operation your game can perform, alongside graphics. The best way to cut down on how long it takes to run collision checks, is to simply do less collision checks. This is where the hashmap comes in. All of the game objects basically get the maximum size of their hitboxes and add themselves to whatever cells of the grid they overlap. If one object needs to check if it's touching another (ex. one of the players checking for collisions with the enemies), it doesn't need to check against every single enemy on the screen. It simply needs to see which cells it's in, and check if it's overlapping any of the enemies that happen to be overlapping the same cells. Technically there are faster lookup routines one can do instead of a hashmap (ex. a quadtree), but I've heard these become net slower when a lot of objects are constantly moving around, so I went with the hashmap for simplicity.

Beforehand, all of my hitboxes and colliders (the lime green things, these are solids like platforms and walls) were structs. These are slow and take up a lot of memory. I replaced them with arrays instead, as the latest Game Maker Studio 2 beta update has changed how you access arrays, making them easier to pass around and modify without any trouble.

Although I'm running this with the YYC compiler in the video, even in VM it runs pretty well, about 1600-2000fps depending on how many instances are on screen at once. YYC boosts it up to about 2500fps-3000fps. If I disable the extra debug drawing modes (which I'd have to when releasing the game anyways) it goes even higher too.