Live data from Hacker News

Open Golf: A cross-platform minigolf game written in C

github.com

51–60 of 99 posts

Re: Open Golf: A cross-platform minigolf game written in C

#52

Earlier quoted context omitted.

Builds and runs well in Asahi Linux :) Frame rate isn't great without GPU support, but totally playable.

Absolutely crazy that Asahi Linux beats MacOS on even one silly datapoint of compatibility lol. Open source is sick.

TBF, the only reason why macOS isn't currently supported seems to be some minor build system details (e.g. the toplevel CMakeLists.txt file has explicit support for Windows, Linux, Android, iOS and Emscripten, but not macOS).

Re: Open Golf: A cross-platform minigolf game written in C

#53

Any recommendations to learn to build cross-platform games like this? I work on frontend projects day-to-day. I'd love to build a simple cross-platform game in C/Zig/C++ for some variety and to learn lower-level programming. I've looked at Handmade Hero in the past but its specific to Windows at the moment.

This might be obvious, but one of the key activities is to minimize platform-dependent code so that most of the game logic is portable and shared across all platforms. So no Win32-isms or Cocoa-isms or littered all over your game.

One way (out of many) to do this is have a cross-platform interface for each non-portable thing, with separate platform-specific implementation files that you swap in depending on which platform build you're doing. For example, if your game has sound, you'll probably have a platform-independent sound.h the rest of the game calls into, and then sound_windows.c, sound_linux.c, sound_mac.c, etc. files that contain the platform-specific implementations of those functions. Repeat for graphics, input, and other things that cannot be done (or you don't want to do) in a portable way.

Another thing is the game loop. Back in the DOS days, when you were the only thing running on the system, you implement main() did something like:

    while (game_running) { do_everything(); }
Modern platforms expect to be in the driver seat, and will instead call into your code, so this turns into something like:

    function windows_call_me_please() {
        do_everything();
    }
Obviously this is a simplification, and there is a lot more to it, but hopefully it answers some basic questions.

Re: Open Golf: A cross-platform minigolf game written in C

#55

Any recommendations to learn to build cross-platform games like this? I work on frontend projects day-to-day. I'd love to build a simple cross-platform game in C/Zig/C++ for some variety and to learn lower-level programming. I've looked at Handmade Hero in the past but its specific to Windows at the moment.

It's all about the libraries. Use Sokol and Dear Imgui and you'll be cross platform.

Re: Open Golf: A cross-platform minigolf game written in C

#56

I tried to analyze the running app with the Firefox dev console, but the GitHub hosted page said there were no sources! Browsing the Sokol Github, it looks like it's compiling to web assembly. I'm not very familiar with web assembly, how does one normally debug it?

I haven't tried it but Chrome dev tools supports debugging C++ compiled to WASM with DWARF debug symbols.

Re: Open Golf: A cross-platform minigolf game written in C

#57
post #54

Level 20, but wish there were more. The fun ones were trying to skip most of the course from the tee. Throw a leaderboard on there and no one's going to be working. Great work, awesome orchestration of cross platform libs.

I think the game not having an online component is one of its charms. Simplicity in nature and execution is the obvious goal.

Have you seen the leaderboards of any online game lately? They usually get wrecked by cheaters and defeat the whole purpose.

Re: Open Golf: A cross-platform minigolf game written in C

#58
post #26

Impressive to see C being able to create x-plat 3D games that run in Browser + popular Desktop + Mobile OS's. Typically there's big companies with large dev teams working on accomplishing such a feat & this project does it with with a 50 year old language and a handful of libs

Not to diminish the value of their efforts, welcome to the days of 16 bit game programming, naturally minus the browser part.

Plenty of retrogaming stuff to learn from.

Post reply on HN