Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
OriolCS2 committed Oct 25, 2018
2 parents 8c2e40c + 7f36a6d commit 847c3f7
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 17 deletions.
15 changes: 0 additions & 15 deletions Pinball/Game/pinball/Background_coords.txt

This file was deleted.

Binary file modified Pinball/Game/pinball/Triangle.wav
Binary file not shown.
31 changes: 30 additions & 1 deletion Pinball/ModulePlayer.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "Globals.h"
#include "Application.h"
#include "ModuleAudio.h"
#include "ModulePlayer.h"
#include "ModulePhysics.h"
#include "ModuleSceneIntro.h"
Expand Down Expand Up @@ -28,6 +29,12 @@ bool ModulePlayer::Start()
DesappearBall = false;
Hole1 = false;

bouncer = App->audio->LoadFx("pinball/Bouncers.wav");
triangle = App->audio->LoadFx("pinball/Triangle.wav");
enthole = App->audio->LoadFx("pinball/Enter Hole.wav");
exhole = App->audio->LoadFx("pinball/Exit Hole.wav");
NewBall = App->audio->LoadFx("pinball/New ball.wav");
lightfx = App->audio->LoadFx("pinball/Light.wav");

return true;
}
Expand Down Expand Up @@ -66,32 +73,37 @@ void ModulePlayer::StartBall()
ball->body->ApplyLinearImpulse({ 0,5 }, { 0,0 }, true, false);
ball->body->SetBullet(false);
Hole1 = false;
App->audio->PlayFx(exhole);
}
else if (Hole2) {
ball = App->physics->CreateCircle(395, 80, 15, b2BodyType::b2_dynamicBody);
ball->listener = this;
ball->body->ApplyLinearImpulse({ 2,6 }, { 0,0 }, true, false);
ball->body->SetBullet(false);
Hole2 = false;
App->audio->PlayFx(exhole);
}
else if (Hole3) {
ball = App->physics->CreateCircle(400, 270, 15, b2BodyType::b2_dynamicBody);
ball->listener = this;
ball->body->ApplyLinearImpulse({ -3,5 }, { 0,0 }, true, false);
ball->body->SetBullet(false);
Hole3 = false;
App->audio->PlayFx(exhole);
}
else if (Hole4) {
ball = App->physics->CreateCircle(23, 700, 15, b2BodyType::b2_dynamicBody);
ball->listener = this;
ball->body->ApplyLinearImpulse({ 13,0 }, { 0,0 }, true, true);
ball->body->SetBullet(false);
Hole4 = false;
App->audio->PlayFx(exhole);
}
else {
ball = App->physics->CreateCircle(454, 421, 15, b2BodyType::b2_dynamicBody);
ball->listener = this;
ball->body->SetBullet(false);
App->audio->PlayFx(NewBall);
}
}

