Skip to content
Merged
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
73 changes: 73 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Deploy Game

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

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

concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true

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

- name: Setup cache
uses: actions/cache@v4
with:
path: "_deps"
key: deps-${{ runner.os }}

- uses: mymindstorm/setup-emsdk@v14
with:
version: 4.0.6
actions-cache-folder: "emsdk-cache"

- name: Download ports
run: |
embuilder build harfbuzz

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

- name: Make
run: emmake make -j4

- uses: actions/upload-pages-artifact@v3
if: github.ref == 'refs/heads/main'
with:
path: ./build

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

- name: Deploy to A.D.S. Games
if: startsWith(github.ref, 'refs/tags/v')
uses: adsgames/deploy-to-adsgames@v1.1.2
with:
project-id: mazes
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 }}
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ $RECYCLE.BIN/
# Icon must ends with two \r.
Icon


# Thumbnails
._*

Expand All @@ -49,4 +48,6 @@ install_manifest.txt
bin
docs
lib
build/Mazes*
build/
_deps/
compile_commands.json
51 changes: 49 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,52 @@
{
"files.associations": {
"fstream": "cpp"
"fstream": "cpp",
"array": "cpp",
"__bit_reference": "cpp",
"__config": "cpp",
"__locale": "cpp",
"__threading_support": "cpp",
"__verbose_abort": "cpp",
"bitset": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"execution": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"ios": "cpp",
"iosfwd": "cpp",
"istream": "cpp",
"limits": "cpp",
"locale": "cpp",
"mutex": "cpp",
"new": "cpp",
"ostream": "cpp",
"ratio": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"string": "cpp",
"string_view": "cpp",
"tuple": "cpp",
"typeinfo": "cpp",
"variant": "cpp",
"algorithm": "cpp",
"bit": "cpp",
"compare": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"*.tcc": "cpp",
"cinttypes": "cpp",
"random": "cpp"
}
}
}
57 changes: 44 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,27 +1,58 @@
cmake_minimum_required(VERSION 3.11)
cmake_minimum_required(VERSION 3.24)

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)

project (Mazes)
include(FetchContent)

project(Mazes)

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

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

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

# 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)

FetchContent_Declare(
asw
GIT_REPOSITORY https://github.com/adsgames/asw.git
GIT_TAG v0.5.4
)
FetchContent_MakeAvailable(asw)

# 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})

if(MINGW)
target_link_libraries(${PROJECT_NAME} -lmingw32)
endif(MINGW)

target_link_libraries(
${PROJECT_NAME}
asw
)

# Emscripten support
if(EMSCRIPTEN)
set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "index")
set(CMAKE_EXECUTABLE_SUFFIX ".html")

target_link_libraries(
${PROJECT_NAME}
-sWASM=1
-sALLOW_MEMORY_GROWTH=1
-sMAXIMUM_MEMORY=1gb
)

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"
)
endif(EMSCRIPTEN)

file(COPY ${CMAKE_CURRENT_LIST_DIR}/assets DESTINATION ${CMAKE_BINARY_DIR}/build)
54 changes: 11 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,59 +1,27 @@
# Mazes

A simple maze Sokoban type game based developed while learning c++ game development with allegro.

## Getting started

### Windows (MSYS2)

#### Install Libraries

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

#### Build

```bash
cmake -G "MSYS Makefiles" .
```

```bash
make
```
[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=AdsGames_mazes&metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=AdsGames_mazes)
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=AdsGames_mazes&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=AdsGames_mazes)
[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=AdsGames_mazes&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=AdsGames_mazes)

### Mac OS
A simple maze Sokoban type game based developed while learning c++ game development with allegro.

#### Install Libraries
## Demo

