Skip to content

Commit

Permalink
Update Pong to use Emscripten 1.38.22 + remove submodules to use old …
Browse files Browse the repository at this point in the history
…version of Jackbengine (commit d5a3adde470f79ee0e67065a6813b6ad2805a64c).
  • Loading branch information
Jackbenfu committed Apr 6, 2019
1 parent 811e0d1 commit 184c768
Show file tree
Hide file tree
Showing 173 changed files with 22,460 additions and 31 deletions.
7 changes: 1 addition & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# Submodules
/external/jackbengine/
/external/resourceGenerator/

# Mac OS
.DS_Store

Expand All @@ -14,7 +10,6 @@ cmake-build-relwithdebinfo/

# Generated source files
resources.cpp
libjackbengine.bc
pong.js.mem
pong.js
resourceGenerator
pong.wasm
10 changes: 0 additions & 10 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,10 +0,0 @@
[submodule "external/jackbengine"]
path = external/jackbengine
url = [email protected]:Jackbenfu/Jackbengine.git
branch = master
ignore = all
[submodule "external/resourceGenerator"]
path = external/resourceGenerator
url = [email protected]:Jackbenfu/ResourceGenerator.git
branch = master
ignore = all
5 changes: 3 additions & 2 deletions Makefile.emscripten
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ CC = emcc

CFLAGS = -Oz \
-Wall -Wextra -Wpedantic \
-std=c++1z \
-std=c++17 \
-s USE_SDL=2 \
-s USE_SDL_TTF=2 \
-s USE_SDL_MIXER=2 \
-s USE_SDL_IMAGE=2 \
-s SDL2_IMAGE_FORMATS='["png"]' \
-s DEMANGLE_SUPPORT=1 \
Expand Down Expand Up @@ -32,7 +33,7 @@ SOURCES = src/main.cpp \
src/scene/2players/state/2playersGameOverState.cpp \
resources.cpp

LIB_JACKBENGINE = libjackbengine.bc
LIB_JACKBENGINE = external/jackbengine/libjackbengine.bc

OUT = export/itch.io/pong.js

Expand Down
20 changes: 9 additions & 11 deletions emscripten.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,23 @@ pwd=`pwd`
# Building Jackbengine library
cd ${pwd}/external/jackbengine
make -f Makefile.emscripten
cp libjackbengine.bc ../..
cd -

# Building Resource generator tool
cd ${pwd}/external/resourceGenerator
make -f Makefile.emscripten
cp resourceGenerator ../..
cd -

# Generating resources.cpp
./resourceGenerator \
resources.cpp \
-bresources/left.wav \
-bresources/right.wav \
-bresources/wall.wav \
-tresources/menu.tmx \
-tresources/wall.tmx \
-tresources/two_players.tmx \
-tresources/one_player.tmx \
./external/resourceGenerator/resourceGenerator \
resources.cpp \
-bresources/left.wav \
-bresources/right.wav \
-bresources/wall.wav \
-tresources/menu.tmx \
-tresources/wall.tmx \
-tresources/two_players.tmx \
-tresources/one_player.tmx \
-bresources/tileset.png

# Building Pong web output
Expand Down
1 change: 0 additions & 1 deletion external/jackbengine
Submodule jackbengine deleted from b05f3d
12 changes: 12 additions & 0 deletions external/jackbengine/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Mac OS
.DS_Store

# CLion
.idea/
cmake-build-debug/
cmake-build-minsizerel/
cmake-build-release/
cmake-build-relwithdebinfo/

# Jackbengine library
libjackbengine.bc
97 changes: 97 additions & 0 deletions external/jackbengine/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
cmake_minimum_required(VERSION 3.9)
project(jackbengine)

# CMake configuration
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic")
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)

# SDL2 include directories
include_directories(${SDL2_INCLUDE_DIR})
include_directories(${SDL2_IMAGE_INCLUDE_DIR})
include_directories(${SDL2_TTF_INCLUDE_DIR})
include_directories(${SDL2_MIXER_INCLUDE_DIR})

# SDL2 library references
find_package(SDL2 REQUIRED)
find_package(SDL2_image REQUIRED)
find_package(SDL2_ttf REQUIRED)
find_package(SDL2_mixer REQUIRED)

# Jackbengine include directories
include_directories(${PROJECT_SOURCE_DIR}/external)
include_directories(${PROJECT_SOURCE_DIR}/src)

