Investigate 2d pixel art solutions

Investigate 2d pixel art solutions

task id: investigate-2d-gameengine

2024-06-22 14:20: Exploring pixels #investigate-2d-gameengine #timelog:00:11:15

Link: https://github.com/parasyte/pixels.

Space invaders example works on my Mac. Good lord that's a lot of dependencies though (it's okay, it's okay, just grit your teeth and do it).

Web example runs on my mac. Noticing use of wasm-bindgen. Is it time for me to bite the bullet and actually learn this? I wouldn't be able to get it done in a weekend.

2024-06-22 14:34: Now time to look at Sokol #investigate-2d-gameengine #timelog:00:08:12

Link: https://github.com/floooh/sokol.

More "comfortable" because it's closer to a tech stack I know already. I've never used it before, so the learning curve may be just as big. But let's see!

Sigh... Emscripten.

Uhhhh... my harddrive just filled up I think.

This is an omen. I am ditching Sokol for this.

2024-06-22 14:55: Now we try Pixels on my Linux box #investigate-2d-gameengine #timelog:00:08:49

This is the ultimate test because nothing every wants to work.

2024-06-22 15:05: Well that didn't work. Attempting softbuffer on Alpine Linux? #investigate-2d-gameengine #timelog:00:07:59

Link: https://github.com/rust-windowing/softbuffer.

2024-06-22 15:14: Well that's a no go. Sokol on Alpine linux? #investigate-2d-gameengine #timelog:00:08:10

Good ol' glfw backend works. I do not really like the strange build system.

2024-06-22 15:24: Another stab at pixels on Alpine linux. #investigate-2d-gameengine

2024-06-22 15:27: Trying sway to try run sway. wish me luck. #investigate-2d-gameengine #timelog:00:58:26

2024-06-22 16:23: Got enough of sway working to re-run pixels invaders example. Still, no luck #investigate-2d-gameengine

I'm starting to think a solution might involving having different backends, with as much logic in the Rust layer. This might take too long as well. Sigh. Graphics.

2024-06-23 09:27: Found this 2d sprite repo today with sokol/sdl. Looks perfect. #investigate-2d-gameengine

link: https://github.com/seyhajin/webgl2-wasm-sdl-sokol-sprite.

WASM builds and runs okay with emcc. I was hoping it would have had a sprite moving, but it's just projecting a static texture.

I'm starting to feel diminishing returns, as this "simple idea" might turn out to be not as simple as I thought, and might require more time/focus than I have right now.

Fail early. Fail often.

2024-06-23 09:55: Back to studying "sapp" #investigate-2d-gameengine #timelog:00:04:52

the "spine" examples seemed to be closest to what I was looking for, but it turns out it's also not what I'm looking for and intended for much larger games that I'd like to build: http://en.esotericsoftware.com/spine-in-depth.

2024-06-23 10:00: Trying out a Sokol add-on for 2d graphics someone made #investigate-2d-gameengine #timelog:00:12:07

link: https://github.com/edubart/sokol_gp

The OSX build in this makefile is out of date. Getting errors. I'd like to see this work, so I'm going to try and get this running on my Linux box. If that fails, I'm back to just learning more about sokol_gfx.h and actually reading the documentation.

Okay! The makefile works on my Linux box! Good. Progress.

Making a dagzet graph for sokol.

2024-06-23 10:17: Studying sokol_gfx more in depth #investigate-2d-gameengine

I want to get the text rendered to a PDF somehow, so I can read it on my remarkable.

Learned about :hardcopy in vim. :hardcopy > foo.ps.

set popts+=number:y will include line numbers

There are two kinds of programmers: those who understand why text editors have a "hardcopy" printing feature in 2024, and those who do not.

Uploaded PDF to Remarkable.

2024-06-23 10:30: Reading =sokol_gfx= header comments on remarkable #investigate-2d-gameengine #timelog:00:25:36

2024-06-23 13:00: Trying out Gate #investigate-2d-gameengine #timelog:00:34:10

Found this while looking up how to do pixel art on OpenGL: https://github.com/SergiusIW/gate

running into linker problems.

Solved by adding println!("cargo:rustc-linker-arg-L/opt/homebrew/lib")=.

Now it is panicking because it can't find OpenGL/GLES library. Probably something to do with it being a Mac?

Working out test file. https://stackoverflow.com/questions/26745284/cmake-not-finding-gl-h-on-os-x. This worked fine, though I had to change the include file from GL/gl.h to OpenGL/gl.h.

Digging into gate library a little more, since it is just SDL underneath it.

There's only so much stack tracing and debugging I can do before I call it quits here. This is another nope.

2024-06-23 13:45: Another look at sokol gp on OSX #investigate-2d-gameengine #timelog:00:39:00

I think the sokol headers are out of date. OSX references things like cocoa, new sokol headers references metal.

Nope. Fortunately, there's documentation on the build incantation used to build cube-sapp.c in the sokol-samples repo:

cc sapp/cube-sapp.c -I ../fips-build/sokol-samples/sapp-metal-osx-make-release/sapp/ libs/sokol/sokol.m -o cube-sapp -DSOKOL_METAL -fobjc-arc -I ../sokol -I libs/ -framework Metal -framework Cocoa -framework MetalKit -framework Quartz -framework AudioToolbox

I want to update the Makefile in sokol gp to match this better

Made a build.sh script. Still getting a lot of weird metal-related junk errors.

Took the clear-sapp example in the sokol-samples and gradually added lines from the rectangle sample in the sokol gp repo. We have a rotating rectangle now!

2024-06-23 19:14: Attempts to import small sokol gp example #investigate-2d-gameengine #timelog:00:28:31

2024-06-23 19:41: Imported. Builds on OSX and Linux now. #investigate-2d-gameengine

2024-06-24 08:27: Initial investigation complete #investigate-2d-gameengine

Sokol and/or SDL is probably going to be my solution moving forward. The general approach is to use textures and rectangles for sprites. There is documentation on this that I can read.

2024-06-27 08:49: I think I've done enough for this research #investigate-2d-gameengine

I've just had the idea to look into tic-80 and hack the audio engine. This seems to be most in the spirit of RC, and probably going to be more fun than trying to get a bunch of graphics libraries working.

Sokol would be what I'd want to try as well for something similar to tic-80 graphics-wise, but that's more upfront work.

There's always p5.js and friends for very quick rapid prototyping. I really need to convince myself to try using these for time constraints.