-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from LManaslu/devel
Release 0.3
- Loading branch information
Showing
88 changed files
with
2,938 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,3 +30,10 @@ | |
|
||
# Vagrant path | ||
.vagrant/ | ||
|
||
# Build paths | ||
bin | ||
obj | ||
|
||
*.swp | ||
*.swo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
sudo: required | ||
dist: trusty | ||
language: cpp | ||
|
||
install: | ||
- sudo apt-get update | ||
- sudo apt-get install libsdl2-2.0-0 libsdl2-dev libsdl2-image-2.0-0 libsdl2-image-dev libsdl2-ttf-2.0-0 libsdl2-ttf-dev libsdl2-mixer-2.0-0 libsdl2-mixer-dev -y | ||
compiler: | ||
- g++ | ||
script: | ||
- make |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
NAME = game | ||
SRC_DIR = src | ||
INC_DIR = include | ||
OBJ_DIR = obj | ||
BIN_DIR = bin | ||
|
||
TARGET = $(BIN_DIR)/$(NAME) | ||
|
||
CC = g++ | ||
CFLAGS = -pedantic -std=c++11 -MMD -g3 -g -fPIC\ | ||
-W -Wall -Wextra -Wshadow -Wcast-align -Wcast-qual -Wctor-dtor-privacy\ | ||
-Wdisabled-optimization -Wformat=2 -Wlogical-op -Wmissing-declarations\ | ||
-Wmissing-include-dirs -Wnoexcept -Woverloaded-virtual -Wredundant-decls\ | ||
-Wsign-promo -Wstrict-null-sentinel -Wundef\ | ||
-Wzero-as-null-pointer-constant -Wuseless-cast -Wnon-virtual-dtor | ||
INCLUDES = -I$(INC_DIR) `sdl2-config --cflags` | ||
LIBS = `sdl2-config --libs` -lSDL2_image -lSDL2_ttf -lSDL2_mixer -ldl | ||
|
||
SRC = ${wildcard $(SRC_DIR)/*.cpp} | ||
OBJ = ${addprefix $(OBJ_DIR)/, ${notdir ${SRC:.cpp=.o}}} | ||
|
||
RMDIR = rm -rf | ||
|
||
#-------------------------------------------------------------- | ||
ifeq ($(OS), Windows_NT) | ||
|
||
SDL_PATH = C:\SDL-2.0.5 | ||
|
||
INCLUDES = -Iinclude/ -I$(SDL_PATH)\include | ||
|
||
LIBS = -L $(SDL_PATH)\lib -lSDL2main\ | ||
-lSDL2 -lSDL2_image -lSDL2_mixer -lSDL2_ttf -lm | ||
|
||
NAME := $(NAME).exe | ||
#-------------------------------------------------------------- | ||
else | ||
|
||
UNAME_S := $(shell uname -s) | ||
|
||
ifeq ($(UNAME_S), Darwin) | ||
|
||
LIBS = -lm -framework SDL2 -framework SDL2_image -framework SDL2_mixer\ | ||
-framework SDL_TTF | ||
|
||
#------------------------------------------------------------- | ||
|
||
endif | ||
endif | ||
|
||
.PHONY: clean depend dist-clean dist | ||
|
||
all: | ||
#------------------------------------------------------------- | ||
@mkdir -p $(OBJ_DIR) $(BIN_DIR) | ||
$(MAKE) $(TARGET) | ||
#------------------------------------------------------------- | ||
|
||
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp | ||
@echo Building $@ | ||
@$(CC) -c $(CFLAGS) $(INCLUDES) $< -o $@ | ||
|
||
$(TARGET): $(OBJ) | ||
@echo Building $@ | ||
$(CC) $(CFLAGS) $(INCLUDES) $(OBJ) -o $@ $(LIBS) | ||
@echo Done. | ||
|
||
run: | ||
$(TARGET) | ||
|
||
reset: | ||
make dist-clean | ||
make -j | ||
|
||
crun: | ||
make dist-clean | ||
make -j | ||
make run | ||
|
||
arun: | ||
make -j | ||
make run | ||
|
||
clean: | ||
@echo Cleaning... | ||
@$(RMDIR) *~ *.o | ||
|
||
dist-clean: clean | ||
@$(RMDIR) $(TARGET)/$(NAME) | ||
@$(RMDIR) *.tar.gz $(OBJ_DIR) $(BIN_DIR) | ||
|
||
print-%: | ||
@echo $* = $($*) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#ifndef ANIMATION_H | ||
#define ANIMATION_H | ||
|
||
#include "GameObject.h" | ||
#include "Timer.h" | ||
#include "Sprite.h" | ||
|
||
class Animation : public GameObject{ | ||
private: | ||
Timer end_timer; | ||
float time_limit; | ||
bool one_time_only; | ||
Sprite sprite; | ||
|
||
public: | ||
Animation(float x, float y, float crotation, string csprite, int frame_count, float frame_time, bool ends); | ||
void update(float delta); | ||
void render(); | ||
|
||
bool is_dead(); | ||
|
||
void notify_collision(GameObject & object); | ||
bool is(string type); | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#ifndef BATTLESTATE_H | ||
#define BATTLESTATE_H | ||
|
||
#include "State.h" | ||
#include "Sprite.h" | ||
#include "Text.h" | ||
#include "Timer.h" | ||
#include "Music.h" | ||
#include "Fighter.h" | ||
|
||
#include <vector> | ||
|
||
class BattleState : public State{ | ||
private: | ||
Sprite background[3]; | ||
vector <Fighter *> fighters; | ||
Music music; | ||
void read_level_design(string stage); | ||
|
||
public: | ||
BattleState(string stage, string cmusic); | ||
~BattleState(); | ||
|
||
void update(float delta); | ||
void render(); | ||
|
||
void pause(); | ||
void resume(); | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#ifndef CAMERA_H | ||
#define CAMERA_H | ||
|
||
#include "GameObject.h" | ||
#include "Vector.h" | ||
|
||
#define LAYERS 4 | ||
|
||
class Camera{ | ||
private: | ||
static GameObject * focus; | ||
|
||
public: | ||
static Vector pos[LAYERS]; | ||
static float layer_speed[LAYERS]; | ||
static Vector speed; | ||
|
||
static void follow(GameObject * new_focus); | ||
static void unfollow(); | ||
static void update(float delta); | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#ifndef COLLISION_H | ||
#define COLLISION_H | ||
|
||
#include <cmath> | ||
#include <algorithm> | ||
|
||
#include "Rectangle.h" | ||
#include "Vector.h" | ||
|
||
class Collision { | ||
public: | ||
static inline bool is_colliding(Rectangle& a, Rectangle& b, float angleOfA, float angleOfB){ | ||
Vector A[] = { Vector( a.get_draw_x(), a.get_draw_y() + a.get_height() ), | ||
Vector( a.get_draw_x() + a.get_width(), a.get_draw_y() + a.get_height() ), | ||
Vector( a.get_draw_x() + a.get_width(), a.get_draw_y() ), | ||
Vector( a.get_draw_x(), a.get_draw_y() ) | ||
}; | ||
Vector B[] = { Vector( b.get_draw_x(), b.get_draw_y() + b.get_height() ), | ||
Vector( b.get_draw_x() + b.get_width(), b.get_draw_y() + b.get_height() ), | ||
Vector( b.get_draw_x() + b.get_width(), b.get_draw_y() ), | ||
Vector( b.get_draw_x(), b.get_draw_y() ) | ||
}; | ||
|
||
for (auto& v : A) { | ||
v = rotate(v - a.get_center(), angleOfA) + a.get_center(); | ||
} | ||
|
||
for (auto& v : B) { | ||
v = rotate(v - b.get_center(), angleOfB) + b.get_center(); | ||
} | ||
|
||
Vector axes[] = { norm(A[0] - A[1]), norm(A[1] - A[2]), norm(B[0] - B[1]), norm(B[1] - B[2]) }; | ||
|
||
for (auto& axis : axes) { | ||
float P[4]; | ||
|
||
for (int i = 0; i < 4; ++i) P[i] = dot(A[i], axis); | ||
|
||
float minA = *std::min_element(P, P + 4); | ||
float maxA = *std::max_element(P, P + 4); | ||
|
||
for (int i = 0; i < 4; ++i) P[i] = dot(B[i], axis); | ||
|
||
float minB = *std::min_element(P, P + 4); | ||
float maxB = *std::max_element(P, P + 4); | ||
|
||
if (maxA < minB || minA > maxB) | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
private: | ||
static inline float mag(const Vector& p){ | ||
return std::sqrt(p.x * p.x + p.y * p.y); | ||
} | ||
static inline Vector norm(const Vector& p){ | ||
return p * (1.f / mag(p)); | ||
} | ||
static inline float dot(const Vector& a, const Vector& b){ | ||
return a.x * b.x + a.y * b.y; | ||
} | ||
static inline Vector rotate(const Vector& p, float angle){ | ||
float cs = std::cos(angle), sn = std::sin(angle); | ||
return Vector ( p.x * cs - p.y * sn, p.x * sn + p.y * cs ); | ||
} | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#ifndef EDITSTATE_H | ||
#define EDITSTATE_H | ||
|
||
#include "State.h" | ||
#include "Sprite.h" | ||
#include "Text.h" | ||
#include "Timer.h" | ||
#include "Fighter.h" | ||
|
||
class EditState : public State{ | ||
private: | ||
Sprite background[3]; | ||
Fighter * test_fighter; | ||
string stage; | ||
|
||
void read_level_design(); | ||
void update_level_design(); | ||
|
||
public: | ||
EditState(string stage); | ||
|
||
void update(float delta); | ||
void render(); | ||
|
||
void pause(); | ||
void resume(); | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#ifndef EDITABLEFLOOR_H | ||
#define EDITABLEFLOOR_H | ||
|
||
#include "Floor.h" | ||
#include "Sprite.h" | ||
|
||
class EditableFloor : public Floor{ | ||
private: | ||
enum FloorState{SELECTED, NOT_SELECTED}; | ||
Sprite normal_sprite, platform_sprite, selected_sprite; | ||
FloorState state; | ||
bool deleted; | ||
bool selected; | ||
|
||
public: | ||
|
||
EditableFloor(float x, float y, float crotation, bool cplatform); | ||
EditableFloor(float x, float y, float width, float crotation, bool cplatform); | ||
|
||
~EditableFloor(); | ||
|
||
void update(float delta); | ||
void render(); | ||
bool is_dead(); | ||
|
||
void notify_collision(GameObject & object); | ||
|
||
string get_information(); | ||
void set_selected(bool cselected); | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#ifndef FIGHTER_H | ||
#define FIGHTER_H | ||
|
||
#include "GameObject.h" | ||
#include "Sprite.h" | ||
#include "Vector.h" | ||
#include "Timer.h" | ||
|
||
class Fighter : public GameObject{ | ||
private: | ||
enum FighterState {IDLE, RUNNING, JUMPING, FALLING, CROUCH}; | ||
enum Orientation {LEFT, RIGHT}; | ||
Sprite sprite[10]; | ||
FighterState state; | ||
Orientation orientation; | ||
Vector speed; | ||
Vector acceleration; | ||
float vertical_speed; | ||
bool on_floor, pass_through; | ||
int last_collided_floor; | ||
float max_speed; | ||
int remaining_life; | ||
void test_limits(); | ||
int special; | ||
Timer crouch_timer; | ||
|
||
public: | ||
Fighter(string name, float x, float y); | ||
~Fighter(); | ||
|
||
void update(float delta); | ||
void post_collision_update(float delta); | ||
void render(); | ||
bool is_dead(); | ||
|
||
int get_remaining_life(); | ||
int get_special(); | ||
|
||
void notify_collision(GameObject & object); | ||
bool is(string type); | ||
|
||
void change_state(FighterState cstate); | ||
void reset_position(float x, float y); | ||
|
||
static const int MAX_LIFE = 500; | ||
|
||
static const int MAX_SPECIAL = 400; | ||
}; | ||
|
||
#endif |
Oops, something went wrong.