Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ GAME_TARGETS = kula kula3D kulatwo
all: $(GAME_TARGETS)

$(GAME_TARGETS): %: %/assets
$(MAKE) $(if $(WINDOWS),-C $@ -f Makefile.win,-C $@) $(filter-out $@,$(MAKECMDGOALS))
$(MAKE) -C $@ -f Makefile.wasm $(filter-out $@,$(MAKECMDGOALS))

%/assets:
python tools/copy_assets_to_game.py $*

# empty rule to avoid "No rule to make target" errors
%:
@:
@:
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ OpenKula has been ported to and tested on various platforms, with varying levels
- [PlayStation Portable](https://github.com/bemxio/OpenKula/tree/psp) (text rendering issues)
- [PlayStation Vita](https://github.com/bemxio/OpenKula/tree/vita)
- [Xbox](https://github.com/bemxio/OpenKula/tree/xbox) (major performance issues)
- [WASM](https://github.com/bemxio/OpenKula/tree/wasm)

<!--
My goal is to port OpenKula to all consoles and I (or my friends) own, and so here's a list of potential future platforms:
Expand Down Expand Up @@ -38,7 +39,7 @@ Before building, ensure you have the following dependencies installed:
- [Python](https://www.python.org/) 3.6+ with [CairoSVG](https://cairosvg.org/)
- [GNU Make](https://www.gnu.org/software/make/)
- [Git](https://git-scm.com/)
- (Optional) [MinGW-w64](https://www.mingw-w64.org/) for cross-compiling to Windows
- [Emscripten SDK](https://emscripten.org/docs/getting_started/downloads.html) for WebAssembly builds

On Debian-based distributions, you can install everything you need with `apt install build-essential git libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev python3 python3-cairosvg`.
On Arch-based distros, use `pacman -S base-devel git sdl2 sdl2_image sdl2_mixer sdl2_ttf python python-cairosvg`.
Expand Down Expand Up @@ -68,9 +69,9 @@ make WINDOWS=1 <kula|kula3D|kulatwo> # Replace <kula|kula3D|kulatwo> with your d

This will produce an executable file together with the assets inside the `build/<kula|kula3D|kulatwo>` directory. You can also run `make <kula|kula3D|kulatwo> run` to immediately launch the game after building, or `make` to build all three targets at once.

In case of cross-compiling for Windows, you can also bundle the required DLLs and package everything into a ZIP file with `make WINDOWS=1 <kula|kula3D|kulatwo> dist`.
Browser audio is started on the first user interaction to comply with autoplay restrictions.

## License
This project is licensed under the MIT License - see the [`LICENSE`](LICENSE) file for details.

Contributions are welcome! If you want to contribute in any way, whether it's an issue you've encountered or a pull request with new features, feel free to do so.
Contributions are welcome! If you want to contribute in any way, whether it's an issue you've encountered or a pull request with new features, feel free to do so.
51 changes: 51 additions & 0 deletions kula/Makefile.wasm
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# constants
CC = emcc
CFLAGS = -Wall -fms-extensions -O2 \
-sUSE_SDL=2 \
-sUSE_SDL_IMAGE=2 \
-sSDL2_IMAGE_FORMATS=png \
-sUSE_SDL_MIXER=2 \
-sSDL2_MIXER_FORMATS=mp3,ogg \
-sUSE_SDL_TTF=2 \
-sUSE_FREETYPE=1
LDFLAGS = $(CFLAGS) \
-sALLOW_MEMORY_GROWTH=1 \
--use-preload-plugins \
--preload-file $(ASSETS_DIR)@/assets \
--shell-file ../web/shell.html

SRC_DIR = src
ASSETS_DIR = assets
BUILD_DIR = ../build/kula
export EM_CACHE ?= $(abspath ../build/.emcache)

SOURCES = $(wildcard $(SRC_DIR)/*.c)
HEADERS = $(wildcard $(SRC_DIR)/*.h)
OBJECTS = $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/%.wasm.o,$(SOURCES))

EXECUTABLE = index.html

# phony
.PHONY: all clean distclean run

# targets
all: $(BUILD_DIR)/$(EXECUTABLE)

clean:
$(RM) -r $(BUILD_DIR)

distclean: clean
$(RM) -r $(ASSETS_DIR)

run: $(BUILD_DIR)/$(EXECUTABLE)
emrun $<

# rules
$(BUILD_DIR)/$(EXECUTABLE): $(OBJECTS) | $(BUILD_DIR)
$(CC) $(OBJECTS) $(LDFLAGS) -o $@

$(BUILD_DIR)/%.wasm.o: $(SRC_DIR)/%.c | $(HEADERS) $(BUILD_DIR)
$(CC) $(CFLAGS) -c $< -o $@

$(BUILD_DIR):
mkdir -p $@
7 changes: 0 additions & 7 deletions kula/src/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,6 @@
#define ENEMY_OPEN_PATH "/dev_hdd0/game/KULA00001/USRDIR/assets/fiende01.png"
#define FONT_PATH "/dev_hdd0/game/KULA00001/USRDIR/assets/skrifttype.ttf"
#define PLAYER_PATH "/dev_hdd0/game/KULA00001/USRDIR/assets/kula.png"
#elif defined(__3DS__)
#define BACKGROUND_PATH "romfs:/kulabakgrunn.png"
#define BGM_PATH "romfs:/mortietunes.mp3"
#define ENEMY_CLOSED_PATH "romfs:/fiende02.png"
#define ENEMY_OPEN_PATH "romfs:/fiende01.png"
#define FONT_PATH "romfs:/skrifttype.ttf"
#define PLAYER_PATH "romfs:/kula.png"
#else
#define BACKGROUND_PATH "assets/kulabakgrunn.png"
#define BGM_PATH "assets/mortietunes.mp3"
Expand Down
Loading