Expand Down Expand Up @@ -157,6 +169,7 @@ void ModulePlayer::OnCollision(PhysBody * bodyA, PhysBody * bodyB)
App->scene_intro->BallIsStopped = true;
App->scene_intro->time = SDL_GetTicks();
App->scene_intro->ActiveHole1 = true;
App->audio->PlayFx(enthole);
if (App->scene_intro->Left)
App->ui->Score += 5000 * bonus;
else App->ui->Score += 1000 * bonus;
Expand All @@ -168,6 +181,7 @@ void ModulePlayer::OnCollision(PhysBody * bodyA, PhysBody * bodyB)
App->scene_intro->BallIsStopped = true;
App->scene_intro->time = SDL_GetTicks();
App->scene_intro->ActiveHole2 = true;
App->audio->PlayFx(enthole);
if (App->scene_intro->Right)
App->ui->Score += 2500 * bonus;
else App->ui->Score += 500 * bonus;
Expand All @@ -179,6 +193,7 @@ void ModulePlayer::OnCollision(PhysBody * bodyA, PhysBody * bodyB)
App->scene_intro->BallIsStopped = true;
App->scene_intro->time = SDL_GetTicks();
App->scene_intro->ActiveHole3 = true;
App->audio->PlayFx(enthole);
if (App->scene_intro->Up)
App->ui->Score += 10000 * bonus;
else App->ui->Score += 1000 * bonus;
Expand All @@ -190,55 +205,68 @@ void ModulePlayer::OnCollision(PhysBody * bodyA, PhysBody * bodyB)
App->scene_intro->time = SDL_GetTicks();
App->scene_intro->ActiveHole4 = true;
App->ui->Score += 20000 * bonus;
App->audio->PlayFx(enthole);
}
if (bodyB == App->scene_intro->BouncyL) {
ball->body->ApplyLinearImpulse({ 2,-2.5f }, { 0,0 }, false, false);
App->ui->Score += 200 * bonus;
App->renderer->Blit(App->scene_intro->bouncerHit, 0, 0, NULL,1.0f);
App->audio->PlayFx(triangle);
}
if (bodyB == App->scene_intro->BouncyR) {
ball->body->ApplyLinearImpulse({ -2,-2.5f }, { 0,0 }, false, false);
App->ui->Score += 200 * bonus;
App->audio->PlayFx(triangle);
}
if (bodyB == App->scene_intro->Light1) {
App->scene_intro->OnLight1 = true;
App->ui->Score += 500 * bonus;
App->audio->PlayFx(lightfx);
}
if (bodyB == App->scene_intro->Light2) {
App->scene_intro->OnLight2 = true;
App->ui->Score += 500 * bonus;
App->audio->PlayFx(lightfx);
}
if (bodyB == App->scene_intro->Light3) {
App->scene_intro->OnLight3 = true;
App->ui->Score += 500 * bonus;
App->audio->PlayFx(lightfx);
}
if (bodyB == App->scene_intro->Light4) {
App->scene_intro->OnLight4 = true;
App->ui->Score += 500 * bonus;
App->audio->PlayFx(lightfx);
}
if (bodyB == App->scene_intro->Light5) {
App->scene_intro->OnLight5 = true;
App->ui->Score += 500 * bonus;
App->ui->Score += 500 * bonus;
App->audio->PlayFx(lightfx);
}
if (bodyB == App->scene_intro->Light6) {
App->scene_intro->OnLight6 = true;
App->ui->Score += 500 * bonus;
App->audio->PlayFx(lightfx);
}
if (bodyB == App->scene_intro->Light7) {
App->scene_intro->OnLight7 = true;
App->ui->Score += 500 * bonus;
App->audio->PlayFx(lightfx);
}
if (bodyB == App->scene_intro->Light8) {
App->scene_intro->OnLight8 = true;
App->ui->Score += 500 * bonus;
App->audio->PlayFx(lightfx);
}
if (bodyB == App->scene_intro->Light9) {
App->scene_intro->OnLight9 = true;
App->ui->Score += 500 * bonus;
App->audio->PlayFx(lightfx);
}
if (bodyB == App->scene_intro->Light10) {
App->scene_intro->OnLight10 = true;
App->ui->Score += 500 * bonus;
App->audio->PlayFx(lightfx);
}
if (bodyB == App->scene_intro->CircleUp) {
App->scene_intro->Circleup1 = true;
Expand Down Expand Up @@ -280,6 +308,7 @@ void ModulePlayer::OnCollision(PhysBody * bodyA, PhysBody * bodyB)
App->ui->Score += 200 * bonus;
vec = ball->body->GetLinearVelocity();
ball->body->ApplyLinearImpulse(-vec, { 0,0 }, true, false);
App->audio->PlayFx(bouncer);
}
if (bodyB == App->scene_intro->Space) {
App->scene_intro->space = true;
Expand Down
7 changes: 7 additions & 0 deletions Pinball/ModulePlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,11 @@ class ModulePlayer : public Module
bool Hole4 = false;
int bonus = 1;
int lives = 3;

uint bouncer;
uint NewBall;
uint enthole;
uint exhole;
uint triangle;
uint lightfx;
};
8 changes: 7 additions & 1 deletion Pinball/ModuleSceneIntro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ bool ModuleSceneIntro::Start()
bonusHeld = App->textures->Load("pinball/Held Bonus.png");
BARRIER2 = App->textures->Load("pinball/Barrier2.png");
bonus_fx = App->audio->LoadFx("pinball/bonus.wav");
song = App->audio->PlayMusic("pinball/song.ogg");
flipperfx = App->audio->LoadFx("pinball/flipper.wav");
App->physics->CreatePinballWalls();
App->physics->CreateSensors();
RightCircle = new PhysBody;
Expand Down Expand Up @@ -168,6 +170,7 @@ update_status ModuleSceneIntro::Update()
Circleup1 = false;
Circleup2 = false;
Circleup3 = false;
App->audio->PlayFx(bonus_fx);
}


Expand Down Expand Up @@ -392,11 +395,14 @@ void ModuleSceneIntro::BlitAll()

void ModuleSceneIntro::ControlBall()
{
if (App->input->GetKey(SDL_SCANCODE_M) == KEY_REPEAT || App->input->GetKey(SDL_SCANCODE_RIGHT) == KEY_REPEAT)
if (App->input->GetKey(SDL_SCANCODE_M) == KEY_REPEAT || App->input->GetKey(SDL_SCANCODE_RIGHT) == KEY_REPEAT) {
RightFlipper->body->ApplyTorque(500, true);
App->audio->PlayFx(flipperfx);
}
if (App->input->GetKey(SDL_SCANCODE_Z) == KEY_REPEAT || App->input->GetKey(SDL_SCANCODE_LEFT) == KEY_REPEAT) {
LeftFlipper->body->ApplyTorque(-500, true);
UpFlipper->body->ApplyTorque(-500, true);
App->audio->PlayFx(flipperfx);
}
if ((App->input->GetKey(SDL_SCANCODE_SPACE) == KEY_REPEAT || App->input->GetKey(SDL_SCANCODE_DOWN) == KEY_REPEAT) && space)
App->player->ball->body->ApplyLinearImpulse({ 0, -0.8f }, { 0,0 }, true, false);
Expand Down
1 change: 1 addition & 0 deletions Pinball/ModuleSceneIntro.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ class ModuleSceneIntro : public Module


uint bonus_fx;
uint flipperfx;
uint song;
uint time = 0;
uint TimeUp = 0;
Expand Down

0 comments on commit 847c3f7

Please sign in to comment.