-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Blood bros 0.5 + depth of field bug fixed
- Loading branch information
1 parent
b9439d8
commit 9dfacfb
Showing
65 changed files
with
4,327 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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#ifndef __ANIMATION_H__ | ||
#define __ANIMATION_H__ | ||
|
||
#include "SDL/include/SDL_rect.h" | ||
#define MAX_FRAMES 25 | ||
|
||
class Animation | ||
{ | ||
public: | ||
friend class ModulePlayer; | ||
bool loop = true; | ||
float speed = 1.0f; | ||
SDL_Rect frames[MAX_FRAMES]; | ||
|
||
private: | ||
float current_frame = 0.0f; | ||
int last_frame = 0; | ||
int loops = 0; | ||
|
||
public: | ||
|
||
Animation() | ||
{} | ||
|
||
Animation(const Animation& anim) : loop(anim.loop), speed(anim.speed), last_frame(anim.last_frame) | ||
{ | ||
SDL_memcpy(&frames, anim.frames, sizeof(frames)); | ||
} | ||
|
||
void PushBack(const SDL_Rect& rect) | ||
{ | ||
frames[last_frame++] = rect; | ||
} | ||
|
||
SDL_Rect& GetCurrentFrame() | ||
{ | ||
current_frame += speed; | ||
if(current_frame >= last_frame) | ||
{ | ||
current_frame = (loop) ? 0.0f : last_frame - 1; | ||
loops++; | ||
} | ||
|
||
return frames[(int)current_frame]; | ||
} | ||
|
||
bool Finished() const | ||
{ | ||
return loops > 0; | ||
} | ||
|
||
void Reset() | ||
{ | ||
current_frame = 0.0f; | ||
} | ||
}; | ||
|
||
#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,99 @@ | ||
#include "Application.h" | ||
#include "ModuleWindow.h" | ||
#include "ModuleRender.h" | ||
#include "ModuleInput.h" | ||
#include "ModuleTextures.h" | ||
#include "ModuleAudio.h" | ||
#include "ModuleSceneSpace.h" | ||
#include "ModuleSceneScore.h" | ||
#include "ModuleSceneSpace.h" | ||
#include "ModuleSceneStage_Pres.h" | ||
#include "ModuleSceneTad.h" | ||
#include "ModuleSceneWelcome.h" | ||
#include "ModuleCollision.h" | ||
#include "ModulePlayer.h" | ||
#include "ModuleFadeToBlack.h" | ||
#include "ModuleParticles.h" | ||
#include "ModuleReticle.h" | ||
#include "ModuleScenario.h" | ||
#include "ModuleEnemies.h" | ||
|
||
Application::Application() | ||
{ | ||
int i = 0; | ||
modules[i++] = window = new ModuleWindow(); | ||
modules[i++] = render = new ModuleRender(); | ||
modules[i++] = input = new ModuleInput(); | ||
modules[i++] = textures = new ModuleTextures(); | ||
modules[i++] = audio = new ModuleAudio(); | ||
modules[i++] = scene_space = new ModuleSceneSpace(); | ||
modules[i++] = scene_score = new ModuleSceneScore(); | ||
modules[i++] = scene_tad = new ModuleSceneTad(); | ||
modules[i++] = scene_welcome = new ModuleSceneWelcome(); | ||
modules[i++] = scene_stage_pres = new ModuleSceneStage_Pres(); | ||
modules[i++] = enemies = new ModuleEnemies(); | ||
modules[i++] = scenario = new ModuleScenario(); | ||
modules[i++] = player = new ModulePlayer(); | ||
modules[i++] = particles = new ModuleParticles(); | ||
modules[i++] = collision = new ModuleCollision(); | ||
modules[i++] = fade = new ModuleFadeToBlack(); | ||
modules[i++] = reticle = new ModuleReticle(); | ||
|
||
} | ||
|
||
Application::~Application() | ||
{ | ||
for(int i = NUM_MODULES - 1; i >= 0; --i) | ||
delete modules[i]; | ||
} | ||
|
||
bool Application::Init() | ||
{ | ||
bool ret = true; | ||
|
||
// Deactivate modules here ---- | ||
scene_space->Disable(); | ||
scene_tad->Disable(); | ||
scene_welcome->Disable(); | ||
scene_stage_pres->Disable(); | ||
player->Disable(); | ||
collision->Disable(); | ||
enemies->Disable(); | ||
reticle->Disable(); | ||
scenario->Disable(); | ||
// ---------------------------- | ||
|
||
for(int i = 0; i < NUM_MODULES && ret == true; ++i) | ||
ret = modules[i]->Init(); | ||
|
||
for(int i = 0; i < NUM_MODULES && ret == true; ++i) | ||
ret = modules[i]->IsEnabled() ? modules[i]->Start() : true; | ||
|
||
return ret; | ||
} | ||
|
||
update_status Application::Update() | ||
{ | ||
update_status ret = UPDATE_CONTINUE; | ||
|
||
for(int i = 0; i < NUM_MODULES && ret == UPDATE_CONTINUE; ++i) | ||
ret = modules[i]->IsEnabled() ? modules[i]->PreUpdate() : UPDATE_CONTINUE; | ||
|
||
for(int i = 0; i < NUM_MODULES && ret == UPDATE_CONTINUE; ++i) | ||
ret = modules[i]->IsEnabled() ? modules[i]->Update() : UPDATE_CONTINUE; | ||
|
||
for(int i = 0; i < NUM_MODULES && ret == UPDATE_CONTINUE; ++i) | ||
ret = modules[i]->IsEnabled() ? modules[i]->PostUpdate() : UPDATE_CONTINUE; | ||
|
||
return ret; | ||
} | ||
|
||
bool Application::CleanUp() | ||
{ | ||
bool ret = true; | ||
|
||
for(int i = NUM_MODULES - 1; i >= 0 && ret == true; --i) | ||
ret = modules[i]->IsEnabled() ? modules[i]->CleanUp() : true; | ||
|
||
return ret; | ||
} |
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,65 @@ | ||
#ifndef __APPLICATION_H__ | ||
#define __APPLICATION_H__ | ||
|
||
#include "Globals.h" | ||
|
||
#define NUM_MODULES 17 | ||
|
||
class ModuleWindow; | ||
class ModuleInput; | ||
class ModuleTextures; | ||
class ModuleRender; | ||
class ModuleParticles; | ||
class ModuleSceneSpace; | ||
class ModuleSceneScore; | ||
class ModuleSceneTad; | ||
class ModuleSceneWelcome; | ||
class ModuleSceneStage_Pres; | ||
class ModulePlayer; | ||
class ModuleFadeToBlack; | ||
class ModuleAudio; | ||
class ModuleCollision; | ||
class ModuleEnemies; | ||
class ModuleReticle; | ||
class ModuleScenario; | ||
class Module; | ||
|
||
class Application | ||
{ | ||
public: | ||
|
||
Module* modules[NUM_MODULES]; | ||
ModuleWindow* window; | ||
ModuleRender* render; | ||
ModuleInput* input; | ||
ModuleTextures* textures; | ||
ModuleSceneSpace* scene_space; | ||
ModuleSceneScore* scene_score; | ||
ModuleSceneTad* scene_tad; | ||
ModuleSceneWelcome* scene_welcome; | ||
ModuleSceneStage_Pres* scene_stage_pres; | ||
ModuleCollision* collision; | ||
ModulePlayer* player; | ||
ModuleFadeToBlack* fade; | ||
ModuleAudio* audio; | ||
ModuleParticles* particles; | ||
ModuleEnemies* enemies; | ||
ModuleReticle* reticle; | ||
ModuleScenario* scenario; | ||
|
||
|
||
public: | ||
|
||
Application(); | ||
~Application(); | ||
|
||
bool Init(); | ||
update_status Update(); | ||
bool CleanUp(); | ||
|
||
}; | ||
|
||
// Global var made extern for Application --- | ||
extern Application* App; | ||
|
||
#endif // __APPLICATION_H__ |
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,33 @@ | ||
#include "Application.h" | ||
#include "Enemy.h" | ||
#include "ModuleCollision.h" | ||
#include "ModuleRender.h" | ||
|
||
Enemy::Enemy(int x, int y) : position(x, y), collider(nullptr) | ||
{} | ||
|
||
Enemy::~Enemy() | ||
{ | ||
if(collider != nullptr) | ||
App->collision->EraseCollider(collider); | ||
} | ||
|
||
const Collider* Enemy::GetCollider() const | ||
{ | ||
return collider; | ||
} | ||
|
||
void Enemy::Draw(SDL_Texture* sprites) | ||
{ | ||
|
||
|
||
SDL_Rect r = animation->GetCurrentFrame(); | ||
|
||
if(collider != nullptr) | ||
collider->SetPos(position.x, position.y - r.h); | ||
|
||
App->render->Blit(sprites, position.x, position.y - r.h, &r); | ||
|
||
} | ||
|
||
|
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 __ENEMY_H__ | ||
#define __ENEMY_H__ | ||
|
||
#include "p2Point.h" | ||
#include "Animation.h" | ||
|
||
struct SDL_Texture; | ||
struct Collider; | ||
|
||
class Enemy | ||
{ | ||
friend class ModuleEnemies; | ||
protected: | ||
Animation* animation; | ||
Collider* collider; | ||
|
||
public: | ||
iPoint position; | ||
bool is_protecting = false; | ||
|
||
public: | ||
Enemy(int x, int y); | ||
virtual ~Enemy(); | ||
|
||
const Collider* GetCollider() const; | ||
|
||
virtual void Update() {}; | ||
virtual void Draw(SDL_Texture* sprites); | ||
virtual void Die() {}; | ||
}; | ||
|
||
#endif // __ENEMY_H__ |
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,81 @@ | ||
#include "Application.h" | ||
#include "Enemy_Barrel_Guy.h" | ||
#include "Path.h" | ||
#include "ModuleCollision.h" | ||
#include "p2Point.h" | ||
#include "ModuleSceneSpace.h" | ||
#include "ModuleParticles.h" | ||
|
||
Enemy_Barrel_Guy::Enemy_Barrel_Guy(int x, int y) : Enemy(x, y) | ||
{ | ||
|
||
walking.PushBack({ 92, 554, 76, 138 }); | ||
walking.PushBack({ 218, 552, 56, 141 }); | ||
walking.PushBack({ 330, 555, 61, 141 }); | ||
walking.PushBack({ 456, 552, 55, 144 }); | ||
walking.speed = 0.1f; | ||
|
||
protect.PushBack({ 456, 723, 55, 133 }); | ||
protect.PushBack({ 101, 875, 57, 98 }); | ||
protect.PushBack({ 215, 904, 55, 70 }); | ||
protect.PushBack({ 215, 904, 55, 70 }); | ||
protect.PushBack({ 101, 875, 57, 98 }); | ||
protect.PushBack({ 456, 723, 55, 133 }); | ||
protect.speed = 0.1f; | ||
protect.loop = false; | ||
|
||
shooting.PushBack({ 90, 712, 77, 142 }); | ||
shooting.PushBack({ 206, 715, 76, 139 }); | ||
shooting.PushBack({ 312, 715, 88, 139 }); | ||
shooting.PushBack({ 206, 715, 76, 139 }); | ||
shooting.PushBack({ 90, 712, 77, 142 }); | ||
shooting.speed = 0.1f; | ||
shooting.loop = false; | ||
|
||
collider = App->collision->AddCollider({ position.x, position.y - 138, 76, 138 }, COLLIDER_TYPE::COLLIDER_ENEMY, (Module*)App->enemies); | ||
|
||
orig_pos.x = x; | ||
orig_pos.y = y; | ||
|
||
Barrel_Guy_path.PushBack({ -2, 0 }, 100, &walking); | ||
Barrel_Guy_path.PushBack({ 0, 0 }, 100, &shooting); | ||
Barrel_Guy_path.PushBack({ 0, 0 }, 100, &protect); | ||
Barrel_Guy_path.PushBack({ -2, 0 }, 100, &walking); | ||
Barrel_Guy_path.PushBack({ 0, 0 }, 100, &shooting); | ||
Barrel_Guy_path.PushBack({ 0, 0 }, 100, &protect); | ||
Barrel_Guy_path.PushBack({ 2, 0 }, 100, &walking); | ||
Barrel_Guy_path.PushBack({ 0, 0 }, 100, &shooting); | ||
Barrel_Guy_path.PushBack({ 0, 0 }, 100, &protect); | ||
Barrel_Guy_path.PushBack({ 2, 0 }, 500, &walking); | ||
|
||
} | ||
|
||
void Enemy_Barrel_Guy::Update() | ||
{ | ||
|
||
position = orig_pos + Barrel_Guy_path.GetCurrentSpeed(&animation); | ||
if (animation == &protect && !(is_protecting)){ | ||
is_protecting = true; | ||
} | ||
else if(animation != &protect && is_protecting){ | ||
is_protecting = false; | ||
protect.Reset(); | ||
} | ||
|
||
if (animation == &shooting && !(has_shot)){ | ||
App->particles->AddParticle(App->particles->enemy_shot, position.x + 25, position.y - 120, COLLIDER_ENEMY_SHOT, 400); | ||
has_shot = true; | ||
} | ||
else if (animation != &shooting){ | ||
has_shot = false; | ||
shooting.Reset(); | ||
} | ||
} | ||
|
||
void Enemy_Barrel_Guy::Die(){ | ||
|
||
App->particles->AddParticle(App->particles->barrel_guy_dying, position.x, position.y); | ||
App->scene_space->defeated_enemies++; | ||
|
||
|
||
} |
Oops, something went wrong.