Separate example game to Example.GameLib.
1
.gitignore
vendored
@@ -9,3 +9,4 @@ shot-????.png
|
|||||||
.vscode/.BROWSE.VC.DB
|
.vscode/.BROWSE.VC.DB
|
||||||
.vscode/.BROWSE.VC.DB-wal
|
.vscode/.BROWSE.VC.DB-wal
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
*/DIST/*
|
||||||
|
|||||||
59
Example.GameLib/Makefile
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
|
||||||
|
VERBOSE_BUILD := false
|
||||||
|
GAMELIB_DIR := ..
|
||||||
|
GameLibConfig := $(GAMELIB_DIR)/gamelib-config
|
||||||
|
|
||||||
|
LIBS := $(shell $(GameLibConfig) --libs)
|
||||||
|
STATICLIBS := $(shell $(GameLibConfig) --static-libs)
|
||||||
|
CFLAGS := $(shell $(GameLibConfig) --cflags)
|
||||||
|
PLATFORM := $(shell $(GameLibConfig) --platform)
|
||||||
|
EXEEXT := $(shell $(GameLibConfig) --exe-extension)
|
||||||
|
LDFLAGS :=
|
||||||
|
|
||||||
|
RES_GAME := game$(EXEEXT)
|
||||||
|
BUILDDIR := build-$(PLATFORM)
|
||||||
|
|
||||||
|
IsMinGW := $(findstring MINGW,$(shell uname -s)) $(findstring MSYS,$(shell uname -s))
|
||||||
|
IsDarwin := $(findstring Darwin,$(shell uname -s))
|
||||||
|
ifneq (,$(IsMinGW))
|
||||||
|
TARGET_ARCH := mingw
|
||||||
|
else
|
||||||
|
ifneq (,$(IsDarwin))
|
||||||
|
TARGET_ARCH := macosx
|
||||||
|
else
|
||||||
|
TARGET_ARCH := linux
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(TARGET_ARCH),mingw)
|
||||||
|
CC := gcc
|
||||||
|
AR := ar
|
||||||
|
LAUNCHER :=
|
||||||
|
RM := rm -rf
|
||||||
|
MKDIR := mkdir
|
||||||
|
ECHO := echo
|
||||||
|
SLASH := /
|
||||||
|
endif
|
||||||
|
ifeq ($(TARGET_ARCH),linux)
|
||||||
|
CC := gcc
|
||||||
|
AR := ar
|
||||||
|
LAUNCHER :=
|
||||||
|
RM := rm -rf
|
||||||
|
MKDIR := mkdir
|
||||||
|
ECHO := echo
|
||||||
|
SLASH := /
|
||||||
|
|
||||||
|
endif
|
||||||
|
ifeq ($(TARGET_ARCH),macosx)
|
||||||
|
CC := gcc
|
||||||
|
AR := ar
|
||||||
|
LAUNCHER :=
|
||||||
|
RM := rm -rf
|
||||||
|
MKDIR := mkdir
|
||||||
|
ECHO := echo
|
||||||
|
VERBOSE_BUILD := false
|
||||||
|
SLASH := /
|
||||||
|
LIBS := $(LIBS) macosx/SDLMain.m
|
||||||
|
endif
|
||||||
|
|
||||||
|
include Makefile.common.mk
|
||||||
74
Example.GameLib/Makefile.common.mk
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
|
||||||
|
########################
|
||||||
|
# Utility Declarations #
|
||||||
|
########################
|
||||||
|
ifeq ($(VERBOSE_BUILD),true)
|
||||||
|
DO_CC=$(CC) $(CFLAGS) -o $@ -c $<
|
||||||
|
DO_CXX=$(CXX) $(CFLAGS) -o $@ -c $<
|
||||||
|
else
|
||||||
|
DO_CC=@$(ECHO) "CC: $@" ;\
|
||||||
|
$(CC) $(CFLAGS) -o $@ -c $<
|
||||||
|
DO_CXX=@$(ECHO) "CXX: $@" ;\
|
||||||
|
$(CXX) $(CFLAGS) -o $@ -c $<
|
||||||
|
endif
|
||||||
|
|
||||||
|
#####################
|
||||||
|
# Game Declarations #
|
||||||
|
#####################
|
||||||
|
GAME_HEADS := $(GAMELIB_HEADS) Game$(SLASH)GameEnts.h Game$(SLASH)GameMap.h
|
||||||
|
GAME_OBJS := \
|
||||||
|
$(BUILDDIR)$(SLASH)Game.o$(SLASH)GameEnts.o \
|
||||||
|
$(BUILDDIR)$(SLASH)Game.o$(SLASH)GameMap.o \
|
||||||
|
$(BUILDDIR)$(SLASH)Game.o$(SLASH)main.o
|
||||||
|
RES_GAME_OUT := $(BUILDDIR)$(SLASH)$(RES_GAME)
|
||||||
|
|
||||||
|
|
||||||
|
#################
|
||||||
|
# General Rules #
|
||||||
|
#################
|
||||||
|
|
||||||
|
.FORCE:
|
||||||
|
(cd $(GAMELIB_DIR) && make lib $(GAMELIB_MAKEPARAMS))
|
||||||
|
|
||||||
|
all: .FORCE $(BUILDDIR) $(RES_GAME_OUT)
|
||||||
|
|
||||||
|
$(BUILDDIR):
|
||||||
|
$(MKDIR) $(BUILDDIR)
|
||||||
|
$(MKDIR) $(BUILDDIR)$(SLASH)Game.o
|
||||||
|
|
||||||
|
full-clean: clean
|
||||||
|
(cd $(GAMELIB_DIR) && make clean $(GAMELIB_MAKEPARAMS))
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) $(GAME_OBJS) $(RES_GAME_OUT)
|
||||||
|
|
||||||
|
run: $(BUILDDIR) $(RES_GAME_OUT)
|
||||||
|
$(LAUNCHER) ./$(RES_GAME_OUT) debug
|
||||||
|
|
||||||
|
rebuild: clean all
|
||||||
|
|
||||||
|
|
||||||
|
##############
|
||||||
|
# Game Rules #
|
||||||
|
##############
|
||||||
|
|
||||||
|
$(BUILDDIR)$(SLASH)Game.o$(SLASH)GameEnts.o: src$(SLASH)GameEnts.c $(HEADS)
|
||||||
|
$(DO_CC)
|
||||||
|
$(BUILDDIR)$(SLASH)Game.o$(SLASH)GameMap.o: src$(SLASH)GameMap.c $(HEADS)
|
||||||
|
$(DO_CC)
|
||||||
|
$(BUILDDIR)$(SLASH)Game.o$(SLASH)main.o: src$(SLASH)main.c $(HEADS)
|
||||||
|
$(DO_CC)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
################
|
||||||
|
# Result Rules #
|
||||||
|
################
|
||||||
|
|
||||||
|
$(RES_GAME_OUT): $(GAME_OBJS)
|
||||||
|
@$(ECHO) "LINK: $@"
|
||||||
|
@$(CC) $(GAME_OBJS) $(STATICLIBS) -o $(RES_GAME_OUT) $(LIBS) $(CFLAGS) $(LDFLAGS)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
31
Example.GameLib/Makefile.emscripten.mk
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
CC := emcc
|
||||||
|
AR := emar
|
||||||
|
LAUNCHER := emrun --port 8080
|
||||||
|
RM := del
|
||||||
|
MKDIR := mkdir
|
||||||
|
ECHO := echo
|
||||||
|
VERBOSE_BUILD := true
|
||||||
|
SLASH := \\
|
||||||
|
|
||||||
|
GAMELIB_DIR := ..
|
||||||
|
GAMELIB_MAKEPARAMS := -f Makefile.emscripten.mk target=release
|
||||||
|
|
||||||
|
LIBS :=
|
||||||
|
STATICLIBS := $(GAMELIB_DIR)$(SLASH)build-emscripten$(SLASH)libgame.a
|
||||||
|
CFLAGS := -s FULL_ES2=1 -s ASM_JS=1 -O1 -Wno-implicit-function-declaration -DEMSCRIPTEN -I$(GAMELIB_DIR)$(SLASH)src
|
||||||
|
PLATFORM := emscripten
|
||||||
|
EXEEXT := .html
|
||||||
|
LDFLAGS := --preload-file data -s TOTAL_MEMORY=134217728 -lidbfs.js
|
||||||
|
|
||||||
|
RES_GAME := game$(EXEEXT)
|
||||||
|
BUILDDIR := build-$(PLATFORM)
|
||||||
|
|
||||||
|
ifeq ($(target),release)
|
||||||
|
CFLAGS := $(CFLAGS) -O2
|
||||||
|
BUILDDIR := build-emscripten-release
|
||||||
|
GAMELIB_MAKEPARAMS := -f Makefile.emscripten.mk target=release
|
||||||
|
endif
|
||||||
|
|
||||||
|
include Makefile.common.mk
|
||||||
|
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 652 B After Width: | Height: | Size: 652 B |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
11
Example.GameLib/dist-emscripten.cmd
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
call c:\emsdk\emsdk_env.bat
|
||||||
|
|
||||||
|
make -f Makefile.emscripten.mk target=release full-clean
|
||||||
|
make -f Makefile.emscripten.mk target=release
|
||||||
|
|
||||||
|
mkdir DIST\web
|
||||||
|
copy web\* DIST\web\
|
||||||
|
copy build-emscripten-release\game.* DIST\web\
|
||||||
|
|
||||||
|
|
||||||
|
pause
|
||||||
@@ -81,20 +81,26 @@
|
|||||||
});
|
});
|
||||||
}],
|
}],
|
||||||
postRun: [],
|
postRun: [],
|
||||||
canvas: document.getElementById('canvas'),
|
|
||||||
progressContainer: document.getElementById('progress-container'),
|
progressContainer: document.getElementById('progress-container'),
|
||||||
progressCode: document.getElementById('progress-code'),
|
progressCode: document.getElementById('progress-code'),
|
||||||
progressData: document.getElementById('progress-data'),
|
progressData: document.getElementById('progress-data'),
|
||||||
print: function(text) {
|
printErr: function(text) {
|
||||||
|
if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
|
||||||
if(console && console.log){
|
if(console && console.log){
|
||||||
console.log(text);
|
console.log(text);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
printErr: function(text) {
|
canvas: (function() {
|
||||||
this.print(text);
|
var canvas = document.getElementById('canvas');
|
||||||
},
|
|
||||||
|
// As a default initial behavior, pop up an alert when webgl context is lost. To make your
|
||||||
|
// application robust, you may want to override this behavior before shipping!
|
||||||
|
// See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2
|
||||||
|
canvas.addEventListener("webglcontextlost", function(e) { alert('WebGL context lost. You will need to reload the page.'); e.preventDefault(); }, false);
|
||||||
|
|
||||||
|
return canvas;
|
||||||
|
})(),
|
||||||
setStatus: function(text) {
|
setStatus: function(text) {
|
||||||
this.print(text);
|
|
||||||
var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
|
var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
|
||||||
if(m){
|
if(m){
|
||||||
this.progressData.value = parseInt(m[2]);
|
this.progressData.value = parseInt(m[2]);
|
||||||
@@ -121,7 +127,12 @@
|
|||||||
xhr.onload = function(event) {
|
xhr.onload = function(event) {
|
||||||
var packageData = xhr.response;
|
var packageData = xhr.response;
|
||||||
// Launch loaded code
|
// Launch loaded code
|
||||||
eval.call(null,packageData);
|
try{
|
||||||
|
eval.call(null,packageData);
|
||||||
|
}catch(e){
|
||||||
|
alert("Error "+parent+" "+e);
|
||||||
|
parent.postMessage("Error","");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
xhr.onerror = function(event) {
|
xhr.onerror = function(event) {
|
||||||
alert(event);
|
alert(event);
|
||||||
@@ -131,6 +142,5 @@
|
|||||||
};
|
};
|
||||||
Module.LaunchCode();
|
Module.LaunchCode();
|
||||||
</script>
|
</script>
|
||||||
<!-- <script async type="text/javascript" src="game.js"></script> -->
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
53
Makefile
@@ -1,5 +1,7 @@
|
|||||||
|
|
||||||
IsMinGW := $(findstring MINGW,$(shell uname -s))
|
VERBOSE_BUILD := false
|
||||||
|
|
||||||
|
IsMinGW := $(findstring MINGW,$(shell uname -s)) $(findstring MSYS,$(shell uname -s))
|
||||||
IsDarwin := $(findstring Darwin,$(shell uname -s))
|
IsDarwin := $(findstring Darwin,$(shell uname -s))
|
||||||
ifneq (,$(IsMinGW))
|
ifneq (,$(IsMinGW))
|
||||||
TARGET_ARCH := mingw
|
TARGET_ARCH := mingw
|
||||||
@@ -12,11 +14,54 @@ endif
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(TARGET_ARCH),mingw)
|
ifeq ($(TARGET_ARCH),mingw)
|
||||||
include Makefile.win32
|
CC := gcc
|
||||||
|
AR := ar
|
||||||
|
LAUNCHER :=
|
||||||
|
RM := rm -rf
|
||||||
|
MKDIR := mkdir
|
||||||
|
ECHO := echo
|
||||||
|
SLASH := /
|
||||||
|
|
||||||
|
LIBS := -L/mingw/lib -lopengl32 -lSDL -lm
|
||||||
|
CFLAGS := -g -mwindows -D_GNU_SOURCE=1 -DWIN32
|
||||||
|
LDFLAGS := -g -mwindows -D_GNU_SOURCE=1
|
||||||
|
|
||||||
|
RES_GAMELIB := libgame.a
|
||||||
|
BUILDDIR := build-$(shell gcc -v 2>&1 | grep "Target:" | cut --delimiter=' ' --fields=2)
|
||||||
endif
|
endif
|
||||||
ifeq ($(TARGET_ARCH),linux)
|
ifeq ($(TARGET_ARCH),linux)
|
||||||
include Makefile.linux
|
CC := gcc
|
||||||
|
AR := ar
|
||||||
|
LAUNCHER :=
|
||||||
|
RM := rm -rf
|
||||||
|
MKDIR := mkdir
|
||||||
|
ECHO := echo
|
||||||
|
SLASH := /
|
||||||
|
|
||||||
|
LIBS := -lSDL -lpthread -L/usr/X11R6/lib -L/usr/lib -lm -lGL -lX11
|
||||||
|
CFLAGS := -Wall -g -I/usr/include/ -I/usr/include/SDL/ -I/usr/X11R6/include/
|
||||||
|
LDFLAGS :=
|
||||||
|
|
||||||
|
RES_GAMELIB := libgame.a
|
||||||
|
RES_GAME := game
|
||||||
|
BUILDDIR := build-$(shell gcc -v 2>&1 | grep "Target:" | cut --delimiter=' ' --fields=2)
|
||||||
endif
|
endif
|
||||||
ifeq ($(TARGET_ARCH),macosx)
|
ifeq ($(TARGET_ARCH),macosx)
|
||||||
include Makefile.macosx
|
CC := gcc
|
||||||
|
AR := ar
|
||||||
|
LAUNCHER :=
|
||||||
|
RM := rm -rf
|
||||||
|
MKDIR := mkdir
|
||||||
|
ECHO := echo
|
||||||
|
VERBOSE_BUILD := false
|
||||||
|
SLASH := /
|
||||||
|
|
||||||
|
LIBS := -framework Cocoa -lm -framework OpenGL -framework SDL macosx/SDLMain.m
|
||||||
|
CFLAGS := -Wall -g -DMACOSX -ObjC -Dmain=SDL_main -I/usr/include/ -I/usr/include/SDL/ -I/usr/X11R6/include/
|
||||||
|
LDFLAGS :=
|
||||||
|
|
||||||
|
RES_GAMELIB := libgame.a
|
||||||
|
BUILDDIR := build-$(shell gcc -v 2>&1 | grep "Target:" | cut -d ' ' -f 2)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
include Makefile.common.mk
|
||||||
172
Makefile.common
@@ -1,172 +0,0 @@
|
|||||||
|
|
||||||
########################
|
|
||||||
# Utility Declarations #
|
|
||||||
########################
|
|
||||||
ifeq ($(VERBOSE_BUILD),true)
|
|
||||||
DO_CC=$(CC) $(CFLAGS) -o $@ -c $<
|
|
||||||
DO_CXX=$(CXX) $(CFLAGS) -o $@ -c $<
|
|
||||||
else
|
|
||||||
DO_CC=@$(ECHO) "CC: $@" ;\
|
|
||||||
$(CC) $(CFLAGS) -o $@ -c $<
|
|
||||||
DO_CXX=@$(ECHO) "CXX: $@" ;\
|
|
||||||
$(CXX) $(CFLAGS) -o $@ -c $<
|
|
||||||
endif
|
|
||||||
|
|
||||||
########################
|
|
||||||
# GameLib Declarations #
|
|
||||||
########################
|
|
||||||
CFLAGS += -IGameLib
|
|
||||||
GAMELIB_HEADS := \
|
|
||||||
GameLib$(SLASH)Time.h \
|
|
||||||
GameLib$(SLASH)Util.h \
|
|
||||||
GameLib$(SLASH)QuadArray2D.h \
|
|
||||||
GameLib$(SLASH)Draw.h \
|
|
||||||
GameLib$(SLASH)Input.h \
|
|
||||||
GameLib$(SLASH)Audio.h \
|
|
||||||
GameLib$(SLASH)Anim.h \
|
|
||||||
GameLib$(SLASH)Entity.h \
|
|
||||||
GameLib$(SLASH)GameLib.h
|
|
||||||
GAMELIBS_OBJS := \
|
|
||||||
<<<<<<< HEAD
|
|
||||||
$(BUILDDIR)$(SLASH)GameLib$(SLASH)Time.o \
|
|
||||||
$(BUILDDIR)$(SLASH)GameLib$(SLASH)Util.o \
|
|
||||||
$(BUILDDIR)$(SLASH)GameLib$(SLASH)QuadArray2D.o \
|
|
||||||
$(BUILDDIR)$(SLASH)GameLib$(SLASH)Draw.o \
|
|
||||||
$(BUILDDIR)$(SLASH)GameLib$(SLASH)Input.o \
|
|
||||||
$(BUILDDIR)$(SLASH)GameLib$(SLASH)Audio.o \
|
|
||||||
$(BUILDDIR)$(SLASH)GameLib$(SLASH)Anim.o \
|
|
||||||
$(BUILDDIR)$(SLASH)GameLib$(SLASH)Entity.o \
|
|
||||||
$(BUILDDIR)$(SLASH)GameLib$(SLASH)GameLib.o
|
|
||||||
RES_GAMELIB_OUT := $(BUILDDIR)$(SLASH)$(RES_GAMELIB)
|
|
||||||
=======
|
|
||||||
$(BUILDDIR)/GameLib.o/Time.o \
|
|
||||||
$(BUILDDIR)/GameLib.o/Util.o \
|
|
||||||
$(BUILDDIR)/GameLib.o/QuadArray2D.o \
|
|
||||||
$(BUILDDIR)/GameLib.o/Draw.o \
|
|
||||||
$(BUILDDIR)/GameLib.o/Input.o \
|
|
||||||
$(BUILDDIR)/GameLib.o/Audio.o \
|
|
||||||
$(BUILDDIR)/GameLib.o/Anim.o \
|
|
||||||
$(BUILDDIR)/GameLib.o/Entity.o \
|
|
||||||
$(BUILDDIR)/GameLib.o/GameLib.o
|
|
||||||
RES_GAMELIB_OUT := $(BUILDDIR)/$(RES_GAMELIB)
|
|
||||||
>>>>>>> c38b321 (Add support for MacOSX)
|
|
||||||
|
|
||||||
#####################
|
|
||||||
# Game Declarations #
|
|
||||||
#####################
|
|
||||||
GAME_HEADS := $(GAMELIB_HEADS) Game$(SLASH)GameEnts.h Game$(SLASH)GameMap.h
|
|
||||||
GAME_OBJS := \
|
|
||||||
<<<<<<< HEAD
|
|
||||||
$(BUILDDIR)$(SLASH)Game$(SLASH)GameEnts.o \
|
|
||||||
$(BUILDDIR)$(SLASH)Game$(SLASH)GameMap.o \
|
|
||||||
$(BUILDDIR)$(SLASH)Game$(SLASH)main.o
|
|
||||||
RES_GAME_OUT := $(BUILDDIR)$(SLASH)$(RES_GAME)
|
|
||||||
=======
|
|
||||||
$(BUILDDIR)/Game.o/GameEnts.o \
|
|
||||||
$(BUILDDIR)/Game.o/GameMap.o \
|
|
||||||
$(BUILDDIR)/Game.o/main.o
|
|
||||||
RES_GAME_OUT := $(BUILDDIR)/$(RES_GAME)
|
|
||||||
>>>>>>> c38b321 (Add support for MacOSX)
|
|
||||||
|
|
||||||
|
|
||||||
#################
|
|
||||||
# General Rules #
|
|
||||||
#################
|
|
||||||
all: $(BUILDDIR) $(RES_GAME_OUT)
|
|
||||||
|
|
||||||
$(BUILDDIR):
|
|
||||||
$(MKDIR) $(BUILDDIR)
|
|
||||||
<<<<<<< HEAD
|
|
||||||
$(MKDIR) $(BUILDDIR)$(SLASH)GameLib
|
|
||||||
$(MKDIR) $(BUILDDIR)$(SLASH)Game
|
|
||||||
=======
|
|
||||||
$(MKDIR) $(BUILDDIR)/GameLib.o
|
|
||||||
$(MKDIR) $(BUILDDIR)/Game.o
|
|
||||||
>>>>>>> c38b321 (Add support for MacOSX)
|
|
||||||
|
|
||||||
clean:
|
|
||||||
$(RM) $(GAMELIBS_OBJS) $(RES_GAMELIB_OUT) $(GAME_OBJS) $(RES_GAME_OUT)
|
|
||||||
|
|
||||||
run: $(BUILDDIR) $(RES_GAME_OUT)
|
|
||||||
$(LAUNCHER) .$(SLASH)$(RES_GAME_OUT) debug
|
|
||||||
|
|
||||||
rebuild: clean all
|
|
||||||
|
|
||||||
#################
|
|
||||||
# GameLib Rules #
|
|
||||||
#################
|
|
||||||
<<<<<<< HEAD
|
|
||||||
$(BUILDDIR)$(SLASH)GameLib$(SLASH)Time.o: GameLib$(SLASH)Time.c $(HEADS)
|
|
||||||
$(DO_CC)
|
|
||||||
$(BUILDDIR)$(SLASH)GameLib$(SLASH)Util.o: GameLib$(SLASH)Util.c $(HEADS)
|
|
||||||
$(DO_CC)
|
|
||||||
$(BUILDDIR)$(SLASH)GameLib$(SLASH)QuadArray2D.o: GameLib$(SLASH)QuadArray2D.c $(HEADS)
|
|
||||||
$(DO_CC)
|
|
||||||
$(BUILDDIR)$(SLASH)GameLib$(SLASH)Draw.o: GameLib$(SLASH)Draw.c $(HEADS)
|
|
||||||
$(DO_CC)
|
|
||||||
$(BUILDDIR)$(SLASH)GameLib$(SLASH)Input.o: GameLib$(SLASH)Input.c $(HEADS)
|
|
||||||
$(DO_CC)
|
|
||||||
$(BUILDDIR)$(SLASH)GameLib$(SLASH)Audio.o: GameLib$(SLASH)Audio.c $(HEADS)
|
|
||||||
$(DO_CC)
|
|
||||||
$(BUILDDIR)$(SLASH)GameLib$(SLASH)Entity.o: GameLib$(SLASH)Entity.c $(HEADS)
|
|
||||||
$(DO_CC)
|
|
||||||
$(BUILDDIR)$(SLASH)GameLib$(SLASH)Anim.o: GameLib$(SLASH)Anim.c $(HEADS)
|
|
||||||
$(DO_CC)
|
|
||||||
$(BUILDDIR)$(SLASH)GameLib$(SLASH)GameLib.o: GameLib$(SLASH)GameLib.c $(HEADS)
|
|
||||||
=======
|
|
||||||
$(BUILDDIR)/GameLib.o/Time.o: GameLib/Time.c $(HEADS)
|
|
||||||
$(DO_CC)
|
|
||||||
$(BUILDDIR)/GameLib.o/Util.o: GameLib/Util.c $(HEADS)
|
|
||||||
$(DO_CC)
|
|
||||||
$(BUILDDIR)/GameLib.o/QuadArray2D.o: GameLib/QuadArray2D.c $(HEADS)
|
|
||||||
$(DO_CC)
|
|
||||||
$(BUILDDIR)/GameLib.o/Draw.o: GameLib/Draw.c $(HEADS)
|
|
||||||
$(DO_CC)
|
|
||||||
$(BUILDDIR)/GameLib.o/Input.o: GameLib/Input.c $(HEADS)
|
|
||||||
$(DO_CC)
|
|
||||||
$(BUILDDIR)/GameLib.o/Audio.o: GameLib/Audio.c $(HEADS)
|
|
||||||
$(DO_CC)
|
|
||||||
$(BUILDDIR)/GameLib.o/Entity.o: GameLib/Entity.c $(HEADS)
|
|
||||||
$(DO_CC)
|
|
||||||
$(BUILDDIR)/GameLib.o/Anim.o: GameLib/Anim.c $(HEADS)
|
|
||||||
$(DO_CC)
|
|
||||||
$(BUILDDIR)/GameLib.o/GameLib.o: GameLib/GameLib.c $(HEADS)
|
|
||||||
>>>>>>> c38b321 (Add support for MacOSX)
|
|
||||||
$(DO_CC)
|
|
||||||
|
|
||||||
|
|
||||||
##############
|
|
||||||
# Game Rules #
|
|
||||||
##############
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
$(BUILDDIR)$(SLASH)Game$(SLASH)GameEnts.o: Game$(SLASH)GameEnts.c $(HEADS)
|
|
||||||
$(DO_CC)
|
|
||||||
$(BUILDDIR)$(SLASH)Game$(SLASH)GameMap.o: Game$(SLASH)GameMap.c $(HEADS)
|
|
||||||
$(DO_CC)
|
|
||||||
$(BUILDDIR)$(SLASH)Game$(SLASH)main.o: Game$(SLASH)main.c $(HEADS)
|
|
||||||
=======
|
|
||||||
$(BUILDDIR)/Game.o/GameEnts.o: Game/GameEnts.c $(HEADS)
|
|
||||||
$(DO_CC)
|
|
||||||
$(BUILDDIR)/Game.o/GameMap.o: Game/GameMap.c $(HEADS)
|
|
||||||
$(DO_CC)
|
|
||||||
$(BUILDDIR)/Game.o/main.o: Game/main.c $(HEADS)
|
|
||||||
>>>>>>> c38b321 (Add support for MacOSX)
|
|
||||||
$(DO_CC)
|
|
||||||
|
|
||||||
|
|
||||||
################
|
|
||||||
# Result Rules #
|
|
||||||
################
|
|
||||||
|
|
||||||
$(RES_GAMELIB_OUT): $(GAMELIBS_OBJS)
|
|
||||||
@$(ECHO) "STATICLIB: $@"
|
|
||||||
@$(AR) rcs $(RES_GAMELIB_OUT) $(GAMELIBS_OBJS)
|
|
||||||
|
|
||||||
$(RES_GAME_OUT): $(RES_GAMELIB_OUT) $(GAME_OBJS)
|
|
||||||
@$(ECHO) "LINK: $@"
|
|
||||||
@$(CC) $(GAME_OBJS) $(RES_GAMELIB_OUT) -o $(RES_GAME_OUT) $(CFLAGS) $(LIBS) $(LDFLAGS)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
89
Makefile.common.mk
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
|
||||||
|
########################
|
||||||
|
# Utility Declarations #
|
||||||
|
########################
|
||||||
|
ifeq ($(VERBOSE_BUILD),true)
|
||||||
|
DO_CC=$(CC) $(CFLAGS) -o $@ -c $<
|
||||||
|
DO_CXX=$(CXX) $(CFLAGS) -o $@ -c $<
|
||||||
|
else
|
||||||
|
DO_CC=@$(ECHO) "CC: $@" ;\
|
||||||
|
$(CC) $(CFLAGS) -o $@ -c $<
|
||||||
|
DO_CXX=@$(ECHO) "CXX: $@" ;\
|
||||||
|
$(CXX) $(CFLAGS) -o $@ -c $<
|
||||||
|
endif
|
||||||
|
|
||||||
|
########################
|
||||||
|
# GameLib Declarations #
|
||||||
|
########################
|
||||||
|
CFLAGS += -Isrc
|
||||||
|
GAMELIB_HEADS := \
|
||||||
|
src$(SLASH)Time.h \
|
||||||
|
src$(SLASH)Util.h \
|
||||||
|
src$(SLASH)QuadArray2D.h \
|
||||||
|
src$(SLASH)Draw.h \
|
||||||
|
src$(SLASH)Input.h \
|
||||||
|
src$(SLASH)Audio.h \
|
||||||
|
src$(SLASH)Anim.h \
|
||||||
|
src$(SLASH)Entity.h \
|
||||||
|
src$(SLASH)GameLib.h
|
||||||
|
GAMELIBS_OBJS := \
|
||||||
|
$(BUILDDIR)$(SLASH)GameLib.o$(SLASH)Time.o \
|
||||||
|
$(BUILDDIR)$(SLASH)GameLib.o$(SLASH)Util.o \
|
||||||
|
$(BUILDDIR)$(SLASH)GameLib.o$(SLASH)QuadArray2D.o \
|
||||||
|
$(BUILDDIR)$(SLASH)GameLib.o$(SLASH)Draw.o \
|
||||||
|
$(BUILDDIR)$(SLASH)GameLib.o$(SLASH)Input.o \
|
||||||
|
$(BUILDDIR)$(SLASH)GameLib.o$(SLASH)Audio.o \
|
||||||
|
$(BUILDDIR)$(SLASH)GameLib.o$(SLASH)Anim.o \
|
||||||
|
$(BUILDDIR)$(SLASH)GameLib.o$(SLASH)Entity.o \
|
||||||
|
$(BUILDDIR)$(SLASH)GameLib.o$(SLASH)GameLib.o
|
||||||
|
RES_GAMELIB_OUT := $(BUILDDIR)$(SLASH)$(RES_GAMELIB)
|
||||||
|
|
||||||
|
#################
|
||||||
|
# General Rules #
|
||||||
|
#################
|
||||||
|
all: $(BUILDDIR) $(RES_GAMELIB_OUT)
|
||||||
|
|
||||||
|
$(BUILDDIR):
|
||||||
|
$(MKDIR) $(BUILDDIR)
|
||||||
|
$(MKDIR) $(BUILDDIR)$(SLASH)GameLib.o
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) $(GAMELIBS_OBJS) $(RES_GAMELIB_OUT)
|
||||||
|
|
||||||
|
lib: $(BUILDDIR) $(RES_GAMELIB_OUT)
|
||||||
|
|
||||||
|
rebuild: clean all
|
||||||
|
|
||||||
|
#################
|
||||||
|
# GameLib Rules #
|
||||||
|
#################
|
||||||
|
$(BUILDDIR)$(SLASH)GameLib.o$(SLASH)Time.o: src$(SLASH)Time.c $(HEADS)
|
||||||
|
$(DO_CC)
|
||||||
|
$(BUILDDIR)$(SLASH)GameLib.o$(SLASH)Util.o: src$(SLASH)Util.c $(HEADS)
|
||||||
|
$(DO_CC)
|
||||||
|
$(BUILDDIR)$(SLASH)GameLib.o$(SLASH)QuadArray2D.o: src$(SLASH)QuadArray2D.c $(HEADS)
|
||||||
|
$(DO_CC)
|
||||||
|
$(BUILDDIR)$(SLASH)GameLib.o$(SLASH)Draw.o: src$(SLASH)Draw.c $(HEADS)
|
||||||
|
$(DO_CC)
|
||||||
|
$(BUILDDIR)$(SLASH)GameLib.o$(SLASH)Input.o: src$(SLASH)Input.c $(HEADS)
|
||||||
|
$(DO_CC)
|
||||||
|
$(BUILDDIR)$(SLASH)GameLib.o$(SLASH)Audio.o: src$(SLASH)Audio.c $(HEADS)
|
||||||
|
$(DO_CC)
|
||||||
|
$(BUILDDIR)$(SLASH)GameLib.o$(SLASH)Entity.o: src$(SLASH)Entity.c $(HEADS)
|
||||||
|
$(DO_CC)
|
||||||
|
$(BUILDDIR)$(SLASH)GameLib.o$(SLASH)Anim.o: src$(SLASH)Anim.c $(HEADS)
|
||||||
|
$(DO_CC)
|
||||||
|
$(BUILDDIR)$(SLASH)GameLib.o$(SLASH)GameLib.o: src$(SLASH)GameLib.c $(HEADS)
|
||||||
|
$(DO_CC)
|
||||||
|
|
||||||
|
|
||||||
|
################
|
||||||
|
# Result Rules #
|
||||||
|
################
|
||||||
|
|
||||||
|
$(RES_GAMELIB_OUT): $(GAMELIBS_OBJS)
|
||||||
|
@$(ECHO) "STATICLIB: $@"
|
||||||
|
@$(AR) rcs $(RES_GAMELIB_OUT) $(GAMELIBS_OBJS)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -4,23 +4,22 @@ LAUNCHER := emrun --port 8080
|
|||||||
RM := del
|
RM := del
|
||||||
MKDIR := mkdir
|
MKDIR := mkdir
|
||||||
ECHO := echo
|
ECHO := echo
|
||||||
SLASH := \\
|
|
||||||
VERBOSE_BUILD := true
|
VERBOSE_BUILD := true
|
||||||
|
SLASH := \\
|
||||||
|
|
||||||
LIBS :=
|
LIBS :=
|
||||||
CFLAGS := -s FULL_ES2=1 -s ASM_JS=1 -O1 -Wno-implicit-function-declaration -DEMSCRIPTEN
|
CFLAGS := -s FULL_ES2=1 -s ASM_JS=1 -O1 -Wno-implicit-function-declaration -DEMSCRIPTEN
|
||||||
LDFLAGS := --preload-file data -s TOTAL_MEMORY=134217728
|
LDFLAGS := --preload-file data -s TOTAL_MEMORY=134217728 -lidbfs.js
|
||||||
|
|
||||||
RES_GAMELIB := libgame.a
|
RES_GAMELIB := libgame.a
|
||||||
RES_GAME := game.html
|
|
||||||
BUILDDIR := build-emscripten
|
BUILDDIR := build-emscripten
|
||||||
|
|
||||||
ifeq ($(target),release)
|
ifeq ($(target),release)
|
||||||
CFLAGS := -s FULL_ES2=1 -s ASM_JS=1 -O1 --llvm-lto 1 -Wno-implicit-function-declaration -DEMSCRIPTEN
|
CFLAGS := $(CFLAGS) -O2
|
||||||
BUILDDIR := build-emscripten-release
|
BUILDDIR := build-emscripten-release
|
||||||
LDFLAGS := --preload-file data -s TOTAL_MEMORY=134217728 --emrun
|
LDFLAGS := --preload-file data -s TOTAL_MEMORY=134217728 --emrun
|
||||||
endif
|
endif
|
||||||
|
|
||||||
include Makefile.common
|
include Makefile.common.mk
|
||||||
|
|
||||||
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
CC := gcc
|
|
||||||
AR := ar
|
|
||||||
LAUNCHER :=
|
|
||||||
RM := rm -rf
|
|
||||||
MKDIR := mkdir
|
|
||||||
ECHO := echo
|
|
||||||
SLASH := /
|
|
||||||
|
|
||||||
LIBS := -lSDL -lpthread -L/usr/X11R6/lib -L/usr/lib -lm -lGL -lX11
|
|
||||||
CFLAGS := -Wall -g -I/usr/include/ -I/usr/include/SDL/ -I/usr/X11R6/include/
|
|
||||||
LDFLAGS :=
|
|
||||||
|
|
||||||
RES_GAMELIB := libgame.a
|
|
||||||
RES_GAME := game
|
|
||||||
BUILDDIR := build-$(shell gcc -v 2>&1 | grep "Target:" | cut --delimiter=' ' --fields=2)
|
|
||||||
|
|
||||||
include Makefile.common
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
CC := gcc
|
|
||||||
AR := ar
|
|
||||||
LAUNCHER :=
|
|
||||||
RM := rm -rf
|
|
||||||
MKDIR := mkdir
|
|
||||||
ECHO := echo
|
|
||||||
|
|
||||||
LIBS := -framework Cocoa -lm -framework OpenGL -framework SDL macosx/SDLMain.m
|
|
||||||
CFLAGS := -Wall -g -DMACOSX -ObjC -Dmain=SDL_main -I/usr/include/ -I/usr/include/SDL/ -I/usr/X11R6/include/
|
|
||||||
LDFLAGS :=
|
|
||||||
|
|
||||||
RES_GAMELIB := libgame.a
|
|
||||||
RES_GAME := game
|
|
||||||
BUILDDIR := build-$(shell gcc -v 2>&1 | grep "Target:" | cut -d ' ' -f 2)
|
|
||||||
|
|
||||||
include Makefile.common
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
CC := gcc
|
|
||||||
AR := ar
|
|
||||||
LAUNCHER :=
|
|
||||||
RM := rm -rf
|
|
||||||
MKDIR := mkdir
|
|
||||||
ECHO := echo
|
|
||||||
SLASH := /
|
|
||||||
|
|
||||||
LIBS := -L/mingw/lib -lopengl32 -lSDL -lm
|
|
||||||
#CFLAGS := -I/mingw/include -g -mwindows -D_GNU_SOURCE=1
|
|
||||||
CFLAGS := -g -mwindows -D_GNU_SOURCE=1 -DWIN32
|
|
||||||
LDFLAGS := -g -mwindows -D_GNU_SOURCE=1
|
|
||||||
|
|
||||||
RES_GAMELIB := libgame.a
|
|
||||||
RES_GAME := game.exe
|
|
||||||
BUILDDIR := build-$(shell gcc -v 2>&1 | grep "Target:" | cut --delimiter=' ' --fields=2)
|
|
||||||
|
|
||||||
include Makefile.common
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
CC := gcc
|
|
||||||
AR := ar
|
|
||||||
LAUNCHER :=
|
|
||||||
RM := rm -rf
|
|
||||||
MKDIR := mkdir
|
|
||||||
ECHO := echo
|
|
||||||
SLASH := /
|
|
||||||
|
|
||||||
LIBS := -L/mingw/lib -lopengl32 -lSDL -lm
|
|
||||||
#CFLAGS := -I/mingw/include -g -mwindows -D_GNU_SOURCE=1
|
|
||||||
CFLAGS := -g -mwindows -D_GNU_SOURCE=1 -DWIN32
|
|
||||||
LDFLAGS := -g -mwindows -D_GNU_SOURCE=1
|
|
||||||
|
|
||||||
RES_GAMELIB := libgame.a
|
|
||||||
RES_GAME := game.exe
|
|
||||||
BUILDDIR := build-$(shell gcc -v 2>&1 | grep "Target:" | cut --delimiter=' ' --fields=2)
|
|
||||||
|
|
||||||
include Makefile.common
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
#make -f Makefile.emscripten target=release clean
|
|
||||||
#make -f Makefile.emscripten target=release
|
|
||||||
|
|
||||||
make -f Makefile.emscripten clean
|
|
||||||
make -f Makefile.emscripten
|
|
||||||
|
|
||||||
mkdir -p DIST/web
|
|
||||||
cp -Rv web/* DIST/web/
|
|
||||||
#cp -v build-emscripten-release/game.* DIST/web/
|
|
||||||
cp -v build-emscripten/game.* DIST/web/
|
|
||||||
28
dist.sh
@@ -1,28 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
DIRNAME="TestGame"
|
|
||||||
|
|
||||||
DATE=$(date +%Y%m%d)
|
|
||||||
ZIPNAME="$DIRNAME.$DATE.zip"
|
|
||||||
|
|
||||||
make -f Makefile.linux
|
|
||||||
make -f Makefile.mingw
|
|
||||||
|
|
||||||
mkdir $DIRNAME
|
|
||||||
cd $DIRNAME
|
|
||||||
cp -v ../readme.txt ./
|
|
||||||
cp -v ../build-mingw/game.exe ./game-windows.exe
|
|
||||||
cp -v ../build-linux/game ./game-linux.bin
|
|
||||||
cp -v ../SDL.dll ./
|
|
||||||
cp -v ../libSDL-1.2.so.0 ./
|
|
||||||
mkdir data
|
|
||||||
cp -v ../data/*.bmp data/
|
|
||||||
cp -v ../data/*.wav data/
|
|
||||||
cp -v ../data/level_*.txt data/
|
|
||||||
cd ..
|
|
||||||
|
|
||||||
rm $ZIPNAME
|
|
||||||
zip -r $ZIPNAME $DIRNAME
|
|
||||||
|
|
||||||
rm -rf $DIRNAME
|
|
||||||
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
DIRNAME="TestGame"
|
|
||||||
|
|
||||||
DATE=$(date +%Y%m%d)
|
|
||||||
ZIPNAME="$DIRNAME.$DATE.zip"
|
|
||||||
|
|
||||||
make -f Makefile.win32 clean
|
|
||||||
make -f Makefile.win32
|
|
||||||
|
|
||||||
mkdir $DIRNAME
|
|
||||||
cd $DIRNAME
|
|
||||||
cp -v ../readme.txt ./
|
|
||||||
cp -v ../build-mingw/game.exe ./game.exe
|
|
||||||
cp -v ../SDL.dll ./
|
|
||||||
mkdir data
|
|
||||||
cp -v ../data/*.bmp data/
|
|
||||||
cp -v ../data/*.wav data/
|
|
||||||
cp -v ../data/level_*.txt data/
|
|
||||||
cd ..
|
|
||||||
|
|
||||||
rm $ZIPNAME
|
|
||||||
zip -r $ZIPNAME $DIRNAME
|
|
||||||
|
|
||||||
rm -rf $DIRNAME
|
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ case "$uname" in
|
|||||||
*MINGW* | *MSYS*)
|
*MINGW* | *MSYS*)
|
||||||
# Configuracion de Win32/Mingw
|
# Configuracion de Win32/Mingw
|
||||||
libs="-L/mingw/lib -lopengl32 -lSDL"
|
libs="-L/mingw/lib -lopengl32 -lSDL"
|
||||||
cflags="-g -mwindows -D_GNU_SOURCE=1"
|
cflags="-g -mwindows -D_GNU_SOURCE=1 -DWIN32"
|
||||||
builddir="build-$gcctarget"
|
builddir="build-$gcctarget"
|
||||||
platform="$gcctarget"
|
platform="$gcctarget"
|
||||||
exeextension=".exe"
|
exeextension=".exe"
|
||||||
@@ -37,6 +37,14 @@ case "$uname" in
|
|||||||
platform="emscripten"
|
platform="emscripten"
|
||||||
exeextension=".html"
|
exeextension=".html"
|
||||||
;;
|
;;
|
||||||
|
*Darwin*)
|
||||||
|
# Configuracion de MacOSX
|
||||||
|
libs="-framework Cocoa -lm -framework OpenGL -framework SDL"
|
||||||
|
cflags="-Wall -g -DMACOSX -ObjC -Dmain=SDL_main -I/usr/include/ -I/usr/include/SDL/ -I/usr/X11R6/include/"
|
||||||
|
builddir="build-$gcctarget"
|
||||||
|
platform="$gcctarget"
|
||||||
|
exeextension=""
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
# Configuracion de Linux
|
# Configuracion de Linux
|
||||||
libs="-lSDL -lpthread -L/usr/X11R6/lib -L/usr/lib -lm -lGL -lX11"
|
libs="-lSDL -lpthread -L/usr/X11R6/lib -L/usr/lib -lm -lGL -lX11"
|
||||||
@@ -50,7 +58,7 @@ esac
|
|||||||
while test $# -gt 0; do
|
while test $# -gt 0; do
|
||||||
case $1 in
|
case $1 in
|
||||||
--cflags)
|
--cflags)
|
||||||
echo "$cflags -I$prefix/GameLib"
|
echo "$cflags -I$prefix/src"
|
||||||
;;
|
;;
|
||||||
--libs)
|
--libs)
|
||||||
echo "$libs"
|
echo "$libs"
|
||||||
|
|||||||
@@ -1,122 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
||||||
<title>Game</title>
|
|
||||||
</head>
|
|
||||||
<style>
|
|
||||||
html, body {
|
|
||||||
height: 100%;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
font-family: Verdana,Arial,Helvetica,sans-serif;
|
|
||||||
background-color:#000000;
|
|
||||||
color: #777777;
|
|
||||||
font-size: 10pt;
|
|
||||||
}
|
|
||||||
h1{
|
|
||||||
text-align: left;
|
|
||||||
margin-top: 0;
|
|
||||||
margin-bottom: 1em;
|
|
||||||
font-size: 16pt;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
.header{
|
|
||||||
margin:0 auto;
|
|
||||||
width:600px;
|
|
||||||
padding-top:10px;
|
|
||||||
text-align:center;
|
|
||||||
}
|
|
||||||
.progress-container{
|
|
||||||
border: 1px solid #808080;
|
|
||||||
border-radius: 5px;
|
|
||||||
padding: 5px;
|
|
||||||
box-shadow: 0px 0px 5px #808080;
|
|
||||||
width: 600px;
|
|
||||||
display: block;
|
|
||||||
margin: 0 auto;
|
|
||||||
}
|
|
||||||
.progress-container progress{
|
|
||||||
width:100%;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<body>
|
|
||||||
<div id="progress-container" class="progress-container">
|
|
||||||
<h1>Loading...</h1>
|
|
||||||
<span>Code:</span></br>
|
|
||||||
<progress id="progress-code" max="1" value="0"></progress></br>
|
|
||||||
</br>
|
|
||||||
<span>Data:</span></br>
|
|
||||||
<progress id="progress-data" max="1" value="0"></progress></br>
|
|
||||||
</div>
|
|
||||||
<div style="width:0;height:0;position:absolute;display:block;overflow:hidden;">
|
|
||||||
<input type="button" id="btnFocus" value="focus" />
|
|
||||||
</div>
|
|
||||||
<canvas class="game-screen" id="canvas" style="display:none;"
|
|
||||||
oncontextmenu="event.preventDefault()" onclick="document.getElementById('btnFocus').focus();"></canvas>
|
|
||||||
|
|
||||||
<script type='text/javascript'>
|
|
||||||
var Module = {
|
|
||||||
preRun: [function (){
|
|
||||||
FS.mkdir('/saves');
|
|
||||||
FS.mount(IDBFS, {}, '/saves');
|
|
||||||
addRunDependency("SaveDir");
|
|
||||||
FS.syncfs(true, function (err) {
|
|
||||||
removeRunDependency("SaveDir");
|
|
||||||
});
|
|
||||||
}],
|
|
||||||
postRun: [],
|
|
||||||
canvas: document.getElementById('canvas'),
|
|
||||||
progressContainer: document.getElementById('progress-container'),
|
|
||||||
progressCode: document.getElementById('progress-code'),
|
|
||||||
progressData: document.getElementById('progress-data'),
|
|
||||||
print: function(text) {
|
|
||||||
if(console && console.log){
|
|
||||||
console.log(text);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
printErr: function(text) {
|
|
||||||
this.print(text);
|
|
||||||
},
|
|
||||||
setStatus: function(text) {
|
|
||||||
this.print(text);
|
|
||||||
var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
|
|
||||||
if(m){
|
|
||||||
this.progressData.value = parseInt(m[2]);
|
|
||||||
this.progressData.max = parseInt(m[4]);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
totalDependencies: 0,
|
|
||||||
monitorRunDependencies: function(left) {
|
|
||||||
this.totalDependencies = Math.max(this.totalDependencies, left);
|
|
||||||
if(!left){
|
|
||||||
// All loaded
|
|
||||||
this.progressContainer.style.display="none";
|
|
||||||
this.canvas.style.display="block";
|
|
||||||
}
|
|
||||||
},
|
|
||||||
LaunchCode: function (){
|
|
||||||
var xhr = new XMLHttpRequest();
|
|
||||||
xhr.open('GET', "game.js", true);
|
|
||||||
xhr.responseType = 'text';
|
|
||||||
xhr.onprogress = function(event) {
|
|
||||||
this.progressCode.value = event.loaded;
|
|
||||||
this.progressCode.max = event.total;
|
|
||||||
}.bind(this);
|
|
||||||
xhr.onload = function(event) {
|
|
||||||
var packageData = xhr.response;
|
|
||||||
// Launch loaded code
|
|
||||||
eval.call(null,packageData);
|
|
||||||
};
|
|
||||||
xhr.onerror = function(event) {
|
|
||||||
alert(event);
|
|
||||||
};
|
|
||||||
xhr.send(null);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Module.LaunchCode();
|
|
||||||
</script>
|
|
||||||
<!-- <script async type="text/javascript" src="game.js"></script> -->
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||