@2DArray@mastodon.gamedev.place avatar

2DArray

@2DArray@mastodon.gamedev.place

i make games and silly code demos.

some of my games:
https://2darray.itch.io/

free gamedev tutorials:
https://demoman.net/

This profile is from a federated server and may be incomplete. Browse more on the original instance.

2DArray, to random
@2DArray@mastodon.gamedev.place avatar
2DArray,
@2DArray@mastodon.gamedev.place avatar
2DArray,
@2DArray@mastodon.gamedev.place avatar

@fsouchu nope, lol. i still haven't tried the thing i was talking about at first, but i goofed around a bit with some related-but-less-drastic simd usage, and failed to get any actual speedup (which is what has always happened whenever i've tried to use simd in general)

2DArray,
@2DArray@mastodon.gamedev.place avatar

@fsouchu i did get a nice speedup on the rasterizer by doing that "splat a slice of the dither pattern into an 8-or-32 bit scanline-strip all at once, instead of iterating individual pixels" thing (i already had start/end sub-indices inside each strip, so i did some bitwise shenanigans to create a mask with leading and trailing zeroes, then used that to splat the pattern)

unfortunately, i need per-pixel iteration for wall occlusion, so i can't actually use that 🙃

2DArray,
@2DArray@mastodon.gamedev.place avatar

@twitonatrain the dither pattern is storing u8 thresholds (to compare against a pixel's intended brightness), so it's not currently a blittable sprite! I could convert it into several ready-to-go sprites for different grey levels, but I imagine it'd lose some smoothness (especially in the sky, where it's a lot of smooth fades)...but maybe that'll become necessary at some point

2DArray,
@2DArray@mastodon.gamedev.place avatar

@twitonatrain thanks! and honestly your idea is a good one which i've been trying to find ways to incorporate...i might have an avenue to use it in the mesh rasterizer (which does use blittable patterns!), if it can detect that a certain 32-bit slice of a scanline has no chance of being occluded by a wall (which means the per-pixel checks aren't needed there)

2DArray,
@2DArray@mastodon.gamedev.place avatar

working on replay recording/playback - yes, the clip looks the same as the others in the thread, but it's a pretty good run since i was retrying the map. if you think "i see places where the racing line could have been improved" then the game is working, lol

replay data is quite small: stores keyframes containing a bitmask of user-input states (one byte), along with how many frames you held that state for (one byte). a "normal" 30 second replay tends to be around 200 bytes

2DArray,
@2DArray@mastodon.gamedev.place avatar

unfortunately i doubt there'll be a way to do any online-sharing because of playdate limitations (i'm gonna try to get libcurl to work anyway though - i think they use it for OS features, they just don't expose any networking stuff in their sdk at this point)

2DArray,
@2DArray@mastodon.gamedev.place avatar
2DArray,
@2DArray@mastodon.gamedev.place avatar

@isziaui does seem possible to export like that...but then you'd still have to get the data back into someone else's device!

best I've thought of so far is a companion app that you run on a PC, and they talk to each other over USB. not ideal, but it'd save you from needing to boot the playdate into data-drive mode, at least. an over-engineered version could talk to a webserver from there, lol

2DArray,
@2DArray@mastodon.gamedev.place avatar

