darthdeus / comfy-demos

Small demos made with the Comfy Engine

Home Page:https://comfyengine.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Comfy Demos

This repo currently contains one opensource demo game made for the 1-bit game jam using the Comfy Engine. The code remains unchanged, while the music/SFX were replaced with our own SFX so that we could publish them with a permissive license (the original assets came from asset packs).

BITMOB Screenshot

Disclaimers

We (the authors at LogLog Games) are not in the business of making cleanest code examples and pretty API abstractions. This game is a product of implementing software raytracing and a simple game in a few days for a game jam, while also doing other things. This is not a perfect textbook quality implementation of raytracing, or the fastest code, or the best architecture showing how to make the cleanest game in Comfy.

Instead, this is mostly the code as it was written for the game jam, with a little bit of cleanup (mostly just deleting dead code). Some dead code is left around for the tinkerers who want to play around with the codebase and maybe discover some things.

There will not be extensive documentation or support for this codebase. We're sharing this because we want to show some real code, not because we want this to be an authoritative example of how to do things.

Game architecture

This is not a typical comfy game. The whole game is a single texture that's drawn in a single sprite, where each pixel is calculated by raytracing on the CPU on every frame. What you see as "sprites" (player, enemy, gun) are just pixels that get copied from the source asset into the target texture one by one, every frame. They're copied in the right order, which is why things look the way they are. This whole process is done by the blit_at function.

The raytracing is also calculated quite simply by the calculate lighting function. If you're expecting fancy BVH or other spatial structures prepare yourself to be deeply disappointed. The raytracer just steps each ray pixel by pixel and checks for a wall in the grid.

Is this a terrible idea? Maybe. The game runs at a small resolution, so on desktop it should be "fast enough". If you want to do this in a real game and ship it to players so that it'll run on a 15 year old potato laptop, you may want to do some profiling before releasing the game, and maybe utilize some fancier data structures.

Comfy now has an experiemental spatial hash which could be used here. We have a different game in the works that uses it for software raytracing. Note that the spatial hash is considered unstable and will 100% change in the near future. That being said, if you like it, you should be able to just take the code and modify it to do whatever you want. This goes for the whole repo.

Note that this game uses grids, which is a separate crate for easy 2D arrays, specifically of the grid style usage. This isn't a linear algebra library, but rather just "easy indexing with utilities". If you're making a grid based game or doing anything with 2d grids this may be useful to you.

Running the game

To run the game simply run make and everything should work.

To build for WASM, run make wasm. This requires you to have trunk installed. This will produce a bitmob/dist dir with everything needed in it. You can then run python3 -m http.server in the bitmob/dist dir and open localhost:8000 in your browser, or simply make serve.

Support

All of the code in this repo is meant as a showcase only, and will not be supported in any way. If you're using it, you're on your own :) Feel free to ask questions in our Discord, and if there are problems that are related to Comfy Engine we will 100% address them.

Note the repo also contains CI config that we've used for uploading to itch.io. It's not supposed to be run from this repo, but we're including it in case it's useful for someone. Again, this is not something that should be viewed as "the setup to use for Comfy", and it's up to those using it to figure out how to integrate it into their CI.

License

All of the code in this repository is triple licensed under MIT, Apache 2.0, and The Unlicense. This means you can use it under any of these licenses.

The reason for this is we really don't care what you do with this code, but some people might prefer a license they know over a random "public domain" license, hence MIT/Apache.

All of the assets (images, music, SFX) were created by us from scratch and are licensed under CC0, which means "public domain", which again means "you can do whatever you want, we don't care, you don't have to give credit".

If you want git clone this repo, compile it, put it on Steam and name it The Official Comfiest Comfy Game in Comfy Engine and sell it for money without making any changes, go ahead. The above licenses should allow this, and in case you want clear permission, consider this to be the explicit permission.

About

Small demos made with the Comfy Engine

https://comfyengine.org/


Languages

Language:Rust 85.6%Language:HTML 12.7%Language:Makefile 1.7%