6 ms·
Swift and the Cute 2d game framework: Setting up a project with CMake
- DavidPiper 1y agoSnap, I did something similar a few weeks ago (without the cool PoC) - github.com/davidrpiper/SwiftCmakeModulemapMVP Now that Swift + SourceKit LSP + VS Code is a viable environment, and CMake supports C/C++ and Swift interop out-of-the-box, I'm keen to start using Swift for more cross-platform things.
- pusewicz 1y agoI'm wondering if there will be anything new and cool announced next week during the WWDC in regards to Swift inter-op and cross-platform.
- titouanch 1y agoMaybe a dumb question, but can this be used to make games for other platforms than MacOS & iOS? My (limited) understanding is that Swift is mostly used to make iOS apps.
- DavidPiper 1y agoYep, I've been meaning to get a Swift + SDL project working. The language itself is not limited to Apple platforms, and there are compilers for many others, but until now all the surrounding tooling (IDEs, Swift Package Manager, build toolchain(s), C/C++ interop) has been less than ideal for all non-Apple platforms. Arguably less than ideal on Apple platforms too in some cases ;) There is still a big difference between "I have Xcode" and "I have VSCode + a large manual toolchain", but the gap is closing. CMake can also generate Xcode projects which is a nice touch when bringing cross-platform code back to Apple platforms.
- pusewicz 1y agohttps://github.com/KevinVitale/SwiftSDL https://github.com/KevinVitale/SwiftSDL is a good starting point and already supports macOS and Linux out of the box.
- zombot 1y agohttps://www.swift.org/install https://www.swift.org/install macOS, Linux, Windoze
- JKCalhoun 1y agoThanks. It looks like CMake + SDL2(3) would add some gaming platforms like Nintendo, etc. (if that's important to you).
- krzat 1y agoFor Swift, it would be more natural to use SPM instead of CMake.
- pusewicz 1y agoIt would be, but also more cumbersome to get it up and running. Not impossible, though!
- 90s_dev 1y agoLast night I tried for maybe about 6 hours so many combinations of efforts to compile a C++, SDL3 and Lua program on Windows, with different IDEs, build systems, compilers, package managers etc. Finally I'm just giving up and using VS with CMake and vcpkg. The main problem is that there's way too many words on all those documentation pages. It would have taken 3 or 4 days to read them all, and maybe only 2 hours worth of it would have been helpful or relevant at all.
- raincole 1y agoI wonder if there is a SDL3 wrapper that comes with a scripting language[0], hot reload and build scripts for every major platform. Love2D seems close to that, but afaik it doesn't support SDL3 features like the new GPU API. [0]: It's not like I'm allergic to C++, but I firmly believe when developing something that is mostly interactive, such as complex GUI or games, a language that is garbage collected and can be hot reloaded would be much more apt.
- pusewicz 1y agoTry https://dragonruby.org/ https://dragonruby.org/. It's great! Still on SDL2, but will migrate to SDL3 eventually. Code reload (because it uses MRuby) is just :chef-kiss:
- raincole 1y agoIt looks like Love2D, except you pay $50 to use Ruby instead of Lua (admittedly I think Ruby is a better language.) I haven't used DragonRuby though, so if my above snarky comment is off please point me out.
- pusewicz 1y agoVery often you can snatch free copies. Join the Discord. Just ask :)
- 1y ago
- 90s_dev 1y agoCute looks like a modern version of SDL or maybge SFML[1]. Anyone have any experience with it? [1] https://news.ycombinator.com/item?id=19677201 https://news.ycombinator.com/item?id=19677201
- pusewicz 1y agoCute uses SDL3 under the hood, but provides an entire framework for game development, ready to use. It loads Aseprite files automatically, manages animations, collisions, networking, what have you.
- 90s_dev 1y agoAh thanks Piotr, also Cute looks very useful, great job.
- pusewicz 1y agoIt's not mine, I'm just a fan myself!
- raincole 1y agoSince it uses SDL3, it should be able to do more than 2D, right? Last time I checked SDL3 wraps around a lot of GPU API that you can pretty much do whatever you can do with WebGPU.
- kookamamie 1y ago> For many games variable timestep is a good choice. It really isn't.
- pusewicz 1y agoYou can use fixed time step. Choice is yours.
- OnionBlender 1y agoWhat's funny is that searching for "cute framework fixed timestep" in Google points to this Hacker News thread as the first result. What I would have wanted to find is this page: https://randygaul.github.io/cute_framework/#/topics/game_loop_and_time?id=fixed-timestep https://randygaul.github.io/cute_framework/#/topics/game_loo...
- pusewicz 1y agoLOL
- kookamamie 1y agoVery sorry about that :D
- all2 1y agoIf you divorce the game's time-step from your math it isn't too much of an issue. You just need to keep track of the time-delta so you have it for your calculations.
- kookamamie 1y agoGaffer has summarized most of this quite well years ago. E.g. https://gafferongames.com/post/fix_your_timestep/ https://gafferongames.com/post/fix_your_timestep/
- 90s_dev 1y agoCare to elaborate?
- Kon-Peki 1y ago> And voilà! Come on, if you're going to spell "voilà" correctly, you might as well use it correctly too. "Et voilà!", not "And voilà!" :)
- pusewicz 1y agoFINE
- corytheboyd 1y agoHah I just recently was doing some soul searching for a game dev environment to get started with. I did a wee bit of 2D game dev in college 15 years ago, and wanted to scratch the same itch. At this point, I demand a good IDE experience: as much intellisense as possible, great debugger, hot reloading. Anyway, C# and MonoGame was what won at the end of the day, at least to just get the ball rolling. Rider is a great IDE, and MonoGame… at least has great getting started documentation to get me going again. Once I knock out a few cutesy games I’ll probably go build my own thing on top of SDL3, so that I’m not held back by MonoGame. Also the MonoGame content builder is just completely broken on Mac, so on the side I am building my own Rider plugin to bring actually good intellisense to the mgcb file, so that I don’t need the broken editor gui (all it does is manage the mgcb file anyway, arguably should have just been an IDE plugin the whole time) I tried Dragonruby, really wanted to like it, but the development experience is just… not there. It live reloads, but seems to offer no IDE tooling whatsoever. They talk a lot about emacs, maybe you’re supposed to use it with emacs, which I just have zero interest in doing. You’re also not using MRI, or the full Ruby language, so a lot of tooling for “normal Ruby” may not work. C# is just C# with MonoGame, I can use all the tools, import all the nuget packages (if you really want to), etc. I felt like going with a C based project would lock me out of having hot reloading, but that might not be true, please let me know if I am wrong!. I know of a C++ hot reloading thing specifically made for game dev, it’s in my notes somewhere, just not sure if it’s suitable for use (you sure do have to sift through lots of abandoned experimental stuff in this world)
- nodramallama 1y agofwiw you might want to check out Odin-lang!
- corytheboyd 1y agoAh yeah Í keep seeing it come up, I will take a look! This weekend was gonna toy with C++ to rebuild what I got done with MonoGame, but a next mini experiment can perhaps be Odin!
- v1sea 1y agoThanks for sharing a simple setup that avoids SwiftPM. It is nice to have more options. Swift has to shed the perception that it only works on apple platforms. I've found the the C++ interop to be pretty good for my computer vision use cases.
- pusewicz 1y agoYeah, it's nice to use a cross-platform, well established tool to actually build a Swift project.
- anextio 1y agoCMake support started as a community project but was adopted officially by Apple after they started adopting some Swift in the compiler codebase – an extremely large and complex CMake project – so the support is extremely robust now.
- _mlbt 1y agoWhat’s the advantage to avoiding SwiftPM? Is it just for simplicity or are there other advantages?
- pusewicz 1y agoThe build process requires you to have a C library built with its own dependencies. I don’t think it’s very common to do that with SwiftPM, hence it would require extra work for it to happen.
- shortrounddev2 1y agoHow have we still not come up with anything better than cmake?
- pusewicz 1y agoThere are better tools. It's a matter of adoption.
- shortrounddev2 1y agoI mean with IDE support
- taylorallred 1y agoHow does Cute compare to Raylib?
- dismalaf 1y agoOn first glance, Cute is 2D only. Raylib is 3D but can do 2D. Cute is written in C++, Raylib in C.