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 |
@@ -1,71 +1,71 @@
|
|||||||
######################
|
######################
|
||||||
######################
|
######################
|
||||||
######################
|
######################
|
||||||
######################
|
######################
|
||||||
######################
|
######################
|
||||||
######################
|
######################
|
||||||
######################
|
######################
|
||||||
######################
|
######################
|
||||||
######################
|
######################
|
||||||
######################
|
######################
|
||||||
################## ##
|
################## ##
|
||||||
###############
|
###############
|
||||||
#############
|
#############
|
||||||
#############
|
#############
|
||||||
##############
|
##############
|
||||||
########## ###
|
########## ###
|
||||||
######### ###
|
######### ###
|
||||||
######## ##
|
######## ##
|
||||||
######## ##
|
######## ##
|
||||||
######## ## |||||
|
######## ## |||||
|
||||||
########
|
########
|
||||||
#########
|
#########
|
||||||
##########
|
##########
|
||||||
###########
|
###########
|
||||||
############
|
############
|
||||||
#############
|
#############
|
||||||
######## ## #
|
######## ## #
|
||||||
######### ###
|
######### ###
|
||||||
######## ## #
|
######## ## #
|
||||||
#############
|
#############
|
||||||
#############
|
#############
|
||||||
########
|
########
|
||||||
##########
|
##########
|
||||||
########
|
########
|
||||||
###########
|
###########
|
||||||
########
|
########
|
||||||
########
|
########
|
||||||
############
|
############
|
||||||
########
|
########
|
||||||
#############
|
#############
|
||||||
########
|
########
|
||||||
########
|
########
|
||||||
######## #
|
######## #
|
||||||
######## #
|
######## #
|
||||||
########
|
########
|
||||||
########
|
########
|
||||||
########
|
########
|
||||||
######## P
|
######## P
|
||||||
########
|
########
|
||||||
########
|
########
|
||||||
########
|
########
|
||||||
########
|
########
|
||||||
########
|
########
|
||||||
########
|
########
|
||||||
########
|
########
|
||||||
########
|
########
|
||||||
#########
|
#########
|
||||||
########
|
########
|
||||||
########
|
########
|
||||||
#########
|
#########
|
||||||
######################
|
######################
|
||||||
######################
|
######################
|
||||||
######################
|
######################
|
||||||
######################
|
######################
|
||||||
######################
|
######################
|
||||||
######################
|
######################
|
||||||
######################
|
######################
|
||||||
######################
|
######################
|
||||||
######################
|
######################
|
||||||
######################
|
######################
|
||||||
|
|
||||||
|
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
|
||||||
@@ -1,184 +1,184 @@
|
|||||||
// Copyright (C) 2012 Valeriano Alfonso Rodriguez (Kableado)
|
// Copyright (C) 2012 Valeriano Alfonso Rodriguez (Kableado)
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "GameLib.h"
|
#include "GameLib.h"
|
||||||
extern int gamelib_debug;
|
extern int gamelib_debug;
|
||||||
|
|
||||||
#include "GameEnts.h"
|
#include "GameEnts.h"
|
||||||
|
|
||||||
DrawImg img_player;
|
DrawImg img_player;
|
||||||
DrawImg img_platform;
|
DrawImg img_platform;
|
||||||
DrawImg img_block;
|
DrawImg img_block;
|
||||||
|
|
||||||
Entity ent_Player;
|
Entity ent_Player;
|
||||||
Entity ent_Platform;
|
Entity ent_Platform;
|
||||||
Entity ent_Block;
|
Entity ent_Block;
|
||||||
|
|
||||||
int EntityApplyGravity(Entity e) {
|
int EntityApplyGravity(Entity e) {
|
||||||
float grav = 10.0f;
|
float grav = 10.0f;
|
||||||
float vTerminal = 50.0f;
|
float vTerminal = 50.0f;
|
||||||
vec2 vGrav;
|
vec2 vGrav;
|
||||||
|
|
||||||
// Only apply gravity to some entity types
|
// Only apply gravity to some entity types
|
||||||
if (!(e->type == Ent_Player || 0)) {
|
if (!(e->type == Ent_Player || 0)) {
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply gravity
|
// Apply gravity
|
||||||
vec2_set(vGrav, 0.0f, grav);
|
vec2_set(vGrav, 0.0f, grav);
|
||||||
Entity_AddVelLimit(e, vGrav, vTerminal);
|
Entity_AddVelLimit(e, vGrav, vTerminal);
|
||||||
|
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void player_proc(Entity e, int ft) {
|
void player_proc(Entity e, int ft) {
|
||||||
float acel = 8.0f;
|
float acel = 8.0f;
|
||||||
float maxVel = 30.0f;
|
float maxVel = 30.0f;
|
||||||
float jumpVel = 50.0f;
|
float jumpVel = 50.0f;
|
||||||
float airMovementFactor = 0.1f;
|
float airMovementFactor = 0.1f;
|
||||||
|
|
||||||
|
|
||||||
// Process elasticity
|
// Process elasticity
|
||||||
float entityScale[2];
|
float entityScale[2];
|
||||||
Entity_GetScale(e, entityScale);
|
Entity_GetScale(e, entityScale);
|
||||||
entityScale[0] += (1.0f - entityScale[0]) / 2.0f;
|
entityScale[0] += (1.0f - entityScale[0]) / 2.0f;
|
||||||
entityScale[1] += (1.0f - entityScale[1]) / 2.0f;
|
entityScale[1] += (1.0f - entityScale[1]) / 2.0f;
|
||||||
Entity_SetScale(e, entityScale);
|
Entity_SetScale(e, entityScale);
|
||||||
|
|
||||||
|
|
||||||
if (e->A > 0) {
|
if (e->A > 0) {
|
||||||
if (Input_GetKey(InputKey_Jump) == InputKey_Pressed ||
|
if (Input_GetKey(InputKey_Jump) == InputKey_Pressed ||
|
||||||
Input_GetKey(InputKey_Up) == InputKey_Pressed) {
|
Input_GetKey(InputKey_Up) == InputKey_Pressed) {
|
||||||
|
|
||||||
// Apply jump
|
// Apply jump
|
||||||
if (e->vel[1] > (-jumpVel)) {
|
if (e->vel[1] > (-jumpVel)) {
|
||||||
e->vel[1] = -jumpVel;
|
e->vel[1] = -jumpVel;
|
||||||
}
|
}
|
||||||
Entity_CalcBBox(e);
|
Entity_CalcBBox(e);
|
||||||
|
|
||||||
Entity_SetScale(e, (float[2]){0.6f, 1.4f});
|
Entity_SetScale(e, (float[2]){0.6f, 1.4f});
|
||||||
|
|
||||||
// FIXME: play sound
|
// FIXME: play sound
|
||||||
}
|
}
|
||||||
if (Input_GetKey(InputKey_Left)) {
|
if (Input_GetKey(InputKey_Left)) {
|
||||||
vec2 left;
|
vec2 left;
|
||||||
|
|
||||||
// Apply left movement
|
// Apply left movement
|
||||||
vec2_set(left, -acel, 0.0f);
|
vec2_set(left, -acel, 0.0f);
|
||||||
Entity_AddVelLimit(e, left, maxVel);
|
Entity_AddVelLimit(e, left, maxVel);
|
||||||
}
|
}
|
||||||
if (Input_GetKey(InputKey_Right)) {
|
if (Input_GetKey(InputKey_Right)) {
|
||||||
vec2 right;
|
vec2 right;
|
||||||
|
|
||||||
// Apply right movement
|
// Apply right movement
|
||||||
vec2_set(right, acel, 0.0f);
|
vec2_set(right, acel, 0.0f);
|
||||||
Entity_AddVelLimit(e, right, maxVel);
|
Entity_AddVelLimit(e, right, maxVel);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (Input_GetKey(InputKey_Left)) {
|
if (Input_GetKey(InputKey_Left)) {
|
||||||
vec2 left;
|
vec2 left;
|
||||||
|
|
||||||
// Apply left movement
|
// Apply left movement
|
||||||
vec2_set(left, -(acel * airMovementFactor), 0.0f);
|
vec2_set(left, -(acel * airMovementFactor), 0.0f);
|
||||||
Entity_AddVelLimit(e, left, maxVel * airMovementFactor);
|
Entity_AddVelLimit(e, left, maxVel * airMovementFactor);
|
||||||
}
|
}
|
||||||
if (Input_GetKey(InputKey_Right)) {
|
if (Input_GetKey(InputKey_Right)) {
|
||||||
vec2 right;
|
vec2 right;
|
||||||
|
|
||||||
// Apply right movement
|
// Apply right movement
|
||||||
vec2_set(right, acel * airMovementFactor, 0.0f);
|
vec2_set(right, acel * airMovementFactor, 0.0f);
|
||||||
Entity_AddVelLimit(e, right, maxVel * airMovementFactor);
|
Entity_AddVelLimit(e, right, maxVel * airMovementFactor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Input_GetKey(InputKey_Action1) == InputKey_Pressed ||
|
if (Input_GetKey(InputKey_Action1) == InputKey_Pressed ||
|
||||||
Input_GetKey(InputKey_Action2) == InputKey_Pressed) {
|
Input_GetKey(InputKey_Action2) == InputKey_Pressed) {
|
||||||
Entity_SetScale(e, (float[2]){1.0f, 1.0f});
|
Entity_SetScale(e, (float[2]){1.0f, 1.0f});
|
||||||
}
|
}
|
||||||
|
|
||||||
e->A = 0;
|
e->A = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void player_postproc(Entity e, int ft){
|
void player_postproc(Entity e, int ft){
|
||||||
|
|
||||||
// Scroll View
|
// Scroll View
|
||||||
GameLib_MoveToPos(e->pos, 0.6f);
|
GameLib_MoveToPos(e->pos, 0.6f);
|
||||||
//GameLib_MoveToPos(e->pos, 1.0f);
|
//GameLib_MoveToPos(e->pos, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
int player_collision(Entity ent, Entity ent2, float t, vec2 n){
|
int player_collision(Entity ent, Entity ent2, float t, vec2 n){
|
||||||
if(n[1] < 0 && fabs(n[1]) > fabs(n[0])){
|
if(n[1] < 0 && fabs(n[1]) > fabs(n[0])){
|
||||||
ent->A = 1;
|
ent->A = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fabs(n[0]) > fabs(n[1])) {
|
if (fabs(n[0]) > fabs(n[1])) {
|
||||||
float intensity = (fabs(ent->vel[0]) - 10.0f) / 40.0f;
|
float intensity = (fabs(ent->vel[0]) - 10.0f) / 40.0f;
|
||||||
if (intensity > 0) {
|
if (intensity > 0) {
|
||||||
Entity_SetScale(ent, (float[2]){1.0f - (0.3f * intensity), 1.0f + (0.3f * intensity)});
|
Entity_SetScale(ent, (float[2]){1.0f - (0.3f * intensity), 1.0f + (0.3f * intensity)});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
float intensity = (fabs(ent->vel[1]) - 10.0f) / 40.0f;
|
float intensity = (fabs(ent->vel[1]) - 10.0f) / 40.0f;
|
||||||
if (intensity > 0) {
|
if (intensity > 0) {
|
||||||
Entity_SetScale(ent, (float[2]){1.0f + (0.3f * intensity), 1.0f - (0.3f * intensity)});
|
Entity_SetScale(ent, (float[2]){1.0f + (0.3f * intensity), 1.0f - (0.3f * intensity)});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameEnts_Init() {
|
void GameEnts_Init() {
|
||||||
|
|
||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
// Load and initialize media.
|
// Load and initialize media.
|
||||||
//
|
//
|
||||||
|
|
||||||
img_player = Draw_LoadImage("data/player.png");
|
img_player = Draw_LoadImage("data/player.png");
|
||||||
img_platform = Draw_LoadImage("data/platform.png");
|
img_platform = Draw_LoadImage("data/platform.png");
|
||||||
img_block = Draw_LoadImage("data/block.png");
|
img_block = Draw_LoadImage("data/block.png");
|
||||||
|
|
||||||
/////////////////////////
|
/////////////////////////
|
||||||
// Initialize entity types.
|
// Initialize entity types.
|
||||||
//
|
//
|
||||||
|
|
||||||
ent_Player = Entity_New();
|
ent_Player = Entity_New();
|
||||||
ent_Player->type = Ent_Player;
|
ent_Player->type = Ent_Player;
|
||||||
// ent_Player->flags=EntityFlag_Light;
|
// ent_Player->flags=EntityFlag_Light;
|
||||||
// Entity_SetLight(ent_Player,.2,.2,.2,200);
|
// Entity_SetLight(ent_Player,.2,.2,.2,200);
|
||||||
ent_Player->flags = EntityFlag_Collision | EntityFlag_Overlap;
|
ent_Player->flags = EntityFlag_Collision | EntityFlag_Overlap;
|
||||||
ent_Player->zorder = 0;
|
ent_Player->zorder = 0;
|
||||||
AnimPlay_SetImg(&ent_Player->anim, img_player);
|
AnimPlay_SetImg(&ent_Player->anim, img_player);
|
||||||
ent_Player->proc = player_proc;
|
ent_Player->proc = player_proc;
|
||||||
ent_Player->postproc = player_postproc;
|
ent_Player->postproc = player_postproc;
|
||||||
ent_Player->collision = player_collision;
|
ent_Player->collision = player_collision;
|
||||||
ent_Player->mass = 1.0f;
|
ent_Player->mass = 1.0f;
|
||||||
ent_Player->radius = 12;
|
ent_Player->radius = 12;
|
||||||
ent_Player->width = 24;
|
ent_Player->width = 24;
|
||||||
ent_Player->height = 24;
|
ent_Player->height = 24;
|
||||||
ent_Player->fric_static = 0.0f;
|
ent_Player->fric_static = 0.0f;
|
||||||
ent_Player->fric_dynamic = 0.2f;
|
ent_Player->fric_dynamic = 0.2f;
|
||||||
|
|
||||||
ent_Platform = Entity_New();
|
ent_Platform = Entity_New();
|
||||||
ent_Platform->type = Ent_Platform;
|
ent_Platform->type = Ent_Platform;
|
||||||
ent_Platform->flags = EntityFlag_PlatformCollision;
|
ent_Platform->flags = EntityFlag_PlatformCollision;
|
||||||
ent_Platform->zorder = -1;
|
ent_Platform->zorder = -1;
|
||||||
AnimPlay_SetImg(&ent_Platform->anim, img_platform);
|
AnimPlay_SetImg(&ent_Platform->anim, img_platform);
|
||||||
ent_Platform->mass = 0.0f;
|
ent_Platform->mass = 0.0f;
|
||||||
ent_Platform->radius = 12;
|
ent_Platform->radius = 12;
|
||||||
ent_Platform->width = 64;
|
ent_Platform->width = 64;
|
||||||
ent_Platform->height = 16;
|
ent_Platform->height = 16;
|
||||||
ent_Platform->fric_static = 0.0f;
|
ent_Platform->fric_static = 0.0f;
|
||||||
ent_Platform->fric_dynamic = 0.2f;
|
ent_Platform->fric_dynamic = 0.2f;
|
||||||
|
|
||||||
ent_Block = Entity_New();
|
ent_Block = Entity_New();
|
||||||
ent_Block->type = Ent_Block;
|
ent_Block->type = Ent_Block;
|
||||||
ent_Block->flags = EntityFlag_BlockCollision;
|
ent_Block->flags = EntityFlag_BlockCollision;
|
||||||
ent_Block->zorder = -1;
|
ent_Block->zorder = -1;
|
||||||
AnimPlay_SetImg(&ent_Block->anim, img_block);
|
AnimPlay_SetImg(&ent_Block->anim, img_block);
|
||||||
ent_Block->mass = 0.0f;
|
ent_Block->mass = 0.0f;
|
||||||
ent_Block->radius = 32;
|
ent_Block->radius = 32;
|
||||||
ent_Block->width = 64;
|
ent_Block->width = 64;
|
||||||
ent_Block->height = 64;
|
ent_Block->height = 64;
|
||||||
ent_Block->fric_static = 0.0f;
|
ent_Block->fric_static = 0.0f;
|
||||||
ent_Block->fric_dynamic = 0.2f;
|
ent_Block->fric_dynamic = 0.2f;
|
||||||
}
|
}
|
||||||
@@ -1,19 +1,19 @@
|
|||||||
// Copyright (C) 2012 Valeriano Alfonso Rodriguez (Kableado)
|
// Copyright (C) 2012 Valeriano Alfonso Rodriguez (Kableado)
|
||||||
|
|
||||||
#ifndef _GAMEENTS_H_
|
#ifndef _GAMEENTS_H_
|
||||||
#define _GAMEENTS_H_
|
#define _GAMEENTS_H_
|
||||||
|
|
||||||
|
|
||||||
#define Ent_Player 1
|
#define Ent_Player 1
|
||||||
#define Ent_Platform 2
|
#define Ent_Platform 2
|
||||||
#define Ent_Block 3
|
#define Ent_Block 3
|
||||||
|
|
||||||
extern Entity ent_Player;
|
extern Entity ent_Player;
|
||||||
extern Entity ent_Platform;
|
extern Entity ent_Platform;
|
||||||
extern Entity ent_Block;
|
extern Entity ent_Block;
|
||||||
|
|
||||||
int EntityApplyGravity(Entity e);
|
int EntityApplyGravity(Entity e);
|
||||||
|
|
||||||
void GameEnts_Init();
|
void GameEnts_Init();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -1,115 +1,115 @@
|
|||||||
// Copyright (C) 2012 Valeriano Alfonso Rodriguez (Kableado)
|
// Copyright (C) 2012 Valeriano Alfonso Rodriguez (Kableado)
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "GameLib.h"
|
#include "GameLib.h"
|
||||||
|
|
||||||
#include "GameEnts.h"
|
#include "GameEnts.h"
|
||||||
#include "GameMap.h"
|
#include "GameMap.h"
|
||||||
|
|
||||||
int ReadLine(FILE *f, char *line, int max) {
|
int ReadLine(FILE *f, char *line, int max) {
|
||||||
int c;
|
int c;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (i < (max - 1)) {
|
while (i < (max - 1)) {
|
||||||
c = fgetc(f);
|
c = fgetc(f);
|
||||||
if (c == EOF) {
|
if (c == EOF) {
|
||||||
line[i] = 0;
|
line[i] = 0;
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
if (c == '\r') {
|
if (c == '\r') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (c == '\n') {
|
if (c == '\n') {
|
||||||
line[i] = 0;
|
line[i] = 0;
|
||||||
return (i);
|
return (i);
|
||||||
}
|
}
|
||||||
line[i] = c;
|
line[i] = c;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
line[i] = 0;
|
line[i] = 0;
|
||||||
return (i);
|
return (i);
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity GameMapAux_CreateEnt(Entity ent, int i, int j, int res) {
|
Entity GameMapAux_CreateEnt(Entity ent, int i, int j, int res) {
|
||||||
Entity e;
|
Entity e;
|
||||||
vec2 pos;
|
vec2 pos;
|
||||||
e = Entity_Copy(ent);
|
e = Entity_Copy(ent);
|
||||||
vec2_set(pos, (res / 2) + i * res, (res / 2) + j * res);
|
vec2_set(pos, (res / 2) + i * res, (res / 2) + j * res);
|
||||||
vec2_plus(e->pos, e->pos, pos);
|
vec2_plus(e->pos, e->pos, pos);
|
||||||
Entity_CalcBBox(e);
|
Entity_CalcBBox(e);
|
||||||
GameLib_AddEntity(e);
|
GameLib_AddEntity(e);
|
||||||
return (e);
|
return (e);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MaxLineLen 1024
|
#define MaxLineLen 1024
|
||||||
|
|
||||||
int GameMap_LoadLevel(char *filename, int res) {
|
int GameMap_LoadLevel(char *filename, int res) {
|
||||||
FILE *file;
|
FILE *file;
|
||||||
char line[MaxLineLen];
|
char line[MaxLineLen];
|
||||||
int len, i, j;
|
int len, i, j;
|
||||||
int width, height;
|
int width, height;
|
||||||
char *map;
|
char *map;
|
||||||
|
|
||||||
// Open the file
|
// Open the file
|
||||||
file = fopen(filename, "rb");
|
file = fopen(filename, "rb");
|
||||||
if (!file) {
|
if (!file) {
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read the file to determine sizes
|
// Read the file to determine sizes
|
||||||
width = 0;
|
width = 0;
|
||||||
height = 0;
|
height = 0;
|
||||||
do {
|
do {
|
||||||
len = ReadLine(file, line, MaxLineLen);
|
len = ReadLine(file, line, MaxLineLen);
|
||||||
if (len > -1) {
|
if (len > -1) {
|
||||||
if (len > height) {
|
if (len > height) {
|
||||||
height = len;
|
height = len;
|
||||||
}
|
}
|
||||||
width++;
|
width++;
|
||||||
}
|
}
|
||||||
} while (len > -1);
|
} while (len > -1);
|
||||||
fseek(file, 0, SEEK_SET);
|
fseek(file, 0, SEEK_SET);
|
||||||
|
|
||||||
// Build the map
|
// Build the map
|
||||||
map = malloc(sizeof(char) * width * height);
|
map = malloc(sizeof(char) * width * height);
|
||||||
memset(map, 0, width * height);
|
memset(map, 0, width * height);
|
||||||
#define MAP(x, y) map[(x) + ((y)*width)]
|
#define MAP(x, y) map[(x) + ((y)*width)]
|
||||||
j = 0;
|
j = 0;
|
||||||
do {
|
do {
|
||||||
len = ReadLine(file, line, MaxLineLen);
|
len = ReadLine(file, line, MaxLineLen);
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
MAP(j, (height - 1) - i) = line[i];
|
MAP(j, (height - 1) - i) = line[i];
|
||||||
}
|
}
|
||||||
j++;
|
j++;
|
||||||
} while (len > -1);
|
} while (len > -1);
|
||||||
|
|
||||||
// Close the file
|
// Close the file
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
|
||||||
// Parse the map
|
// Parse the map
|
||||||
for (j = 0; j < height; j++) {
|
for (j = 0; j < height; j++) {
|
||||||
for (i = 0; i < width; i++) {
|
for (i = 0; i < width; i++) {
|
||||||
if (MAP(i, j) == 'P') {
|
if (MAP(i, j) == 'P') {
|
||||||
// Player
|
// Player
|
||||||
GameMapAux_CreateEnt(ent_Player, i, j, res);
|
GameMapAux_CreateEnt(ent_Player, i, j, res);
|
||||||
}
|
}
|
||||||
if (MAP(i, j) == '#') {
|
if (MAP(i, j) == '#') {
|
||||||
// Block
|
// Block
|
||||||
GameMapAux_CreateEnt(ent_Block, i, j, res);
|
GameMapAux_CreateEnt(ent_Block, i, j, res);
|
||||||
}
|
}
|
||||||
if (MAP(i, j) == '|') {
|
if (MAP(i, j) == '|') {
|
||||||
// Platform
|
// Platform
|
||||||
GameMapAux_CreateEnt(ent_Platform, i, j, res);
|
GameMapAux_CreateEnt(ent_Platform, i, j, res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup
|
// Cleanup
|
||||||
free(map);
|
free(map);
|
||||||
#undef MAP
|
#undef MAP
|
||||||
|
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
// Copyright (C) 2012 Valeriano Alfonso Rodriguez (Kableado)
|
// Copyright (C) 2012 Valeriano Alfonso Rodriguez (Kableado)
|
||||||
#ifndef _GAMEMAP_H_
|
#ifndef _GAMEMAP_H_
|
||||||
#define _GAMEMAP_H_
|
#define _GAMEMAP_H_
|
||||||
|
|
||||||
int GameMap_LoadLevel(char *filename, int res);
|
int GameMap_LoadLevel(char *filename, int res);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -1,68 +1,68 @@
|
|||||||
// Copyright (C) 2012 Valeriano Alfonso Rodriguez (Kableado)
|
// Copyright (C) 2012 Valeriano Alfonso Rodriguez (Kableado)
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
#include "GameLib.h"
|
#include "GameLib.h"
|
||||||
extern int gamelib_debug;
|
extern int gamelib_debug;
|
||||||
|
|
||||||
#include "GameEnts.h"
|
#include "GameEnts.h"
|
||||||
#include "GameMap.h"
|
#include "GameMap.h"
|
||||||
|
|
||||||
DrawFnt font;
|
DrawFnt font;
|
||||||
DrawImg imgBackground;
|
DrawImg imgBackground;
|
||||||
|
|
||||||
void MainGame_Text(int x, int y, char *text) {
|
void MainGame_Text(int x, int y, char *text) {
|
||||||
Draw_SetColor(0.0f, 0.0f, 0.0f, 0.5f);
|
Draw_SetColor(0.0f, 0.0f, 0.0f, 0.5f);
|
||||||
Draw_DrawText(font, text, x + 1, y + 1);
|
Draw_DrawText(font, text, x + 1, y + 1);
|
||||||
Draw_SetColor(1.0f, 1.0f, 1.0f, 1.0f);
|
Draw_SetColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
Draw_DrawText(font, text, x, y);
|
Draw_DrawText(font, text, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcGame() {}
|
void ProcGame() {}
|
||||||
void PostProcGame() {
|
void PostProcGame() {
|
||||||
// Apply gravity to every entity
|
// Apply gravity to every entity
|
||||||
GameLib_ForEachEnt(EntityApplyGravity);
|
GameLib_ForEachEnt(EntityApplyGravity);
|
||||||
}
|
}
|
||||||
void PreDrawGame(float f) {}
|
void PreDrawGame(float f) {}
|
||||||
void DrawGame(float f) { MainGame_Text(8, 8, "Hello world!"); }
|
void DrawGame(float f) { MainGame_Text(8, 8, "Hello world!"); }
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
if (!strcmp(argv[1], "debug")) {
|
if (!strcmp(argv[1], "debug")) {
|
||||||
gamelib_debug = 1;
|
gamelib_debug = 1;
|
||||||
printf("Debug Mode Activated!\n");
|
printf("Debug Mode Activated!\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GameLib_Init(640, 480, "Game", 20, 60);
|
GameLib_Init(640, 480, "Game", 20, 60);
|
||||||
|
|
||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
// Load and initialize media.
|
// Load and initialize media.
|
||||||
//
|
//
|
||||||
font = Draw_DefaultFont(255, 255, 255, 255);
|
font = Draw_DefaultFont(255, 255, 255, 255);
|
||||||
imgBackground = Draw_LoadImage("data/background.png");
|
imgBackground = Draw_LoadImage("data/background.png");
|
||||||
Draw_SetOffset(imgBackground, 0, 0);
|
Draw_SetOffset(imgBackground, 0, 0);
|
||||||
GameEnts_Init();
|
GameEnts_Init();
|
||||||
|
|
||||||
/////////////////////////
|
/////////////////////////
|
||||||
// Initialize world.
|
// Initialize world.
|
||||||
//
|
//
|
||||||
GameLib_DelEnts();
|
GameLib_DelEnts();
|
||||||
GameMap_LoadLevel("data/level_01.txt", 64);
|
GameMap_LoadLevel("data/level_01.txt", 64);
|
||||||
|
|
||||||
/////////////////////////
|
/////////////////////////
|
||||||
// Run the world.
|
// Run the world.
|
||||||
//
|
//
|
||||||
GameLib_CleanParallaxBackgrounds();
|
GameLib_CleanParallaxBackgrounds();
|
||||||
GameLib_AddParallaxBackground(imgBackground, (int[2]){512, 512},
|
GameLib_AddParallaxBackground(imgBackground, (int[2]){512, 512},
|
||||||
(int[2]){0, 0}, (float[2]){0.5f, 0.0f});
|
(int[2]){0, 0}, (float[2]){0.5f, 0.0f});
|
||||||
GameLib_Loop(ProcGame, PostProcGame, PreDrawGame, DrawGame);
|
GameLib_Loop(ProcGame, PostProcGame, PreDrawGame, DrawGame);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@@ -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)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,26 +1,25 @@
|
|||||||
CC := emcc
|
CC := emcc
|
||||||
AR := emar
|
AR := emar
|
||||||
LAUNCHER := emrun --port 8080
|
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 := $(CFLAGS) -O2
|
||||||
CFLAGS := -s FULL_ES2=1 -s ASM_JS=1 -O1 --llvm-lto 1 -Wno-implicit-function-declaration -DEMSCRIPTEN
|
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.mk
|
||||||
include Makefile.common
|
|
||||||
|
|
||||||
|
|
||||||
@@ -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>
|
|
||||||