Prototype / mining game

i remember some mining games of yore i used to play for a lot of hours. i thought i'd try making a prototype of such a game in 2d platformer style as a homage.

gem

the goal would be to mine a bunch of precious metals and sell them to upgrade equipment, much like the previous games in this lineage. naturally turning the crank will swing the pick-axe, saving the B button for a radial menu or similar. if the player can equip a drill i can see using the crank for charging up energy instead and they can just hold B to mine a wall.

i think i want a rock conversation system.

i can't seem to get above 30 FPS since there's a lot of sprites onscreen, i think i need a smarter chunking technique. or rewrite everything in C maybe but i don't know any. i once tried just drawing the tiles with a tilemap really early on but didn't find a good collision strategy yet ?

i also followed another game, which looked really neat.

so not sure if i will continue past this point, but it was quite fun delving into all the playdate internals for once !

and thanks to the author of pp-lib for a good starting point.

4 Likes

One of those days I really gotta finish this project of mine! At least, I'm glad to see people are getting at least inspired by it.

Naturally turning the crank will swing the pick-axe, saving the B button for a radial menu or similar.

I did thought about adding an item allowing you to refuel for free by cranking the device or aim for throwing items but I couldn't make a decent control scheme to select items. How would your control go? Press B once to go into a menu and then navigate with the crank or hold B down?

Or rewrite everything in C maybe but i don't know any.

It's a bit of a difficulty ramp compared to Lua but it's doable. There's another solution you could look into: making specific parts of your code in C so you can limit the amount of code done in C while still programming the most of your game in Lua. The documentation lists a few functions specifically related to provide additional functions to the Lua environment and doing some data exchanging between C and Lua.

So, you did do chunks in Lua? I discussed with someone else about their project and I wasn't sure about how expensive it'd have been to do what I did in Lua. May I ask you what's your strategy to keep track of tiles? Do you only add visible tiles to the collision system? Do you use fixed-size chunking (see Minecraft's)?

I can't give you pointers (hah!) to where to learn C though, I learnt from reading a French tutorial and getting mentored by a friend when I was still trying to grok it, but if you're willing to jump into the void (re-hah!), I wish you good luck with it!

thanks for the response. i am also quite enamored by the idea of carrying around a motherlode-type beat on this humble console one day so i hope you or i or someone can make it work out !

How would your control go? Press B once to go into a menu and then navigate with the crank or hold B down?

for sure it was tricky. first I thought about simply mapping B to swing the axe but that meant the crank wouldn't be used in alot of places until the player gets the drill. and i found cranking to axe to be more enjoyable with just the fast enough rotation.

so with B left over I was thinking about holding B + crank to select item or second tier menu like Casual Birder does. also i tested a thing where the player can dock the crank to put away the current item. could be neat if holding the item causes a speed penalty so the player can feel like docking is a useful behaviour.

It's a bit of a difficulty ramp compared to Lua but it's doable. There's another solution you could look into: making specific parts of your code in C so you can limit the amount of code done in C while still programming the most of your game in Lua.

hum, i don't know much C but i do know a bit of Rust having programmed some simple tools before. i think there was a guy that wrote this whole Rust toolchain for playdate that was busted in places. only issues is i rely on a bunch o' lua libraries to do heavy lifting like platforming logic and i don't wanna to rewrite it all so soon.

think what i'll do is, figure out what's actually fun in Lua first regardless of FPS, since C or Rust will be higher difficulty as a programming wizard i am not. then when FPS is really a concern, but otherwise the game is fun, port everything over...somehow. if i was sure about finishing this (which, i'm not to sure honestly).

main issues right now is i'm not really sure where the bottleneck is yet, and the CPU sampler wasn't terribly enlightening since it just declares field update [C] (in playdate.sprite) to absorb the most frames. i think it is a limitation of the current sampler - if there is a sprite callback it doesn't cross the C barrier to profile the Lua inside ? but i am not so sure. regardless it is likely to be a sprite issue i think, probably just too many on screen at once (~230 when underground)

So, you did do chunks in Lua?

at first yes, however i found in practice setting the chunk size to 1 gave the best performance. anything above 2 causes too much hitching on real hardware. at that point i think i'd be better off just checking screen bounds and unloading tiles outside the camera

how it works is - the world is divided into N x N chunks. inside a given radius all chunks that must be displayed on screen are loaded. if a new chunk is about to be shown but is missing, first any chunks that are off-screen are "reallocated" by moving all their tiles to the new coordinates and repurposing each sprite with a new image etc. (so no allocations) each tile is represented as both a table of "definition" data in the world and (when onscreen) a sprite with a collision box colliding with the player. the world itself can be pretty large (mine is 48 x 300 currently)

so the chunking is really for just "the subset of tiles visible on screen". it has evolved into being used more like a culling mechanism. so i think i may need to replace it. i was very curious about how yours worked by the way.

for allocating sprites themselves i use a resource pool that keeps a set of sprites loaded in memory upfront. when a new tile is needed its taken from the pool and given the correct image/ID.

so those are the metrics kept track of. alloc/realloc for tile's sprites, calloc/crealloc for "chunks". ideally keep "alloc" as small as possible. but even with this system in place and hardly any allocs beyond initial load i still get alot of hitching when running around.

and thank you for the bundle of luck, i will probably need it :slight_smile:

1 Like