@@ -0,0 +1,275 @@
#include "DeathScreen.h"
#include "GL\glew.h"
#include "shader.hpp"
#include "Utility.h"
#include "MeshBuilder.h"
#include "LoadTGA.h"
#include "LoadOBJ.h"
#include "LoadHmap.h"
#include "GenerateRange.h"
#include "Collision.h"
#include "Application.h"
#include "SceneManager.h"

DeathScreen::DeathScreen() {
}

DeathScreen::~DeathScreen() {
}

void DeathScreen::Exit() {

for (unsigned int i = 0; i < NUM_GEOMETRY; ++i) {
if (meshList[i]) {
delete meshList[i];
}
}

for (unsigned int i = 0; i < NUM_SPRITE; ++i) {
if (spriteAnimationList[i]) {
delete spriteAnimationList[i];
}
}

Scene3D::Exit();
}

void DeathScreen::Init() {

InitGL();

//Create & User Our Shader
InitShaders("Shader//Default.vertexshader", "Shader//Default.fragmentshader", DEFAULT);
UseShader(DEFAULT);

Scene3D::Init();
InitMeshes();
InitSpriteAnimations();

InitLights();
InitFog(Color(0.5f, 0.5f, 0.5f), 2, 20.0f, 800.0f, 0.005f);
EnableFog(false);


tileMap.LoadFile("TileMap//DeathScreen.csv");
tileMap.SetTileSize(1.0f);
InitPlayer();
InitCamera();

drop = 0.0f;
Level = 1;
}

void DeathScreen::InitMeshes() {

for (unsigned int i = 0; i < NUM_GEOMETRY; ++i) {
meshList[i] = nullptr;
}
//meshList[GEO_PLAYER] = MeshBuilder::Generate2DTile("Player", Color(1, 1, 1), 1);

//meshList[GEO_TILE_BRICK] = MeshBuilder::Generate2DTile("Tile Brick", Color(1, 1, 1), 1);

meshList[GEO_DIRT] = MeshBuilder::GenerateQuad("Tile Brick", Color(1, 1, 1), 1);
meshList[GEO_DIRT]->textureArray[0] = LoadTGA("Image//SP3_Texture//Tiles//ground.tga");

meshList[GEO_GRASS] = MeshBuilder::GenerateQuad("Tile Brick", Color(1, 1, 1), 1);
meshList[GEO_GRASS]->textureArray[0] = LoadTGA("Image//SP3_Texture//Tiles//ground_grass.tga");

meshList[GEO_BACKGROUND_1] = MeshBuilder::GenerateQuad("Background1", Color(1, 1, 1), 1);
meshList[GEO_BACKGROUND_1]->textureArray[0] = LoadTGA("Image//SP3_Texture//Background//death.tga");

meshList[GEO_BACKGROUND_2] = MeshBuilder::GenerateQuad("Background2", Color(1, 1, 1), 0.7);
meshList[GEO_BACKGROUND_2]->textureArray[0] = LoadTGA("Image//SP3_Texture//Background//mountains.tga");

meshList[GEO_BACKGROUND_3] = MeshBuilder::GenerateQuad("Background3", Color(1, 1, 1), 0.4);
meshList[GEO_BACKGROUND_3]->textureArray[0] = LoadTGA("Image//SP3_Texture//Background//clouds.tga");

}

void DeathScreen::InitSpriteAnimations() {

for (unsigned int i = 0; i < NUM_SPRITE; ++i) {
spriteAnimationList[i] = nullptr;
}

spriteAnimationList[SPRITE_PLAYER] = MeshBuilder::GenerateSpriteAnimation("Player", 1, 4);
spriteAnimationList[SPRITE_PLAYER]->textureArray[0] = LoadTGA("Image//SP3_Texture//Sprite_Animation//player.tga");
spriteAnimationList[SPRITE_PLAYER]->animation = new Animation();
spriteAnimationList[SPRITE_PLAYER]->animation->Set(0, 3, 0, 1.f, true);

spriteAnimationList[SPRITE_PLAYER_IDLE] = MeshBuilder::GenerateSpriteAnimation("Player", 1, 2);
spriteAnimationList[SPRITE_PLAYER_IDLE]->textureArray[0] = LoadTGA("Image//SP3_Texture//Sprite_Animation//player_idle.tga");
spriteAnimationList[SPRITE_PLAYER_IDLE]->animation = new Animation();
spriteAnimationList[SPRITE_PLAYER_IDLE]->animation->Set(0, 1, 0, 1.f, true);

spriteAnimationList[SPRITE_PLAYER_JUMP] = MeshBuilder::GenerateSpriteAnimation("Player", 1, 1);
spriteAnimationList[SPRITE_PLAYER_JUMP]->textureArray[0] = LoadTGA("Image//SP3_Texture//Sprite_Animation//player_jump.tga");
spriteAnimationList[SPRITE_PLAYER_JUMP]->animation = new Animation();
spriteAnimationList[SPRITE_PLAYER_JUMP]->animation->Set(0, 0, 0, 1.f, true);

spriteAnimationList[SPRITE_PORTAL] = MeshBuilder::GenerateSpriteAnimation("portal", 1, 4);
spriteAnimationList[SPRITE_PORTAL]->textureArray[0] = LoadTGA("Image//SP3_Texture//Sprite_Animation//portal.tga");
spriteAnimationList[SPRITE_PORTAL]->animation = new Animation();
spriteAnimationList[SPRITE_PORTAL]->animation->Set(0, 3, 0, 1.f, true);




}

void DeathScreen::InitPlayer() {

player.SetTileMap(tileMap);

for (int row = 0; row < tileMap.GetNumRows(); ++row) {
for (int col = 0; col < tileMap.GetNumColumns(); ++col) {
if (tileMap.map[row][col] == 99) {
housePos.Set(col * tileMap.GetTileSize(), row * tileMap.GetTileSize(), -20);
player.transform.SetPosition(tileMap.GetTileSize() * col, tileMap.GetTileSize() * row, 0);
}
}
}


}

void DeathScreen::InitCamera() {

camera.SetPlayer(player);
camera.SetTileMap(tileMap);

}

void DeathScreen::Update(const double& deltaTime) {


for (unsigned int i = 0; i < NUM_SPRITE; ++i)
{

spriteAnimationList[i]->Update(deltaTime);
spriteAnimationList[i]->animation->animActive = true;
}

player.Update(deltaTime);
camera.Update(deltaTime);

}

void DeathScreen::Render() {
SetToCameraView(&camera);
//Scene3D::Render();
RenderDeath();

RenderTileMap();
RenderBackground();
RenderPlayer();
RenderText();

}

void DeathScreen::RenderTileMap() {

float cameraAspectRatio = static_cast<float>(camera.aspectRatio.x) / static_cast<float>(camera.aspectRatio.y);
float cameraWidth = cameraAspectRatio * camera.GetOrthoSize();

int startCol = tileMap.GetTileX(camera.transform.position.x - cameraWidth);
int endCol = tileMap.GetTileX(camera.transform.position.x + cameraWidth) + 1;

int startRow = tileMap.GetTileX(camera.transform.position.y - camera.GetOrthoSize());
int endRow = tileMap.GetTileX(camera.transform.position.y + camera.GetOrthoSize()) + 1;

for (int row = Math::Max(0, startRow); row < Math::Min(endRow, tileMap.GetNumRows()); ++row) {
for (int col = Math::Max(0, startCol); col < Math::Min(endCol, tileMap.GetNumColumns()); ++col) {
modelStack.PushMatrix();
modelStack.Translate(col * tileMap.GetTileSize(), row * tileMap.GetTileSize(), -1);
modelStack.Scale(tileMap.GetTileSize(), tileMap.GetTileSize(), tileMap.GetTileSize());
switch (tileMap.map[row][col]) {
case 1:
//RenderMesh(meshList[GEO_DIRT]);
break;
case 2:
//RenderMesh(meshList[GEO_GRASS]);
break;
case 3:
glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
RenderSpriteAnimation(spriteAnimationList[SPRITE_PORTAL]);
glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
break;
case 9:
glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
RenderSpriteAnimation(spriteAnimationList[SPRITE_PORTAL]);
glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
break;

}
modelStack.PopMatrix();
}
}

}


void DeathScreen::RenderPlayer() {

modelStack.PushMatrix();
modelStack.Translate(player.transform.position.x, player.transform.position.y - 0.1f, player.transform.position.z);
//modelStack.Rotate(player.transform.rotation.z, 0, 0, 1);
if (player.getInvert())
modelStack.Scale(-player.transform.scale.x, player.transform.scale.y, player.transform.scale.z);
else
modelStack.Scale(player.transform.scale.x, player.transform.scale.y, player.transform.scale.z);
if (player.playerState == Player::WALKING)
RenderSpriteAnimation(spriteAnimationList[SPRITE_PLAYER], false, player.getInvert());
else if (player.playerState == Player::IDLE)
RenderSpriteAnimation(spriteAnimationList[SPRITE_PLAYER_IDLE], false, player.getInvert());
else if (player.playerState == Player::JUMPING)
RenderSpriteAnimation(spriteAnimationList[SPRITE_PLAYER_JUMP], false, player.getInvert());
modelStack.PopMatrix();

}

void DeathScreen::RenderText() {
RenderTextOnScreen(fontList[FONT_CONSOLAS], "DEAD", Color(1, 0, 0), 4, -8, 5);

if (player.transform.position.x < housePos.x + 5)
RenderTextOnScreen(fontList[FONT_CONSOLAS], "Enter the portal on the left to respawn", Color(1, 0, 0), 0.8, -16, 0);
else
RenderTextOnScreen(fontList[FONT_CONSOLAS], "Are you sure you want to abandon your family?", Color(1, 0, 0), 0.65, -16, 0);

}
void DeathScreen::RenderBackground()
{

float xRatio = (static_cast<float>(camera.aspectRatio.x / static_cast<float>(camera.aspectRatio.y)));
float camWidth = xRatio * camera.GetOrthoSize();
float backgroundScaleX = camWidth * 2.0f;
float backgroundScaleY = camera.GetOrthoSize() * 2.0f;

glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
modelStack.PushMatrix();
modelStack.Translate(housePos.x, housePos.y + 2, housePos.z);
modelStack.Scale(50, 50, 1);
RenderMesh(meshList[GEO_BACKGROUND_1], false);
modelStack.PopMatrix();
glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);

/*for (int i = 0; i < 5; ++i)
{
modelStack.PushMatrix();
modelStack.Translate((0.7 * camera.transform.position.x) + (i * backgroundScaleX), camera.transform.position.y, -49);
modelStack.Scale(backgroundScaleX, backgroundScaleY, 1);
RenderMesh(meshList[GEO_BACKGROUND_2], false);
modelStack.PopMatrix();
}
for (int i = 0; i < 5; ++i)
{
modelStack.PushMatrix();
modelStack.Translate((0.5 * camera.transform.position.x) + (i * backgroundScaleX), 8.7, -48);
modelStack.Scale(backgroundScaleX, backgroundScaleY, 1);
RenderMesh(meshList[GEO_BACKGROUND_3], false);
modelStack.PopMatrix();
}*/
}


@@ -0,0 +1,75 @@
#ifndef DEATH_SCREEN_H
#define DEATH_SCREEN_H

#include "Scene3D.h"
#include "Mesh.h"
#include "SpriteAnimation.h"
#include "TileMap.h"
#include "Camera2D.h"
#include "PlayerSS.h"

class DeathScreen : public Scene3D {

private:
enum GEOMETRY_TYPE {
//Tiles
GEO_EMPTY,
GEO_DIRT,
GEO_GRASS,
GEO_BACKGROUND_1,
GEO_BACKGROUND_2,
GEO_BACKGROUND_3,

//Others
GEO_PLAYER,

NUM_GEOMETRY,
};

enum SPRITE_TYPE {
SPRITE_PLAYER,
SPRITE_PLAYER_IDLE,
SPRITE_PLAYER_JUMP,
SPRITE_PORTAL,
NUM_SPRITE,
};

Mesh* meshList[NUM_GEOMETRY];
SpriteAnimation* spriteAnimationList[NUM_SPRITE];

TileMap tileMap;

void InitMeshes();
void InitSpriteAnimations();
void InitCamera();
virtual void InitPlayer();

void RenderTileMap();
void RenderPlayer();
void RenderBackground();
void RenderText();

Camera2D camera;
PlayerSS player;

float drop;
int Level;

Vector3 housePos;

public:
//Constructor(s) & Destructor
DeathScreen();
virtual ~DeathScreen();

//Virtual Function(s)
virtual void Init();
virtual void Update(const double& deltaTime);
virtual void UpdateSub(const double& deltaTime){};
virtual void Render();
virtual void RenderSub(){};
virtual void Exit();

};

#endif
@@ -111,10 +111,19 @@ void InputManager::Update() {
inputInfo.keyDown[INPUT_WELL2] = 1;
inputInfo.keyValue[INPUT_WELL2] = 1.0f;
}

if (keyboard.IsKeyReleased('D')){
inputInfo.keyReleased[INPUT_WELL2] = 1;
inputInfo.keyValue[INPUT_WELL2] = 1.0f;
}
if (keyboard.IsKeyPressed('P')){
inputInfo.keyDown[INPUT_PAUSE] = 1;
inputInfo.keyValue[INPUT_PAUSE] = 1.0f;
}
if (keyboard.IsKeyReleased('P')){
inputInfo.keyReleased[INPUT_PAUSE] = 1;
inputInfo.keyValue[INPUT_PAUSE] = 1.0f;
}

/********************************************************************************************************************/
//Do not touch anything below unless you know what you're doing.
@@ -20,7 +20,7 @@ enum INPUT_TYPE {
INPUT_WELL,
INPUT_WELL2,
INPUT_JUMP,

INPUT_PAUSE,
INPUT_QUIT,

NUM_KEYS,
@@ -6,7 +6,7 @@ name(vname),
num(vnum),
position(Vector3(0, 0, 0))
{

}

void Item::setName(const string& name) {
@@ -32,7 +32,8 @@ void ItemManager::addItem(Item* item) {
pair<map<string, Item*>::iterator, bool> mit;
mit = itemMap.insert(pair<string, Item*>(item->getName(), item));
if (mit.second == false) {
mit.first->second->setNum(mit.first->second->getNum() + item->getNum());
if (mit.first->second->getNum() < 99)
mit.first->second->setNum(mit.first->second->getNum() + item->getNum());
}
}

@@ -53,9 +54,6 @@ Item* ItemManager::removeItem(string vname, int val)
temp->setNum(val);

(*mit).second->setNum((*mit).second->getNum() - val);
if ((*mit).second->getNum() <= 0) {
itemMap.erase(mit++);
}
}
return temp;
}
@@ -36,21 +36,6 @@ class Item
int num;
};

class ItemManager : public Singleton<ItemManager>
{
friend class Singleton<ItemManager>;

public:
~ItemManager(){
};

void addItem(Item* item);
Item* removeItem(string vname, int val);

map<string, Item*>itemMap;
private:
ItemManager() {};
};

class Inventory : public Singleton<Inventory>
{
@@ -101,6 +86,37 @@ class Milk : public Item
return position;
}

virtual void Update(const double& deltaTime){};

private:
Attributes attri;
};


class Meat : public Item
{
public:
Meat(int vnum = 1) {
setName("Meat");
setNum(vnum);
attri.setAttributes(8, 2, 2, 2, 2);
};

virtual ~Meat() {};
virtual Attributes getAttributes() {
return attri;
}

virtual void setPosition(const Vector3& pos) {
position = pos;
}

virtual Vector3 getPosition() {
return position;
}

virtual void Update(const double& deltaTime){};

private:
Attributes attri;
};
@@ -126,6 +142,35 @@ class Egg : public Item
return position;
}

virtual void Update(const double& deltaTime){};

private:
Attributes attri;
};

class Water : public Item
{
public:
Water(int vnum = 1) {
setName("Water");
setNum(vnum);
attri.setAttributes(8, 2, 2, 2, 2);
};

virtual ~Water() {};
virtual Attributes getAttributes() {
return attri;
}
virtual void setPosition(const Vector3& pos) {
position = pos;
}

virtual Vector3 getPosition() {
return position;
}

virtual void Update(const double& deltaTime){};

private:
Attributes attri;
};
@@ -153,21 +198,23 @@ class Apple : public Item

virtual void Update(const double& deltaTime) {
position.y += (float)GRAVITY * deltaTime;
}
};

private:
Attributes attri;
};

class Cabbage : public Item

class Fish : public Item
{
public:
Cabbage(int vnum = 1)
{
setName("Cabbage");
Fish(int vnum = 1) {
setName("Fish");
setNum(vnum);
attri.setAttributes(0, 0, 0, 0, 1);
}
virtual ~Cabbage(){};
attri.setAttributes(8, 2, 2, 2, 2);
};

virtual ~Fish() {};
virtual Attributes getAttributes() {
return attri;
}
@@ -179,20 +226,22 @@ class Cabbage : public Item
return position;
}

virtual void Update(const double& deltaTime) {};

private:
Attributes attri;
};

class Carrot : public Item
class Cabbage : public Item
{
public:
Carrot(int vnum = 1)
{
setName("Carrot");
Cabbage(int vnum = 1) {
setName("Cabbage");
setNum(vnum);
attri.setAttributes(0, 0, 0, 0, 1);
}
virtual ~Carrot(){};
attri.setAttributes(8, 2, 2, 2, 2);
};

virtual ~Cabbage() {};
virtual Attributes getAttributes() {
return attri;
}
@@ -204,20 +253,22 @@ class Carrot : public Item
return position;
}

virtual void Update(const double& deltaTime) {};

private:
Attributes attri;
};

class Potato : public Item
{
public:
Potato(int vnum = 1)
{
Potato(int vnum = 1) {
setName("Potato");
setNum(vnum);
attri.setAttributes(0, 0, 0, 0, 1);
}
virtual ~Potato(){};
attri.setAttributes(8, 2, 2, 2, 2);
};

virtual ~Potato() {};
virtual Attributes getAttributes() {
return attri;
}
@@ -229,20 +280,22 @@ class Potato : public Item
return position;
}

virtual void Update(const double& deltaTime) {};

private:
Attributes attri;
};

class Wheat : public Item
class Corn : public Item
{
public:
Wheat(int vnum = 1)
{
setName("Wheat");
Corn(int vnum = 1) {
setName("Corn");
setNum(vnum);
attri.setAttributes(0, 0, 0, 0, 1);
}
virtual ~Wheat(){};
attri.setAttributes(8, 2, 2, 2, 2);
};

virtual ~Corn() {};
virtual Attributes getAttributes() {
return attri;
}
@@ -254,20 +307,22 @@ class Wheat : public Item
return position;
}

virtual void Update(const double& deltaTime) {};

private:
Attributes attri;
};

class Corn : public Item
class Carrot : public Item
{
public:
Corn(int vnum = 1)
{
setName("Wheat");
Carrot(int vnum = 1) {
setName("Carrot");
setNum(vnum);
attri.setAttributes(0, 0, 0, 0, 1);
}
virtual ~Corn(){};
attri.setAttributes(8, 2, 2, 2, 2);
};

virtual ~Carrot() {};
virtual Attributes getAttributes() {
return attri;
}
@@ -279,7 +334,37 @@ class Corn : public Item
return position;
}

virtual void Update(const double& deltaTime) {};

private:
Attributes attri;
};

class ItemManager : public Singleton<ItemManager>
{
friend class Singleton<ItemManager>;

public:
~ItemManager(){
};

void addItem(Item* item);
Item* removeItem(string vname, int val);

map<string, Item*>itemMap;
private:
ItemManager() {
addItem(new Milk(10));
addItem(new Meat(10));
addItem(new Egg(10));
addItem(new Water(10));
addItem(new Apple(98));
addItem(new Fish(10));
addItem(new Cabbage(10));
addItem(new Potato(10));
addItem(new Corn(10));
addItem(new Carrot(10));
};
};

#endif
@@ -0,0 +1,275 @@
#include "LoseScreen.h"
#include "GL\glew.h"
#include "shader.hpp"
#include "Utility.h"
#include "MeshBuilder.h"
#include "LoadTGA.h"
#include "LoadOBJ.h"
#include "LoadHmap.h"
#include "GenerateRange.h"
#include "Collision.h"
#include "Application.h"
#include "SceneManager.h"

LoseScreen::LoseScreen() {
}

LoseScreen::~LoseScreen() {
}