```bash
https://github.com/msikma/liballeg.4.4.2-osx
```
[Web Demo](https://adsgames.github.io/mazes/)

#### Build
## Setup

```bash
cmake -G "Unix Makefiles" .
```
### Build

```bash
cmake .
make
```

### Linux

#### Install Libraries

```bash
sudo apt-get install liballegro4-dev libloadpng4-dev liblogg4-dev
```

#### Build

```bash
cmake -G "Unix Makefiles" .
```
### Build Emscripten

```bash
emcmake cmake .
make
```
Binary file added assets/fonts/dosis.ttf
Binary file not shown.
Binary file added assets/images/background.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/blocks/2d/box.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/blocks/2d/broom.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/blocks/2d/character.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/blocks/2d/garbagecan.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/blocks/2d/ground.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/blocks/2d/janitor_room.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/blocks/2d/janitor_room_open.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/blocks/2d/robot.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/blocks/2d/scrap.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/blocks/2d/wall.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/blocks/2d/wall2.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/blocks/2d/wood_floor.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/blocks/3d/box.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/blocks/3d/broom.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/blocks/3d/character_down.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/blocks/3d/character_left.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/blocks/3d/character_old.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/blocks/3d/character_right.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/blocks/3d/character_up.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/blocks/3d/garbagecan.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/blocks/3d/janitor_room.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/blocks/3d/janitor_room_open.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/blocks/3d/robot.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/blocks/3d/scrap.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/blocks/3d/wall.png
Binary file added assets/images/blocks/3d/wall2.png
Binary file added assets/images/blocks/3d/wood_floor.png
Binary file added assets/images/buttons/back.png
Binary file added assets/images/buttons/back_hover.png
Binary file added assets/images/buttons/help.png
Binary file added assets/images/buttons/help_hover.png
Binary file added assets/images/buttons/mode_2d.png
Binary file added assets/images/buttons/mode_2d_hover.png
Binary file added assets/images/buttons/mode_3d.png
Binary file added assets/images/buttons/mode_3d_hover.png
Binary file added assets/images/buttons/quit.png
Binary file added assets/images/buttons/quit_hover.png
Binary file added assets/images/buttons/start.png
Binary file added assets/images/buttons/start_hover.png
Binary file added assets/images/cursor1.png
Binary file added assets/images/cursor2.png
Binary file added assets/images/help.png
Binary file added assets/images/intro.png
Binary file added assets/images/levelSelect.png
Binary file added assets/images/levelSelectLeft.png
Binary file added assets/images/levelSelectRight.png
Binary file added assets/images/menu.png
Binary file added assets/images/splash.png
Binary file added assets/images/winscreen.png
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.
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.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file removed build/fonts/arial_black.pcx
Binary file not shown.
Binary file removed build/images/background.png
Diff not rendered.
Binary file removed build/images/blocks/2d/box.png
Diff not rendered.
Binary file removed build/images/blocks/2d/broom.png
Diff not rendered.
Binary file removed build/images/blocks/2d/character.png
Diff not rendered.
Binary file removed build/images/blocks/2d/garbagecan.png
Diff not rendered.
Binary file removed build/images/blocks/2d/ground.png
Diff not rendered.
Binary file removed build/images/blocks/2d/janitor_room.png
Diff not rendered.
Binary file removed build/images/blocks/2d/janitor_room_open.png
Diff not rendered.
Binary file removed build/images/blocks/2d/robot.png
Diff not rendered.
Binary file removed build/images/blocks/2d/scrap.png
Diff not rendered.
Binary file removed build/images/blocks/2d/wall.png
Diff not rendered.
Binary file removed build/images/blocks/2d/wall2.png
Diff not rendered.
Binary file removed build/images/blocks/2d/wood_floor.png
Diff not rendered.
Binary file removed build/images/blocks/3d/box.png
Diff not rendered.
Binary file removed build/images/blocks/3d/broom.png
Diff not rendered.
Binary file removed build/images/blocks/3d/character_down.png
Diff not rendered.
Binary file removed build/images/blocks/3d/character_left.png
Diff not rendered.
Binary file removed build/images/blocks/3d/character_old.png
Diff not rendered.
Binary file removed build/images/blocks/3d/character_right.png
Diff not rendered.
Binary file removed build/images/blocks/3d/character_up.png
Diff not rendered.
Binary file removed build/images/blocks/3d/garbagecan.png
Diff not rendered.
Binary file removed build/images/blocks/3d/janitor_room.png
Diff not rendered.
Binary file removed build/images/blocks/3d/janitor_room_open.png
Diff not rendered.
Binary file removed build/images/blocks/3d/robot.png
Diff not rendered.
Binary file removed build/images/blocks/3d/scrap.png
Diff not rendered.
Binary file removed build/images/blocks/3d/wall.png
Diff not rendered.
Binary file removed build/images/blocks/3d/wall2.png
Diff not rendered.
Binary file removed build/images/blocks/3d/wood_floor.png
Diff not rendered.
Binary file removed build/images/buttons/back.png
Diff not rendered.
Binary file removed build/images/buttons/back_hover.png
Diff not rendered.
Binary file removed build/images/buttons/help.png
Diff not rendered.
Binary file removed build/images/buttons/help_hover.png
Diff not rendered.
Binary file removed build/images/buttons/mode_2d.png
Diff not rendered.
Binary file removed build/images/buttons/mode_2d_hover.png
Diff not rendered.
Binary file removed build/images/buttons/mode_3d.png
Diff not rendered.
Binary file removed build/images/buttons/mode_3d_hover.png
Diff not rendered.
Binary file removed build/images/buttons/quit.png
Diff not rendered.
Binary file removed build/images/buttons/quit_hover.png
Diff not rendered.
Binary file removed build/images/buttons/start.png
Diff not rendered.
Binary file removed build/images/buttons/start_hover.png
Diff not rendered.
Binary file removed build/images/cursor1.png
Diff not rendered.
Binary file removed build/images/cursor2.png
Diff not rendered.
Binary file removed build/images/help.png
Diff not rendered.
Binary file removed build/images/intro.png
Diff not rendered.
Binary file removed build/images/levelSelect.png
Diff not rendered.
Binary file removed build/images/levelSelectLeft.png
Diff not rendered.
Binary file removed build/images/levelSelectRight.png
Diff not rendered.
Binary file removed build/images/menu.png
Diff not rendered.
Binary file removed build/images/splash.png
Diff not rendered.
Binary file removed build/images/winscreen.png
Diff not rendered.
File renamed without changes.
42 changes: 42 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Mazes</title>
<meta charset="utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<style>
html,
body {
margin: 0;
padding: 0;
overflow: hidden;
width: 100%;
height: 100%;
background-color: #000000;
display: flex;
align-items: center;
justify-content: center;
}
</style>
</head>

<body>
<canvas
id="canvas"
oncontextmenu="event.preventDefault()"
onclick="this.focus()"
tabindex="-1"
></canvas>

<script type="text/javascript">
var Module = {
canvas: (function () {
return document.getElementById("canvas");
})(),
};
</script>

{{{ SCRIPT }}}
</body>
</html>
40 changes: 10 additions & 30 deletions src/block.cpp
Original file line number Diff line number Diff line change
@@ -1,22 +1,8 @@
#include "block.h"

#include <loadpng.h>

Block::Block()
: x(0), y(0), type(0), frame(0), selected(false), sound(nullptr) {
images[0] = nullptr;
images[1] = nullptr;
}

Block::~Block() {
destroy_bitmap(images[0]);
destroy_bitmap(images[1]);
destroy_sample(sound);
}

void Block::SetImages(const char* image1, const char* image2) {
images[0] = load_png(image1, nullptr);
images[1] = load_png(image2, nullptr);
void Block::SetImages(const std::string& path1, const std::string& path2) {
images[0] = asw::assets::loadTexture(path1);
images[1] = asw::assets::loadTexture(path2);
}

int Block::GetX() const {
Expand All @@ -35,18 +21,12 @@ void Block::SetY(int newValue) {
y = newValue;
}

void Block::draw(BITMAP* buffer) {
if (frame == 0 || frame == 1 || frame == 2 || frame == 3 || frame == 4) {
frame += 1;
draw_sprite(buffer, images[0], GetX(), GetY());
} else if (frame == 5 || frame == 6 || frame == 7 || frame == 8 ||
frame == 9 || frame == 10 || frame == 11 || frame == 12 ||
frame == 13 || frame == 14 || frame == 15) {
frame += 1;
draw_sprite(buffer, images[1], GetX(), GetY());

if (frame == 16) {
frame = 0;
}
void Block::draw() {
if (frame <= 4) {
asw::draw::sprite(images[0], asw::Vec2<float>(x, y));
} else {
asw::draw::sprite(images[1], asw::Vec2<float>(x, y));
}

frame += (frame + 1) % 16;
}
Loading
Loading