Skip to content

Commit

Permalink
Added all class files and stubbed member functions to get the program…
Browse files Browse the repository at this point in the history
… to compile.
  • Loading branch information
Jordan Baxter committed May 21, 2018
1 parent 313e8db commit b625d44
Show file tree
Hide file tree
Showing 10 changed files with 248 additions and 38 deletions.
57 changes: 57 additions & 0 deletions Ball.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
//Ball.cpp
//Jordan Baxter

#include "Ball.h"

Ball::Ball() {
//TODO
}

void Ball::move() {

}

void Ball::draw() {
//TODO
}

void Ball::bounceWall() {
//TODO
}

void Ball::bounceCeiling() {
//TODO
}

void Ball::bounceBrick() {
//TODO
}

void Ball::bouncePaddle() {
//TODO
}

bool Ball::hitPaddle() {
//TODO
return true;
}

bool Ball::hitWall() {
//TODO
return true;
}

bool Ball::hitCeiling() {
//TODO
return true;
}

bool Ball::hitFloor() {
//TODO
return true;
}

bool Ball::hitBrick() {
//TODO
return true;
}
34 changes: 34 additions & 0 deletions Ball.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//Ball.h
//Jordan Baxter

#pragma once
#include "ofMain.h"

class GameWorld;
class Paddle;
class Brick;

class Ball {
public:
Ball();
void move();
void draw();
void bounceWall();
void bounceCeiling();
void bounceBrick();
void bouncePaddle();
bool hitPaddle();
bool hitWall();
bool hitCeiling();
bool hitFloor();
bool hitBrick();

private:
float x;
float y;
float r;
float v;
float s;
ofColor color;

};
16 changes: 16 additions & 0 deletions Brick.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//Brick.cpp
//Jordan Baxter

#include "Brick.h"

Brick::Brick() {
//TODO
}

void Brick::damage() {
//TODO
}

void Brick::draw() {
//TODO
}
18 changes: 18 additions & 0 deletions Brick.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//Brick.h
//Jordan Baxter

#pragma once

class GameWorld;
class Ball;
class Paddle;

class Brick {
public:
Brick();
void damage();
void draw();
private:
int strength;
bool powerup;
};
35 changes: 31 additions & 4 deletions GameWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "GameWorld.h"
#include "Ball.h"
#include "Brick.h"
#include "ofApp.h"
#include "ofMain.h"

GameWorld::GameWorld() {
this->gameState = PLAY;
Expand All @@ -25,6 +25,33 @@ void GameWorld::fetchLevelLayout(string file1, string file2, string file3) {
}
}

Brick* GameWorld::generateBricks() {

}
void GameWorld::nextLevel() {
//TODO
}
void GameWorld::changeState(enum Game_State gs) {
//TODO
}
void GameWorld::draw() {
//TODO
}
void GameWorld::resize() {
//TODO
}
enum Game_State GameWorld::getState() {
//TODO
return PLAY;
}
bool GameWorld::noBricks() {
//TODO
return true;
}
bool GameWorld::noLives() {
//TODO
return true;
}
/*Brick* GameWorld::generateBricks() {
//TODO
}
Ball* GameWorld::generateBalls() {
//TODO
}*/
21 changes: 16 additions & 5 deletions GameWorld.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,33 @@
//Jordan Baxter

#pragma once
#include "ofApp.h"
#include "ofMain.h"

class Brick;
class Ball;
class Paddle;

enum Game_State {
PLAY,
WIN,
LOSE
};


class GameWorld {
public:
GameWorld();
void fetchLevelLayout(string file1, string file2, string file3);
Brick* generateBricks();
Ball* generateBalls();
void nextLevel();
void changeState(const int state);
void changeState(enum Game_State gs);
void draw();
void getState();
void resize();
void loseLife();
enum Game_State getState();
bool noBricks();
bool noLives();
//Brick* generateBricks();
//Ball* generateBalls();

private:

Expand All @@ -29,5 +38,7 @@ class GameWorld {
char levelLayout3[4][12];
enum Game_State gameState;
int level;
int lives;


};
15 changes: 15 additions & 0 deletions Paddle.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//Paddle.cpp
//Jordan Baxter

#include "Paddle.h"

Paddle::Paddle() {
//TODO
}
void Paddle::draw() {
//TODO
}

void Paddle::move() {
//TODO
}
24 changes: 24 additions & 0 deletions Paddle.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//Paddle.h
//Jordan Baxter

#pragma once

class GameWorld;
class Brick;
class Ball;

class Paddle {
public:
Paddle();
void draw();
void move();

private:
float w;
float h;
float x;
float y;
bool big;
bool laser;
bool sticky;
};
61 changes: 37 additions & 24 deletions ofApp.cpp
Original file line number Diff line number Diff line change
@@ -1,50 +1,63 @@
//ofApp.cpp
//Jordan Baxter

#include "ofApp.h"
#include "Paddle.h"
#include "GameWorld.h"
#include "Ball.h"
#include "Brick.h"

//--------------------------------------------------------------
void ofApp::setup(){
gameWorld = new GameWorld();
paddle = new Paddle();
gameWorld->fetchLevelLayout();
gameWorld->generateBricks(Brick* []);
gameWorld->generateBalls();
//gameWorld->fetchLevelLayout();
//gameWorld->generateBricks();
//gameWorld->generateBalls();

}

//--------------------------------------------------------------
void ofApp::update(){
if (gameWorld->getState == PLAY) {
ball->move();
if (ball->hitwall()) {
ball->bounceWall();
}
if (ball->hitCeiling()) {
ball->bounceCeiling();
}
if (ball->hitPaddle()) {
ball->bouncePaddle();
}
if (ball->hitFloor()) {
ball->loseLife();
if (gameWorld->getState() == PLAY) {
for (int i = 0; i < 5; ++i) {
balls[i]->move();
if (balls[i]->hitWall()) {
balls[i]->bounceWall();
}
if (balls[i]->hitCeiling()) {
balls[i]->bounceCeiling();
}
if (balls[i]->hitPaddle()) {
balls[i]->bouncePaddle();
}
if (balls[i]->hitFloor()) {
gameWorld->loseLife();
}
if (balls[i]->hitBrick()) {
balls[i]->bounceBrick();
//brick->damage();
}
}
if (ball->hitBrick()) {
ball->bounceBrick();
brick->damage();

if (gameWorld->noLives()) {
gameWorld->changeState(LOSE);
}
if (brick->noneLeft()) {
if (gameWorld->noBricks()) {
gameWorld->nextLevel();
}
if (ball->noneLeft()) {
gameWorld->changeState(LOSE);
}
}
}

//--------------------------------------------------------------
void ofApp::draw(){
gameWorld->draw();
if (gameWorld->getState() == PLAY) {
brick->draw();
//bricks->draw();
paddle->draw();
for (int i = 0; i < 5; ++i) {
balls[i]->draw();
}
}
}

Expand Down
5 changes: 0 additions & 5 deletions ofApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ class ofApp : public ofBaseApp{
Brick* bricks[4][12];
Ball* balls[5];

enum Game_State{
PLAY,
WIN,
LOSE
};


void setup();
Expand Down

0 comments on commit b625d44

Please sign in to comment.