void LoseScreen::Exit() {

for (unsigned int i = 0; i < NUM_GEOMETRY; ++i) {
if (meshList[i]) {
delete meshList[i];
}
}

for (unsigned int i = 0; i < NUM_SPRITE; ++i) {
if (spriteAnimationList[i]) {
delete spriteAnimationList[i];
}
}

Scene3D::Exit();
}

void LoseScreen::Init() {

InitGL();

//Create & User Our Shader
InitShaders("Shader//Default.vertexshader", "Shader//Default.fragmentshader", DEFAULT);
UseShader(DEFAULT);

Scene3D::Init();
InitMeshes();
InitSpriteAnimations();

InitLights();
InitFog(Color(0.5f, 0.5f, 0.5f), 2, 20.0f, 800.0f, 0.005f);
EnableFog(false);


tileMap.LoadFile("TileMap//LoseScreen.csv");
tileMap.SetTileSize(1.0f);
InitPlayer();
InitCamera();

drop = 0.0f;
Level = 1;
}

void LoseScreen::InitMeshes() {

for (unsigned int i = 0; i < NUM_GEOMETRY; ++i) {
meshList[i] = nullptr;
}
//meshList[GEO_PLAYER] = MeshBuilder::Generate2DTile("Player", Color(1, 1, 1), 1);

//meshList[GEO_TILE_BRICK] = MeshBuilder::Generate2DTile("Tile Brick", Color(1, 1, 1), 1);

meshList[GEO_DIRT] = MeshBuilder::GenerateQuad("Tile Brick", Color(1, 1, 1), 1);
meshList[GEO_DIRT]->textureArray[0] = LoadTGA("Image//SP3_Texture//Tiles//ground.tga");

meshList[GEO_GRASS] = MeshBuilder::GenerateQuad("Tile Brick", Color(1, 1, 1), 1);
meshList[GEO_GRASS]->textureArray[0] = LoadTGA("Image//SP3_Texture//Tiles//ground_grass.tga");

meshList[GEO_BACKGROUND_1] = MeshBuilder::GenerateQuad("Background1", Color(1, 1, 1), 1);
meshList[GEO_BACKGROUND_1]->textureArray[0] = LoadTGA("Image//SP3_Texture//Background//lose.tga");

meshList[GEO_BACKGROUND_2] = MeshBuilder::GenerateQuad("Background2", Color(1, 1, 1), 0.7);
meshList[GEO_BACKGROUND_2]->textureArray[0] = LoadTGA("Image//SP3_Texture//Background//mountains.tga");

meshList[GEO_BACKGROUND_3] = MeshBuilder::GenerateQuad("Background3", Color(1, 1, 1), 0.4);
meshList[GEO_BACKGROUND_3]->textureArray[0] = LoadTGA("Image//SP3_Texture//Background//clouds.tga");

}

void LoseScreen::InitSpriteAnimations() {

for (unsigned int i = 0; i < NUM_SPRITE; ++i) {
spriteAnimationList[i] = nullptr;
}

spriteAnimationList[SPRITE_PLAYER] = MeshBuilder::GenerateSpriteAnimation("Player", 1, 4);
spriteAnimationList[SPRITE_PLAYER]->textureArray[0] = LoadTGA("Image//SP3_Texture//Sprite_Animation//player.tga");
spriteAnimationList[SPRITE_PLAYER]->animation = new Animation();
spriteAnimationList[SPRITE_PLAYER]->animation->Set(0, 3, 0, 1.f, true);

spriteAnimationList[SPRITE_PLAYER_IDLE] = MeshBuilder::GenerateSpriteAnimation("Player", 1, 2);
spriteAnimationList[SPRITE_PLAYER_IDLE]->textureArray[0] = LoadTGA("Image//SP3_Texture//Sprite_Animation//player_idle.tga");
spriteAnimationList[SPRITE_PLAYER_IDLE]->animation = new Animation();
spriteAnimationList[SPRITE_PLAYER_IDLE]->animation->Set(0, 1, 0, 1.f, true);

spriteAnimationList[SPRITE_PLAYER_JUMP] = MeshBuilder::GenerateSpriteAnimation("Player", 1, 1);
spriteAnimationList[SPRITE_PLAYER_JUMP]->textureArray[0] = LoadTGA("Image//SP3_Texture//Sprite_Animation//player_jump.tga");
spriteAnimationList[SPRITE_PLAYER_JUMP]->animation = new Animation();
spriteAnimationList[SPRITE_PLAYER_JUMP]->animation->Set(0, 0, 0, 1.f, true);

spriteAnimationList[SPRITE_PORTAL] = MeshBuilder::GenerateSpriteAnimation("portal", 1, 4);
spriteAnimationList[SPRITE_PORTAL]->textureArray[0] = LoadTGA("Image//SP3_Texture//Sprite_Animation//portal.tga");
spriteAnimationList[SPRITE_PORTAL]->animation = new Animation();
spriteAnimationList[SPRITE_PORTAL]->animation->Set(0, 3, 0, 1.f, true);




}

void LoseScreen::InitPlayer() {

player.SetTileMap(tileMap);

for (int row = 0; row < tileMap.GetNumRows(); ++row) {
for (int col = 0; col < tileMap.GetNumColumns(); ++col) {
if (tileMap.map[row][col] == 99) {
housePos.Set(col * tileMap.GetTileSize(), row * tileMap.GetTileSize(), -20);
player.transform.SetPosition(tileMap.GetTileSize() * col, tileMap.GetTileSize() * row, 0);
}
}
}


}

void LoseScreen::InitCamera() {

camera.SetPlayer(player);
camera.SetTileMap(tileMap);

}

void LoseScreen::Update(const double& deltaTime) {


for (unsigned int i = 0; i < NUM_SPRITE; ++i)
{

spriteAnimationList[i]->Update(deltaTime);
spriteAnimationList[i]->animation->animActive = true;
}

player.Update(deltaTime);
camera.Update(deltaTime);

}

void LoseScreen::Render() {
SetToCameraView(&camera);
//Scene3D::Render();
RenderDeath();

RenderTileMap();
RenderBackground();
RenderPlayer();
RenderText();

}

void LoseScreen::RenderTileMap() {

float cameraAspectRatio = static_cast<float>(camera.aspectRatio.x) / static_cast<float>(camera.aspectRatio.y);
float cameraWidth = cameraAspectRatio * camera.GetOrthoSize();

int startCol = tileMap.GetTileX(camera.transform.position.x - cameraWidth);
int endCol = tileMap.GetTileX(camera.transform.position.x + cameraWidth) + 1;

int startRow = tileMap.GetTileX(camera.transform.position.y - camera.GetOrthoSize());
int endRow = tileMap.GetTileX(camera.transform.position.y + camera.GetOrthoSize()) + 1;

for (int row = Math::Max(0, startRow); row < Math::Min(endRow, tileMap.GetNumRows()); ++row) {
for (int col = Math::Max(0, startCol); col < Math::Min(endCol, tileMap.GetNumColumns()); ++col) {
modelStack.PushMatrix();
modelStack.Translate(col * tileMap.GetTileSize(), row * tileMap.GetTileSize(), -1);
modelStack.Scale(tileMap.GetTileSize(), tileMap.GetTileSize(), tileMap.GetTileSize());
switch (tileMap.map[row][col]) {
case 1:
//RenderMesh(meshList[GEO_DIRT]);
break;
case 2:
//RenderMesh(meshList[GEO_GRASS]);
break;
case 3:
glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
RenderSpriteAnimation(spriteAnimationList[SPRITE_PORTAL]);
glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
break;
case 9:
glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
RenderSpriteAnimation(spriteAnimationList[SPRITE_PORTAL]);
glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
break;

}
modelStack.PopMatrix();
}
}

}


void LoseScreen::RenderPlayer() {

modelStack.PushMatrix();
modelStack.Translate(player.transform.position.x, player.transform.position.y - 0.1f, player.transform.position.z);
//modelStack.Rotate(player.transform.rotation.z, 0, 0, 1);
if (player.getInvert())
modelStack.Scale(-player.transform.scale.x, player.transform.scale.y, player.transform.scale.z);
else
modelStack.Scale(player.transform.scale.x, player.transform.scale.y, player.transform.scale.z);
if (player.playerState == Player::WALKING)
RenderSpriteAnimation(spriteAnimationList[SPRITE_PLAYER], false, player.getInvert());
else if (player.playerState == Player::IDLE)
RenderSpriteAnimation(spriteAnimationList[SPRITE_PLAYER_IDLE], false, player.getInvert());
else if (player.playerState == Player::JUMPING)
RenderSpriteAnimation(spriteAnimationList[SPRITE_PLAYER_JUMP], false, player.getInvert());
modelStack.PopMatrix();

}

void LoseScreen::RenderText() {

RenderTextOnScreen(fontList[FONT_CONSOLAS], "LOSE", Color(1, 0, 0), 4, -8, 5);

if (player.transform.position.x < housePos.x + 5)
RenderTextOnScreen(fontList[FONT_CONSOLAS], "Enter the portal on the left to restart", Color(1, 0, 0), 0.8, -16, 0);
else
RenderTextOnScreen(fontList[FONT_CONSOLAS], "Are you sure you don't want to retry?", Color(1, 0, 0), 0.8, -16, 0);
}
void LoseScreen::RenderBackground()
{

float xRatio = (static_cast<float>(camera.aspectRatio.x / static_cast<float>(camera.aspectRatio.y)));
float camWidth = xRatio * camera.GetOrthoSize();
float backgroundScaleX = camWidth * 2.0f;
float backgroundScaleY = camera.GetOrthoSize() * 2.0f;

glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
modelStack.PushMatrix();
modelStack.Translate(housePos.x, housePos.y + 2, housePos.z);
modelStack.Scale(50, 50, 1);
RenderMesh(meshList[GEO_BACKGROUND_1], false);
modelStack.PopMatrix();
glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);

/*for (int i = 0; i < 5; ++i)
{
modelStack.PushMatrix();
modelStack.Translate((0.7 * camera.transform.position.x) + (i * backgroundScaleX), camera.transform.position.y, -49);
modelStack.Scale(backgroundScaleX, backgroundScaleY, 1);
RenderMesh(meshList[GEO_BACKGROUND_2], false);
modelStack.PopMatrix();
}
for (int i = 0; i < 5; ++i)
{
modelStack.PushMatrix();
modelStack.Translate((0.5 * camera.transform.position.x) + (i * backgroundScaleX), 8.7, -48);
modelStack.Scale(backgroundScaleX, backgroundScaleY, 1);
RenderMesh(meshList[GEO_BACKGROUND_3], false);
modelStack.PopMatrix();
}*/
}