@fsouchu yep! floating point is deterministic and the app is single-threaded, so (at least as far as i've seen...) the only thing that's unpredictable is the user-input. i wouldn't be surprised if the simulator and playdate produce replays which are incompatible with each other due to compiler differences...but i haven't serialized any replays, so i haven't seen that happen yet lol. if it turns out to be a problem, i can resort to a heftier format!

2DArray,
@2DArray@mastodon.gamedev.place avatar

@fsouchu (and crucially, the app is using a fixed tick-rate, not a variable physics-step!)

2DArray,
@2DArray@mastodon.gamedev.place avatar

@fsouchu correct, all C! but yeah even when the performance is variable, the game just moves slower instead of using a variable deltaTime (I'm now assuming I'm gonna lock to 30fps at some point because I can't stop adding visual stuff, so I just need to make sure it's always able to run faster than that - but even if it was a problem, the sim is WAY faster than the rendering, so it could do a multi-stepping fixed-tick for the physics whenever it was dropping frames)

2DArray,
@2DArray@mastodon.gamedev.place avatar

smarter sampling on the floor...

when it samples the floor tex, it raycasts the texelspace grid to see how many screen-pixels it'll step along the scanline before hitting the next texel, and it can reuse the latest sample until then - fewer samples, sharper result!

it also does some smooth LOD, where it starts using a bigger and bigger "screen-pixel steps per sample" ratio as pixels get farther away

(before/after)

A similar screenshot of the racing game, but now the checkerboard pattern has much sharper edges between its squares.

2DArray,
@2DArray@mastodon.gamedev.place avatar

added a realtime shadow for the player's car

it only works on the floor (not the walls) but that's probably okay-enough for me

More footage of the racing game, now with a shadow from the car cast onto the floor.

2DArray,
@2DArray@mastodon.gamedev.place avatar

@ruby0x1 thank you!

2DArray,
@2DArray@mastodon.gamedev.place avatar

@fsouchu yeeep the mesh rasterizer is using simpler patterns everywhere so it can do the 32-bit-blitting stuff (when it knows there's no risk of wall-occlusion)

that said, I could probably bake a few blittable blue noise patterns for this. I'm not quite happy with the look of the shadow yet, so maybe that'd do the trick!

2DArray,
@2DArray@mastodon.gamedev.place avatar

@ikesau to me, the shadow is looking a little too strong at the moment, at "50% alpha" - so maybe it'll look better to you once it's a bit milder!

2DArray,
@2DArray@mastodon.gamedev.place avatar

@fsouchu walls are "wolfenstyle" so they start by doing a per-column raycast, and save the resulting screenspace wall-heights to an array. then, during the fullscreen per-pixel pass (walls/floor/sky), it just has to check if a pixel is above/below the wall-range for its screen-x position

the shadow is a copy of the car mesh with a weird/flattened local-to-world matrix - what are you imagining for wall-shadows? all i've thought of is "pretend the nearby wall is a plane, project a mesh onto that"

2DArray,
@2DArray@mastodon.gamedev.place avatar

@fsouchu oh that's wackier than i was expecting! will give this some thought

2DArray,
@2DArray@mastodon.gamedev.place avatar

kinda going off the deep end here but now the car can cast its shadow onto the walls

it's kind of a ridiculously subtle effect, but it ties the mesh-geo, the raycaster-geo, and the skybox together, so uhhh maybe that's something

the racing-game car slowly drives past some walls, and its shadow gets cast correctly onto both the floor and the walls.

2DArray,
@2DArray@mastodon.gamedev.place avatar

@fsouchu thanks!

ended up doing the less-fancy "pretend the nearby wall is a flat plane, project the car-mesh onto that" idea...mostly because it seemed easier to implement

now in the worst case, i get down to like 33fps (player car, player floor-shadow, player wall-shadow, ghost car, giant "START" mesh) but hey i'm still above 30 lol and i might be out of ideas for more wacky gfx shit to add, so i might be getting away with it

2DArray,
@2DArray@mastodon.gamedev.place avatar

starting to think about a title screen but i'm not really sure wut to do yet

but hey i have an easy way to make text into 3D meshes (thank you, blender!) so that seems like a sane place to start

A black Playdate screen with the text "Trackminia" displayed in the middle. The text slowly rotates slightly back and forth in 3D, sort of like a wind vane.

2DArray,
@2DArray@mastodon.gamedev.place avatar

@fsouchu i was thinking about drawing the sun...but i think at the moment i'm interested in getting the title card to look like it's own thing, instead of just showing what the normal gameplay looks like (dunno if it's the right call, but that's where i'm at so far)

the motion here is temp, but it's partway to something more interesting...

a title card reading "Trackminia" in front of a waving checkered flag

2DArray,
@2DArray@mastodon.gamedev.place avatar
2DArray,
@2DArray@mastodon.gamedev.place avatar

@Felice thanks!

implementation is dead simple: it's the exact same as what you'd do for Bayer dithering (dither pattern is a pixel-grid of brightness values, each final screen pixel becomes either black or white by comparing its intended brightness to a value in the pattern), but with a blue-noise texture as the pattern

i got a texture from here:
https://momentsingraphics.de/BlueNoise.html

in this case, the dither pattern is fullscreen, but tiling a smaller pattern is fine, too

  • All
  • Subscribed
  • Moderated
  • Favorites
  • megavids
  • kavyap
  • thenastyranch
  • mdbf
  • DreamBathrooms
  • InstantRegret
  • magazineikmin
  • Youngstown
  • cisconetworking
  • slotface
  • vwfavf
  • everett
  • Durango
  • rosin
  • tester
  • GTA5RPClips
  • khanakhh
  • osvaldo12
  • ngwrru68w68
  • normalnudes
  • anitta
  • ethstaker
  • cubers
  • modclub
  • tacticalgear
  • provamag3
  • Leos
  • JUstTest
  • All magazines