Skip to content
Snippets Groups Projects
Commit e93cf9af authored by Charlie Ringer's avatar Charlie Ringer
Browse files

Committing more improvements. The player now has a pointer to the enemies inside it.

This is so that I don't have to pass it around all of the time. also put the endpoint file in the right place.
parent e4be09db
Branches
No related merge requests found
bin/data/Assets/Player/Upper/test.png

9.6 KiB

No preview for this file type
......@@ -13,7 +13,7 @@
CBB718751BF24A54004104C6 /* Enemy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CBB7186F1BF24A54004104C6 /* Enemy.cpp */; settings = {ASSET_TAGS = (); }; };
CBB718761BF24A54004104C6 /* ImageBank.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CBB718711BF24A54004104C6 /* ImageBank.cpp */; settings = {ASSET_TAGS = (); }; };
CBB718771BF24A54004104C6 /* Wall.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CBB718731BF24A54004104C6 /* Wall.cpp */; settings = {ASSET_TAGS = (); }; };
CBB718791BF24AF9004104C6 /* Endpoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CBB718781BF24AF9004104C6 /* Endpoint.cpp */; settings = {ASSET_TAGS = (); }; };
CBB7187B1BF25C42004104C6 /* Endpoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CBB7187A1BF25C42004104C6 /* Endpoint.cpp */; settings = {ASSET_TAGS = (); }; };
E4328149138ABC9F0047C5CB /* openFrameworksDebug.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E4328148138ABC890047C5CB /* openFrameworksDebug.a */; };
E4B69E200A3A1BDC003C02F2 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4B69E1D0A3A1BDC003C02F2 /* main.cpp */; };
E4B69E210A3A1BDC003C02F2 /* ofApp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4B69E1E0A3A1BDC003C02F2 /* ofApp.cpp */; };
......@@ -62,7 +62,7 @@
CBB718721BF24A54004104C6 /* ImageBank.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ImageBank.hpp; sourceTree = "<group>"; };
CBB718731BF24A54004104C6 /* Wall.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Wall.cpp; sourceTree = "<group>"; };
CBB718741BF24A54004104C6 /* Wall.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Wall.hpp; sourceTree = "<group>"; };
CBB718781BF24AF9004104C6 /* Endpoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Endpoint.cpp; sourceTree = SOURCE_ROOT; };
CBB7187A1BF25C42004104C6 /* Endpoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Endpoint.cpp; sourceTree = "<group>"; };
CBDD74AF1BE3ED8100C005D3 /* Endpoint.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Endpoint.hpp; sourceTree = "<group>"; };
E4328143138ABC890047C5CB /* openFrameworksLib.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = openFrameworksLib.xcodeproj; path = ../../../libs/openFrameworksCompiled/project/osx/openFrameworksLib.xcodeproj; sourceTree = SOURCE_ROOT; };
E4B69E1D0A3A1BDC003C02F2 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = main.cpp; path = src/main.cpp; sourceTree = SOURCE_ROOT; };
......@@ -123,7 +123,7 @@
E4B69E1C0A3A1BDC003C02F2 /* src */ = {
isa = PBXGroup;
children = (
CBB718781BF24AF9004104C6 /* Endpoint.cpp */,
CBB7187A1BF25C42004104C6 /* Endpoint.cpp */,
CBDD74AF1BE3ED8100C005D3 /* Endpoint.hpp */,
CBB7186F1BF24A54004104C6 /* Enemy.cpp */,
CBB718701BF24A54004104C6 /* Enemy.hpp */,
......@@ -241,7 +241,7 @@
buildActionMask = 2147483647;
files = (
CBB7186B1BF240A8004104C6 /* Game.cpp in Sources */,
CBB718791BF24AF9004104C6 /* Endpoint.cpp in Sources */,
CBB7187B1BF25C42004104C6 /* Endpoint.cpp in Sources */,
CB1AB1451BE1957A00F75B58 /* Player.cpp in Sources */,
CBB718751BF24A54004104C6 /* Enemy.cpp in Sources */,
CB0239291BE38637005BAB90 /* Vision.cpp in Sources */,
......
......@@ -242,14 +242,30 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "src/Game.cpp"
timestampString = "468861715.142089"
timestampString = "468868053.937676"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "33"
endingLineNumber = "33"
startingLineNumber = "34"
endingLineNumber = "34"
landmarkName = "Game::update()"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "src/Player.cpp"
timestampString = "468867812.544434"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "13"
endingLineNumber = "13"
landmarkName = "Player::Player(vector&lt;Wall&gt; &amp;walls, ImageBank &amp;imgBank, vector&lt;Enemy&gt; &amp;badGuys)"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
File moved
......@@ -19,11 +19,12 @@ Game::Game(string wallLocations)
}
}
end = new Endpoint(walls);
player = new Player(walls, imgBank);
for (int i = 1; i < 10; i++)
{
enemies.push_back(Enemy(walls, imgBank));
}
player = new Player(walls, imgBank, enemies);
bgImage.loadImage("Assets/Background/0.png");
}
......@@ -41,7 +42,7 @@ void Game::update()
int Game::getState()
{
return player->checkGameEnd(enemies, end);
return player->checkGameEnd(end);
}
......
......@@ -8,12 +8,12 @@
#include "Player.hpp"
Player::Player(vector<Wall> &walls, ImageBank &imgBank): height(20), width(20), speed(2)
Player::Player(vector<Wall> &walls, ImageBank &imgBank, vector<Enemy> &badGuys): height(20), width(20), speed(2)
{
enemies = &badGuys;
//This finds a random place on the map that is not occupied by a wall
bool done = false;
//Potentail X and Ys
//Potentail X and Y
int potX, potY;
while(!done)
{
......@@ -134,8 +134,8 @@ void Player::handleKeyOn(int keyIn)
else if (keyIn == 'a') left = true;
else if (keyIn == 's') down = true;
else if (keyIn == 'd') right = true;
else if (keyIn == ' ') torchOn = !torchOn;
else if (keyIn == OF_KEY_RETURN) ;
else if (keyIn == 'e') torchOn = !torchOn;
//else if (keyIn == ' ') attack(enemies);
}
void Player::handleKeyOff(int keyIn)
......@@ -146,16 +146,19 @@ void Player::handleKeyOff(int keyIn)
else if (keyIn == 'd') right = false;
}
int Player::checkGameEnd(vector<Enemy> enemies, Endpoint *endPoint)
int Player::checkGameEnd(Endpoint *endPoint)
{
if((X+width) > endPoint->getSX() && X < endPoint->getEX()
&& (Y+width) > endPoint->getSY() && Y < endPoint->getEY()) return 1;
if(std::any_of(enemies.begin(), enemies.end(), [this](Enemy enemy)
if(std::any_of(enemies->begin(), enemies->end(), [this](Enemy enemy)
{return (X+width) > (enemy.getSX()+10) && X < (enemy.getEX()-10)
&& (Y+width) > (enemy.getSY()+10) && Y < (enemy.getEY()-10);}))return -1;
return 0;
}
//bool hit(enemies)
\ No newline at end of file
bool Player::attack()
{
return true;
}
\ No newline at end of file
......@@ -29,7 +29,9 @@ private:
float speed;
//The current bottom half of the sprite
int currentBottom = 0;
bool torchOn, up, down, left, right, goingUp, goingDown, goingLeft, goingRight = false;
vector<Enemy> *enemies;
bool torchOn = false, up = false, down = false, left = false, right = false, goingUp = false, goingDown = false, goingLeft = false, goingRight = false;
vector<ofImage*> walkingBot;
ofImage *standingBot, *top, *torchTop;
int prevRot = 0;
......@@ -37,7 +39,7 @@ private:
public:
// Constuctor
Player(vector<Wall> &walls, ImageBank &imgBank);
Player(vector<Wall> &walls, ImageBank &imgBank, vector<Enemy> &badGuys);
//Getters
int getX() { return X;};
......@@ -60,7 +62,10 @@ public:
void handleKeyOff(int keyIn);
//Checks if the user has reached an end point or enemy
int checkGameEnd(vector<Enemy> enemies, Endpoint *endPoint);
int checkGameEnd(Endpoint *endPoint);
//Attack
bool attack();
};
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment