Skip to content

Commit

Permalink
feat: use asw (#6)
Browse files Browse the repository at this point in the history
* chore: use asw and add emscripten target

* chore: update readme

* fix: emscripten build

* fix: submodule
  • Loading branch information
alegemaate authored Sep 11, 2023
1 parent 70fd412 commit 3abaaf2
Show file tree
Hide file tree
Showing 222 changed files with 822 additions and 1,016 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Deploy Game

on:
push:
branches:
- main
tags:
- v*

env:
EM_VERSION: "latest"
EM_CACHE_FOLDER: "emsdk-cache"

permissions:
contents: read
pages: write
id-token: write

jobs:
deploy:
name: Deploy
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: recursive

- name: Setup cache
id: cache-system-libraries
uses: actions/cache@v2
with:
path: ${{env.EM_CACHE_FOLDER}}
key: ${{env.EM_VERSION}}-${{ runner.os }}

- uses: mymindstorm/setup-emsdk@v11
with:
version: ${{env.EM_VERSION}}
actions-cache-folder: ${{env.EM_CACHE_FOLDER}}

- name: Run CMake
run: emcmake cmake -G "Unix Makefiles" .

- name: Make
run: emmake make -j4

- uses: actions/upload-pages-artifact@v1
with:
path: ./build

- name: Deploy to GitHub Pages
if: github.ref == 'refs/heads/main'
id: deployment
uses: actions/deploy-pages@v2

- name: Deploy to A.D.S. Games
if: startsWith(github.ref, 'refs/tags/v')
uses: adsgames/[email protected]
with:
project-id: jimsalienadventure
build-dir: ./build/
platform: WEB
bucket-access-key: ${{ secrets.LINODE_BUCKET_ACCESS_KEY }}
bucket-secret-key: ${{ secrets.LINODE_BUCKET_SECRET_KEY }}
api-key: ${{ secrets.ADSGAMES_API_KEY }}
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,7 @@ Makefile
install_manifest.txt
bin
docs
lib
build/JimsAlienAdventure*
build/
*.ninja*
compile_commands.json
_deps
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "lib/asw"]
path = lib/asw
url = https://github.com/AdsGames/asw
12 changes: 12 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"configurations": [
{
"name": "Win32",
"includePath": ["${default}", "${workspaceFolder}/lib/asw/include"],
"defines": ["_DEBUG", "UNICODE", "_UNICODE"],
"compileCommands": "${workspaceFolder}/compile_commands.json",
"configurationProvider": "ms-vscode.cmake-tools"
}
],
"version": 4
}
79 changes: 79 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"files.associations": {
"any": "cpp",
"array": "cpp",
"atomic": "cpp",
"bit": "cpp",
"*.tcc": "cpp",
"bitset": "cpp",
"cctype": "cpp",
"charconv": "cpp",
"chrono": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"codecvt": "cpp",
"compare": "cpp",
"concepts": "cpp",
"condition_variable": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"forward_list": "cpp",
"list": "cpp",
"map": "cpp",
"set": "cpp",
"string": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"ratio": "cpp",
"source_location": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"format": "cpp",
"fstream": "cpp",
"future": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"mutex": "cpp",
"new": "cpp",
"numbers": "cpp",
"ostream": "cpp",
"semaphore": "cpp",
"span": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"stdfloat": "cpp",
"stop_token": "cpp",
"streambuf": "cpp",
"thread": "cpp",
"cinttypes": "cpp",
"typeinfo": "cpp",
"variant": "cpp",
"ranges": "cpp",
"valarray": "cpp"
}
}
18 changes: 18 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Build",
"type": "shell",
"detail": "Run and build jim farm",
"command": "cmake --build . && cd build && ./JimsAlienAdventure",
"windows": {
"command": "cmake --build . && cd build && JimsAlienAdventure.exe"
},
"group": "build",
"problemMatcher": "$gcc"
}
]
}
89 changes: 79 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,25 +1,94 @@
cmake_minimum_required(VERSION 3.11)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

include(FetchContent)

project (JimsAlienAdventure)

