Skip to content

Commit 87e1c7e

Browse files
committed
checked collision conditions and moved walls
1 parent df601db commit 87e1c7e

File tree

5 files changed

+4
-50
lines changed

5 files changed

+4
-50
lines changed

Game/XMultiply.exe

3.5 KB
Binary file not shown.

Game/XMultiply.zip

1.86 KB
Binary file not shown.

ModuleCollision.cpp

Lines changed: 3 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -174,46 +174,8 @@ Collider* ModuleCollision::AddCollider(SDL_Rect rect, COLLIDER_TYPE type, Module
174174

175175
bool Collider::CheckCollision(const SDL_Rect& r) const
176176
{
177-
// TODO 0: Return true if there is an overlap
178-
// between argument "r" and property "rect"
179-
180-
//The sides of the rectangles
181-
int leftA, leftB;
182-
int rightA, rightB;
183-
int topA, topB;
184-
int bottomA, bottomB;
185-
186-
//Calculate the sides of rect A
187-
leftA = r.x;
188-
rightA = r.x + r.w;
189-
topA = r.y;
190-
bottomA = r.y + r.h;
191-
192-
//Calculate the sides of rect B
193-
leftB = rect.x;
194-
rightB = rect.x + rect.w;
195-
topB = rect.y;
196-
bottomB = rect.y + rect.h;
197-
198-
//If any of the sides from A are outside of B
199-
if (bottomA <= topB)
200-
{
201-
return false;
202-
}
203-
204-
if (topA >= bottomB)
205-
{
177+
if (r.y + r.h <= rect.y || r.y >= rect.y + rect.h || r.x + r.w <= rect.x || r.x >= rect.x + rect.w)
206178
return false;
207-
}
208-
209-
if (rightA <= leftB)
210-
{
211-
return false;
212-
}
213-
214-
if (leftA >= rightB)
215-
{
216-
return false;
217-
}
218-
return true;
179+
else
180+
return true;
219181
}

ModuleParticles.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ bool ModuleParticles::Start()
2727
graphics = App->textures->Load("Assets/Player.png"); // arcade version
2828

2929
shoot.anim.PushBack({ 64, 30, 17, 18});
30-
//shoot.fx = SHOOT_FX;
3130
shoot.anim.loop = false;
3231
shoot.anim.speed = 3.0f;
3332
shoot.life = 2000;
@@ -93,13 +92,6 @@ update_status ModuleParticles::Update()
9392
p->fx_played = true;
9493
p->speed.x = 2;
9594
App->audio->PlaySound(p->common_fx);
96-
/*
97-
switch (p->fx){
98-
case EXPLOSION_FX:
99-
App->audio->PlaySound(p->common_fx);
100-
case SHOOT_FX:
101-
App->audio->PlaySound(shoot.common_fx);
102-
}*/
10395
}
10496
}
10597
}

ModuleSceneStage1.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ bool ModuleSceneStage1::Start()
4747
back = App->textures->Load("Assets/FirstLvlMap3.png");
4848

4949
// Colliders ---
50-
App->collision->AddCollider({ 0, 224, 3930, 16 }, COLLIDER_WALL);
50+
App->collision->AddCollider({ 0, 208, 3930, 16 }, COLLIDER_WALL);
5151
App->collision->AddCollider({ 1380, 0, 100, 100 }, COLLIDER_WALL);
5252
App->collision->AddCollider({ 1380, 140, 100, 120 }, COLLIDER_WALL);
5353

0 commit comments

Comments
 (0)