@@ -0,0 +1,75 @@
#ifndef LOSE_SCREEN_H
#define LOSE_SCREEN_H

#include "Scene3D.h"
#include "Mesh.h"
#include "SpriteAnimation.h"
#include "TileMap.h"
#include "Camera2D.h"
#include "PlayerSS.h"

class LoseScreen : public Scene3D {

private:
enum GEOMETRY_TYPE {
//Tiles
GEO_EMPTY,
GEO_DIRT,
GEO_GRASS,
GEO_BACKGROUND_1,
GEO_BACKGROUND_2,
GEO_BACKGROUND_3,

//Others
GEO_PLAYER,

NUM_GEOMETRY,
};

enum SPRITE_TYPE {
SPRITE_PLAYER,
SPRITE_PLAYER_IDLE,
SPRITE_PLAYER_JUMP,
SPRITE_PORTAL,
NUM_SPRITE,
};

Mesh* meshList[NUM_GEOMETRY];
SpriteAnimation* spriteAnimationList[NUM_SPRITE];

TileMap tileMap;

void InitMeshes();
void InitSpriteAnimations();
void InitCamera();
virtual void InitPlayer();

void RenderTileMap();
void RenderPlayer();
void RenderBackground();
void RenderText();

Camera2D camera;
PlayerSS player;

float drop;
int Level;

Vector3 housePos;

public:
//Constructor(s) & Destructor
LoseScreen();
virtual ~LoseScreen();

//Virtual Function(s)
virtual void Init();
virtual void Update(const double& deltaTime);
virtual void UpdateSub(const double& deltaTime){};
virtual void Render();
virtual void RenderSub(){};
virtual void Exit();

};

#endif
@@ -410,4 +410,24 @@ float Player::GetHotspotCentre() {

return this->hotspotOffset;

}

void Player::setVelocity(Vector3 vel)
{
velocity = vel;
}
Vector3 Player::getVelocity()
{
return velocity;
}

bool Player::CheckElectric()
{
int tileX = tileMap->GetTileX(transform.position.x);
int tileY = tileMap->GetTileY(transform.position.y);
if (tileMap->map[tileY][tileX] == TILE_ELECTRIC)
{
return true;
}
return false;
}
@@ -10,52 +10,56 @@
class Player : public GameObject {

protected:
Vector3 velocity;
vector<TILE_TYPE> collidables;
vector<TILE_TYPE> collectibles;
vector<TILE_TYPE> portal;
vector<TILE_TYPE> bounce;


bool CheckIfInsideTileMap();
bool CheckCollisionLeft();
bool CheckCollisionRight();
bool CheckCollisionUp();
bool CheckCollisionDown();
Vector3 velocity;
vector<TILE_TYPE> collidables;
vector<TILE_TYPE> collectibles;
vector<TILE_TYPE> portal;
vector<TILE_TYPE> bounce;


bool CheckIfInsideTileMap();
bool CheckCollisionLeft();
bool CheckCollisionRight();
bool CheckCollisionUp();
bool CheckCollisionDown();

int CheckPortal();
bool CheckTrigger();
bool CheckCollect();
bool CheckVegetation();
bool CheckTrigger();
bool CheckCollect();
bool CheckVegetation();
bool CheckElectric();

TileMap* tileMap;

TileMap* tileMap;
float hotspotOffset;

float hotspotOffset;



public:
Player();
virtual ~Player();
Player();
virtual ~Player();

virtual void Update(const double& deltaTime);
void SetTileMap(TileMap& tileMap);
void RemoveTileMap();
virtual void Update(const double& deltaTime);
void SetTileMap(TileMap& tileMap);
void RemoveTileMap();

void SetHotspotOffset(float hotspotOffset = 1.0f);
float GetHotspotCentre();
void SetHotspotOffset(float hotspotOffset = 1.0f);
float GetHotspotCentre();
int score;
int Level;
bool onElectricity;
void setVelocity(Vector3 vel);
Vector3 getVelocity();

enum PLAYER_STATE
{
WALKING,
IDLE,
JUMPING,
TOTAL
};
enum PLAYER_STATE
{
WALKING,
IDLE,
JUMPING,
TOTAL
};

PLAYER_STATE playerState = IDLE;
PLAYER_STATE playerState = IDLE;
};