# Source code
file(GLOB_RECURSE SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)
file(GLOB_RECURSE HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/src/*.h)
file(GLOB_RECURSE SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp ${CMAKE_CURRENT_SOURCE_DIR}/lib/*.cpp)
file(GLOB_RECURSE HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/src/*.h ${CMAKE_CURRENT_SOURCE_DIR}/lib/*.h)

add_executable (${PROJECT_NAME} ${SOURCES} ${HEADERS})
add_executable(${PROJECT_NAME} ${SOURCES} ${HEADERS})

target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -pedantic)

FetchContent_Declare(json URL https://github.com/nlohmann/json/releases/download/v3.11.2/json.tar.xz)
FetchContent_MakeAvailable(json)

add_subdirectory(lib/asw)

# Find libs
find_library(ALLEGRO_LIBRARY NAMES alleg44 alleg REQUIRED)
find_library(ALLEGRO_PNG_LIBRARY NAMES loadpng REQUIRED)
find_library(ALLEGRO_OGG_LIBRARY NAMES logg REQUIRED)
if(NOT EMSCRIPTEN)
find_library(SDL_LIBRARY NAMES SDL2 REQUIRED)
find_library(SDL_MIXER_LIBRARY NAMES SDL2_mixer REQUIRED)
find_library(SDL_IMAGE_LIBRARY NAMES SDL2_image REQUIRED)
find_library(SDL_TTF_LIBRARY NAMES SDL2_ttf REQUIRED)
find_library(SDL_GFX_LIBRARY NAMES SDL2_gfx REQUIRED)
find_library(SDL_MAIN_LIBRARY NAMES SDL2main REQUIRED)
endif(NOT EMSCRIPTEN)


# Link Libs
target_link_libraries(${PROJECT_NAME} ${ALLEGRO_LIBRARY})
target_link_libraries(${PROJECT_NAME} ${ALLEGRO_PNG_LIBRARY})
target_link_libraries(${PROJECT_NAME} ${ALLEGRO_OGG_LIBRARY})
# Emscripten support
if(EMSCRIPTEN)
set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "index")
set(CMAKE_EXECUTABLE_SUFFIX ".html")
target_compile_options(
${PROJECT_NAME}
PRIVATE
-sUSE_SDL=2
-sUSE_SDL_IMAGE=2
-sUSE_SDL_TTF=2
-sUSE_SDL_MIXER=2
-sUSE_SDL_GFX=2
-sSDL2_IMAGE_FORMATS=["png"]
-sSTACK_SIZE=128MB
)
target_link_libraries(
${PROJECT_NAME}
-sWASM=1
-sUSE_SDL=2
-sUSE_SDL_IMAGE=2
-sUSE_SDL_TTF=2
-sUSE_SDL_MIXER=2
-sUSE_SDL_GFX=2
-sSDL2_IMAGE_FORMATS=["png"]
-sDEMANGLE_SUPPORT=1
-sTOTAL_MEMORY=512MB
-sSTACK_SIZE=128MB
nlohmann_json::nlohmann_json
asw
)
set_target_properties(
${PROJECT_NAME}
PROPERTIES
LINK_FLAGS
"--preload-file ${CMAKE_CURRENT_LIST_DIR}/assets@/assets --use-preload-plugins --shell-file ${CMAKE_CURRENT_LIST_DIR}/index.html"
)

# Run of the mill executable
else(EMSCRIPTEN)
if(MINGW)
target_link_libraries(${PROJECT_NAME} -lmingw32)
endif(MINGW)
target_link_libraries(
${PROJECT_NAME}
-lm
${SDL_MAIN_LIBRARY}
${SDL_LIBRARY}
${SDL_MIXER_LIBRARY}
${SDL_IMAGE_LIBRARY}
${SDL_TTF_LIBRARY}
${SDL_GFX_LIBRARY}
nlohmann_json::nlohmann_json
asw
)
endif(EMSCRIPTEN)

file(COPY ${CMAKE_CURRENT_LIST_DIR}/assets/ DESTINATION ${CMAKE_BINARY_DIR}/build/assets/)

45 changes: 17 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,59 +2,48 @@

A button mashing game with the objective of preventing goat aliens from destroying famous international cities

## Getting started
## Demo

### Windows (MSYS2)
[Web Demo](https://adsgames.github.io/jims-alien-adventure/)

#### Install Libraries
## Setup

```bash
https://www.allegro.cc/files/?v=4.4
```
### Dependencies

#### Build

```bash
cmake -G "MSYS Makefiles" .
```
To pull the submodules, run the following command:

```bash
make
git submodule update --init --recursive
```

### Mac OS

#### Install Libraries
### Windows (MSYS2)

```bash
https://github.com/msikma/liballeg.4.4.2-osx
pacman -S mingw-w64-i686-gcc-libs mingw-w64-i686-SDL2 mingw-w64-i686-SDL2_mixer mingw-w64-i686-SDL2_image mingw-w64-i686-SDL2_ttf
```

#### Build

```bash
cmake -G "Unix Makefiles" .
```
### Mac OS

```bash
make
brew install sdl2 sdl2_image sdl2_ttf sdl2_mixer
```

### Linux

#### Install Libraries

```bash
sudo apt-get install liballegro4-dev libloadpng4-dev liblogg4-dev
sudo apt install libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev libsdl2-mixer-dev
```

#### Build
### Build

```bash
cmake -G "Unix Makefiles" .
cmake .
make
```

### Build Emscripten

```bash
emcmake cmake .
make
```

Binary file added assets/fonts/dosis.ttf
Binary file not shown.
Binary file added assets/images/goat_alien.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/goat_alien_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Binary file added assets/images/levels/cn_tower/brick.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/levels/cn_tower/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/levels/cn_tower/parallax.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/levels/cn_tower/sky.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/levels/cn_tower/stage_end_green.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/levels/cn_tower/stage_end_red.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/levels/cn_tower/stairs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/levels/pyramids/brick.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/levels/pyramids/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/levels/pyramids/parallax.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/levels/pyramids/sky.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/levels/pyramids/stage_end_green.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/levels/pyramids/stage_end_red.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/levels/pyramids/stairs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/levels/statue_of_liberty/brick.png
Binary file added assets/images/levels/statue_of_liberty/icon.png
Binary file added assets/images/levels/statue_of_liberty/sky.png
Binary file added assets/images/levels/statue_of_liberty/stairs.png
Binary file added assets/images/levels/stone_henge/brick.png
Binary file added assets/images/levels/stone_henge/icon.png
Binary file added assets/images/levels/stone_henge/parallax.png
Binary file added assets/images/levels/stone_henge/sky.png
Binary file added assets/images/levels/stone_henge/stairs.png
Binary file added assets/images/levels/taj_mahal/brick.png
Binary file added assets/images/levels/taj_mahal/icon.png
Binary file added assets/images/levels/taj_mahal/parallax.png
Binary file added assets/images/levels/taj_mahal/sky.png
Binary file added assets/images/levels/taj_mahal/stage_end_green.png
Binary file added assets/images/levels/taj_mahal/stage_end_red.png
Binary file added assets/images/levels/taj_mahal/stairs.png
Binary file added assets/images/levels/wall_of_china/brick.png
Binary file added assets/images/levels/wall_of_china/icon.png
Binary file added assets/images/levels/wall_of_china/parallax.png
Binary file added assets/images/levels/wall_of_china/sky.png
Binary file added assets/images/levels/wall_of_china/stairs.png
Binary file added assets/images/logo.png
Binary file added assets/images/map/cursor.png
Binary file added assets/images/map/map.png
Binary file added assets/images/map/pin.png
Binary file added assets/images/map/pin_grey.png
Binary file added assets/images/menu/angle_buttons.png
Binary file added assets/images/menu/button_exit.png
Binary file added assets/images/menu/button_options.png
Binary file added assets/images/menu/button_play.png
Binary file added assets/images/menu/button_pushed_exit.png
Binary file added assets/images/menu/button_pushed_options.png
Binary file added assets/images/menu/button_pushed_play.png
Binary file added assets/images/menu/button_pushed_story.png
Binary file added assets/images/menu/button_story.png
Binary file added assets/images/menu/cursor1.png
Binary file added assets/images/menu/cursor2.png
Binary file added assets/images/menu/menu.png
Binary file added assets/images/menu/menu_2.png
Binary file added assets/images/menu/title.png
Binary file added assets/images/player/player_1.png
Binary file added assets/images/player/player_2.png
Binary file added assets/images/player/player_3.png
Binary file added assets/images/player/player_4.png
Binary file added assets/images/player/player_5.png
Binary file added assets/images/player/player_6.png
Binary file added assets/images/player/player_7.png
Binary file added assets/images/player/player_8.png
Binary file added assets/images/splash.png
Binary file added assets/images/story_splash.png
Binary file added assets/images/watch.png
Binary file added assets/images/youlose.png
Binary file added assets/images/youwin.png
Loading

0 comments on commit 3abaaf2

Please sign in to comment.