# Jackbengine source files
set(SOURCE_FILES
external/easywsclient/easywsclient.cpp
external/tinyxml/tinystr.cpp
external/tinyxml/tinyxml.cpp
external/tinyxml/tinyxmlerror.cpp
external/tinyxml/tinyxmlparser.cpp
src/application/abstract/abstractApplication.cpp
src/application/application.cpp
src/component/audio/audioSourceComponent.cpp
src/component/body/shape/boxShapeComponent.cpp
src/component/body/transformComponent.cpp
src/component/body/velocityComponent.cpp
src/component/input/mouseListenerComponent.cpp
src/component/layout/containerComponent.cpp
src/component/layout/zOrderComponent.cpp
src/component/misc/nameComponent.cpp
src/component/misc/tagComponent.cpp
src/component/view/colorComponent.cpp
src/component/view/spriteComponent.cpp
src/component/view/textComponent.cpp
src/component/generic/stringComponent.cpp
src/core/sdl/io/sdlRwops.cpp
src/core/sdl/surface/sdlSurface.cpp
src/core/audio/sound.cpp
src/core/audio/sound.impl.cpp
src/core/input/input.cpp
src/core/input/input.impl.cpp
src/core/render/color32.cpp
src/core/render/cursor/cursor.cpp
src/core/render/cursor/cursor.impl.cpp
src/core/render/font/defaultFont.cpp
src/core/render/font/font.cpp
src/core/render/font/font.impl.cpp
src/core/render/renderer/renderer.cpp
src/core/render/renderer/renderer.impl.cpp
src/core/render/texture/texture.cpp
src/core/render/texture/texture.impl.cpp
src/core/render/window/window.cpp
src/core/render/window/window.impl.cpp
src/core/state/stateMachine.cpp
src/core/time/timer.cpp
src/core/time/timer.impl.cpp
src/core/tmx/tmxImage.cpp
src/core/tmx/tmxLayer.cpp
src/core/tmx/tmxMap.cpp
src/core/tmx/tmxObject.cpp
src/core/tmx/tmxObjectGroup.cpp
src/core/tmx/tmxProperty.cpp
src/core/tmx/tmxPropertyGroup.cpp
src/core/tmx/tmxText.cpp
src/core/tmx/tmxTileset.cpp
src/entity/entityManager.cpp
src/scene/scene.cpp
src/scene/loader/tmxSceneLoader.cpp
src/system/animation/motionSystem.cpp
src/system/debug/debugProfileSystem.cpp
src/system/debug/debugSpriteSystem.cpp
src/system/debug/debugTextSystem.cpp
src/system/input/mouseEventTriggerSystem.cpp
src/system/physic/aabbCollisionSystem.cpp
src/system/render/spriteRenderSystem.cpp
src/system/render/textRenderSystem.cpp
src/system/system.cpp
src/system/systemManager.cpp
${PLATFORM_SOURCE_FILES}
)

add_library(jackbengine ${SOURCE_FILES})
target_link_libraries(jackbengine ${SDL2_LIBRARY})
target_link_libraries(jackbengine ${SDL2_IMAGE_LIBRARY})
target_link_libraries(jackbengine ${SDL2_TTF_LIBRARY})
target_link_libraries(jackbengine ${SDL2_MIXER_LIBRARY})
85 changes: 85 additions & 0 deletions external/jackbengine/Makefile.emscripten
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
CC = emcc

CFLAGS = -Oz \
-Wall -Wextra -Wpedantic \
-std=c++17 \
-s USE_SDL=2 \
-s USE_SDL_TTF=2 \
-s USE_SDL_MIXER=2 \
-s USE_SDL_IMAGE=2 \
-s SDL2_IMAGE_FORMATS='["png"]' \
-s DEMANGLE_SUPPORT=1 \
-s WARN_ON_UNDEFINED_SYMBOLS=1

INCLUDES = -Iexternal \
-Isrc

SOURCES = external/easywsclient/easywsclient.cpp \
external/tinyxml/tinystr.cpp \
external/tinyxml/tinyxml.cpp \
external/tinyxml/tinyxmlerror.cpp \
external/tinyxml/tinyxmlparser.cpp \
src/application/abstract/abstractApplication.cpp \
src/application/application.cpp \
src/component/audio/audioSourceComponent.cpp \
src/component/body/shape/boxShapeComponent.cpp \
src/component/body/transformComponent.cpp \
src/component/body/velocityComponent.cpp \
src/component/input/mouseListenerComponent.cpp \
src/component/layout/containerComponent.cpp \
src/component/layout/zOrderComponent.cpp \
src/component/misc/nameComponent.cpp \
src/component/misc/tagComponent.cpp \
src/component/view/colorComponent.cpp \
src/component/view/spriteComponent.cpp \
src/component/view/textComponent.cpp \
src/component/generic/stringComponent.cpp \
src/core/sdl/io/sdlRwops.cpp \
src/core/sdl/surface/sdlSurface.cpp \
src/core/audio/sound.cpp \
src/core/audio/sound.impl.cpp \
src/core/input/input.cpp \
src/core/input/input.impl.cpp \
src/core/render/color32.cpp \
src/core/render/cursor/cursor.cpp \
src/core/render/cursor/cursor.impl.cpp \
src/core/render/font/defaultFont.cpp \
src/core/render/font/font.cpp \
src/core/render/font/font.impl.cpp \
src/core/render/renderer/renderer.cpp \
src/core/render/renderer/renderer.impl.cpp \
src/core/render/texture/texture.cpp \
src/core/render/texture/texture.impl.cpp \
src/core/render/window/window.cpp \
src/core/render/window/window.impl.cpp \
src/core/state/stateMachine.cpp \
src/core/time/timer.cpp \
src/core/time/timer.impl.cpp \
src/core/tmx/tmxImage.cpp \
src/core/tmx/tmxLayer.cpp \
src/core/tmx/tmxMap.cpp \
src/core/tmx/tmxObject.cpp \
src/core/tmx/tmxObjectGroup.cpp \
src/core/tmx/tmxProperty.cpp \
src/core/tmx/tmxPropertyGroup.cpp \
src/core/tmx/tmxText.cpp \
src/core/tmx/tmxTileset.cpp \
src/entity/entityManager.cpp \
src/scene/scene.cpp \
src/scene/loader/tmxSceneLoader.cpp \
src/system/animation/motionSystem.cpp \
src/system/debug/debugProfileSystem.cpp \
src/system/debug/debugSpriteSystem.cpp \
src/system/debug/debugTextSystem.cpp \
src/system/input/mouseEventTriggerSystem.cpp \
src/system/physic/aabbCollisionSystem.cpp \
src/system/render/spriteRenderSystem.cpp \
src/system/render/textRenderSystem.cpp \
src/system/system.cpp \
src/system/systemManager.cpp


OUT = libjackbengine.bc

all:
EMCC_DEBUG=1 $(CC) $(CFLAGS) $(INCLUDES) $(SOURCES) -o $(OUT)
58 changes: 58 additions & 0 deletions external/jackbengine/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Jackbengine
A multi-platform C++ 2D game engine.

## Features

#### Multi-platform
The engine runs and was successfully tested on the following platforms:
- OS X, macOS
- Windows (MinGW)
- Web (Emscripten)

#### ECS pattern implementation
Summary of the Entity-component-system approach:
- _Entities_ are made up of one or more components
- _Components_ contain data to store the state of an entity
- _Systems_ contain the logic and operate on entities that have the required components

The engine provides standard components and systems usually needed in a game:
* Components: `Transform`, `Velocity`, `BoxShape`, `Sprite`, `Text`, `MouseListener`, `AudioSource` etc.
* Systems: `Motion`, `SpriteRender`, `TextRender`, `MouseEventTrigger`, `AABBCollision`, `DebugProfile`, `DebugSprite` etc.

This collection of components and systems can be extended.

#### Scene management
- Scenes can be used to split the game in logical parts (menus, in-game, options etc.) and/or functional parts (levels, screens etc.).
- A scene has its own context and cannot interact with other scenes.
- Transitions between scenes is possible by loading a scene from the current one (the previous scene being automatically unloaded).

#### Resource management
- Resources can be loaded from files or embedded resources.
- Embedded resources can be generated using the [ResourceGenerator](https://github.com/Jackbenfu/ResourceGenerator) tool.

#### Tile Map XML basic support (see [official reference](http://doc.mapeditor.org/reference/tmx-map-format/))
* Current implementation supports loading of following nodes:
* `Map`
* `Tileset` (only one per file)
* `Layer`
* `Object` and `ObjectGroup`
* `Property` and `Properties`
* `Text`

#### WebSocket client
- The class `WebSocket` wraps a web socket connection and allows to bind one `deserializer` and one `callback` per typed network message.

## Development information
- All targets (except Web) are compiled using [CMake](https://cmake.org/).
- Web targets are compiled using [Emscripten](http://emscripten.org/) and Makefiles.
- My main IDE is [CLion](https://www.jetbrains.com/clion/), the powerfull cross-platform C/C++ IDE from JetBrains!

## External dependencies
The engine relies on the following awesome libraries and tools:
- [Emscripten](http://emscripten.org/)
- [SDL2](https://www.libsdl.org/)
- [SDL2_image](https://www.libsdl.org/projects/SDL_image/)
- [SDL2_ttf](https://www.libsdl.org/projects/SDL_ttf/)
- [SDL2_mixer](https://www.libsdl.org/projects/SDL_mixer/)
- [TinyXML](https://sourceforge.net/projects/tinyxml/)
- [easywsclient](https://github.com/dhbaird/easywsclient)
Loading

0 comments on commit 184c768

Please sign in to comment.