#endif
@@ -67,37 +67,60 @@ void PlayerSS::Update(const double& deltaTime) {
{
case TILE_PORTAL:
{
switch (SceneManager::GetInstance().getCurrSceneEnum())
{
case (0) :
SceneManager::GetInstance().chgCurrEnumScene(static_cast<SCENE_TYPE>(TOTAL_SCENES - 1));
velocity.x = 0;
velocity.y = 0;
break;
default:
SceneManager::GetInstance().chgCurrEnumScene(static_cast<SCENE_TYPE>(SceneManager::GetInstance().getCurrSceneEnum() - 1));
velocity.x = 0;
velocity.y = 0;
break;
}
break;
switch (SceneManager::GetInstance().getCurrSceneEnum())
{
case (HOME) :
SceneManager::GetInstance().chgCurrEnumScene(static_cast<SCENE_TYPE>(TOTAL_SCENES - 1));
velocity.x = 0;
velocity.y = 0;
break;
case(DEAD) :
SceneManager::GetInstance().chgCurrEnumScene(HOME);
//SceneManager::GetInstance().setPrevScene(COW);
SceneManager::GetInstance().setPrevScene(WHEAT);
velocity.x = 0;
velocity.y = 0;
//insert game reset here
break;
case(LOSE) :
//temp
SceneManager::GetInstance().chgCurrEnumScene(HOME);
//SceneManager::GetInstance().setPrevScene(COW);
SceneManager::GetInstance().setPrevScene(WHEAT);
velocity.x = 0;
velocity.y = 0;
//insert game restart here
break;
default:
SceneManager::GetInstance().chgCurrEnumScene(static_cast<SCENE_TYPE>(SceneManager::GetInstance().getCurrSceneEnum() - 1));
velocity.x = 0;
velocity.y = 0;
break;
}
break;
}
case TILE_PORTAL2:
{
switch (SceneManager::GetInstance().getCurrSceneEnum())
{
case (TOTAL_SCENES - 1) :
SceneManager::GetInstance().chgCurrEnumScene(HOME);
velocity.x = 0;
velocity.y = 0;
break;
default:
SceneManager::GetInstance().chgCurrEnumScene(static_cast<SCENE_TYPE>(SceneManager::GetInstance().getCurrSceneEnum() + 1));
velocity.x = 0;
velocity.y = 0;
break;
}
break;
switch (SceneManager::GetInstance().getCurrSceneEnum())
{
case (TOTAL_SCENES - 1) :
SceneManager::GetInstance().chgCurrEnumScene(HOME);
velocity.x = 0;
velocity.y = 0;
break;
case(DEAD) :
//return to main menu
break;
case(LOSE) :
//return to main menu
break;
default:
SceneManager::GetInstance().chgCurrEnumScene(static_cast<SCENE_TYPE>(SceneManager::GetInstance().getCurrSceneEnum() + 1));
velocity.x = 0;
velocity.y = 0;
break;
}
break;
}
}

@@ -204,37 +227,47 @@ void PlayerSS::Update(const double& deltaTime) {
velocity.x *= 0.95f * (1.0f - deltaTime);
if (CheckTrigger()) {
{
if (InputManager::GetInstance().GetInputInfo().keyDown[INPUT_INTERACT]) {

switch (SceneManager::GetInstance().getCurrSceneEnum())
{
case FISH:
{
if (accumTime > 0.5f)
{
switch (SceneManager::GetInstance().getCurrSceneEnum())
{
case FISH:
{
if (InputManager::GetInstance().GetInputInfo().keyDown[INPUT_INTERACT]) {
if (accumTime > 0.5f) {
if (SceneManager::GetInstance().getIsChgScene() == false)
SceneManager::GetInstance().isChgScene(true);
else if (SceneManager::GetInstance().getIsChgScene() == true)
SceneManager::GetInstance().isChgScene(false);
accumTime = 0.f;
}
break;
}
case APPLE:
{
break;
}

case APPLE:
{
if (InputManager::GetInstance().GetInputInfo().keyDown[INPUT_INTERACT]) {
if (SceneManager::GetInstance().getIsChgScene() == false)
SceneManager::GetInstance().isChgScene(true);
break;
}
default:
if (SceneManager::GetInstance().getIsChgScene() == false)
SceneManager::GetInstance().isChgScene(true);
break;
break;
}

case WELL:
{
if (SceneManager::GetInstance().getIsChgScene() == false)
SceneManager::GetInstance().isChgScene(true);
SceneManager::GetInstance().chgCurrEnumScene(SUB_WELL);
break;
}

default:
if (SceneManager::GetInstance().getIsChgScene() == false)
SceneManager::GetInstance().isChgScene(true);
break;

}
}
}
}
}

if (CheckVegetation())
{
@@ -244,18 +277,14 @@ void PlayerSS::Update(const double& deltaTime) {

switch (SceneManager::GetInstance().getChgScene()) {
case(CHG_APPLE) : {
if (InputManager::GetInstance().GetInputInfo().keyDown[INPUT_SHOW_ATTRIBUTES] || !CheckTrigger()) {
//if(InputManager::GetInstance().GetInputInfo().keyDown[INPUT_QUIT])
if (SceneManager::GetInstance().getIsChgScene()) {
SceneManager::GetInstance().isChgScene(false);
}
}
break;
}
if (InputManager::GetInstance().GetInputInfo().keyDown[INPUT_SHOW_ATTRIBUTES] /*if(InputManager::GetInstance().GetInputInfo().keyDown[INPUT_QUIT])*/ || !CheckTrigger()) {

switch (SceneManager::GetInstance().getSubScene()) {

}
if (SceneManager::GetInstance().getIsChgScene()) {
SceneManager::GetInstance().isChgScene(false);
}
}
break;
}
}
}
//
@@ -147,7 +147,7 @@ void Scene1House::InitPlayer() {

}

if (SceneManager::GetInstance().getPrevScene() == COW)
if (SceneManager::GetInstance().getPrevScene() == COW || SceneManager::GetInstance().getPrevScene() == DEAD)

{
if (tileMap.map[row][col] == 100) {
@@ -154,7 +154,6 @@ void Scene3Chicken::InitPlayer() {
void Scene3Chicken::InitCamera() {

camera.SetPlayer(player);
camera.SetTileMap(tileMap);

if (SceneManager::GetInstance().getChgScene() == false)
camera.SetTileMap(tileMap);
@@ -181,10 +180,6 @@ void Scene3Chicken::Render() {

Scene3D::Render();
SetToCameraView(&camera);
RenderTileMap();
RenderBackground();
RenderPlayer();
RenderText();
if (SceneManager::GetInstance().getChgScene() == true)
RenderSub();
else
@@ -7,6 +7,7 @@
#include "LoadTGA.h"
#include "InputManager.h"
#include "ItemManager.h"
#include "SceneManager.h"
//#include "Application.h"

//Constructor(s) & Destructor
@@ -46,7 +47,6 @@ void Scene3D::Exit() {
delete statUiBackground;
delete barBackground;
delete inventoryBar;
delete apple_item;
}

void Scene3D::DeleteShaders() {
@@ -293,8 +293,8 @@ void Scene3D::InitFog(Color color, int fogType, float start, float end, float de

void Scene3D::Update(const double& deltaTime) {
UpdateAttributeUI(deltaTime);
Application::clock->UpdateTime(deltaTime);
cout << Application::clock->getTime();
Application::clock->UpdateTime(deltaTime);
cout << Application::clock->getTime();
}

//Things that need to be updated every frame.
@@ -430,6 +430,7 @@ void Scene3D::Render() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
RenderAttributeUI();
RenderInventoryUI();
PauseMenu();
}
void Scene3D::RenderSub() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
@@ -601,7 +602,7 @@ void Scene3D::RenderText(Mesh* mesh, std::string text, Color color) {

}

void Scene3D::RenderTextOnScreen(Mesh* mesh, std::string text, Color color, float size, float x, float y) {
void Scene3D::RenderTextOnScreen(Mesh* mesh, std::string text, Color color, float size, float x, float y, float z) {

if (!mesh || mesh->textureArray[0] <= 0) {
return;
@@ -611,7 +612,7 @@ void Scene3D::RenderTextOnScreen(Mesh* mesh, std::string text, Color color, floa
viewStack.LoadIdentity();
modelStack.PushMatrix();
modelStack.LoadIdentity();
modelStack.Translate(x, y, 0);
modelStack.Translate(x, y, z);
modelStack.Scale(size, size, size);
glUniform1i(shaderParameters[currentShader * U_TOTAL + U_TEXT_ENABLED], 1);
glUniform3fv(shaderParameters[currentShader * U_TOTAL + U_TEXT_COLOR], 1, &color.r);
@@ -647,13 +648,15 @@ void Scene3D::InitAttributeUI()
healthUiBackground->textureArray[0] = LoadTGA("Image//SP3_Texture//Background//health2.tga");
statUiBackground = MeshBuilder::GenerateQuad("uiBackground", Color(1, 1, 1), 1);
statUiBackground->textureArray[0] = LoadTGA("Image//SP3_Texture//Background//stats2.tga");
barBackground = MeshBuilder::GenerateQuad("barBackground", Color(0.5, 0.5, 0.5), 1);
bigClock = MeshBuilder::GenerateQuad("Clock", Color(1, 1, 1));
bigClock->textureArray[0] = LoadTGA("Image//SP3_Texture//Background//clockWOHands.tga");
clockHandH = MeshBuilder::GenerateQuad("Hour Hand", Color(1, 1, 1));
clockHandH->textureArray[0] = LoadTGA("Image//SP3_Texture//Background//clockWithHands.tga");
barBackground = MeshBuilder::GenerateQuad("barBackground", Color(0.5, 0.5, 0.5), 1);
barBackground->textureArray[0] = LoadTGA("Image//SP3_Texture//Background//border.tga");
bigClock = MeshBuilder::GenerateQuad("Clock", Color(1, 1, 1));
bigClock->textureArray[0] = LoadTGA("Image//SP3_Texture//Background//clockWOHands.tga");
clockHandH = MeshBuilder::GenerateQuad("Hour Hand", Color(1, 1, 1));
clockHandH->textureArray[0] = LoadTGA("Image//SP3_Texture//Background//clockWithHands.tga");
//statUiBackground->textureArray[0] = LoadTGA("Image//SP3_Texture//Background//health.tga");

pause = MeshBuilder::GenerateQuad("Pause", Color(1, 1, 1));
pause->textureArray[0] = LoadTGA("Image//SP3_Texture//Background//pause.tga");
Application::mother->Init();
Application::son->Init();
Application::daughter->Init();
@@ -666,6 +669,11 @@ void Scene3D::UpdateAttributeUI(const double& deltaTime)
Application::son->Update(deltaTime);
Application::daughter->Update(deltaTime);

Application::mother->boundStats();
Application::son->boundStats();
Application::daughter->boundStats();


if (InputManager::GetInstance().GetInputInfo().keyDown[INPUT_SHOW_ATTRIBUTES]) {
showStats = true;
}
@@ -682,6 +690,7 @@ void Scene3D::RenderAttributeUI()
{
if (!showStats)
{
glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
if (Application::mother->getHealth() > 0)
RenderMeshIn2D(healthBar, Application::mother->getHealth() / 20000, 0.5, -14.4, 10.2, 5, 0.5);
RenderMeshIn2D(barBackground, 5, 0.5, -14.4, 10.2, 5, 0.5);
@@ -691,7 +700,7 @@ void Scene3D::RenderAttributeUI()
if (Application::daughter->getHealth() > 0)
RenderMeshIn2D(healthBar, Application::daughter->getHealth() / 20000, 0.5, -14.4, 7.2, 5, 0.5);
RenderMeshIn2D(barBackground, 5, 0.5, -14.4, 7.2, 5, 0.5);
glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);

RenderMeshIn2D(healthUiBackground, 11, 11, -12.9, 9.5);

glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
@@ -700,7 +709,7 @@ void Scene3D::RenderAttributeUI()
{
glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
RenderTextOnScreen(fontList[FONT_CONSOLAS], "STATS", Color(1, 0, 0), 1, -2, 11);
glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);



if (Application::son->getProtein() > 0)
@@ -751,18 +760,18 @@ void Scene3D::RenderAttributeUI()
RenderMeshIn2D(hydrationBar, Application::daughter->getHydration() * 0.05f, 0.5, 5, -9.25, 5, 0.5);
RenderMeshIn2D(barBackground, 5, 0.5, 5, -9.25, 5, 0.5);

glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);

RenderMeshIn2D(statUiBackground, 30, 30);
glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
}
glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
RenderMeshIn2D(bigClock, 5, 5, 12, 8, 0, 0, 0, 0, 0, 0);
glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);

glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
RenderMeshIn2D(bigClock, 5, 5, 12, 8, 0, 0, 0, 0, 0, 0);
glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);

glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
RenderMeshIn2D(clockHandH, 2, 1, 11.98, 8.034, 1, -0.38, 0, 0, 0, Application::clock->getRotation());
glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
RenderMeshIn2D(clockHandH, 2, 1, 11.98, 8.034, 1, -0.38, 0, 0, 0, Application::clock->getRotation());
glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);

}

void Scene3D::InitInventoryUI()
@@ -772,8 +781,7 @@ void Scene3D::InitInventoryUI()
Inventory::GetInstance().setPos(Vector3(0, -10, 5));
Inventory::GetInstance().setSize(Vector3(30, 5, 0));

apple_item = MeshBuilder::GenerateQuad("apple_item", Color(0, 0, 0), 1);
apple_item->textureArray[0] = LoadTGA("Image//SP3_Texture//Item//item_apple.tga");

}

void Scene3D::UpdateInventoryUI(const double& deltaTime)
@@ -783,19 +791,62 @@ void Scene3D::UpdateInventoryUI(const double& deltaTime)

void Scene3D::RenderInventoryUI()
{
glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
RenderMeshIn2D(inventoryBar, Inventory::GetInstance().getSize().x, Inventory::GetInstance().getSize().y, Inventory::GetInstance().getPos().x, Inventory::GetInstance().getPos().y);
glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
if (!SceneManager::GetInstance().getIsChgScene()) {
glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
RenderMeshIn2D(inventoryBar, Inventory::GetInstance().getSize().x, Inventory::GetInstance().getSize().y, Inventory::GetInstance().getPos().x, Inventory::GetInstance().getPos().y);
glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
float xCoord = -13.1f;
for (map<string, Item*>::iterator it = ItemManager::GetInstance().itemMap.begin();
it != ItemManager::GetInstance().itemMap.end();
++it) {

for (map<string, Item*>::iterator it = ItemManager::GetInstance().itemMap.begin(); it != ItemManager::GetInstance().itemMap.end(); ++it) {
if (it->first == "Apple") {
ostringstream ss;
ss << it->second->getNum();
glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
RenderMeshIn2D(apple_item, 2, 2, -1.7, Inventory::GetInstance().getPos().y - 0.6, Inventory::GetInstance().getPos().z + 1);
if (it->first == "Milk") {
RenderTextOnScreen(fontList[FONT_CONSOLAS], ss.str(), Color(1, 1, 1), 1, xCoord, -12, 5);
}
if (it->first == "Meat") {
RenderTextOnScreen(fontList[FONT_CONSOLAS], ss.str(), Color(1, 1, 1), 1, xCoord + 3, -12, 5);
}
if (it->first == "Egg") {
RenderTextOnScreen(fontList[FONT_CONSOLAS], ss.str(), Color(1, 1, 1), 1, xCoord + 6, -12, 5);
}
if (it->first == "Water") {
RenderTextOnScreen(fontList[FONT_CONSOLAS], ss.str(), Color(1, 1, 1), 1, xCoord + 8.9, -12, 5);
}
if (it->first == "Apple") {
RenderTextOnScreen(fontList[FONT_CONSOLAS], ss.str(), Color(1, 1, 1), 1, xCoord + 11.8, -12, 5);
}
if (it->first == "Fish") {
RenderTextOnScreen(fontList[FONT_CONSOLAS], ss.str(), Color(1, 1, 1), 1, xCoord + 14.8, -12, 5);
}
if (it->first == "Cabbage") {
RenderTextOnScreen(fontList[FONT_CONSOLAS], ss.str(), Color(1, 1, 1), 1, xCoord + 17.6, -12, 5);
}
if (it->first == "Potato") {
RenderTextOnScreen(fontList[FONT_CONSOLAS], ss.str(), Color(1, 1, 1), 1, xCoord + 20.6, -12, 5);
}
if (it->first == "Corn") {
RenderTextOnScreen(fontList[FONT_CONSOLAS], ss.str(), Color(1, 1, 1), 1, xCoord + 23.5, -12, 5);
}
if (it->first == "Carrot") {
RenderTextOnScreen(fontList[FONT_CONSOLAS], ss.str(), Color(1, 1, 1), 1, xCoord + 26.5, -12, 5);
}
glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
}
}
}

void Scene3D::PauseMenu()
{
if (Application::GetInstance().bPaused == true)
{
RenderMeshIn2D(pause, 34, 25, 0, 0, 10);
}
}


bool Scene3D::getDistXY(Vector3 one, Vector3 two, float dist)
{
Vector3 temp = one - two;
@@ -846,4 +897,14 @@ void Scene3D::setZoomValues(float zoomAmount, float zoomOffsetX, float zoomOffse
this->zoomAmount = zoomAmount;
this->zoomOffsetX = zoomOffsetX;
this->zoomOffsetY = zoomOffsetY;
}

void Scene3D::UpdateDeath(const double& deltaTime)
{

}
void Scene3D::RenderDeath()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

}
@@ -229,11 +229,10 @@ class Scene3D : public Scene {
Mesh* healthUiBackground;
Mesh* statUiBackground;
Mesh* barBackground;
Mesh* bigClock;
Mesh* clockHandH;
Mesh* bigClock;
Mesh* clockHandH;
Mesh* inventoryBar;
Mesh* apple_item;

Mesh* pause;
bool showStats;

float zoomAmount;
@@ -264,7 +263,7 @@ class Scene3D : public Scene {
virtual void UpdateLights();
virtual void UpdateLightAttributes(unsigned int n);
virtual void UseShader(SHADER_TYPE shaderType);

virtual void PauseMenu();
//Rendering
virtual void SetToCameraView(Camera* camera, float zoom = 0.f);
virtual void Render();
@@ -278,7 +277,7 @@ class Scene3D : public Scene {
virtual void RenderSpriteAnimation(SpriteAnimation* sa, bool enableLight = false, bool invert = false);
//virtual void RenderMeshWithOutline(Mesh* mesh, bool enableLight, SHADER_TYPE shaderType = DEFAULT);
virtual void RenderText(Mesh* mesh, std::string text, Color color);
virtual void RenderTextOnScreen(Mesh* mesh, std::string text, Color color, float size, float x, float y);
virtual void RenderTextOnScreen(Mesh* mesh, std::string text, Color color, float size, float x, float y, float z = 0);

bool getDistXY(Vector3 one, Vector3 two, float dist);
bool getDistX(Vector3 one, Vector3 two, float dist);
@@ -294,7 +293,8 @@ class Scene3D : public Scene {
void UpdateInventoryUI(const double& deltaTime);
void RenderInventoryUI();


void UpdateDeath(const double& deltaTime);
void RenderDeath();
};

#endif
@@ -68,7 +68,15 @@ void Scene4FishingPond::Init() {
maxFish = 6;
fishCount = 0;
accumTime = 0.5f;
onElectricity = false;
player.onElectricity = false;
for (std::vector<FishObject *>::iterator it = m_foList.begin(); it != m_foList.end(); ++it)
{
FishObject *fo = (FishObject *)*it;
if (fo->active)
{
fo->active = false;
}
}
}

void Scene4FishingPond::InitMeshes() {
@@ -102,7 +110,7 @@ void Scene4FishingPond::InitMeshes() {
meshList[GEO_TROUT]->textureArray[0] = LoadTGA("Image//SP3_Texture//Collectibles//fish3.tga");

meshList[GEO_SHARK] = MeshBuilder::GenerateQuad("shark", Color(1, 1, 1), 0.4);
meshList[GEO_SHARK]->textureArray[0] = LoadTGA("Image//SP3_Texture//Background//shark.tga");
meshList[GEO_SHARK]->textureArray[0] = LoadTGA("Image//SP3_Texture//Background//shark2.tga");

}

@@ -193,11 +201,17 @@ void Scene4FishingPond::Update(const double& deltaTime) {
displacementOfFish(deltaTime);

if (SceneManager::GetInstance().getIsChgScene()) {
onElectricity = true;
player.onElectricity = true;
}
else
onElectricity = false;
player.onElectricity = false;

if (player.transform.GetPosition().y < 2)
{
SceneManager::GetInstance().chgCurrEnumScene(DEAD);

player.setVelocity(Vector3(0, 0, 0));
}
Scene3D::Update(deltaTime);
}

@@ -271,7 +285,7 @@ void Scene4FishingPond::RenderTileMap() {
glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
break;
case 23:
if (onElectricity == true)
if (player.onElectricity == true)
{
glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
RenderSpriteAnimation(spriteAnimationList[SPRITE_ELECTRICITY]);
@@ -404,7 +418,7 @@ void Scene4FishingPond::RenderFO(FishObject *fo)

void Scene4FishingPond::spawningOfFish(const double& deltaTime)
{
if (fishCount < maxFish && onElectricity)
if (fishCount < maxFish && player.onElectricity)
{
int randNo = Math::RandFloatMinMax(1, 10);
FishObject * fo = FetchFO();
@@ -462,15 +476,18 @@ void Scene4FishingPond::displacementOfFish(const double& deltaTime)
fo->active = false;
}
}
if (fo->type == FishObject::FT_SHARK)
{
if (Scene3D::getDistXY(player.transform.position, fo->pos, 1))
{
//kills player leads him to death screen
fishCount -= 1;
fo->active = false;
}
}
if (fo->type == FishObject::FT_SHARK)
{
if (Scene3D::getDistXY(player.transform.position, fo->pos, 1))
{
//kills player leads him to death screen
fishCount -= 1;
fo->active = false;
SceneManager::GetInstance().chgCurrEnumScene(DEAD);

player.setVelocity(Vector3(0, 0, 0));
}
}
if (fo->vel.x > 0)
{
fo->invert = true;
@@ -61,7 +61,7 @@ class Scene4FishingPond : public Scene3D {

float drop;
float accumTime;
bool onElectricity;

int Level;
int maxFish;
int fishCount;
@@ -52,19 +52,13 @@ void Scene6Well::Init() {
EnableFog(false);


tileMap.LoadFile("TileMap//Scene6WellSub.csv");
tileMap.LoadFile("TileMap//Scene6Well.csv");
tileMap.SetTileSize(1.0f);
InitPlayer();
InitCamera();

drop = 0.0f;
Level = 1;

BucketObject *bo = FetchBO();
bo->type = BucketObject::BT_WATER;
bo->scale.Set(2, 2, 1);
bo->pos.Set(16.5, 3, 0);
bo->vel.SetZero();

}

@@ -94,16 +88,6 @@ void Scene6Well::InitMeshes() {

meshList[GEO_BACKGROUND_4] = MeshBuilder::GenerateQuad("Background3", Color(1, 1, 1), 1);
meshList[GEO_BACKGROUND_4]->textureArray[0] = LoadTGA("Image//SP3_Texture//Background//water_well.tga");

meshList[GEO_WELL] = MeshBuilder::GenerateQuad("Background3", Color(1, 1, 1), 1);
meshList[GEO_WELL] ->textureArray[0] = LoadTGA("Image//SP3_Texture//Tiles//well.tga");

meshList[GEO_WELL2] = MeshBuilder::GenerateQuad("Background3", Color(1, 1, 1), 1);
meshList[GEO_WELL2]->textureArray[0] = LoadTGA("Image//SP3_Texture//Tiles//well2.tga");

meshList[GEO_BUCKET] = MeshBuilder::GenerateQuad("Background3", Color(1, 1, 1), 1);
meshList[GEO_BUCKET]->textureArray[0] = LoadTGA("Image//SP3_Texture//Collectibles//water_bucket.tga");

}

void Scene6Well::InitSpriteAnimations() {
@@ -132,26 +116,33 @@ void Scene6Well::InitSpriteAnimations() {
spriteAnimationList[SPRITE_PORTAL]->animation = new Animation();
spriteAnimationList[SPRITE_PORTAL]->animation->Set(0, 3, 0, 1.f, true);

spriteAnimationList[SPRITE_WATER] = MeshBuilder::GenerateSpriteAnimation("water", 1, 32);
spriteAnimationList[SPRITE_WATER]->textureArray[0] = LoadTGA("Image//SP3_Texture//Sprite_Animation//water.tga");
spriteAnimationList[SPRITE_WATER]->animation = new Animation();
spriteAnimationList[SPRITE_WATER]->animation->Set(0, 31, 0, 5.f, true);

spriteAnimationList[SPRITE_WATER] = MeshBuilder::GenerateSpriteAnimation("water", 1, 32);
spriteAnimationList[SPRITE_WATER]->textureArray[0] = LoadTGA("Image//SP3_Texture//Sprite_Animation//water.tga");
spriteAnimationList[SPRITE_WATER]->animation = new Animation();
spriteAnimationList[SPRITE_WATER]->animation->Set(0, 31, 0, 5.f, true);
}

void Scene6Well::InitPlayer() {


player.SetTileMap(tileMap);

for (int row = 0; row < tileMap.GetNumRows(); ++row) {
for (int col = 0; col < tileMap.GetNumColumns(); ++col) {
if (tileMap.map[row][col] == 99) {
player.transform.SetPosition(tileMap.GetTileSize() * col, tileMap.GetTileSize() * row, 0);
}
}

}
player.SetTileMap(tileMap);

for (int row = 0; row < tileMap.GetNumRows(); ++row) {
for (int col = 0; col < tileMap.GetNumColumns(); ++col) {
if (SceneManager::GetInstance().getPrevScene() == DRAGON)
{
if (tileMap.map[row][col] == 99) {
player.transform.SetPosition(tileMap.GetTileSize() * col, tileMap.GetTileSize() * row, 0);
}
}
if (SceneManager::GetInstance().getPrevScene() == APPLE)
{
if (tileMap.map[row][col] == 100) {
player.transform.SetPosition(tileMap.GetTileSize() * col, tileMap.GetTileSize() * row, 0);
}
}
}
}
}

void Scene6Well::InitCamera() {
@@ -181,16 +172,7 @@ void Scene6Well::Update(const double& deltaTime) {
void Scene6Well::Render() {

Scene3D::Render();
for (std::vector<BucketObject *>::iterator it = m_boList.begin(); it != m_boList.end(); ++it)
{
BucketObject *bo = (BucketObject *)*it;
if (bo->active)
{
glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
RenderBO(bo);
glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
}
}

SetToCameraView(&camera);
RenderTileMap();
RenderBackground();
@@ -246,15 +228,10 @@ void Scene6Well::RenderTileMap() {
RenderSpriteAnimation(spriteAnimationList[SPRITE_PORTAL]);
glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
break;
case 11:
RenderMesh(meshList[GEO_WELL]);
break;
case 12:
RenderMesh(meshList[GEO_WELL2]);
break;

case 88:
wellPos.Set(col * tileMap.GetTileSize(), row * tileMap.GetTileSize(), 20);
break;
RenderMesh(meshList[GEO_DIRT]); break;
}
modelStack.PopMatrix();
}
@@ -304,15 +281,15 @@ void Scene6Well::RenderBackground()

glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
modelStack.PushMatrix();
modelStack.Translate(wellPos.x + 0.55f, wellPos.y + 1.2f, wellPos.z-20);
modelStack.Translate(wellPos.x + 0.55f, wellPos.y + 2.2, wellPos.z-20);
modelStack.Scale(8.8, 6.2, 1);
RenderMesh(meshList[GEO_BACKGROUND_1], false);
modelStack.PopMatrix();
glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);

glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
modelStack.PushMatrix();
modelStack.Translate(wellPos.x + 0.55f, wellPos.y + 1.2f, wellPos.z - 21);
modelStack.Translate(wellPos.x + 0.55f, wellPos.y + 2.2, wellPos.z - 21);
modelStack.Scale(8.8, 6.2, 1);
RenderMesh(meshList[GEO_BACKGROUND_4], false);
modelStack.PopMatrix();
@@ -338,40 +315,3 @@ void Scene6Well::RenderBackground()
}


BucketObject* Scene6Well::FetchBO()
{
for (std::vector<BucketObject *>::iterator it = m_boList.begin(); it != m_boList.end(); ++it)
{
BucketObject *bo = (BucketObject *)*it;
if (!bo->active)
{
bo->active = true;
//m_objectCount;
return bo;
}
}
for (unsigned i = 0; i < 1; ++i)
{
BucketObject *bo = new BucketObject(BucketObject::BT_WATER);
m_boList.push_back(bo);
}
BucketObject *bo = m_boList.back();
bo->active = true;
//++m_objectCount;
return bo;
}

void Scene6Well::RenderBO(BucketObject *bo)
{
switch (bo->type)
{
case BucketObject::BT_WATER:
modelStack.PushMatrix();
modelStack.Translate(bo->pos.x, bo->pos.y, bo->pos.z);
modelStack.Scale(bo->scale.x, bo->scale.y, bo->scale.z);
RenderMesh(meshList[GEO_BUCKET], false);
modelStack.PopMatrix();
break;

}
}
@@ -21,9 +21,7 @@ class Scene6Well : public Scene3D {
GEO_BACKGROUND_2,
GEO_BACKGROUND_3,
GEO_BACKGROUND_4,
GEO_WELL,
GEO_WELL2,
GEO_BUCKET,

//Others
GEO_PLAYER,

@@ -63,7 +61,7 @@ class Scene6Well : public Scene3D {
Vector3 wellPos;
Vector3 bucketPos;

std::vector<BucketObject *> m_boList;


public:
//Constructor(s) & Destructor
@@ -78,9 +76,6 @@ class Scene6Well : public Scene3D {
virtual void RenderSub(){};
virtual void Exit();

void RenderBO(BucketObject *fo);

BucketObject* FetchBO();
};

#endif
@@ -52,13 +52,19 @@ void Scene6Well2::Init() {
EnableFog(false);


tileMap.LoadFile("TileMap//Scene6Well2.csv");
tileMap.LoadFile("TileMap//Scene6WellSub.csv");
tileMap.SetTileSize(1.0f);
InitPlayer();
InitCamera();

drop = 0.0f;
Level = 1;

BucketObject *bo = FetchBO();
bo->type = BucketObject::BT_WATER;
bo->scale.Set(2, 2, 1);
bo->pos.Set(16.5, 3, 0);
bo->vel.SetZero();
}

void Scene6Well2::InitMeshes() {
@@ -88,6 +94,14 @@ void Scene6Well2::InitMeshes() {
meshList[GEO_BACKGROUND_4] = MeshBuilder::GenerateQuad("Background3", Color(1, 1, 1), 1);
meshList[GEO_BACKGROUND_4]->textureArray[0] = LoadTGA("Image//SP3_Texture//Background//water_well.tga");

meshList[GEO_WELL] = MeshBuilder::GenerateQuad("Background3", Color(1, 1, 1), 1);
meshList[GEO_WELL]->textureArray[0] = LoadTGA("Image//SP3_Texture//Tiles//well.tga");

meshList[GEO_WELL2] = MeshBuilder::GenerateQuad("Background3", Color(1, 1, 1), 1);
meshList[GEO_WELL2]->textureArray[0] = LoadTGA("Image//SP3_Texture//Tiles//well2.tga");

meshList[GEO_BUCKET] = MeshBuilder::GenerateQuad("Background3", Color(1, 1, 1), 1);
meshList[GEO_BUCKET]->textureArray[0] = LoadTGA("Image//SP3_Texture//Collectibles//water_bucket.tga");
}

void Scene6Well2::InitSpriteAnimations() {
@@ -120,14 +134,10 @@ void Scene6Well2::InitSpriteAnimations() {
spriteAnimationList[SPRITE_WATER]->textureArray[0] = LoadTGA("Image//SP3_Texture//Sprite_Animation//water.tga");
spriteAnimationList[SPRITE_WATER]->animation = new Animation();
spriteAnimationList[SPRITE_WATER]->animation->Set(0, 31, 0, 5.f, true);



}

void Scene6Well2::InitPlayer() {


player.SetTileMap(tileMap);

for (int row = 0; row < tileMap.GetNumRows(); ++row) {
@@ -172,7 +182,16 @@ void Scene6Well2::Render() {
RenderBackground();
RenderPlayer();
RenderText();

for (std::vector<BucketObject *>::iterator it = m_boList.begin(); it != m_boList.end(); ++it)
{
BucketObject *bo = (BucketObject *)*it;
if (bo->active)
{
glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
RenderBO(bo);
glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
}
}
}

void Scene6Well2::RenderTileMap() {
@@ -219,6 +238,18 @@ void Scene6Well2::RenderTileMap() {
RenderSpriteAnimation(spriteAnimationList[SPRITE_PORTAL]);
glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
break;

case 11:
glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
RenderMesh(meshList[GEO_WELL]);
glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
break;
case 12:
glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
RenderMesh(meshList[GEO_WELL2]);
glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
break;

case 88:
wellPos.Set(col * tileMap.GetTileSize(), row * tileMap.GetTileSize(), 20);
glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
@@ -274,16 +305,16 @@ void Scene6Well2::RenderBackground()

glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
modelStack.PushMatrix();
modelStack.Translate(wellPos.x, wellPos.y + 2.2f, wellPos.z);
modelStack.Scale(7.8, 6.2, 1);
modelStack.Translate(wellPos.x - 0.45, wellPos.y + 1.1f, wellPos.z);
modelStack.Scale(8.8, 6.2, 1);
RenderMesh(meshList[GEO_BACKGROUND_1], false);
modelStack.PopMatrix();
glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);

glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
modelStack.PushMatrix();
modelStack.Translate(wellPos.x, wellPos.y + 2.2f, -2);
modelStack.Scale(7.8, 6.2, 1);
modelStack.Translate(wellPos.x - 0.45, wellPos.y + 1.1f, -2);
modelStack.Scale(8.8, 6.2, 1);
RenderMesh(meshList[GEO_BACKGROUND_4], false);
modelStack.PopMatrix();
glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
@@ -307,4 +338,40 @@ void Scene6Well2::RenderBackground()
}
}

BucketObject* Scene6Well2::FetchBO()
{
for (std::vector<BucketObject *>::iterator it = m_boList.begin(); it != m_boList.end(); ++it)
{
BucketObject *bo = (BucketObject *)*it;
if (!bo->active)
{
bo->active = true;
//m_objectCount;
return bo;
}
}
for (unsigned i = 0; i < 1; ++i)
{
BucketObject *bo = new BucketObject(BucketObject::BT_WATER);
m_boList.push_back(bo);
}
BucketObject *bo = m_boList.back();
bo->active = true;
//++m_objectCount;
return bo;
}

void Scene6Well2::RenderBO(BucketObject *bo)
{
switch (bo->type)
{
case BucketObject::BT_WATER:
modelStack.PushMatrix();
modelStack.Translate(bo->pos.x, bo->pos.y, bo->pos.z);
modelStack.Scale(bo->scale.x, bo->scale.y, bo->scale.z);
RenderMesh(meshList[GEO_BUCKET], false);
modelStack.PopMatrix();
break;

}
}
@@ -23,7 +23,9 @@ class Scene6Well2 : public Scene3D {
GEO_BACKGROUND_4,
//Others
GEO_PLAYER,

GEO_WELL,
GEO_WELL2,
GEO_BUCKET,
NUM_GEOMETRY,
};

@@ -58,7 +60,7 @@ class Scene6Well2 : public Scene3D {
int Level;

Vector3 wellPos;

std::vector<BucketObject *> m_boList;
public:
//Constructor(s) & Destructor
Scene6Well2();
@@ -72,6 +74,9 @@ class Scene6Well2 : public Scene3D {
virtual void RenderSub(){};
virtual void Exit();

void RenderBO(BucketObject *fo);

BucketObject* FetchBO();
};

#endif
@@ -211,7 +211,6 @@ void Scene7Apple::Render() {
SetToCameraView(&camera);
Scene3D::Render();
Scene3D::setZoomValues(2, 0, -2);
//if (SceneManager::GetInstance().getSubScene())
if (SceneManager::GetInstance().getIsChgScene())
SetToCameraView(&camera, 1);
else
@@ -229,7 +228,6 @@ void Scene7Apple::RenderSub() {
RenderBasket();
}
void Scene7Apple::RenderTileMap() {

float cameraAspectRatio = static_cast<float>(camera.aspectRatio.x) / static_cast<float>(camera.aspectRatio.y);
float cameraWidth = cameraAspectRatio * camera.GetOrthoSize();

@@ -226,13 +226,13 @@ void Scene8Cabbage::RenderTileMap() {
break;
case 16:
glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
modelStack.Translate(0, -0.5f, -1);
modelStack.Translate(0, -0.5f, 1);
RenderMesh(meshList[GEO_CARROT]);
glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
break;
case 17:
glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
modelStack.Translate(0, -0.2f, -1);
modelStack.Translate(0, -0.2f, 1);
RenderMesh(meshList[GEO_POTATO]);
glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
break;
@@ -7,7 +7,6 @@
#include "TileMap.h"
#include "Camera2D.h"
#include "PlayerSS.h"
#include "ItemManager.h"

class Scene8Cabbage : public Scene3D {

@@ -50,9 +49,6 @@ class Scene8Cabbage : public Scene3D {
void InitCamera();
void InitPlayer();

Item* FetchCabbages();
void RenderCabbages(Item* item);

void RenderTileMap();
void RenderPlayer();
void RenderBackground();
@@ -74,7 +70,7 @@ class Scene8Cabbage : public Scene3D {
//Virtual Function(s)
virtual void Init();
virtual void Update(const double& deltaTime);
virtual void UpdateSub(const double& deltaTime){};
virtual void UpdateSub(const double& deltaTime){};
virtual void Render();
virtual void RenderSub(){};
virtual void Exit();
@@ -7,7 +7,6 @@
#include "TileMap.h"
#include "Camera2D.h"
#include "PlayerSS.h"
#include "ItemManager.h"

class Scene9Wheat : public Scene3D {

@@ -48,9 +47,6 @@ class Scene9Wheat : public Scene3D {
void InitCamera();
void InitPlayer();

Item* FetchWheats();
void RenderWheats(Item* item);

void RenderTileMap();
void RenderPlayer();
void RenderBackground();
@@ -72,7 +68,7 @@ class Scene9Wheat : public Scene3D {
//Virtual Function(s)
virtual void Init();
virtual void Update(const double& deltaTime);
virtual void UpdateSub(const double& deltaTime){};
virtual void UpdateSub(const double& deltaTime){};
virtual void Render();
virtual void RenderSub(){};
virtual void Exit();
@@ -9,6 +9,8 @@
#include "Scene7Apple.h"
#include "Scene8Cabbage.h"
#include "Scene9Wheat.h"
#include "DeathScreen.h"
#include "LoseScreen.h"
#include "Sound.h"

SceneManager::~SceneManager()
@@ -23,6 +25,8 @@ void SceneManager::Init()
chgScene = CHG_NONE;
chgSceneMode = false;

sceneList[LOSE] = new LoseScreen;
sceneList[DEAD] = new DeathScreen;
sceneList[HOME] = new Scene1House;
sceneList[COW] = new Scene2Cow;
sceneList[CHICKEN] = new Scene3Chicken;
@@ -33,7 +37,8 @@ void SceneManager::Init()
sceneList[CABBAGE] = new Scene8Cabbage;
sceneList[WHEAT] = new Scene9Wheat;

//subList[SUB_WELL] = new <CPP_NAME>
//sceneList[SUB_WELL] = new Scene6Well2
sceneList[SUB_WELL] = new Scene6Well2;

setPrevScene(WHEAT);
sceneType = HOME;
@@ -76,6 +81,11 @@ void SceneManager::Init()
sceneList[i]->Init();
}

for (int i = TOTAL_SCENES + 1; i < TOTAL_FINALSCENES; ++i)
{
sceneList[i]->Init();
}

}

void SceneManager::chgCurrEnumScene(SCENE_TYPE type)
@@ -122,10 +132,8 @@ bool SceneManager::getIsChgScene() const

void SceneManager::Update(double dt)
{
if (subType == SUB_NONE)
sceneList[sceneType]->Update(dt);
//else
// subList[subType]->Update(dt);
sceneList[sceneType]->Update(dt);

if (chgScene != CHG_NONE)
sceneList[sceneType]->UpdateSub(dt);

@@ -171,17 +179,15 @@ void SceneManager::Update(double dt)

void SceneManager::Render()
{
if (subType == SUB_NONE)
sceneList[sceneType]->Render();
//else
// subList[subType]->Render(dt);
sceneList[sceneType]->Render();

if (chgScene != CHG_NONE)
sceneList[sceneType]->RenderSub();
}

void SceneManager::Exit()
{
for (int i = 0; i < TOTAL_SCENES; ++i)
for (int i = 0; i < TOTAL_FINALSCENES; ++i)
{
if (sceneList[i])
{
@@ -8,6 +8,8 @@

enum SCENE_TYPE
{
LOSE,
DEAD,
HOME,
COW,
CHICKEN,
@@ -17,17 +19,12 @@ enum SCENE_TYPE
APPLE,
CABBAGE,
WHEAT,
TOTAL_SCENES
};

enum SUBSCENE_TYPE
{
//for those scenes that doesn't need a new scene don't put here
SUB_NONE,
SUB_COW,
SUB_CHICKEN,
TOTAL_SCENES,

SUB_WELL,
TOTAL_SUBSCENES

TOTAL_FINALSCENES
};

enum CHANGESCENE_TYPE
@@ -52,9 +49,6 @@ class SceneManager : public Singleton<SceneManager>
void setPrevScene(SCENE_TYPE prev);
SCENE_TYPE getPrevScene() const;

void setSubScene(SUBSCENE_TYPE type){};
SUBSCENE_TYPE getSubScene() const { return subType; };

void setChgScene(CHANGESCENE_TYPE type);
CHANGESCENE_TYPE getChgScene() const;

@@ -71,10 +65,8 @@ class SceneManager : public Singleton<SceneManager>
SceneManager();
SCENE_TYPE sceneType;
SCENE_TYPE prevScene;
SUBSCENE_TYPE subType;
CHANGESCENE_TYPE chgScene;
Scene3D* sceneList[TOTAL_SCENES];
Scene3D* subList[TOTAL_SUBSCENES];
Scene3D* sceneList[TOTAL_FINALSCENES];

bool Home;
bool World;
@@ -27,7 +27,7 @@ enum TILE_TYPE {
TILE_DAUGHTER = 20,
TILE_MOTHER,
TILE_SON,

TILE_ELECTRIC,

TILE_CENTRE = 88,

@@ -1,88 +1,94 @@
#include "Time.h"

Time::Time()
:
hour(0),
minute(0.f),
day(1),
active(false),
rotation(0)
:
hour(0),
minute(0.f),
day(1),
active(false),
rotation(0)
{}

Time::Time(int h, double m)
:
hour(h),
minute(m),
day(1),
active(false),
rotation(0)
:
hour(h),
minute(m),
day(1),
active(false),
rotation(0)
{}

Time::Time(int h, double m, int d, bool a)
:
hour(h),
minute(m),
day(d),
active(a),
rotation(0)
:
hour(h),
minute(m),
day(d),
active(a),
rotation(0)
{}

Time::~Time()
{}

void Time::UpdateTime(const double& deltaTime)
{
if (active)
{
minute += 4.5 * deltaTime;
rotation = -hour * 30;
if (minute > 60)
{
hour++;
minute = 0;
}
if (active)
{
minute += 1.8 * deltaTime;
rotation = float(-hour * 30);
if (minute > 60)
{
hour++;
minute = 0;
}

if (hour > 9)
{
hour = minute = 0;
day++;
}
}
if (hour >= 9)
{
hour = minute = 0;
day++;
}
}
}

float Time::getRotation()
{
return rotation;
return rotation;
}

int Time::getHour()
{
return hour;
return hour;
}

double Time::getMinute()
{
return minute;
return minute;
}

int Time::getDay()
{
return day;
return day;
}

bool Time::getActive()
{
return active;
return active;
}

Time Time::getTime()
{
return Time(hour, minute, day, active);
return Time(hour, minute, day, active);
}

void Time::setTime(int h, double min)
{
hour = h;
minute = min;
}

std::ostream & operator<<(std::ostream& os, Time& time)
{
os.precision(3);
os << time.getHour() << "hr, " << time.getMinute() << "mins, " << time.getDay() << "days, " << time.getActive() << std::endl;
return os;
os.precision(3);
os << time.getHour() << "hr, " << time.getMinute() << "mins, " << time.getDay() << "days, " << time.getActive() << std::endl;
return os;
}
@@ -0,0 +1,30 @@
0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
3,,,,,,,,,,,,,,,,99,,,,,,,,,,,,,,,,,9
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
@@ -0,0 +1,30 @@
0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
3,,,,,,,,,,,,,,,,99,,,,,,,,,,,,,,,,,9
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
@@ -21,7 +21,7 @@
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,2,,,,,,2,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,2,8,8,8,8,8,2,,,,,,,,,,,,,,,,
3,99,,,,,,,,,,,,,,,,,,2,2,8,8,8,8,8,2,2,,,,,,,,,,,,,,100,9
3,99,,,,,,,,,,,,,,,,,,,2,8,8,8,8,8,2,,,,,,,,,,,,,,,100,9
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,88,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
@@ -3,7 +3,7 @@
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,2,,,,,,,2,,,,,,,,,,,,,
,,,,,,,,,,,8,99,1,,,,,,,1,,,,,,,,,,,,,
,,,,,,,,,,,,99,1,,,,,,,1,,,,,,,,,,,,,
1,2,2,2,2,2,2,2,2,2,2,2,2,1,,,88,,,,1,2,2,2,2,2,2,2,2,2,2,2,2,2
1,1,1,1,1,1,1,1,1,1,1,1,1,11,12,12,12,12,12,12,11,1,1,1,1,1,1,1,1,1,1,1,1,1
1,1,1,1,1,1,1,1,1,1,1,1,1,11,12,12,12,12,12,12,11,1,1,1,1,1,1,1,1,1,1,1,1,1
BIN +120 KB (120%) SP3 Framework/Debug/Base.exe
Binary file not shown.
BIN +0 Bytes (100%) SP3 Framework/Debug/Common.lib
Binary file not shown.