init project
authorwatkinsr <ryanwatkins54@gmail.com>
Fri, 12 Jun 2020 22:26:49 +0000 (23:26 +0100)
committerwatkinsr <ryanwatkins54@gmail.com>
Fri, 12 Jun 2020 22:26:49 +0000 (23:26 +0100)
73 files changed:
Makefile [new file with mode: 0644]
README.org [new file with mode: 0644]
src/Battle.cpp [new file with mode: 0644]
src/Battle.h [new file with mode: 0644]
src/BattleManager.cpp [new file with mode: 0644]
src/BattleManager.h [new file with mode: 0644]
src/ClassDiagram.cd [new file with mode: 0644]
src/CollisionRect.cpp [new file with mode: 0644]
src/CollissionRect.h [new file with mode: 0644]
src/ConsoleDebug.cpp [new file with mode: 0644]
src/ConsoleDebug.h [new file with mode: 0644]
src/Enemies.cpp [new file with mode: 0644]
src/Enemies.h [new file with mode: 0644]
src/Enemy.cpp [new file with mode: 0644]
src/Enemy.h [new file with mode: 0644]
src/EntityManager.cpp [new file with mode: 0644]
src/EntityManager.h [new file with mode: 0644]
src/Environment.cpp [new file with mode: 0644]
src/Environment.h [new file with mode: 0644]
src/EventManager.cpp [new file with mode: 0644]
src/EventManager.h [new file with mode: 0644]
src/FileManagement.cpp [new file with mode: 0644]
src/FileManagement.h [new file with mode: 0644]
src/GameLoop.cpp [new file with mode: 0644]
src/GameLoop.h [new file with mode: 0644]
src/GameMenu.cpp [new file with mode: 0644]
src/GameMenu.h [new file with mode: 0644]
src/Interaction.cpp [new file with mode: 0644]
src/Interaction.h [new file with mode: 0644]
src/Items.cpp [new file with mode: 0644]
src/Items.h [new file with mode: 0644]
src/Loot.cpp [new file with mode: 0644]
src/Loot.h [new file with mode: 0644]
src/Main.cpp [new file with mode: 0644]
src/MainCharacter.cpp [new file with mode: 0644]
src/MainCharacter.h [new file with mode: 0644]
src/MainMenu.cpp [new file with mode: 0644]
src/MainMenu.h [new file with mode: 0644]
src/Map.cpp [new file with mode: 0644]
src/Map.h [new file with mode: 0644]
src/MapManager.cpp [new file with mode: 0644]
src/MapManager.h [new file with mode: 0644]
src/NPC.cpp [new file with mode: 0644]
src/NPC.h [new file with mode: 0644]
src/NPCManager.cpp [new file with mode: 0644]
src/NPCManager.h [new file with mode: 0644]
src/PlayerManager.cpp [new file with mode: 0644]
src/PlayerManager.h [new file with mode: 0644]
src/Point.cpp [new file with mode: 0644]
src/Point.h [new file with mode: 0644]
src/Quests.cpp [new file with mode: 0644]
src/Quests.h [new file with mode: 0644]
src/SDL_Font_Setup.cpp [new file with mode: 0644]
src/SDL_Font_Setup.h [new file with mode: 0644]
src/SDL_Keyboard.cpp [new file with mode: 0644]
src/SDL_Keyboard.h [new file with mode: 0644]
src/SDL_Setup.cpp [new file with mode: 0644]
src/SDL_Setup.h [new file with mode: 0644]
src/SDL_Sound.cpp [new file with mode: 0644]
src/SDL_Sound.h [new file with mode: 0644]
src/SFXManager.cpp [new file with mode: 0644]
src/SFXManager.h [new file with mode: 0644]
src/Sprite.cpp [new file with mode: 0644]
src/Sprite.h [new file with mode: 0644]
src/Text.cpp [new file with mode: 0644]
src/Text.h [new file with mode: 0644]
src/TextManager.cpp [new file with mode: 0644]
src/TextManager.h [new file with mode: 0644]
src/Tree.cpp [new file with mode: 0644]
src/Tree.h [new file with mode: 0644]
src/resource.h [new file with mode: 0644]
src/stdafx.cpp [new file with mode: 0644]
src/stdafx.h [new file with mode: 0644]

diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..eb17a50
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,28 @@
+TARGET_EXEC ?= rpg
+
+BUILD_DIR ?= ./build
+SRC_DIRS ?= ./src
+
+SRCS := $(shell find $(SRC_DIRS) -name *.cpp)
+OBJS := $(SRCS:%=$(BUILD_DIR)/%.o)
+DEPS := $(OBJS:.o=.d)
+
+CPPFLAGS ?= `sdl2-config --cflags --libs` -lm -lSDL2_image -lSDL2 -lSDL2_mixer -lSDL2_ttf
+
+$(BUILD_DIR)/$(TARGET_EXEC): $(OBJS)
+       $(CC) $(OBJS) -o $@ $(LDFLAGS) -lstdc++ -lm -lSDL2_image -lSDL2 -lSDL2_mixer -lSDL2_ttf
+
+# c++ source
+$(BUILD_DIR)/%.cpp.o: %.cpp
+       $(MKDIR_P) $(dir $@)
+       $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
+
+
+.PHONY: clean
+
+clean:
+       $(RM) -r $(BUILD_DIR)
+
+-include $(DEPS)
+
+MKDIR_P ?= mkdir -p
diff --git a/README.org b/README.org
new file mode 100644 (file)
index 0000000..991e1fe
--- /dev/null
@@ -0,0 +1,8 @@
+* Description
+2D RPG Game coded with SDL Libraries in C++
+
+* Dependencies
+- SDL2-devel
+- SDL2_image-deel
+- SDL2_mixer-devel
+- SDL2_TTF-devel
diff --git a/src/Battle.cpp b/src/Battle.cpp
new file mode 100644 (file)
index 0000000..a089067
--- /dev/null
@@ -0,0 +1,79 @@
+#include "stdafx.h"
+#include "Battle.h"
+
+CBattle::CBattle(CSDL_Setup* passed_SDL_Setup, int *passed_MouseX, int *passed_MouseY, float *passed_CameraX, float *passed_CameraY)
+{
+       csdl_setup = passed_SDL_Setup;
+       CameraX = passed_CameraX;
+       CameraY = passed_CameraY;
+       MouseX = passed_MouseX;
+       MouseY = passed_MouseY;
+
+       DiaBox = new Sprite(csdl_setup->GetRenderer(),"res/data/dia_box_norm.png",0,385,640,100,CameraX,CameraY, CollisionRect());
+       En_HP = new Sprite(csdl_setup->GetRenderer(),"res/data/hp_enem.png",10,-10,24,4,CameraX,CameraY, CollisionRect());
+       dialogIcon = new Sprite(csdl_setup->GetRenderer(),"res/data/menu_select.png",32,426,13,13,CameraX,CameraY, CollisionRect());
+       isBattle = false;
+       count = 0;
+}
+
+CBattle::~CBattle()
+{
+
+}
+
+
+bool CBattle::CheckBattle(vector <CEnemy*> *Enemies, MainCharacter* Player, Sprite* playerSprite)
+{
+       int diffX = 250;
+       int diffY = 250;
+       int EnemyVectSize = (*Enemies).size();
+       
+               for (vector<CEnemy*>::iterator i = (*Enemies).begin(); i != (*Enemies).end(); ++i)
+               {
+                       count++;
+
+                       if (count == (*Enemies).size())
+                       {
+                               count = 0;
+                       }
+                       if (playerSprite->GetSpriteCameraX() - (*i)->GetSpriteCameraX() < 60 && playerSprite->GetSpriteCameraX() - (*i)->GetSpriteCameraX() > -60 
+                               && playerSprite->GetSpriteCameraY() - (*i)->GetSpriteCameraY() < 60 && playerSprite->GetSpriteCameraY() - (*i)->GetSpriteCameraY() > -60)
+                       {
+                               int testEnemySpriteX = (*i)->GetSpriteCameraX();
+                               int testEnemySpriteY = (*i)->GetSpriteCameraY();
+                               int testPlayerSpriteX = playerSprite->GetSpriteCameraX();
+                               int testPlayerSpriteY = playerSprite->GetSpriteCameraY();
+
+                               cout << "Enemy sprite loc: " << (*i)->GetSpriteCameraX() << " " <<  (*i)->GetSpriteCameraY() << endl;
+                               cout << "Player sprite loc: " << playerSprite->GetSpriteCameraX() <<  " " << playerSprite->GetSpriteCameraY() << endl;
+
+                               enemyBattleNum = count-1;
+                               if (enemyBattleNum == -1)
+                               {
+                                       enemyBattleNum = 0;
+                               }
+                               diffX = playerSprite->GetSpriteCameraX()-30 - (*i)->GetSpriteCameraX(); 
+                               diffY = playerSprite->GetSpriteCameraY()-50 - (*i)->GetSpriteCameraY();
+                       }
+               }
+
+       if (diffX < 30 && diffX > -30 && diffY < 30 && diffY > -30)
+       {
+               isBattle = true;
+               return isBattle;
+       }
+       else
+               isBattle = false;
+               return isBattle;
+}
+
+
+
+void CBattle::DrawEnemies(vector <CEnemy*> Enemies)
+{
+       for (vector<CEnemy*>::iterator i = Enemies.begin(); i != Enemies.end(); ++i)
+       {
+               (*i)->Draw();
+       }
+       En_HP->Draw();
+}
diff --git a/src/Battle.h b/src/Battle.h
new file mode 100644 (file)
index 0000000..f207c47
--- /dev/null
@@ -0,0 +1,49 @@
+#pragma once
+
+#ifndef BATTLE_H
+#define BATTLE_H
+
+#include "stdafx.h"
+#include "Sprite.h"
+#include "SDL_Font_Setup.h"
+#include "SDL_Setup.h"
+#include "Interaction.h"
+#include "MainCharacter.h"
+#include "TextManager.h"
+#include "EventManager.h"
+
+class CBattle
+{
+public:
+       CBattle(CSDL_Setup* passed_SDL_Setup, int *passed_MouseX, int *passed_MouseY, float *passed_CameraX, float *passed_CameraY);
+       ~CBattle();
+       bool CheckBattle(vector <CEnemy*> *Enemies, MainCharacter* Player, Sprite* playerSprite);
+       void DrawEnemies(vector <CEnemy*> Enemies);
+
+       Sprite* GetDiaBoxSprite(){return DiaBox;};
+       Sprite* GetEnHP(){return En_HP;};
+       Sprite* GetDialogIcon(){return dialogIcon;};
+       int GetEnemyNum(){return enemyBattleNum;};
+
+private:
+       Sprite* DiaBox;
+       Sprite* En_HP;
+       Sprite* dialogIcon;
+       CSDL_Setup* csdl_setup;
+
+       int *MouseX;
+       int *MouseY;
+       float *CameraX;
+       float *CameraY;
+       int count;
+       int enemyBattleNum;
+
+       bool isBattle;
+       bool x;
+       bool keyDown;
+       
+       bool stopAnimation;
+
+};
+
+#endif
diff --git a/src/BattleManager.cpp b/src/BattleManager.cpp
new file mode 100644 (file)
index 0000000..fcdfbd4
--- /dev/null
@@ -0,0 +1,265 @@
+#include "stdafx.h"
+#include "BattleManager.h"
+
+const int ATTACKRANGE = 40;
+
+BattleManager::BattleManager(CSDL_Setup* passed_CSDL_Setup, int *passed_MouseX, int *passed_MouseY){
+       csdl_setup = passed_CSDL_Setup;
+       mouseX = passed_MouseX;
+       mouseY = passed_MouseY;
+
+       dialogSuccess = false;
+       runOnce = false;
+       EnterPressed = false;
+       firstDialog = false;
+       secondDialog = false;
+       thirdDialog = false;
+       battleSuccessDialogue = false;
+       battle_dialogue = false;
+       DialogueEnd = false;
+       allowedtoDraw = true;
+       text = new CSDLFont_Setup(csdl_setup);
+       dialog = new TextManager(csdl_setup);
+       kill_count = 0;
+       enemynum = 0;
+       battleSuccessDialogue = true;
+       killSuccess = false;
+}
+
+
+BattleManager::~BattleManager(void){
+       delete text;
+       delete dialog;
+}
+
+//should create a vector of Text, that has the first line of battle log, the second line and the third.
+//If the first dialog is true, then add to the vector the first dialog, however, if the second dialog has been activated, 
+//replace the first dialog with the text for the second dialog and do the same process for the next dialog.
+void BattleManager::InitBattleLog(){
+       if (firstDialog){
+               dialogMsgs.clear();
+               Text* firstLine = new Text(DIALOGXLOC, FIRSTLINEY, "A wild enemy appeared!");
+               Text* secondLine = new Text(DIALOGXLOC, SECONDLINEY, "Press enter to continue.");
+               dialogMsgs.push_back(*firstLine);
+               dialogMsgs.push_back(*secondLine);
+       }
+       if (secondDialog){
+               dialogMsgs.clear();
+               Text* firstLine = new Text(DIALOGXLOC, FIRSTLINEY, "What would you like to do?");
+               Text* secondLine = new Text(DIALOGXLOC, SECONDLINEY, "Attack");
+               Text* thirdLine = new Text(DIALOGXLOC, THIRDLINEY, "Flee");
+               dialogMsgs.push_back(*firstLine);
+               dialogMsgs.push_back(*secondLine);
+               dialogMsgs.push_back(*thirdLine);
+       }
+       if (thirdDialog){
+               dialogMsgs.clear();
+               Text* firstLine = new Text(DIALOGXLOC, FIRSTLINEY, "Your attack was successful!");
+               Text* secondLine = new Text(DIALOGXLOC, SECONDLINEY, "Press enter to continue.");
+               dialogMsgs.push_back(*firstLine);
+               dialogMsgs.push_back(*secondLine);
+       }
+}
+
+void BattleManager::SetKillCount(int p_kill_amount){
+       kill_count = p_kill_amount;
+}
+
+int BattleManager::GetKillCount(){
+       return kill_count;
+}
+
+void BattleManager::HandleBattle(MainCharacter* player, Sprite* playerSprite, Sprite* diaBoxSprite,
+               Sprite* enHP, CInteraction* interaction, CEnvironment* pub, Sprite* dialogIcon, vector<CEnemy*>*enemies, int enemyBattleNum){
+               enemynum = enemyBattleNum;
+               firstDialog = true;
+               DialogueEnd = false;
+               
+               int enemyVectSize = enemies->size();
+               EventManager event(csdl_setup, mouseX, mouseY);
+               InitBattleLog();
+
+               while (firstDialog == true)
+               {
+                       dialog->DrawDialog(dialogMsgs, FONTFILE, text, 10);
+                       event.DrawGame(player, playerSprite, enHP, pub, *enemies);
+                       event.BattleDialogEvent(dialogMsgs, interaction, dialogIcon, diaBoxSprite);
+                       //get user press
+                       if (interaction->checkEnter(dialogIcon, 640, 480) == 1 || interaction->checkEnter(dialogIcon, 640, 480) == 2){
+                       secondDialog = true;
+                       firstDialog = false;
+                       }
+               }
+               InitBattleLog();
+               while (secondDialog == true)
+               {
+                       dialog->DrawDialog(dialogMsgs, FONTFILE, text,10);
+                       event.DrawGame(player, playerSprite, enHP, pub, *enemies);
+                       event.BattleDialogEvent(dialogMsgs, interaction, dialogIcon, diaBoxSprite);
+
+                                       if (interaction->checkEnter(dialogIcon, 640, 480) == 1)
+                                       {
+                                               //DoDamageToEnemy(player, player->GetPlayerSprite(), enHP, pub, enemies, enemyBattleNum, sounds);
+                                       }
+                                               //this tests to see if the vector has dropped by 1, aka the enemy has been killed.
+                                               if ((*enemies).size() != enemyVectSize)
+                                               {
+
+                                                       secondDialog = false;
+                                                       thirdDialog = false;
+                                                       battleSuccessDialogue = true;
+                                               }
+                                       
+                                       else if (dialogIcon->GetY() >= 446 && dialogIcon->GetY() <= 466)
+                                       {
+                                               //open invent
+                                       }
+               
+
+                       else if (thirdDialog == true)
+                       {
+                               //if (result)
+                               //{
+                                       DialogueEnd = true;
+                               //}
+                       }
+               }
+                       while (battleSuccessDialogue == true && DialogueEnd == false)
+                       {
+                               string xp_str = to_string(addedXPFromBattle);
+                               xp_str.append(" XP gained");
+                               cout << "XP for Player: " << player->GetXP() << endl;           
+                               //if (result)
+                               {
+                               kill_count++;
+                               cout << "Kill count now: " << kill_count << endl;
+                               battleSuccessDialogue = false;
+                               DialogueEnd = true;
+                                       
+                               }
+                       }
+               }
+
+//if the player is in the right place to hit and space is pressed, then do damage.
+void BattleManager::HandlePlayerAttack(MainCharacter* player, Sprite* playerSprite, Sprite* enHP, CEnvironment* pub, vector<CEnemy*> *enemies, SFXManager* sounds){
+       count = 0;
+       float playerX = (float)playerSprite->GetSpriteCameraX() - 20.0f;
+       float playerY = (float)playerSprite->GetSpriteCameraY() - 40.0f;
+       
+
+       for (vector<CEnemy*>::iterator i = (*enemies).begin(); i != (*enemies).end(); ++i)
+       {
+               float enemyX = (float)(*i)->GetSpriteCameraX();
+               float enemyY = (float)(*i)->GetSpriteCameraY();
+
+               float rangeBetweenX = playerX - enemyX;
+               float rangeBetweenY = playerY - enemyY;
+               count++;
+               if (enemyX-playerX < ATTACKRANGE && enemyX-playerX > 0 && enemyY-playerY < 40 && enemyY-playerY > -40){
+                       switch (csdl_setup->GetMainEvent()->type)
+                       {
+                       case SDL_KEYDOWN:
+
+                               switch(csdl_setup->GetMainEvent()->key.keysym.sym){
+                               case SDLK_SPACE:
+                                       if(count!= 1){
+                                               cout << "the EnemyVectNumber is wrong!" << endl;
+                                       }
+                                       if (!killSuccess){
+                                               enemynum = count-1;
+                                               DoDamageToEnemy(player, playerSprite, enHP, pub,enemies, enemynum, sounds);
+                                       }
+                               }
+                       }
+               }
+               
+               if (killSuccess){
+                       kill_count++;
+                       killSuccess = false;
+                       break;
+               }
+       }
+}
+
+//if the enemy is to the left of player, then take player damage.
+void BattleManager::HandleEnemyMeleeAttack(MainCharacter* player, Sprite* playerSprite, Sprite* enHP, CEnvironment* pub, vector<CEnemy*> *enemies, SFXManager* sounds){
+       count = 0;
+       float player_x = (float)playerSprite->GetSpriteCameraX() - 20.0f;
+       float player_y = (float)playerSprite->GetSpriteCameraY() - 40.0f;
+       for (vector<CEnemy*>::iterator i = (*enemies).begin(); i != (*enemies).end(); ++i){
+               float enemy_x = (float)(*i)->GetSpriteCameraX();
+               float enemy_y = (float)(*i)->GetSpriteCameraY();
+
+               float range_x = player_x - enemy_x;
+               float range_y = player_y - enemy_y;
+               count++;
+               if (range_x < ATTACKRANGE && range_x > 0 && range_y < 40 && range_y > -40){
+                       DoDamageToPlayer(player, playerSprite, enHP, pub,enemies, enemynum, sounds);
+               }
+       }
+}
+
+void BattleManager::DoDamageToEnemy(MainCharacter* player, Sprite* playerSprite, Sprite* enHP, CEnvironment* pub, vector<CEnemy*>*enemies, int EnemyVectNum, SFXManager* sounds){
+       player->DisplayAttackAnim();
+       sounds->SwordAttack();
+       player->GetLevelStats();
+       int dmg = player->GetDamage();
+
+       if((*enemies)[EnemyVectNum]->getHP() >= 0){
+               (*enemies)[EnemyVectNum]->setHP(-dmg);
+               (*enemies)[EnemyVectNum]->changeHP((*enemies), EnemyVectNum, player->GetDamage());
+       }
+
+       if ((*enemies)[EnemyVectNum]->getHP() <= 0){
+               allowedtoDraw = false;
+               killSuccess = true;
+       }
+       if (!allowedtoDraw) {
+               allowedtoDraw = true;
+               player->AddXP((*enemies)[EnemyVectNum]->GetXP());
+               addedXPFromBattle = (*enemies)[EnemyVectNum]->GetXP();
+               (*enemies).erase((*enemies).begin() + EnemyVectNum);
+       }
+
+       string dmg_str = std::to_string(dmg);
+       Text dmgtext(250, 178, dmg_str);
+       vector<Text>tempTextVect;
+       tempTextVect.push_back(dmgtext);
+       CSDLFont_Setup font(csdl_setup);
+       float time = (float)SDL_GetTicks();
+       do{
+       EventManager* event = new EventManager(csdl_setup, mouseX, mouseY);
+       event->DrawGame(player, playerSprite, enHP, pub, *enemies);
+       dialog->DrawDialog(tempTextVect, FONT_FILE, &font, 15);
+       csdl_setup->End();
+       delete event;
+       }while (SDL_GetTicks() < time + 300);
+}
+
+void BattleManager::DoDamageToPlayer(MainCharacter* player, Sprite* player_sprite, Sprite* en_hp, CEnvironment* pub, vector<CEnemy*>*enemies, int enemy_id, SFXManager* sounds){
+       int damage = (*enemies)[enemy_id]->getDamage();
+       if(player->GetHP() >= 0){
+               player->SetHP(-damage);
+               // TODO: EDIT PLAYERS HP SPRITE
+       }
+       if (player->GetHP() <= 0){
+       //if player is dead, display game over, insert coins to play or load game.
+       }
+
+       string damage_str = std::to_string(damage);
+       //moving the text further to the right for testing purposes, need to adjust.
+       Text damage_text(400, 178, damage_str);
+       vector<Text>temp_text_vect;
+       temp_text_vect.push_back(damage_text);
+       CSDLFont_Setup font(csdl_setup);
+       float time = (float)SDL_GetTicks();
+       //draw the game and the text for 300ms.
+       do{
+       EventManager* event = new EventManager(csdl_setup, mouseX, mouseY);
+       event->DrawGame(player, player_sprite, en_hp, pub, *enemies);
+       HandlePlayerAttack(player, player_sprite, en_hp, pub, enemies, sounds);
+       dialog->DrawDialog(temp_text_vect, FONT_FILE, &font, 15);
+       csdl_setup->End();
+       delete event;
+       }while (SDL_GetTicks() < time + 300);
+}
diff --git a/src/BattleManager.h b/src/BattleManager.h
new file mode 100644 (file)
index 0000000..6d23102
--- /dev/null
@@ -0,0 +1,61 @@
+#pragma once
+#include "TextManager.h"
+#include "SDL_Setup.h"
+#include "SDL_Font_Setup.h"
+#include "EventManager.h"
+#include "Interaction.h"
+#include "Enemies.h"
+#include "SFXManager.h"
+
+const int DIALOGXLOC = 50;
+const int FIRSTLINEY = 400;
+const int SECONDLINEY = 420;
+const int THIRDLINEY = 440;
+const string FONTFILE = "res/fonts/Minecraftia.ttf";
+
+class BattleManager
+{
+public:
+       BattleManager(CSDL_Setup* passed_CSDL_Setup, int *passed_MouseX, int *passed_MouseY);
+       ~BattleManager(void);
+       void HandleBattle(MainCharacter* player, Sprite* playerSprite, Sprite* diaBoxSprite,
+               Sprite* enHP, CInteraction* interaction, CEnvironment* pub, Sprite* dialogIcon, vector<CEnemy*>*Enemies, int enemyBattleNum);
+       void InitBattleLog();
+       void DoDamageToEnemy(MainCharacter* player, Sprite* playerSprite, Sprite* enHP, CEnvironment* pub, vector<CEnemy*>*enemies, int EnemyVectNum, SFXManager* sounds);
+       void DoDamageToPlayer(MainCharacter* player, Sprite* playerSprite, Sprite* enHP, CEnvironment* pub, vector<CEnemy*>*enemies, int EnemyVectNum, SFXManager* sounds);
+       void HandlePlayerAttack(MainCharacter* player, Sprite* playerSprite, Sprite* enHP, CEnvironment* pub, vector<CEnemy*> *enemies, SFXManager* sounds);
+       void HandleEnemyMeleeAttack(MainCharacter* player, Sprite* playerSprite, Sprite* enHP, CEnvironment* pub, vector<CEnemy*> *enemies, SFXManager* sounds);
+       void SetKillCount(int kill_amount);
+       int GetKillCount();
+       
+private:
+       TextManager* dialog;
+       CSDL_Setup* csdl_setup;
+
+       int *mouseX;
+       int *mouseY;
+       bool dialogSuccess;
+       bool runOnce;
+       bool fight;
+       bool battle_dialogue;
+       bool battleSuccessDialogue;
+       bool EnterPressed;
+       bool firstDialog;
+       bool secondDialog;
+       bool thirdDialog;
+       bool DialogueEnd;
+       bool allowedtoDraw;
+       bool killSuccess;
+
+       int enemynum;
+       int count;
+       int addedXPFromBattle;
+       int HP;
+       int xInt;
+       int yInt;
+       int kill_count;
+
+       CSDLFont_Setup* text;
+       vector<Text>dialogMsgs;
+};
+
diff --git a/src/ClassDiagram.cd b/src/ClassDiagram.cd
new file mode 100644 (file)
index 0000000..7b89419
--- /dev/null
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="utf-8"?>
+<ClassDiagram /> 
\ No newline at end of file
diff --git a/src/CollisionRect.cpp b/src/CollisionRect.cpp
new file mode 100644 (file)
index 0000000..eae9fc8
--- /dev/null
@@ -0,0 +1,33 @@
+#include "stdafx.h"
+#include "CollissionRect.h"
+
+CollisionRect::CollisionRect()
+{
+       SetRectangle(0,0,0,0);
+       OffsetX = 0;
+       OffsetY = 0;
+}
+
+CollisionRect::CollisionRect(int x, int y, int w, int h)
+{
+       OffsetX = x;
+       OffsetY = y;
+       SetRectangle(0,0,w,h);
+}
+
+
+CollisionRect::~CollisionRect(void)
+{
+}
+
+void CollisionRect::SetRectangle(int x, int y, int w, int h)
+{
+       collisionRectangle.x = x + OffsetX;
+       collisionRectangle.y = y + OffsetY;
+       collisionRectangle.w = w;
+       collisionRectangle.h = h;
+}
+
+SDL_Rect CollisionRect::GetRectangle() {
+       return collisionRectangle;
+}
diff --git a/src/CollissionRect.h b/src/CollissionRect.h
new file mode 100644 (file)
index 0000000..a7b64cc
--- /dev/null
@@ -0,0 +1,23 @@
+#pragma once
+#include "stdafx.h"
+
+class CollisionRect
+{
+public:
+       CollisionRect();
+       CollisionRect(int x, int y, int w, int h);
+       ~CollisionRect(void);
+
+       void SetRectangle(int x, int y, int w, int h);
+       SDL_Rect GetRectangle();
+
+       void SetX(int x) { collisionRectangle.x = x +OffsetX;   }
+       void SetY(int y) { collisionRectangle.y = y +OffsetY;   }
+private:
+       int OffsetX;
+       int OffsetY;
+       SDL_Rect collisionRectangle;
+};
+
+
+
diff --git a/src/ConsoleDebug.cpp b/src/ConsoleDebug.cpp
new file mode 100644 (file)
index 0000000..f3a43e7
--- /dev/null
@@ -0,0 +1,44 @@
+#include "stdafx.h"
+#include "ConsoleDebug.h"
+
+
+ConsoleDebug::ConsoleDebug(void)
+{
+       time_init = false;
+}
+
+
+ConsoleDebug::~ConsoleDebug(void)
+{
+}
+
+void ConsoleDebug::PrintLoop(){
+       for(auto i : items_to_print) {
+    // process i
+       cout << i << " "; 
+       } 
+}
+//Flush the console's strings out.
+void ConsoleDebug::ClearConsole(float time_delay){
+
+       //if we haven't obtained the time, get the time.
+       if (!time_init){
+               orig_time = (float)SDL_GetTicks();
+               time_init = true;
+       }
+       //is the current time more than the previous and the delay. If so, let's clear the console.
+       float current_time = (float)SDL_GetTicks();
+       if (current_time > orig_time + time_delay){
+               for (int i = 0; i < 20; i++)
+               {
+                       cout << "\n" << endl;
+               }
+               //get time again.
+               time_init = false;
+       }
+
+}
+
+void ConsoleDebug::AddStatementToPrint(string debug_string){
+       items_to_print.push_back(debug_string);
+}
\ No newline at end of file
diff --git a/src/ConsoleDebug.h b/src/ConsoleDebug.h
new file mode 100644 (file)
index 0000000..f45d25c
--- /dev/null
@@ -0,0 +1,20 @@
+#pragma once
+#include <string>
+#include <vector>
+
+using namespace std;
+
+class ConsoleDebug
+{
+public:
+       ConsoleDebug(void);
+       ~ConsoleDebug(void);
+       void PrintLoop();
+       void ClearConsole(float time_delay);
+       void AddStatementToPrint(string debug_string);
+private:
+       vector<string>items_to_print;
+       float orig_time;
+       bool time_init;
+};
+
diff --git a/src/Enemies.cpp b/src/Enemies.cpp
new file mode 100644 (file)
index 0000000..e9474a9
--- /dev/null
@@ -0,0 +1,127 @@
+#include "Enemies.h"
+
+CEnemies::CEnemies(CSDL_Setup* passed_SDL_Setup, int passed_TempX, int passed_TempY, int *passed_MouseX, int *passed_MouseY,  float *passed_CameraX, float *passed_CameraY, int passed_ScreenWidth, int passed_ScreenHeight)
+{
+       cameraX = passed_CameraX;
+       cameraY = passed_CameraY;
+
+       csdl_setup = passed_SDL_Setup;
+
+       mouseX = passed_MouseX;
+       mouseY = passed_MouseY;
+
+       count = 0;
+
+       TempX = passed_TempX;
+       TempY = passed_TempY;
+
+       CheckMouseEvent();
+
+       HP = 0;
+       xInt = 0;
+       yInt = 0;
+
+       ScreenWidth = passed_ScreenWidth;
+       ScreenHeight = passed_ScreenHeight;
+       
+}
+
+CEnemies::CEnemies()
+{
+
+}
+
+CEnemies::~CEnemies()
+{
+}
+
+void CEnemies::setHP(int passed_HP)
+{
+       HP = passed_HP;
+}
+
+int CEnemies::getHP()
+{
+       return HP;
+}
+
+void CEnemies::SpawnEnemy(int amount, int Health, int Damage, int XP, CEnvironment* level)
+{
+       for (int i = 0; i < amount; i++)
+       {
+               //randomise x and y based on map size.
+               xInt = rand() % (level->GetMapSizeX() * ScreenWidth);
+               yInt = 60;
+               cout << "Enemy " << i << "'s X Location is set to: " << xInt << endl;
+               cout << "Enemy " << i << "'s Y Location is set to: " << yInt << endl;
+               Enemies.push_back(new CEnemy(xInt, yInt,cameraX,cameraY,csdl_setup,Health,Damage, XP)); 
+       }
+}
+
+vector<CEnemy*>* CEnemies::GetEnemies()
+{
+       return &Enemies;
+}
+
+void CEnemies::Draw()
+{
+       for (vector<CEnemy*>::iterator i = Enemies.begin(); i != Enemies.end(); ++i)
+       {
+               (*i)->Draw();
+       }
+       if (Enemies.size() > 0){
+       Enemies[0]->getEnemyHPSprite()->Draw();
+       }
+       else 
+               cout << "Error 001: Can't draw Enemy's HP Sprite as the vector size is 0" << endl;;
+       //testcase
+       
+}
+
+void CEnemies::PrintEnemyTestLoc(){
+       cout << "EnemyX: " << Enemies[0]->GetEnemySprite()->GetSpriteCameraX() << endl;
+       cout << "EnemyY: " << Enemies[0]->GetEnemySprite()->GetSpriteCameraY() << endl;
+}
+
+void CEnemies::DetectPlayer(Sprite* player){
+       float range = 80;
+       for (vector<CEnemy*>::iterator i = Enemies.begin(); i != Enemies.end(); ++i)
+       {
+               if ((*i)->GetEnemySprite()->IsSpriteClose(player, (*i)->GetEnemySprite(), 80)){
+                               //MoveSpriteTowardsEntity needs revision.
+                               (*i)->SetAttackAnim(true);
+                               (*i)->GetEnemySprite()->MoveSpriteTowardsEntity(player, (*i)->GetEnemySprite());
+               }
+       }
+}
+
+void CEnemies::CheckMouseEvent()
+{
+       tempMouseX = (float)*mouseX;
+       tempMouseY = (float)*mouseY;
+       if (csdl_setup->GetMainEvent()->type == SDL_MOUSEMOTION)
+       {
+               for (vector<CEnemy*>::iterator i = Enemies.begin(); i != Enemies.end(); ++i)
+               {
+                       if (tempMouseX >= (*i)->GetSpriteCameraX() && tempMouseX <= (*i)->GetSpriteCameraX()+50 && tempMouseY >= (*i)->GetSpriteCameraY() && tempMouseY <= (*i)->GetSpriteCameraY()+50)
+                       {
+                               //En_Fight->Draw();
+                               cout << "You have scrolled over an enemy!" << endl;
+                       }
+
+                       //for clicking
+                       if (csdl_setup->GetMainEvent()->type == SDL_MOUSEBUTTONDOWN)
+                       {
+
+                               if (csdl_setup->GetMainEvent()->button.button == SDL_BUTTON_LEFT)
+                               {
+                                       if (tempMouseX >= (*i)->GetSpriteCameraX() && tempMouseX <= (*i)->GetSpriteCameraX()+50 && tempMouseY >= (*i)->GetSpriteCameraY() && tempMouseY <= (*i)->GetSpriteCameraY()+50)
+                                       {
+                                               cout << "You have clicked the enemy!" << endl;
+                                               cout << "HP = " << endl; //mc->getHP() << endl;
+                                       }
+                               }
+                       }
+               }
+       }
+}
diff --git a/src/Enemies.h b/src/Enemies.h
new file mode 100644 (file)
index 0000000..60d950e
--- /dev/null
@@ -0,0 +1,54 @@
+#ifndef ENEMIES_H
+#define ENEMIES_H
+#pragma once
+#include "stdafx.h"
+#include "Sprite.h"
+#include "SDL_Setup.h"
+#include <sstream>
+#include <fstream>
+#include "SDL_Font_Setup.h"
+#include "Environment.h"
+#include "Enemy.h"
+
+class CEnemies
+{
+public:
+       CEnemies(CSDL_Setup* passed_SDL_Setup, int passed_TempX, int passed_TempY, int *passed_MouseX, int *passed_MouseY,  float *passed_CameraX, float *passed_CameraY, int passed_ScreenWidth, int passed_ScreenHeight);
+       CEnemies();
+       ~CEnemies();
+
+       void Draw();
+       void CheckMouseEvent();
+       void setHP(int passed_HP);
+       void DetectPlayer(Sprite* player);
+       void PrintEnemyTestLoc();
+       int getHP();
+       vector<CEnemy*>* GetEnemies();
+
+       void SpawnEnemy(int amount, int Health, int Damage, int XP, CEnvironment* level);
+       
+private:
+       CSDL_Setup* csdl_setup;
+       vector<CEnemy*>Enemies;
+       Sprite* en_HP;
+       float tempMouseX;
+       float tempMouseY;
+       float *cameraX;
+       float *cameraY;
+       int *mouseX;
+       int *mouseY;
+       int TempX;
+       int TempY;
+       int ScreenWidth;
+       int ScreenHeight;
+
+       int HP;
+       int xInt;
+       int yInt;
+       int count; 
+
+       bool fight;
+};
+
+
+#endif
diff --git a/src/Enemy.cpp b/src/Enemy.cpp
new file mode 100644 (file)
index 0000000..5225968
--- /dev/null
@@ -0,0 +1,159 @@
+#include "Enemy.h"
+
+
+CEnemy::CEnemy(int x_passed, int y_passed, float *CameraX, float *CameraY, CSDL_Setup* csdl_setup, int passed_HP, int passed_Damage, int passed_XPGive){
+       x = x_passed;
+       y = y_passed;
+
+       enemy_sprite = new Sprite(csdl_setup->GetRenderer(),"res/data/environment/enemy_spritesheet.png",x,y,50,50,CameraX,CameraY, CollisionRect());
+       enemy_sprite->SetUpAnimation(5,1);
+       //enemy_sprite->SetOrgin(enemy_sprite->GetWidth()/2.0f, enemy_sprite->GetHeight());
+       En_HP = new Sprite(csdl_setup->GetRenderer(),"res/data/hp_enem.png",x+10,y-10,24,4,CameraX,CameraY, CollisionRect());
+
+       Damage = passed_Damage;
+       HP = passed_HP;
+       XPGive = passed_XPGive;
+
+       count = 0;
+       DecreaseHPBy = 0;
+       PercentageHPChange = 0;
+       temp = 0;
+       HPWidth = 0;
+       isTimeSet = false;
+       goDown = false;
+       goUp = false;
+       goRight = true;
+       goLeft = false;
+       attack_anim = false;
+       time = 0;
+}
+
+CEnemy::CEnemy(){
+
+}
+Sprite* CEnemy::getEnemyHPSprite(){
+       return En_HP;
+}
+CEnemy::~CEnemy(){
+       delete enemy_sprite;
+}
+
+//if the enemy is not attacking, display the attack animation, otherwise, display attack animation.
+void CEnemy::Draw(){
+       if (!attack_anim)
+               enemy_sprite->PlayAnimation(0,2,0,300);
+       else
+               enemy_sprite->PlayAnimation(0,4,0,200);
+
+       enemy_sprite->Draw();
+       //map the HP to the enemy sprite so that when the enemy moves, the HP moves along with it.
+       En_HP->SetX(enemy_sprite->GetX()+10);
+       En_HP->SetY(enemy_sprite->GetY()-10);
+       En_HP->Draw();
+}
+
+void CEnemy::setHP(int passed_HP){
+       HP = HP + passed_HP;
+}
+
+void CEnemy::SetAttackAnim(bool p_attack){
+       attack_anim = p_attack;
+}
+
+int CEnemy::getHPWidth(){
+       return En_HP->GetWidth();
+}
+
+void CEnemy::changeHP(vector<CEnemy*> EnemyVect, int EnemyVectNum, int PlayerDamage){
+       if (count == 0){
+               count ++;
+               PercentageHPChange = (float)PlayerDamage;
+               temp = (float)(getHP() + PlayerDamage);
+               PercentageHPChange = PercentageHPChange/temp;
+               PercentageHPChange = PercentageHPChange*100;
+               DecreaseHPBy = (float)En_HP->GetWidth();
+               DecreaseHPBy = DecreaseHPBy/100*PercentageHPChange;//100;
+               HPWidth = En_HP->GetWidth();
+       }
+       HPWidth = (int)(HPWidth - DecreaseHPBy);
+       EnemyVect[EnemyVectNum]->En_HP->TestWidthChange(HPWidth);
+       float temp2 = (float)En_HP->GetWidth();
+}
+
+int CEnemy::getHP(){
+       return HP;
+}
+
+int CEnemy::getDamage(){
+       return Damage;
+}
+
+int CEnemy::GetSpriteCameraX(){
+       return enemy_sprite->GetSpriteCameraX();
+}
+
+int CEnemy::GetXP(){
+       return XPGive;
+}
+
+int CEnemy::GetSpriteCameraY(){
+       return enemy_sprite->GetSpriteCameraY();
+}
+
+//move the enemy 2 pixels every half a second, but stop when they have reached moving 30 pixels.
+//we can accomplish this by checking that the original position of the enemy is now 30, and if it is, stop doing so and move downwards
+//after we move downwards for 30 pixels, move left for 30 then up for 30.
+void CEnemy::GetAIPathSquare(){
+       float prevX = (float)x;
+       float prevY = (float)y;
+       float currentX = enemy_sprite->GetX();
+       float currentY = enemy_sprite->GetY();
+       
+       if (!isTimeSet){
+               time = (float)SDL_GetTicks();
+       }
+       isTimeSet = true;
+
+       //if sufficient time has elapsed, let's move our enemy sprite.
+
+       //determine whether go right, down, left or up by checking enemy's coords.
+       if (SDL_GetTicks() > time + 30){
+               if (goRight){
+                       isTimeSet = false;
+                       enemy_sprite->SetPosition(currentX + 2, currentY);
+                       En_HP->SetPosition(En_HP->GetX() + 2, En_HP->GetY() );
+                       if (currentX - prevX == 30){
+                               goRight = false;
+                               goDown = true; 
+                       }
+               }
+               if (goDown){
+                       isTimeSet = false;
+                       enemy_sprite->SetPosition(currentX, currentY + 2);
+                       En_HP->SetPosition(En_HP->GetX(), En_HP->GetY() + 2);
+                       if (currentY - prevY == 30){
+                               goDown = false;
+                               goLeft = true;
+                       }
+               }
+               if (goLeft){
+                       isTimeSet = false;
+                       enemy_sprite->SetPosition(currentX - 2, currentY);
+                       En_HP->SetPosition(En_HP->GetX() - 2, En_HP->GetY());
+                       if (currentX - prevX <= -30){
+                               goLeft = false;
+                               goUp = true;
+                       }
+               }
+               if (goUp){
+                       isTimeSet = false;
+                       enemy_sprite->SetPosition(currentX, currentY - 2);
+                       En_HP->SetPosition(En_HP->GetX(), En_HP->GetY() - 2);
+                       if (currentY - prevY == -30){
+                               goUp = false;
+                               goRight = true;
+                       }
+               }
+
+       }
+}
diff --git a/src/Enemy.h b/src/Enemy.h
new file mode 100644 (file)
index 0000000..a3be809
--- /dev/null
@@ -0,0 +1,57 @@
+#pragma once
+#ifndef ENEMY_H
+#define ENEMY_H
+
+#include "stdafx.h"
+#include "Sprite.h"
+#include <vector>
+
+class CEnemy {
+public:
+       CEnemy(int x_passed, int y_passed, float *CameraX, float *CameraY, CSDL_Setup* csdl_setup, int passed_HP, int passed_Damage, int passed_XPGive);
+       CEnemy();
+       ~CEnemy();
+       void Draw();
+       void setHP(int passed_HP);
+       void setStats(int val);
+       void SetAttackAnim(bool p_attack);
+       int getHP();
+       int GetSpriteCameraX();
+       int GetSpriteCameraY();
+       int GetXP();
+       
+       int getDamage();
+       void changeHP(vector<CEnemy*> EnemyVect, int EnemyVectNum, int PlayerDamage);
+       void GetAIPathSquare();
+       int getHPWidth();
+       Sprite* getEnemyHPSprite();
+       Sprite* GetEnemySprite() {return enemy_sprite;}
+
+private:
+       int x;
+       int y;
+       int HP;
+       int Damage;
+       enum Difficulty {
+               Easy,
+               Medium,
+               Hard 
+       };
+       int XPGive;
+       Sprite* enemy_sprite;
+       Sprite* En_HP;
+       bool goRight;
+       bool goDown;
+       bool goUp;
+       bool goLeft;
+       bool isTimeSet;
+       bool attack_anim;
+       float time;
+       float DecreaseHPBy;
+       float PercentageHPChange;
+       float temp;
+       int count;
+       int HPWidth;
+};
+
+#endif
diff --git a/src/EntityManager.cpp b/src/EntityManager.cpp
new file mode 100644 (file)
index 0000000..124117b
--- /dev/null
@@ -0,0 +1,74 @@
+#include "EntityManager.h"
+
+
+EntityManager::EntityManager(void)
+{
+}
+
+
+EntityManager::~EntityManager(void)
+{
+}
+
+void EntityManager::AddQuests(Quests* quest){
+       quests.push_back(quest);
+}
+
+void EntityManager::RemoveQuest(int quest_id){
+       quests.erase(quests.begin()+quest_id);
+}
+
+bool EntityManager::AnyQuestAccepted(){
+       for (unsigned int i = 0; i < quests.size(); i++){
+               return quests[i]->GetQuestAccept();
+       }
+
+       return false;
+}
+
+void EntityManager::AddNPCs(NPC* npc){
+       npcs.push_back(npc);
+}
+
+vector<Quests*> EntityManager::GetQuests(){
+       return quests;
+}
+
+vector<NPC*> EntityManager::GetNPCs(){
+       return npcs;
+}
+
+void EntityManager::AddSprites(Sprite* sprite){
+       sprites.push_back(sprite);
+}
+
+vector<Sprite*> EntityManager::GetSprites(){
+       return sprites;
+}
+
+void EntityManager::DrawAll(){
+       for (vector<NPC*>::iterator i = npcs.begin(); i != npcs.end(); ++i){
+               (*i)->Draw();
+       }
+
+}
+
+bool EntityManager::CheckPlayerClose(Sprite* player){
+       int count = 0;
+       for (vector<NPC*>::iterator i = npcs.begin(); i != npcs.end(); ++i){
+               count++;
+               int player_x = player->GetSpriteCameraX();
+               int player_y = player->GetSpriteCameraY();
+               int npc_x = (*i)->GetNPCX();
+               int npc_y = (*i)->GetNPCY();
+               int diff_x = player_x - npc_x;
+               int diff_y = player_y - npc_y;
+               if (player_x - npc_x < 60 && player_x - npc_x > -60 
+                       && player_y - npc_y < 60 && player_y - npc_y > -60){
+                               //get quest, pick NPC by identifying who is closest (current i identifies this!), then give user option to accept or decline the quest in a menu.
+                               //(*i)->InitialiseQuestMenu(count, quests[count-1]);
+                               return true;
+               }
+       }
+       return false;
+}
diff --git a/src/EntityManager.h b/src/EntityManager.h
new file mode 100644 (file)
index 0000000..476d5f9
--- /dev/null
@@ -0,0 +1,33 @@
+#pragma once
+
+#include "Quests.h"
+#include "NPC.h"
+#include "Sprite.h"
+#include "Environment.h"
+#include <vector>
+
+//this class will have vectors of NPCs, quests, sprites, maps and will be able to add onto/remove from them
+//there should be a GetQuests() and CreateQuests() function for example.
+class EntityManager
+{
+public:
+       EntityManager(void);
+       ~EntityManager(void);
+       void AddQuests(Quests* quest);
+       void RemoveQuest(int quest_id);
+       bool AnyQuestAccepted();
+       vector<Quests*>GetQuests();
+       void AddNPCs(NPC* npc);
+       vector<NPC*>GetNPCs();
+       void AddSprites(Sprite* sprite);
+       vector<Sprite*> GetSprites();
+       void DrawAll();
+       bool CheckPlayerClose(Sprite* player);
+       vector<Sprite*>sprites;
+
+private:
+       vector<Quests*>quests;
+       vector<NPC*>npcs;
+       vector<CEnvironment*>maps;
+};
+
diff --git a/src/Environment.cpp b/src/Environment.cpp
new file mode 100644 (file)
index 0000000..a10bc24
--- /dev/null
@@ -0,0 +1,305 @@
+#include "Environment.h"
+
+const int MAPONE = 1;
+const int MAPTWO = 2;
+const int MAPTHREE = 3;
+
+CEnvironment::CEnvironment(){
+
+}
+
+CEnvironment::CEnvironment(int ScreenWidth, int ScreenHeight, float *passed_CameraX, float *passed_CameraY, string mapLoc, CSDL_Setup* passed_csdl_setup, 
+                                                  int passed_TileSizeX, int passed_TileSizeY, int passed_TexSizeX, int passed_TexSizeY, bool tables, bool trees, int passed_LevelNum){
+       csdl_setup = passed_csdl_setup;
+       TileSizeX = passed_TileSizeX;
+       TileSizeY = passed_TileSizeY;
+
+       CameraX = passed_CameraX;
+       CameraY = passed_CameraY;
+       levelNum = passed_LevelNum;
+
+       LoadEnvFile();
+       StoolY = 350;
+
+       for (int i = 0; i < TileSizeX; i++){
+               for (int j = 0; j < TileSizeY; j++){
+                       maps.push_back(new CMap(i,j, TileSizeX, TileSizeY, passed_TexSizeX, passed_TexSizeY, mapLoc,CameraX, CameraY, csdl_setup, tables, trees, StoolY - 10));
+               }
+       }
+
+
+       GameMode = GamePlay;
+
+
+       onePressed = false;
+
+}
+
+CEnvironment::~CEnvironment(){
+       for (vector<CMap*>::iterator i = maps.begin(); i != maps.end(); ++i)
+       {
+               delete (*i);
+       }
+
+       //clear all from memory
+       for (vector<Tree*>::iterator i = trees.begin(); i != trees.end(); ++i)
+       {
+               delete (*i);
+       }
+
+       //then clear the vector
+       trees.clear();
+       maps.clear();
+}
+
+//if a specific level, we need to init a vector of loot objects, push back the loot for each level into that vector, then return that vector.
+vector<Loot*> CEnvironment::GetLootForMap(){
+       switch (levelNum)
+       {
+       case MAPONE:
+               break;
+       case MAPTWO:
+               break;
+       case MAPTHREE:
+               break;
+       }
+       return mapLoot;
+}
+
+int CEnvironment::GetMapSizeX(){
+       return TileSizeX;
+}
+
+int CEnvironment::GetMapSizeY(){
+       return TileSizeY;
+}
+
+void CEnvironment::DrawBack(){
+       for (vector<CMap*>::iterator i = maps.begin(); i != maps.end(); ++i){
+               (*i)->DrawTexture();
+               (*i)->DrawTable();
+               (*i)->DrawStool();
+       }
+}
+
+void CEnvironment::DrawFront(){
+       for (vector<Tree*>::iterator i = trees.begin(); i != trees.end(); ++i){
+               (*i)->DrawCrown();
+       }
+}
+
+void CEnvironment::LoadEnvFile(){
+       ifstream LoadedFile ("res/data/Map.txt");
+
+       string line;
+
+       enum Obj_Type {
+               TypeNone,
+               TypeTree,
+               TypeLoot
+       };
+
+       int currentType = TypeNone;
+
+
+       if (LoadedFile.is_open())
+       {
+               while (LoadedFile.good() )
+               {
+                       getline(LoadedFile, line);
+                       if (line == "----====TREE SETTINGS====----")
+                       {
+                               currentType = TypeTree;
+                       }
+                       if (line == "----====LOOT SETTINGS====----")
+                       {
+                               currentType = TypeLoot;
+                       }
+                       if (line == "----====QUEST SETTINGS====----")
+                       {
+                               currentType = TypeTree;
+                       }
+                       else if (line == "----====END TREE====----")
+                       {
+                               currentType = TypeNone;
+                       }
+                       else {
+                               if (currentType == TypeTree)
+                               {
+
+                                       istringstream iss(line);
+
+                                       int TempX = 0; 
+                                       int TempY = 0; 
+                                       string PreviousWord = ""; 
+
+                                       while (iss) 
+                                       { 
+                                               string word; 
+                                               iss >> word; 
+
+                                               if (PreviousWord == "x:") 
+                                               { 
+                                                       TempX = atoi( word.c_str() ); 
+                                               } 
+
+                                               if (PreviousWord == "y:") 
+                                               { 
+                                                       TempY = atoi( word.c_str() ); 
+
+                                                       trees.push_back(new Tree(TempX, TempY,CameraX, CameraY, csdl_setup)); 
+                                               } 
+
+                                               PreviousWord = word; 
+                                       } 
+
+
+                               } 
+
+                               //needs to check what type it is, where it is (x and y) and levelOfLoot.
+                               if (currentType == TypeLoot)
+                               {
+
+                                       istringstream iss(line);
+
+                                       int locationX = 0;
+                                       int locationY = 0; 
+                                       int rewardLevel = 0; 
+                                       string type = "";
+
+                                       string previousWord = ""; 
+
+                                       while (iss) 
+                                       { 
+                                               string word; 
+                                               iss >> word; 
+
+                                               //for instance, could be a chest, a sword, a shield, some gold, a scroll, a map, some player accessories.
+                                               if (previousWord == "type:")
+                                               {
+                                                       type = previousWord;
+
+                                               }
+                                               if (previousWord == "x:") 
+                                               { 
+                                                       locationX = atoi( word.c_str() ); 
+                                               } 
+
+                                               if (previousWord == "y:") 
+                                               { 
+                                                       locationY = atoi( word.c_str() ); 
+
+                                                       
+                                               } 
+                                               if (previousWord == "rewardLevel") 
+                                               {
+                                                       //how good the loot is.
+                                                       rewardLevel = atoi(word.c_str() );
+
+                                                       //lets push back a loot object once we have reached the last 'item' or field for that piece of loot.
+                                                       mapLoot.push_back(new Loot(type, locationX, locationY, rewardLevel, csdl_setup, CameraX, CameraY)); 
+                                               }
+                                               previousWord = word; 
+                                       } 
+
+                               }
+                       } 
+               } 
+       } 
+       else{ 
+               cout << "File Could Not Be Opened: Map.txt" << endl; 
+       } 
+} 
+
+void CEnvironment::FileSave(){
+       ofstream LoadedFile;
+       LoadedFile.open("res/data/Map.txt");
+       LoadedFile << "----====TREE SETTINGS====----" << endl;
+       for (vector<Tree*>::iterator i = trees.begin(); i != trees.end(); ++i){
+               LoadedFile << "x: " << (*i)->GetX() << "\ty: " << (*i)->GetY() << endl;
+               (*i)->DrawCrown();
+       }
+       LoadedFile << "----====TREE END====----" << endl;
+       LoadedFile.close();
+
+
+       cout << "Level Saved!" << endl;
+
+
+}
+
+void CEnvironment::Update(){
+       if (GameMode == LevelCreation){
+               if (csdl_setup->GetMainEvent()->type == SDL_KEYDOWN){
+                       if (!onePressed && csdl_setup->GetMainEvent()->key.keysym.sym == SDLK_F11){
+                               FileSave();
+                               onePressed = true;
+                       }
+               }
+
+               if (csdl_setup->GetMainEvent()->type == SDL_KEYUP){
+                       if (onePressed && csdl_setup->GetMainEvent()->key.keysym.sym == SDLK_F11)
+                       {
+                               onePressed = false;
+                       }
+               }
+
+               if (csdl_setup->GetMainEvent()->type == SDL_KEYDOWN){
+                       if (!onePressed && csdl_setup->GetMainEvent()->key.keysym.sym == SDLK_F1)
+                       {
+                               trees.push_back(new Tree((int)-*CameraX+275,(int)-*CameraY+107, CameraX, CameraY, csdl_setup));
+                               onePressed = true;
+                       }
+               }
+
+               if (csdl_setup->GetMainEvent()->type == SDL_KEYUP){
+                       if (onePressed && csdl_setup->GetMainEvent()->key.keysym.sym == SDLK_F1)
+                       {
+                               onePressed = false;
+                       }
+               }
+       }
+
+       if (csdl_setup->GetMainEvent()->type == SDL_KEYDOWN){
+               if (!onePressed && csdl_setup->GetMainEvent()->key.keysym.sym == SDLK_F2)
+               {
+                       if (trees.size() > 0)
+                       {
+
+                               delete trees[trees.size()-1];
+
+                               trees.pop_back();
+
+                       }
+
+                       onePressed = true;
+               }
+       }
+
+       if (csdl_setup->GetMainEvent()->type == SDL_KEYUP){
+               if (onePressed && csdl_setup->GetMainEvent()->key.keysym.sym == SDLK_F2){
+                       onePressed = false;
+               }
+       }
+
+       if (csdl_setup->GetMainEvent()->type == SDL_KEYDOWN){
+               if (!onePressed && csdl_setup->GetMainEvent()->key.keysym.sym == SDLK_F12){
+                       if (GameMode == LevelCreation){
+                               cout << "Level Creation: OFF" << endl;
+                               GameMode = GamePlay;
+                       }
+                       else if (GameMode == GamePlay){
+                               cout << "Level Creation: ON" << endl;
+                               GameMode = LevelCreation;
+                       }
+                       onePressed = true;
+               }
+       }
+
+       if (csdl_setup->GetMainEvent()->type == SDL_KEYUP){
+               if (onePressed && csdl_setup->GetMainEvent()->key.keysym.sym == SDLK_F12){
+                       onePressed = false;
+               }
+       }
+
+}
\ No newline at end of file
diff --git a/src/Environment.h b/src/Environment.h
new file mode 100644 (file)
index 0000000..42dfc98
--- /dev/null
@@ -0,0 +1,60 @@
+#pragma once
+#include "Sprite.h"
+#include "stdafx.h"
+#include "SDL_Setup.h"
+#include "Tree.h"
+#include <vector>
+#include <sstream>
+#include <fstream>
+#include <string>
+#include "Map.h"
+#include "Loot.h"
+
+using namespace std;
+
+class CEnvironment
+{
+public:
+       CEnvironment();
+       CEnvironment(int ScreenWidth, int ScreenHeight, float *passed_CameraX, float *passed_CameraY, string mapLoc, CSDL_Setup* passed_csdl_setup, 
+                                                  int passed_TileSizeX, int passed_TileSizeY, int passed_TexSizeX, int passed_TexSizeY, bool tables, bool trees, int passed_LevelNum);
+       ~CEnvironment(void);
+
+       void DrawBack();
+       void DrawFront();
+
+       void Update();
+       void LoadEnvFile();
+       void FileSave();
+
+       vector<Loot*> GetLootForMap();
+       
+
+       int GetMapSizeX();
+       int GetMapSizeY();
+
+       enum ModeType
+       {
+               GamePlay,
+               LevelCreation
+       };
+
+       vector <Tree*> GetTrees() {return trees;};
+       vector <CMap*> GetMapElements() {return maps;}
+private:
+       int GameMode;
+       CSDL_Setup* csdl_setup;
+       float* CameraX;
+       float* CameraY;
+       bool onePressed;
+       Sprite* map[4][7];
+       Sprite* Enemy;
+       int TileSizeX;
+       int TileSizeY;
+       int StoolY;
+       int levelNum;
+       vector<CMap*> maps;
+       vector <Tree*> trees;
+       vector <Loot*> mapLoot;
+};
+
diff --git a/src/EventManager.cpp b/src/EventManager.cpp
new file mode 100644 (file)
index 0000000..a2e8c3f
--- /dev/null
@@ -0,0 +1,107 @@
+#include "stdafx.h"
+#include "EventManager.h"
+
+
+EventManager::EventManager(CSDL_Setup* passed_CSDL_Setup, int *passed_MouseX, int *passed_MouseY){
+       csdl_setup = passed_CSDL_Setup;
+       mouseX = passed_MouseX;
+       mouseY = passed_MouseY;
+       show_once = false;
+}
+
+
+EventManager::~EventManager(void){
+}
+
+//might want to think about grouping entities such as sprites into a sprite struct.
+void EventManager::ChestDialogEvent(MainCharacter* player, Sprite* playerSprite, Sprite* diaBoxSprite,
+                                               Sprite* enHP, CInteraction* interaction, CEnvironment* pub, Sprite* dialogIcon, vector<CEnemy*>Enemies){
+
+                                               DrawGame(player, playerSprite, enHP, pub, Enemies);
+                                               diaBoxSprite->DrawSteady();
+                                               //dialogIcon->DrawSteady();
+                                               TextManager dialog(csdl_setup);
+                                               vector<Text>textVect;
+                                               Text text1(DIALOGSTARTPOSX, DIALOGSTARTPOSY, "You have opened a chest!");
+                                               textVect.push_back(text1);
+                                               CSDLFont_Setup font(csdl_setup);
+                                               dialog.DrawDialog(textVect, FONT_FILE, &font, 10);      
+                                               //interaction->checkInteraction(dialogIcon);
+                                               csdl_setup->End();
+
+}
+
+void EventManager::BattleDialogEvent(vector<Text>text, CInteraction* interaction, Sprite* dialogIcon, Sprite* diaBoxSprite){
+       diaBoxSprite->DrawSteady();
+       dialogIcon->DrawSteady();
+       TextManager* dialog = new TextManager(csdl_setup);
+       CSDLFont_Setup* font = new CSDLFont_Setup(csdl_setup);
+       dialog->DrawDialog(text, FONT_FILE, font, 10);
+       interaction->checkInteraction(dialogIcon);
+       csdl_setup->End();
+       delete dialog;
+       delete font;
+}
+
+void EventManager::NPCDialogEvent(vector<Text>text, CInteraction* interaction, Sprite* dialogIcon, Sprite* diaBoxSprite, Sprite* NPC){
+       diaBoxSprite->DrawSteady();
+       dialogIcon->DrawSteady();
+       NPC->Draw();
+       TextManager* dialog = new TextManager(csdl_setup);
+       CSDLFont_Setup* font = new CSDLFont_Setup(csdl_setup);
+       dialog->DrawDialog(text, FONT_FILE, font, 10);
+       interaction->checkInteraction(dialogIcon);
+       csdl_setup->End();
+       delete dialog;
+       delete font;
+}
+//need to show quest success for either 2s and once or await user to press enter on (Press Enter to Continue) to quit the success log.
+//may be worthwhile having a routine in interaction that has takes care of the enter part.
+
+
+void EventManager::QuestSuccessEvent(vector<Text>text, CInteraction* interaction, Sprite* dialogIcon, Sprite* diaBoxSprite, int font_size){
+       if (!show_once){
+       show_once = true;
+       diaBoxSprite->DrawSteady();
+       dialogIcon->DrawSteady();
+       TextManager* dialog = new TextManager(csdl_setup);
+       CSDLFont_Setup* font = new CSDLFont_Setup(csdl_setup);
+       dialog->DrawDialog(text, FONT_FILE, font, font_size);
+       interaction->checkInteraction(dialogIcon);
+       csdl_setup->End();
+       delete dialog;
+       delete font;
+       }
+}
+
+void EventManager::GameMenuEvent(vector<Text>text, CInteraction* interaction, Sprite* dialogIcon, Sprite* diaBoxSprite, int font_size){
+       diaBoxSprite->DrawSteady();
+       dialogIcon->DrawSteady();
+       TextManager* dialog = new TextManager(csdl_setup);
+       CSDLFont_Setup* font = new CSDLFont_Setup(csdl_setup);
+       dialog->DrawDialog(text, FONT_FILE, font, font_size);
+       interaction->checkInteraction(dialogIcon);
+       csdl_setup->End();
+       delete dialog;
+       delete font;
+}
+
+ //should draw all the loot also.
+void EventManager::DrawGame(MainCharacter* player, Sprite* playerSprite, Sprite* enHP, CEnvironment* pub,vector<CEnemy*>enemies){
+                                               csdl_setup->Begin();
+                                               SDL_GetMouseState(mouseX,mouseY);
+                                               pub->DrawBack();
+                                               player->Draw();
+                                               player->Update(enemies, pub->GetMapElements());
+                                               //TODO: You may not want to stop the player when you draw all the game elements..
+                                               //player->StopMove();
+                                               pub->Update();
+                                               pub->DrawFront();
+                                               for (vector<CEnemy*>::iterator i = enemies.begin(); i != enemies.end(); ++i)
+                                               {
+                                                       (*i)->Draw();
+                                               }
+                                               enHP->Draw();
+
+
+}
diff --git a/src/EventManager.h b/src/EventManager.h
new file mode 100644 (file)
index 0000000..780fb96
--- /dev/null
@@ -0,0 +1,36 @@
+#pragma once
+#ifndef EVENTMANAGER_H
+#define EVENTMANAGER_H
+
+#include "Sprite.h"
+#include "MainCharacter.h"
+#include "PlayerManager.h"
+#include "TextManager.h"
+#include "Interaction.h"
+#include "Text.h"
+#include "SDL_Setup.h"
+
+const string FONT_FILE = "res/fonts/Minecraftia.ttf";
+const int DIALOGSTARTPOSX = 50;
+const int DIALOGSTARTPOSY = 400;
+
+class EventManager
+{
+public:
+       EventManager(CSDL_Setup* passed_CSDL_Setup, int *passed_MouseX, int *passed_MouseY);
+       ~EventManager(void);
+       void ChestDialogEvent(MainCharacter* player, Sprite* playerSprite, Sprite* diaBoxSprite,
+               Sprite* enHP, CInteraction* interaction, CEnvironment* pub, Sprite* dialogIcon, vector<CEnemy*>Enemies);
+       void DrawGame(MainCharacter* player, Sprite* playerSprite, Sprite* enHP, CEnvironment* pub,vector<CEnemy*>Enemies);
+       void BattleDialogEvent(vector<Text>text, CInteraction* interaction, Sprite* dialogIcon, Sprite* diaBoxSprite);
+       void NPCDialogEvent(vector<Text>text, CInteraction* interaction, Sprite* dialogIcon, Sprite* diaBoxSprite, Sprite* NPC);
+       void QuestSuccessEvent(vector<Text>text, CInteraction* interaction, Sprite* dialogIcon, Sprite* diaBoxSprite, int font_size);
+       void GameMenuEvent(vector<Text>text, CInteraction* interaction, Sprite* dialogIcon, Sprite* diaBoxSprite, int font_size);
+private:
+       int *mouseX;
+       int *mouseY;
+       bool show_once;
+       CSDL_Setup* csdl_setup;
+};
+
+#endif
diff --git a/src/FileManagement.cpp b/src/FileManagement.cpp
new file mode 100644 (file)
index 0000000..f14295b
--- /dev/null
@@ -0,0 +1,176 @@
+#include "FileManagement.h"
+
+
+FileManagement::FileManagement(CSDL_Setup* p_csdl_setup, float* p_camera_x, float* p_camera_y){
+       csdl_setup = p_csdl_setup;
+       camera_x = p_camera_x;
+       camera_y = p_camera_y;
+       entities = new EntityManager();
+}
+
+
+FileManagement::~FileManagement(void){
+       delete entities;
+       delete npc;
+       delete sprite;
+       delete quest;
+}
+
+bool FileManagement::OpenFile(string file_loc){
+       ifstream LoadedFile (file_loc);
+       bool file_open = LoadedFile.good();
+       if (!LoadedFile.good()){
+               cout << "ERROR: Could not load file: " + file_loc << endl;
+       }
+       return file_open;
+}
+
+//file type refers to NPC/Quest etc, the type of file we would like to read.
+//read in a file from file location
+void FileManagement::HandleQuestFile(string file_loc){
+       string quest_type;
+       string quest_desc;
+       int gold;
+       int xp;
+       int level_threshold;
+       int item_threshold;
+       string previous_word = ""; 
+       
+
+       ifstream LoadedFile (file_loc);
+       string line;
+       while (LoadedFile.good() ){
+               getline(LoadedFile, line);
+               istringstream iss(line);
+               while (iss) { 
+                       string word; 
+                       iss >> word; 
+                       if (previous_word == "quest_type:") { 
+                               quest_type = word;
+                       }
+                       if (previous_word == "quest_desc:") { 
+                               quest_desc = quest_desc.append(line, 12, line.size());
+                       }
+                       if (previous_word == "gold:"){
+                               gold = atoi(word.c_str());
+                       }
+                       if (previous_word == "xp:"){
+                               xp = atoi(word.c_str());
+                       }
+                       if (previous_word == "level_threshold:"){
+                               level_threshold = atoi(word.c_str());
+                       }
+                       if (previous_word == "item_threshold:"){
+                               item_threshold = atoi(word.c_str());
+                               //Quests quest(quest_type, quest_desc, gold, xp, level_threshold, item_threshold);
+                               quest = new Quests(quest_type, quest_desc, gold, xp, level_threshold, item_threshold);
+                               entities->AddQuests(quest);
+                       }
+                       previous_word = word; 
+               }
+       }
+}
+
+void FileManagement::HandleNPCFile(string file_loc){
+       int x;
+       int y;
+       int npc_id;
+       string npc_sprite_loc;
+       string name;
+       string previous_word = ""; 
+
+       ifstream LoadedFile (file_loc);
+       string line;
+       while (LoadedFile.good() ){
+               getline(LoadedFile, line);
+               istringstream iss(line);
+               while (iss) { 
+                       string word; 
+                       iss >> word; 
+                       if (previous_word == "x:") { 
+                               x = atoi(word.c_str());
+                       }
+                       if (previous_word == "y:") { 
+                               y = atoi(word.c_str());
+                       }
+                       if (previous_word == "npc_id:") { 
+                               npc_id = atoi(word.c_str());
+                       }
+                       if (previous_word == "npc_sprite_loc:") { 
+                               npc_sprite_loc = word;
+                       }
+                       if (previous_word == "name:") { 
+                               name = word;
+                               npc = new NPC(x,y,npc_id,npc_sprite_loc,name,camera_x,camera_y,csdl_setup,entities->GetQuests());
+                               entities->AddNPCs(npc);
+                       }
+                       previous_word = word; 
+               }
+       }
+}
+
+void FileManagement::HandleSpriteFile(){
+       string sprite_loc;
+       string file_loc = "res/data/sprites.txt";
+       int x;
+       int y;
+       bool animation;
+       int w;
+       int h;
+       int column_amount;
+       int row_amount;
+       string previous_word = ""; 
+
+       ifstream LoadedFile (file_loc);
+       string line;
+       while (LoadedFile.good() ){
+               getline(LoadedFile, line);
+               istringstream iss(line);
+               while (iss) { 
+                       string word; 
+                       iss >> word; 
+                       if (previous_word == "sprite_loc:") { 
+                               sprite_loc = word;
+                       }
+                       if (previous_word == "x:") { 
+                               x = atoi(word.c_str());
+                       }
+                       if (previous_word == "y:") { 
+                               y = atoi(word.c_str());
+                       }
+                       if (previous_word == "animation:") { 
+                               if (word == "yes")
+                                       animation = true;
+                               else
+                                       animation = false;
+                       }
+                       if (previous_word == "spritesheet_column:") { 
+                               column_amount = atoi(word.c_str());
+                       }
+                       if (previous_word == "spritesheet_row:") { 
+                               row_amount = atoi(word.c_str());
+                       }
+                       if (previous_word == "w:") { 
+                               w = atoi(word.c_str());
+                       }
+                       if (previous_word == "h:") { 
+                               h = atoi(word.c_str());
+                               //TODO:
+                               CollisionRect collision(0,0,0,0);
+                               sprite = new Sprite(csdl_setup->GetRenderer(), sprite_loc, x, y, w, h, camera_x, camera_y, collision);
+                               if (animation){
+                                       sprite->SetUpAnimation(row_amount, column_amount);
+                               }
+                               entities->AddSprites(sprite);
+                       }
+                       previous_word = word;   
+               }
+
+       }
+}
+
+EntityManager* FileManagement::GetEntities(){
+       return entities;
+}
+
+
diff --git a/src/FileManagement.h b/src/FileManagement.h
new file mode 100644 (file)
index 0000000..7aaf92d
--- /dev/null
@@ -0,0 +1,33 @@
+#pragma once
+
+#include <sstream>
+#include <fstream>
+#include <string>
+#include "stdafx.h"
+#include <vector>
+#include "EntityManager.h"
+#include "SDL_Setup.h"
+
+using namespace std;
+
+class FileManagement
+{
+public:
+       FileManagement(CSDL_Setup* csdl_setup, float* p_camera_x, float* p_camera_y);
+       ~FileManagement(void);
+       bool OpenFile(string file_loc);
+       void HandleQuestFile(string file_loc);
+       void HandleNPCFile(string file_loc);
+       void HandleSpriteFile();
+       EntityManager* GetEntities();
+private:
+       vector<Quests*>quests;
+       Quests* quest;
+       NPC* npc;
+       EntityManager* entities;
+       Sprite* sprite;
+       CSDL_Setup* csdl_setup;
+       float* camera_x;
+       float* camera_y;
+};
+
diff --git a/src/GameLoop.cpp b/src/GameLoop.cpp
new file mode 100644 (file)
index 0000000..de6327d
--- /dev/null
@@ -0,0 +1,247 @@
+#include "GameLoop.h"
+
+GameLoop::GameLoop(int passed_ScreenWidth, int passed_ScreenHeight){
+       CameraX = 0;
+       CameraY = 0;
+       MouseX = 0;
+       MouseY = 0;
+       ScreenWidth = passed_ScreenWidth;
+       ScreenHeight = passed_ScreenHeight;
+       
+       csdl_setup = new CSDL_Setup(&quit, ScreenWidth, ScreenHeight);
+       mainmenu = new MainMenu(csdl_setup, &MouseX, &MouseY, ScreenWidth, ScreenHeight, &CameraX, &CameraY); //5mb
+
+
+
+       pub = new CEnvironment(ScreenWidth, ScreenHeight, &CameraX, &CameraY, "res/data/environment/pub/floorbig.png", csdl_setup,2,2,640,480, true, false, 1); //13mb
+       player = new MainCharacter(csdl_setup, &MouseX, &MouseY, &CameraX, &CameraY, pub); //shouldn't even be taking in pub, it makes no sense.
+       playermanager = new PlayerManager(csdl_setup,&CameraX, &CameraY);
+
+       // enemies = new CEnemies(csdl_setup,0,0, &MouseX, &MouseY, &CameraX, &CameraY, ScreenWidth, ScreenHeight); //60mb
+       text = new CSDLFont_Setup(csdl_setup);
+
+       // quests = new Quests();
+       // battle = new CBattle(csdl_setup, &MouseX, &MouseY, &CameraX, &CameraY);
+       // interaction = new CInteraction (csdl_setup,&MouseX, &MouseY, &CameraX, &CameraY);
+       // gamemenu = new GameMenu(csdl_setup ,&MouseX, &MouseY, &CameraX, &CameraY, ScreenWidth, ScreenHeight);
+       // npcs = new NPC(0, 0, &MouseX, &MouseY, &CameraX, &CameraY, ScreenWidth, ScreenHeight, csdl_setup, 0);
+
+       //testing this, really the values should be more clearcut as to what you are passing.
+       // loot = new Loot("chest", 0, 0, 0, csdl_setup, &CameraX, &CameraY);
+       // events = new EventManager(csdl_setup, &MouseX, &MouseY);
+
+       // battlemanager = new BattleManager(csdl_setup, &MouseX, &MouseY);
+       sounds = new SFXManager();
+
+       debug = new ConsoleDebug();
+
+       filemanager = new FileManagement(csdl_setup, &CameraX, &CameraY);
+       // entities = new EntityManager();
+
+
+
+       level_str = "LVL: ";
+       hp_str = "HP: ";
+       dmg_str = "DMG: ";
+       xp_str = "XP: ";
+
+       temp = "";
+
+       quit = false;
+       start = false;
+
+       StartMenu();
+}
+
+
+GameLoop::~GameLoop(void){
+       delete csdl_setup;
+       delete mainmenu;
+
+       delete pub;
+       delete player;
+
+       delete enemies;
+       delete text;
+
+       delete quests;
+       delete battle;
+       delete interaction;
+       delete gamemenu;
+       delete npcs;
+
+       delete playermanager;
+       delete loot;
+       delete events;
+
+       delete battlemanager;
+       delete sounds;
+
+       // delete chest;
+
+       delete debug;
+
+       delete filemanager;
+       delete entities;
+}
+
+void GameLoop::StartMenu(){
+while (!quit && csdl_setup->GetMainEvent()->type != SDL_QUIT && start != true)
+       {
+               csdl_setup->Begin();
+               SDL_GetMouseState(&MouseX,&MouseY);
+
+               cout << MouseX;
+
+               mainmenu->Draw();
+               //if user presses start, start the game
+               if (mainmenu->GetButtonClick() == 1)
+               {
+                       start = true;
+                       Begin();
+               }
+               //if user presses options, get options
+               else if (mainmenu->GetButtonClick() == 2)
+               {
+
+               }
+               //if user presses about, get about
+               else if (mainmenu->GetButtonClick() == 3)
+               {
+                               while (mainmenu->AboutMenu() != true)
+                               {
+                                       csdl_setup->Begin();
+                                       SDL_GetMouseState(&MouseX,&MouseY);
+                                       mainmenu->AboutMenu();
+                                       csdl_setup->End();
+                               }
+               }
+               csdl_setup->End();
+       }
+}
+
+void GameLoop::Begin(){
+       // enemies->SpawnEnemy(10, 30, 3, 100, pub);
+       GetStats();
+       LoadFiles();
+       Play();
+}
+
+//this routine takes all the objects created in the constructor and places
+//them individually into vectors for easy sprite management
+void GameLoop::GroupEntities(){
+
+}
+
+//must load quests before npc's as npc's need a quest to be initialised.
+void GameLoop::LoadFiles(){
+filemanager->HandleQuestFile("res/data/quests.txt");
+filemanager->HandleNPCFile("res/data/npcs.txt");
+filemanager->HandleSpriteFile();
+// entities = filemanager->GetEntities();
+}
+
+
+
+//really, this should have loadMap() which inits vector of npcs, chests, other various entities such as enemies and so on.
+void GameLoop::Play(){
+       while (!quit && csdl_setup->GetMainEvent()->type != SDL_QUIT){
+               csdl_setup->Begin();
+
+               // cout << "Test" << endl;
+
+               // SDL_GetMouseState(&MouseX,&MouseY);
+
+               // if (enemies->GetEnemies()->size() != 0){
+               //      // enemies->PrintEnemyTestLoc();
+               // }
+       
+               // cout << "PlayerX: " << player->GetPlayerSprite()->GetSpriteCameraX() << endl;
+               // cout << "PlayerY: " << player->GetPlayerSprite()->GetSpriteCameraY() << endl;
+       
+               pub->DrawBack();
+               player->Draw();
+               // player->Update(*enemies->GetEnemies(), pub->GetMapElements());
+               pub->Update();
+               pub->DrawFront();
+               // sounds->GetSceneMusic();
+
+               //draws NPC's for the time being, should draw every form of sprite however.
+               // entities->DrawAll();
+
+               //just to enable quest success.
+               // battlemanager->SetKillCount(5);
+
+               // const float LOOTRANGE = 60;
+
+               // if (playermanager->IsClose(loot->GetLoot(), LOOTRANGE)){
+               //      loot->OpenChest();
+               //      player->StopMove();
+               //      //Sprites shouldn't come from battle, this is just temporary testing usage. There instead should be a class that deals with DialogSprites and returns them.
+               //      events->ChestDialogEvent(player, player->GetPlayerSprite(), battle->GetDiaBoxSprite(),
+               //              battle->GetEnHP(), interaction, pub, battle->GetDialogIcon(), *enemies->GetEnemies());
+               // }
+
+               // if (entities->CheckPlayerClose(player->GetPlayerSprite())){
+               //      npcs->DisplayQuestMenu(1, entities->GetQuests(), player, player->GetPlayerSprite(),
+               //              battle->GetDiaBoxSprite(), battle->GetEnHP(), interaction, pub, battle->GetDialogIcon(), *enemies->GetEnemies());
+               // }
+
+               //should be draw all loot objects.
+               // loot->DrawChest();
+
+               // enemies->Draw();
+               // enemies->GetEnemies();
+               // enemies->DetectPlayer(player->GetPlayerSprite());
+
+               // battlemanager->HandlePlayerAttack(player, player->GetPlayerSprite(), battle->GetEnHP(), pub, enemies->GetEnemies(), sounds);
+               // battlemanager->HandleEnemyMeleeAttack(player, player->GetPlayerSprite(), battle->GetEnHP(), pub, enemies->GetEnemies(), sounds);
+
+               //if quest finished. Get gamemenu object to remove the quest from the quests.
+               // if (quests->CheckQuestComplete(1, battlemanager)){
+               //      quests->QuestSuccess(entities->GetQuests(), 0, player, player->GetPlayerSprite(), battle->GetDiaBoxSprite(),
+               //              battle->GetEnHP(), interaction, pub, battle->GetDialogIcon(), *enemies->GetEnemies(), events);
+               //      gamemenu->RemoveQuest(battlemanager, entities);
+
+               // }
+
+               // DrawPlayerDebugStats();
+
+               // gamemenu->CheckForEsc(csdl_setup);
+               // if (gamemenu->IsEscPressed()){
+               //      gamemenu->DisplayGameMenu(player, player->GetPlayerSprite(), battle->GetDiaBoxSprite(),
+               //              battle->GetEnHP(), interaction, pub, battle->GetDialogIcon(), *enemies->GetEnemies(), entities);
+               // }
+
+               // GetStats();
+
+               csdl_setup->End();      
+       }
+}
+
+void GameLoop::DrawPlayerDebugStats(){
+       text->getText(xp_str, FONT_FILE, 300, 10, text->getColor(), 6, false, true, csdl_setup->GetRenderer());
+       text->getText(level_str, FONT_FILE, 380, 10, text->getColor(), 6, false, true, csdl_setup->GetRenderer());
+       text->getText(hp_str,   FONT_FILE, 460, 10, text->getColor(), 6, false, true, csdl_setup->GetRenderer());
+       text->getText(dmg_str, FONT_FILE, 540, 10, text->getColor(), 6, false, true, csdl_setup->GetRenderer());
+}
+
+void GameLoop::GetStats(){
+               //player->GetLevelStats();
+               player->CheckLevelUp();
+               damage = player->GetDamage();
+               temp = to_string(damage);
+               dmg_str.replace(4,5,temp);
+
+               hp = player->GetHP();
+               temp = to_string(hp);
+               hp_str.replace(4,5,temp);
+
+               level = player->GetLevel();
+               temp = to_string(level);
+               level_str.replace(4,5,temp);
+
+               xp = player->GetXP();
+               temp = to_string(xp);
+               xp_str.replace(4,5,temp);
+}
diff --git a/src/GameLoop.h b/src/GameLoop.h
new file mode 100644 (file)
index 0000000..323658c
--- /dev/null
@@ -0,0 +1,87 @@
+#pragma once
+
+#include <stdlib.h>
+
+
+#include "SDL_Setup.h"
+#include "Sprite.h"
+#include "MainCharacter.h"
+#include <math.h>
+#include "stdafx.h"
+#include "Environment.h"
+#include "MainMenu.h"
+#include "Items.h"
+#include "Interaction.h"
+#include "Enemies.h"
+#include "SDL_Font_Setup.h"
+#include "Battle.h"
+#include "GameMenu.h"
+#include "NPC.h"
+#include "Quests.h"
+#include "GameMenu.h"
+#include "Loot.h"
+#include "PlayerManager.h"
+#include "EventManager.h"
+#include "SFXManager.h"
+#include "ConsoleDebug.h"
+#include "FileManagement.h"
+#include "EntityManager.h"
+
+class GameLoop
+{
+public:
+       GameLoop(int passed_ScreenWidth, int passed_ScreenHeight);
+       ~GameLoop(void);
+       void Begin();
+       void StartMenu();
+       void Play();
+       void GetStats();
+       void LoadFiles();
+       void GroupEntities();
+       void DrawPlayerDebugStats();
+private:
+       int ScreenWidth;
+       int ScreenHeight;
+
+       float CameraX;
+       float CameraY;
+
+       MainCharacter* player;
+       CEnvironment* pub;
+       Items *chest;
+       MainMenu* mainmenu;
+       NPC* npcs;
+       Quests* quests;
+       CEnemies* enemies;
+       CSDLFont_Setup* text;
+       CInteraction* interaction;
+       CSDL_Setup* csdl_setup;
+       CBattle* battle;
+       GameMenu* gamemenu;
+       Loot* loot;
+       PlayerManager* playermanager;
+       EventManager* events;
+       BattleManager* battlemanager;
+       SFXManager* sounds;
+       ConsoleDebug* debug;
+       FileManagement* filemanager;
+       EntityManager* entities;
+
+       string level_str;
+       string xp_str;
+       string hp_str;
+       string dmg_str;
+
+       bool start;
+       bool quit;
+
+       int damage;
+       int hp;
+       int xp;
+       int level;
+
+       string temp;
+       int MouseX;
+       int MouseY;
+};
+
diff --git a/src/GameMenu.cpp b/src/GameMenu.cpp
new file mode 100644 (file)
index 0000000..5a50fe2
--- /dev/null
@@ -0,0 +1,274 @@
+#include "GameMenu.h"
+
+
+
+GameMenu::GameMenu(CSDL_Setup* passed_SDL_Setup, int *passed_MouseX, int *passed_MouseY,  float *passed_CameraX, float *passed_CameraY, int ScreenWidth, int ScreenHeight) {
+       CameraX = passed_CameraX;
+       CameraY = passed_CameraY;
+
+       csdl_setup = passed_SDL_Setup;
+
+       MouseX = passed_MouseX;
+       MouseY = passed_MouseY;
+
+       w = 0;
+       h = 0;
+       rangeX = 0;
+       rangeY = 0;
+       count = 0;
+       prev_menu_choice_y = 220;
+
+       keyEsc = false;
+       keyPress = false;
+       hasKeyBeenReleased = false;
+
+       screenWidth = 0;
+       screenHeight = 0;
+       opt_select = 0;
+
+       Dialog = new CSDLFont_Setup(csdl_setup);
+       point = new Point();
+
+       GameMenuTextObj = new Text();
+}
+
+GameMenu::~GameMenu(){
+
+       delete Dialog;
+       delete point;
+       delete GameMenuTextObj;
+       delete objOfQuests;
+}
+
+void GameMenu::CheckForEsc(CSDL_Setup* passed_CSDL_Setup){
+       //has the user pressed esc? If so, let's start the menu.
+       csdl_setup = passed_CSDL_Setup;
+       if (csdl_setup->GetMainEvent()->key.keysym.sym == SDLK_ESCAPE){
+               keyEsc = true;
+               point->setPointVect(6, 245, 220, 245, 235, 245, 250);
+               InitialiseGameMenu();
+       }
+}
+
+
+bool GameMenu::IsEscPressed(){
+       return keyEsc;
+}
+
+void GameMenu::InitialiseGameMenu(){
+       GameMenuTextObj->eraseAllMessagesInVector();
+       Text menuItem1(263, 215, "Return to Game");
+       Text menuItem2(263, 230, "Inventory");
+       Text menuItem3(263, 245, "Quests");
+       Text menuItem4(263, 260, "Load/Save Game");
+       Text menuItem5(263, 275, "Options");
+       
+       GameMenuTextObj->addToTextVector(menuItem1);
+       GameMenuTextObj->addToTextVector(menuItem2);
+       GameMenuTextObj->addToTextVector(menuItem3);
+       GameMenuTextObj->addToTextVector(menuItem4);
+       GameMenuTextObj->addToTextVector(menuItem5);
+}
+
+void GameMenu::initialiseYValues(){
+       yValues.push_back(y);
+       yValues.push_back(y+15);
+       yValues.push_back(y+30);
+       yValues.push_back(y+45);
+       yValues.push_back(y+60);
+}
+
+void GameMenu::SetMenuGFX(Sprite* diaBoxSprite, Sprite* dialogIcon){
+       //store the previous values for later usage when we want to reset where these icons etc were previously.
+       GameMenuGFXVals.clear();
+       GameMenuGFXVals.push_back((int)diaBoxSprite->GetX());
+       GameMenuGFXVals.push_back((int)diaBoxSprite->GetY());
+       GameMenuGFXVals.push_back(diaBoxSprite->GetWidth());
+       GameMenuGFXVals.push_back(diaBoxSprite->GetHeight());
+       GameMenuGFXVals.push_back((int)dialogIcon->GetX());
+       GameMenuGFXVals.push_back((int)dialogIcon->GetY());
+
+       //set the sprites so the menu gfx are in the right place.
+       diaBoxSprite->SetX(240);
+       diaBoxSprite->SetWidth(170);
+       diaBoxSprite->SetHeight(150);
+       diaBoxSprite->SetY(170);
+       dialogIcon->SetX(250);
+       dialogIcon->SetY(220);
+}
+
+void GameMenu::ResetMenuGFX(Sprite* diaBoxSprite, Sprite* dialogIcon){
+       if (GameMenuGFXVals.size() == 6){
+               diaBoxSprite->SetX((float)GameMenuGFXVals[0]);
+               diaBoxSprite->SetWidth(GameMenuGFXVals[1]);
+               diaBoxSprite->SetHeight(GameMenuGFXVals[2]);
+               diaBoxSprite->SetY((float)GameMenuGFXVals[3]);
+               dialogIcon->SetX((float)GameMenuGFXVals[4]);
+               dialogIcon->SetY((float)GameMenuGFXVals[5]);
+       }
+       else 
+               cout << "Error 0: GameMenuGFXVector size incorrect, can't reset the vector" << endl;
+}
+
+void GameMenu::DisplayGameMenu(MainCharacter* player, Sprite* playerSprite, Sprite* diaBoxSprite,
+                                                          Sprite* enHP, CInteraction* interaction, CEnvironment* pub, Sprite* dialogIcon, vector<CEnemy*>Enemies, EntityManager* entities){
+
+                                                                  SetMenuGFX(diaBoxSprite, dialogIcon);
+                                                                  //Constantly draw menu for SDL
+                                                                  EventManager event(csdl_setup, MouseX, MouseY);
+                                                                  event.DrawGame(player, playerSprite, enHP, pub, Enemies);
+
+                                                                  //get option
+                                                                  CheckUserPress(dialogIcon, point->getPointVect(), entities);
+
+                                                                  //displays the text.
+                                                                  event.GameMenuEvent(GameMenuTextObj->getTextVect(), interaction, dialogIcon, diaBoxSprite, 9);
+
+                                                                  
+
+                                                                  csdl_setup->End();
+
+                                                                  //reset sprites back to previous location
+                                                                  //this routine will take the previous values it had and put them back in.
+                                                                  ResetMenuGFX(diaBoxSprite, dialogIcon);
+}
+
+
+int GameMenu::CheckUserPress(Sprite* menu_choice, vector<int>coords, EntityManager* entities){
+       vector<Quests*>quests = entities->GetQuests();
+
+       opt_select = 0;
+
+       menu_choice->SetY((float)prev_menu_choice_y);
+
+       switch (csdl_setup->GetMainEvent()->type)
+       {
+       case SDL_KEYDOWN:
+
+               switch(csdl_setup->GetMainEvent()->key.keysym.sym){
+               case SDLK_DOWN:
+                       switch((int)menu_choice->GetY()){
+                       case 220:
+                               menu_choice->SetY(menu_choice->GetY() +15);
+                               hasKeyBeenReleased = false;
+                               break;
+                       case 235:
+                               if (hasKeyBeenReleased == true)
+                                       menu_choice->SetY(menu_choice->GetY() +15); 
+                               hasKeyBeenReleased = false;
+                               break;
+                       case 250:
+                               if (hasKeyBeenReleased == true)
+                                       menu_choice->SetY(menu_choice->GetY() +15); 
+                               hasKeyBeenReleased = false;
+                               break;
+                       case 265:
+                               if (hasKeyBeenReleased == true)
+                                       menu_choice->SetY(menu_choice->GetY() +15); 
+                               hasKeyBeenReleased = false;
+                               break;
+                       }
+               case SDLK_UP:
+                       switch((int)menu_choice->GetY()){
+                       case 280:
+                               if (hasKeyBeenReleased == true)
+                                       menu_choice->SetY(menu_choice->GetY() -15);
+                               hasKeyBeenReleased = false;
+                               break;
+                       case 265:
+                               if (hasKeyBeenReleased == true)
+                                       menu_choice->SetY(menu_choice->GetY() -15);
+                               hasKeyBeenReleased = false;
+                               break;
+                       case 250:
+                               if (hasKeyBeenReleased == true)
+                                       menu_choice->SetY(menu_choice->GetY() -15);
+                               hasKeyBeenReleased = false;
+                               break;
+                       case 235:
+                               if (hasKeyBeenReleased == true)
+                                       menu_choice->SetY(menu_choice->GetY() -15); 
+                               hasKeyBeenReleased = false;
+                               break;
+                       }
+
+
+                       break;
+               case SDLK_RETURN:
+                       if (menu_choice->GetY() == coords[1])
+                       {
+                               cout << "You have pressed enter on first option" << endl;
+                               keyEsc = false;
+                               opt_select = 1;
+                       }
+
+                       if (menu_choice->GetY() == coords[3])
+                       {
+                               cout << "You have pressed enter on second option" << endl;
+                               for (int i = 0; i < 5; i++){
+                               g_GameMenuText.push_back("Inventory");
+                               }
+                               GameMenuTextObj->editAllMessagesInVector(5, g_GameMenuText, coords);
+                               opt_select = 2;
+                       }
+                       if (menu_choice->GetY() == coords[5])
+                       {
+                               cout << "You have pressed enter on third option" << endl;
+                               for (unsigned int i = 0; i < quests.size(); i++){
+                                       if (entities->AnyQuestAccepted()){
+                                               g_GameMenuText.push_back(quests[i]->GetQuest());
+                                               GameMenuTextObj->eraseAllMessagesInVector();
+                                               GameMenuTextObj->addToTextVector(quests[i]->makeTextObj(i, 245, 215));
+                                       }
+                                       else{
+                                               Text noQuests(250, 215, "No Quests Available");
+                                               GameMenuTextObj->eraseAllMessagesInVector();
+                                               GameMenuTextObj->addToTextVector(noQuests);
+                                       }
+                               }
+                               opt_select = 3;
+                       }
+                       break;
+               case SDLK_ESCAPE:
+                               initialiseYValues();
+                               GameMenuTextObj->ResizeVector(5);
+                               g_GameMenuText.push_back("Return to Game");
+                               g_GameMenuText.push_back("Inventory");
+                               g_GameMenuText.push_back("Quests");
+                               g_GameMenuText.push_back("Load/Save Game");
+                               g_GameMenuText.push_back("Options");
+                               
+                               GameMenuTextObj->editAllMessagesInVector(5, g_GameMenuText, yValues);
+                               break;
+                       }
+                       break;
+       case SDL_KEYUP:
+               switch(csdl_setup->GetMainEvent()->key.keysym.sym)
+               {
+               case SDLK_RETURN:
+                       hasKeyBeenReleased = true;
+                       break;
+               case SDLK_DOWN:
+                       hasKeyBeenReleased = true;
+                       break;
+               case SDLK_UP:
+                       hasKeyBeenReleased = true;
+                       break;
+               }
+               break;
+       }
+       prev_menu_choice_y = (int)menu_choice->GetY();
+
+       return opt_select;
+}
+
+void GameMenu::RemoveQuest(BattleManager* battlemanager, EntityManager* entities){
+       vector<Quests*>quests = entities->GetQuests();
+       for (unsigned int i = 0; i < quests.size(); i++){
+               int quest_id = i;
+               if (quests[i]->CheckQuestComplete(quest_id, battlemanager)){
+                       //TODO:
+                       entities->RemoveQuest(quest_id);
+               }
+       }
+}
diff --git a/src/GameMenu.h b/src/GameMenu.h
new file mode 100644 (file)
index 0000000..5bff3b4
--- /dev/null
@@ -0,0 +1,87 @@
+#pragma once
+#ifndef GAMEMENU_H
+#define GAMEMENU_H
+
+#include "stdafx.h"
+#include "Sprite.h"
+#include "SDL_Setup.h"
+#include "Interaction.h"
+#include "TextManager.h"
+#include "Point.h"
+#include <map>
+#include "Text.h"
+#include "EventManager.h"
+#include "Quests.h"
+#include "EntityManager.h"
+
+class GameMenu
+{
+
+public:
+GameMenu(CSDL_Setup* passed_SDL_Setup, int *passed_MouseX, int *passed_MouseY,  float *passed_CameraX, float *passed_CameraY,
+                                int ScreenWidth, int ScreenHeight);
+~GameMenu();
+
+void CheckForEsc(CSDL_Setup* passed_CSDL_Setup);
+void DisplayGameMenu(MainCharacter* player, Sprite* playerSprite, Sprite* diaBoxSprite,
+                                        Sprite* enHP, CInteraction* interaction, CEnvironment* pub, Sprite* dialogIcon, vector<CEnemy*>Enemies,
+                                        EntityManager* entities);
+void InitialiseGameMenu();
+void RemoveQuest(BattleManager* battlemanager, EntityManager* entities);
+void SetMenuGFX(Sprite* diaBoxSprite, Sprite* dialogIcon);
+void ResetMenuGFX(Sprite* diaBoxSprite, Sprite* dialogIcon);
+bool IsEscPressed();
+int CheckUserPress(Sprite* menu_choice, vector<int>coords, EntityManager* entities);
+void initialiseYValues();
+
+vector<string>g_GameMenuText;
+
+private:
+       int w;
+       int h;
+
+       int rangeX;
+       int rangeY;
+       int count;
+
+       static const int x = 263;
+       int y;
+
+       bool keyUp;
+       bool keyPress;
+       bool keyEsc;
+       bool hasKeyBeenReleased;
+
+       vector<int>GameMenuGFXVals;
+
+       int prev_menu_choice_y;
+       int opt_select;
+       int screenWidth;
+       int screenHeight;
+
+       
+
+       float *CameraX;
+       float *CameraY;
+
+       int *MouseX;
+       int *MouseY;
+
+       Quests* objOfQuests;
+
+       Text* GameMenuTextObj;
+
+       CSDL_Setup* csdl_setup;
+
+       Point* point;
+
+
+
+       CSDLFont_Setup* Dialog;
+
+
+
+       vector <int>yValues;
+};
+
+#endif
diff --git a/src/Interaction.cpp b/src/Interaction.cpp
new file mode 100644 (file)
index 0000000..9048c32
--- /dev/null
@@ -0,0 +1,192 @@
+#include "Interaction.h"
+
+CInteraction::CInteraction(CSDL_Setup* passed_SDL_Setup, int *passed_MouseX, int *passed_MouseY,  float *passed_CameraX, float *passed_CameraY)
+{
+
+       CameraX = passed_CameraX;
+       CameraY = passed_CameraY;
+
+       csdl_setup = passed_SDL_Setup;
+
+       MouseX = passed_MouseX;
+       MouseY = passed_MouseY;
+
+       w = 0;
+       h = 0;
+       rangeX = 0;
+       rangeY = 0;
+       count = 0;
+
+       keyDown = false;
+       click = false;
+       keyPress = false;
+
+       screenWidth = 0;
+       screenHeight = 0;
+       opt_select = 0;
+       hasKeyBeenReleased = true;
+       Menu_Select = new Sprite(csdl_setup->GetRenderer(),"res/data/menu_select.png",32,426,13,13,CameraX,CameraY, CollisionRect());
+}
+
+CInteraction::~CInteraction()
+{
+       delete csdl_setup;
+}
+
+void CInteraction::setRange(int x1, int y1, int x2, int y2)
+{
+       rangeX = x2 - x1;
+       rangeY = y2 - y1;
+}
+
+int CInteraction::getRangeX()
+{
+       return rangeX;
+}
+
+int CInteraction::getRangeY()
+{
+       return rangeY;
+}
+
+bool CInteraction::checkInteraction(Sprite* some_sprite)
+{
+       /*getchar();*/
+       //use keyboard input to animate fight or not
+       keyPress = false;
+       keyDown = false;
+       if (csdl_setup->GetMainEvent()->key.keysym.sym == SDLK_DOWN)
+       {
+               if (some_sprite->GetY() > 425 && some_sprite->GetY() <= 440)
+               {
+                       some_sprite->SetY(some_sprite->GetY()+20);
+                       keyPress = true;
+                       keyDown = true;
+                       return keyPress;
+               }
+       }
+
+       if (csdl_setup->GetMainEvent()->key.keysym.sym == SDLK_UP)
+       {
+               if (some_sprite->GetY() > 430 && some_sprite->GetY() <= 446)
+               {
+                       some_sprite->SetY(some_sprite->GetY()-20);
+                       keyPress = true;
+                       keyUp = true;
+
+                       return keyPress;
+               }
+
+       }
+
+       if (*MouseX > some_sprite->GetX() && *MouseX <= some_sprite->GetX()+some_sprite->GetWidth() && *MouseY > some_sprite->GetY() && *MouseY <= some_sprite->GetY()+some_sprite->GetHeight())
+       {
+
+               //get anim for mouseclick, run gameloop
+               cout << "You have clicked on something" << endl;
+               click = true;
+               return click;
+       }
+
+       return false;
+
+}
+
+bool CInteraction::EnterPress(){
+       switch (csdl_setup->GetMainEvent()->type)
+       {
+       case SDL_KEYDOWN:
+               switch(csdl_setup->GetMainEvent()->key.keysym.sym)
+               {
+               case SDLK_RETURN:
+                       return true;
+               }
+       }
+       return false;
+}
+
+int CInteraction::checkEnter(Sprite* menu_select, int passed_screenWidth, int passed_screenHeight)
+{
+       opt_select = 0;
+       switch (csdl_setup->GetMainEvent()->type)
+       {
+       case SDL_KEYDOWN:
+               switch(csdl_setup->GetMainEvent()->key.keysym.sym)
+               {
+               case SDLK_RETURN:
+                       if (menu_select->GetY() > 420 && menu_select->GetY() <= 440)
+                       {
+                               if(hasKeyBeenReleased){
+                               cout << "You have pressed enter on first option" << endl;
+                               hasKeyBeenReleased = false;
+                               opt_select = 1;
+                               }
+
+                       }
+
+                       if (menu_select->GetY() > 440 && menu_select->GetY() <= 460)
+                       {
+                               if(hasKeyBeenReleased){
+                               cout << "You have pressed enter on second option" << endl;
+                               hasKeyBeenReleased = false;
+                               opt_select = 2;
+                               }
+
+                       }
+                       break;
+               }
+               break;
+       case SDL_KEYUP:
+               switch(csdl_setup->GetMainEvent()->key.keysym.sym)
+               {
+               case SDLK_RETURN:
+                       opt_select = 0;
+                       hasKeyBeenReleased = true;
+                       break;
+               }
+               break;
+       }
+
+       return opt_select;
+
+}
+
+bool CInteraction::CheckKeyPress()
+{
+       switch (csdl_setup->GetMainEvent()->type)
+       {
+       case SDL_KEYDOWN:
+               if (!keyDown)
+               {
+                       keyDown = true;
+                       switch (csdl_setup->GetMainEvent()->key.keysym.sym)
+                       {
+                       case SDLK_RETURN:
+                               return true;
+                               break;
+
+                       default:
+                               break;
+                       }
+
+                       break;
+               }
+
+
+       case SDL_KEYUP:
+               keyDown = false;
+               switch (csdl_setup->GetMainEvent()->key.keysym.sym)
+               {
+               case SDLK_RETURN:
+                       return false;
+                       break;
+               default:
+                       break;
+               }
+
+               break;
+       default:
+               break;
+       }
+       return false;
+}
diff --git a/src/Interaction.h b/src/Interaction.h
new file mode 100644 (file)
index 0000000..0d33a1e
--- /dev/null
@@ -0,0 +1,55 @@
+#ifndef INTERACTION_H
+#define INTERACTION_H
+
+#pragma once
+#include "SDL_Setup.h"
+#include "Sprite.h"
+#include "MainCharacter.h"
+#include "stdafx.h"
+#include "Environment.h"
+#include "SDL_Font_Setup.h"
+
+
+
+class CInteraction: public MainCharacter
+{
+public:
+       CInteraction(CSDL_Setup* passed_SDL_Setup, int *passed_MouseX, int *passed_MouseY,  float *passed_CameraX, float *passed_CameraY);
+       ~CInteraction();
+
+       void setRange(int x1, int y1, int x2, int y2);
+
+       int checkEnter(Sprite* menu_select, int passed_screenWidth, int passed_screenHeight);
+
+       bool checkInteraction(Sprite* some_sprite);
+
+       int getRangeX();
+       int getRangeY();
+       bool CheckKeyPress();
+       bool EnterPress();
+       Sprite* getMenuArrow() {return Menu_Select;}
+private:
+       int w;
+       int h;
+
+       int rangeX;
+       int rangeY;
+       int count;
+
+       bool click;
+
+       bool keyDown;
+       bool keyUp;
+       bool keyPress;
+       int opt_select;
+       int screenWidth;
+       int screenHeight;
+       bool hasKeyBeenReleased;
+
+       Sprite* Menu_Select;
+
+
+};
+
+
+#endif
diff --git a/src/Items.cpp b/src/Items.cpp
new file mode 100644 (file)
index 0000000..fbd67f4
--- /dev/null
@@ -0,0 +1,101 @@
+#include "Items.h"
+
+Items::Items()
+{
+
+}
+
+Items::Items(CSDL_Setup* passed_SDL_Setup, int *passed_MouseX, int *passed_MouseY, float *passed_CameraX, float *passed_CameraY)
+{
+       CameraX = passed_CameraX;
+       CameraY = passed_CameraY;
+
+       csdl_setup = passed_SDL_Setup;
+       MouseX = passed_MouseX;
+       MouseY = passed_MouseY;
+
+
+       chest = new Sprite(csdl_setup->GetRenderer(), "res/data/misc/tchest.png", 400, 100, 47,47, CameraX, CameraY, CollisionRect(0,0,47,47));
+       chest->SetUpAnimation(12,8);
+       chest->SetOrgin((float)chest->GetWidth()/2.0f, (float)chest->GetHeight());
+
+
+       timeCheck = SDL_GetTicks();Follow = false;
+       distance = 0;
+       stopAnimation = false;
+}
+Items::~Items()
+{
+       delete chest;
+}
+
+void Items::Draw()
+{
+       chest->Draw();
+}
+
+void Items::Update()
+{
+       UpdateAnimation();
+       UpdateControls();
+}
+
+void Items::UpdateAnimation()
+{
+       //gets angle between mouse and bob's position to determine animation in radians.
+       float angle = atan2(Follow_Point_Y - *CameraY, Follow_Point_X - *CameraX);
+
+       //conversion to degrees
+       angle = (angle * (180.0f/3.14f) + 180.0f);
+
+       if (!stopAnimation)
+       {
+               if (angle >= 0 && angle <= 360)
+               {
+                       cout << distance << endl;
+                       if (distance > 15)
+                               chest->PlayAnimation(0, 2, 0, 300);
+                       else 
+                               chest->PlayAnimation(1,1,2,300);
+               }
+       }
+}
+void Items::UpdateControls()
+{
+       if (csdl_setup->GetMainEvent()->button.button == SDL_BUTTON_LEFT)
+       {
+               //changes position based on camera aswell
+               Follow_Point_X = (int)(*CameraX - *MouseX + 300);
+               Follow_Point_Y = (int)(*CameraY - *MouseY + 250);
+               Follow = true;
+       }
+
+
+       if ((timeCheck + 10 < SDL_GetTicks()) && Follow)
+       {
+
+               distance = (float)GetDistance((int)*CameraX, (int)*CameraY, Follow_Point_X, Follow_Point_Y);
+
+               if (distance == 0.0f)
+                       stopAnimation = true;
+               else
+                       stopAnimation = false;
+
+               if (distance > 15)
+               {
+                       if (*CameraX != Follow_Point_X)
+                       {
+                               *CameraX = *CameraX - (((*CameraX - Follow_Point_X) / distance) * 1.5f);
+                       }
+
+                       if (*CameraY != Follow_Point_Y)
+                       {
+                               *CameraY = *CameraY - (((*CameraY - Follow_Point_Y) / distance) * 1.5f);
+                       }
+               }
+               else
+                       Follow = false;
+
+               timeCheck = SDL_GetTicks();
+       }
+}
diff --git a/src/Items.h b/src/Items.h
new file mode 100644 (file)
index 0000000..2c6317e
--- /dev/null
@@ -0,0 +1,24 @@
+#pragma once
+
+#include "MainCharacter.h"
+#include "Sprite.h"
+#include "SDL_Setup.h"
+#include <math.h>
+#include "stdafx.h"
+
+class Items:public MainCharacter
+{
+public:
+       Items(CSDL_Setup* passed_SDL_Setup, int *passed_MouseX, int *passed_MouseY, float *passed_CameraX, float *passed_CameraY);
+       Items();
+       ~Items();
+       void Draw();
+
+       void Update();
+private:
+       void UpdateAnimation();
+       void UpdateControls();
+
+       Sprite* chest;
+};
+
diff --git a/src/Loot.cpp b/src/Loot.cpp
new file mode 100644 (file)
index 0000000..610ccb1
--- /dev/null
@@ -0,0 +1,82 @@
+#include "stdafx.h"
+#include "Loot.h"
+
+Loot::Loot()
+{
+
+}
+
+Loot::Loot(string type, int passed_X, int passed_Y, int passed_RewardLevel, CSDL_Setup* passed_SDL_Setup, float *passed_CameraX, float *passed_CameraY)
+{
+       csdl_setup = passed_SDL_Setup;
+       CameraX = passed_CameraX;
+       CameraY = passed_CameraY;
+       x = passed_X;
+       y = passed_Y;
+
+       distance = 0;
+
+       if (type == "chest"){
+       InitChest();
+       }
+
+}
+
+Loot::~Loot(void)
+{
+       delete chest;
+}
+
+void Loot::DrawChest(){
+       if (!CHEST_OPEN){
+               GetLoot()->PlayAnimation(1,1,0,200);
+               GetLoot()->Draw();
+       }
+       else 
+               GetLoot()->Draw();
+}
+
+//Play chest open animation when the chest opens then stop the player.
+void Loot::OpenChest(){
+       //in the future, get the chest ID num from map, depending on that ID, give dialog.
+       if (chest->HasAnimationFinished() == false){
+                       chest->AnimateOnce(1,3,0,200);
+                       CHEST_OPEN = true;
+       }
+}
+
+
+
+//get distance by passing in 4 vars, 1 pair of x/y locs's for player, 1 pair for obj.
+//get the difference between the x and y values and then perform equation that gets the distance.
+double Loot::GetDistanceFromObj(int player_x, int player_y, int obj_x, int obj_y){
+       double DifferenceX = player_x - obj_x;
+       double DifferenceY = player_y - obj_y;
+       distance = sqrt((DifferenceX * DifferenceX) + (DifferenceY * DifferenceY));
+       return distance;
+}
+
+//create player sprite object, setup animation and size.
+void Loot::SetPlayerSprite(){
+       player = new Sprite(csdl_setup->GetRenderer(), "res/data/new_mc_spritesheet.png", 300, 250, 55,55, CameraX, CameraY, CollisionRect(290,240,25,20));
+       player->SetUpAnimation(4,2);
+       player->SetOrgin((float)player->GetWidth()/2.0f, (float)player->GetHeight());
+}
+
+Sprite* Loot::GetPlayerSprite(){
+       if (player != NULL)
+               return player;
+
+       return nullptr;
+}
+Sprite* Loot::GetLoot(){
+       return chest;
+}
+
+void Loot::InitChest(){
+       chest = new Sprite(csdl_setup->GetRenderer(), "res/data/environment/red-chest.png", 400, 200, 45, 45, CameraX, CameraY, CollisionRect(0, 0, 46, 46));
+       chest->SetUpAnimation(4, 1);
+       chest->SetOrgin((float)chest->GetWidth(), (float)chest->GetHeight());
+       CHEST_OPEN = false;
+}
+
diff --git a/src/Loot.h b/src/Loot.h
new file mode 100644 (file)
index 0000000..898143c
--- /dev/null
@@ -0,0 +1,36 @@
+#pragma once
+
+#include "SDL_Setup.h"
+#include "Sprite.h"
+
+class Loot
+{
+public:
+       Loot(void);
+       Loot(string type, int passed_X, int passed_Y, int rewardLevel, CSDL_Setup* passed_SDL_Setup, float *passed_CameraX, float *passed_CameraY);
+       ~Loot(void);
+       void InitChest();
+       void DrawChest();
+       void OpenChest();
+       void CloseChest();
+       Sprite* GetLoot();
+       void SetPlayerSprite();
+       double GetDistanceFromObj(int player_x, int player_y, int obj_x, int obj_y);
+       Sprite* GetPlayerSprite();
+
+private:
+       bool CHEST_OPEN;
+       int gold;
+       int x;
+       int y;
+       int rewardLevel;
+       Sprite* chest;
+       CSDL_Setup* csdl_setup;
+       Sprite* player;
+       double distance;
+       float *CameraX;
+       float *CameraY;
+
+
+};
+
diff --git a/src/Main.cpp b/src/Main.cpp
new file mode 100644 (file)
index 0000000..7e20950
--- /dev/null
@@ -0,0 +1,18 @@
+#include "stdafx.h"
+//#include <vld.h>
+#include "GameLoop.h"
+
+const string g_FONT_FILE = "res/fonts/Minecraftia.ttf";
+
+using namespace std;
+
+int main()
+{
+       GameLoop*  mainGame = new GameLoop(640, 480);
+       // mainGame->Begin(false);
+
+       delete mainGame;
+
+       return 0;
+}
+
diff --git a/src/MainCharacter.cpp b/src/MainCharacter.cpp
new file mode 100644 (file)
index 0000000..6dc8e3d
--- /dev/null
@@ -0,0 +1,350 @@
+#include "MainCharacter.h"
+
+MainCharacter::MainCharacter(){
+
+}
+
+MainCharacter::MainCharacter(CSDL_Setup* passed_SDL_Setup, int *passed_MouseX, int *passed_MouseY,
+                                                        float *passed_CameraX, float *passed_CameraY, CEnvironment* passed_Environment){
+       Environment = passed_Environment;
+       CameraX = passed_CameraX;
+       CameraY = passed_CameraY;
+       csdl_setup = passed_SDL_Setup;
+       MouseX = passed_MouseX;
+       MouseY = passed_MouseY;
+       playerSprite = new Sprite(csdl_setup->GetRenderer(), "res/data/new_mc_spritesheet.png", 300, 250, 55,55, CameraX, CameraY, CollisionRect(290,240,25,20));
+       playerSprite->SetUpAnimation(4,2);
+       playerSprite->SetOrgin((float)playerSprite->GetWidth() / 2.0f, (float)playerSprite->GetHeight());
+       playerStats = new Sprite(csdl_setup->GetRenderer(), "res/data/stats_sm.png", 20, 20, 100,35, CameraX, CameraY, CollisionRect());
+       timeCheck = SDL_GetTicks();
+       Follow = false;
+       distance = 0;
+       stopAnimation = false;
+
+       //PLAYER STATS-------
+       hp = 0;
+       damage = 0;
+       level = 1;
+       dex = 0;
+       xp = 0;
+       keyDown = false;
+       canPlayerMove = true;
+}
+
+MainCharacter::~MainCharacter(){
+       delete playerStats;
+       delete playerSprite;
+}
+
+// if level up then set hp higher, check if level up by setting level+1 if XP reaches a threshold, get threshold via checking current level.
+int MainCharacter::GetLevelStats(){
+       if (level == 1)
+       {
+               damage = 10;
+               hp = 100;
+               threshold = 100;
+               return threshold;
+       }
+       if (level == 2)
+       {
+               damage = 15;
+               hp = 150;
+               threshold = 250;
+               return threshold;
+       }
+       if (level == 3)
+       {
+               threshold = 400;
+               return threshold;
+       }
+       if (level == 4)
+       {
+               threshold = 550;
+               return threshold;
+       }
+       else
+               return threshold;
+}
+
+int MainCharacter::GetXP(){
+
+       return xp;
+}
+
+int MainCharacter::GetLevel(){
+       return level;
+}
+
+int MainCharacter::GetHP(){
+       return hp;
+}
+
+int MainCharacter:: GetDamage(){
+       return damage;
+}
+
+void MainCharacter::SetHP(int p_hp){
+       hp = hp + p_hp;
+}
+
+void MainCharacter::SetDamage(int p_damage){
+       damage = p_damage;
+}
+void MainCharacter::SetXP(int p_xp){
+       xp = p_xp;
+}
+void MainCharacter::SetLevel(int p_level){
+       level = p_level;
+}
+
+void MainCharacter::AddXP(int p_xp){
+       xp = xp + p_xp;
+}
+
+void MainCharacter::CheckLevelUp(){
+       if (xp >= threshold){
+               level++;
+               GetLevelStats();
+       }
+}
+
+void MainCharacter::Draw(){
+       playerStats->DrawSteady();
+       playerSprite->DrawSteady();
+       UpdateAnimation(playerSprite);
+}
+
+void MainCharacter::UpdateAnimation(Sprite* some_sprite){
+       //gets angle between mouse and bob's position to determine animation in radians.
+       float angle = atan2(Follow_Point_Y - *CameraY, Follow_Point_X - *CameraX);
+
+       //conversion to degrees
+       angle = (angle * (180.0f/3.14f) + 180.0f);
+
+       if (!stopAnimation)
+       {
+               switch (csdl_setup->GetMainEvent()->type)
+       {
+       case SDL_KEYDOWN:
+               if (!keyDown)
+               {
+                       keyDown = true;
+                       switch (csdl_setup->GetMainEvent()->key.keysym.sym)
+                       {
+                       case SDLK_SPACE:
+                               some_sprite->PlayAnimation(0,3,1,10);
+                               break;
+
+                       default:
+                               break;
+                       }
+
+                       break;
+               }
+
+
+       case SDL_KEYUP:
+               keyDown = false;
+               switch (csdl_setup->GetMainEvent()->key.keysym.sym)
+               {
+               case SDLK_SPACE:
+                       some_sprite->PlayAnimation(0, 0, 0, 10);
+                       break;
+               default:
+                       break;
+               }
+
+               break;
+       default:
+               break;
+       }
+
+
+               if (angle >= 0 && angle <= 360)
+               {
+                       if (distance > 15)
+                               some_sprite->PlayAnimation(0, 2, 0, 300);
+                       else 
+                               some_sprite->PlayAnimation(1,1,0,300);
+               }
+
+       }
+}
+
+void MainCharacter::DisplayAttackAnim(){
+       playerSprite->PlayAnimation(1,3,1,300);
+}
+
+void MainCharacter::UpdateControls(vector<CEnemy*>Enemies, vector<CMap*>Maps){
+       //code for making character follow mouse click
+       if (csdl_setup->GetMainEvent()->type == SDL_MOUSEBUTTONDOWN 
+               || csdl_setup->GetMainEvent()->type == SDL_MOUSEMOTION)
+       {
+               if (csdl_setup->GetMainEvent()->button.button == SDL_BUTTON_LEFT)
+               {
+                       //changes position based on camera aswell
+                       Follow_Point_X = (int)(*CameraX - *MouseX + 300);
+                       Follow_Point_Y = (int)(*CameraY - *MouseY + 250);
+                       Follow = true;
+               }
+       }
+
+       if ((timeCheck+10 < SDL_GetTicks()) && Follow)
+       {
+
+               distance = (float)GetDistance((int)*CameraX, (int)*CameraY, Follow_Point_X, Follow_Point_Y);
+
+               if (distance == 0)
+                       stopAnimation = true;
+               else 
+                       stopAnimation = false;
+
+               if (distance > 15)
+               {
+
+                       bool colliding = false;
+
+                       // for (unsigned int i = 0; i < Environment->GetTrees().size(); i++)
+                       // {
+                       //      if (playerSprite->isColliding(Environment->GetTrees()[i]->GetTrunk()->GetCollisionRect()))
+                       //      {
+                       //              cout << "Player sprite is colliding with a tree!" << endl;
+                       //              colliding = true;
+                       //      }
+                       // }
+
+                       // for (unsigned int i = 0; i < Enemies.size(); i++)
+                       // {
+                       //      if (playerSprite->isColliding(Enemies[i]->GetEnemySprite()->GetCollisionRect()))
+                       //      {
+                       //              cout << "Player sprite is colliding with a enemy sprite!" << endl;
+                       //              if (*CameraX > Follow_Point_X)
+                       //              {
+                       //                      *CameraX = *CameraX + 5;
+                       //              }
+                       //              if (*CameraX < Follow_Point_X)
+                       //              {
+                       //                      *CameraX = *CameraX - 5;
+                       //              }
+                       //              if (*CameraY > Follow_Point_Y)
+                       //              {
+                       //                      *CameraY = *CameraY + 5;
+                       //              }
+                       //              if (*CameraY < Follow_Point_Y)
+                       //              {
+                       //                      *CameraY = *CameraY - 5;
+                       //              }
+                       //              Follow_Point_X = (int)*CameraX;
+                       //              Follow_Point_Y = (int)*CameraY;
+                       //              distance = 0;
+                       //              Follow = false;
+
+                       //              colliding = true;
+                       //      }
+
+                       // }
+
+                       // for (int i = 0; i < Maps[i]->GetTableNum(); i++)
+                       // {
+                       //      if (playerSprite->isColliding(Maps[i]->GetTable()->GetCollisionRect()))
+                       //      {
+                       //              cout << "Player sprite is colliding with a table!" << endl;
+                       //              if (*CameraX > Follow_Point_X)
+                       //              {
+                       //                      *CameraX = *CameraX + 5;
+                       //              }
+                       //              if (*CameraX < Follow_Point_X)
+                       //              {
+                       //                      *CameraX = *CameraX - 5;
+                       //              }
+                       //              if (*CameraY > Follow_Point_Y)
+                       //              {
+                       //                      *CameraY = *CameraY + 5;
+                       //              }
+                       //              if (*CameraY < Follow_Point_Y)
+                       //              {
+                       //                      *CameraY = *CameraY - 5;
+                       //              }
+                       //              Follow_Point_X = (int)*CameraX;
+                       //              Follow_Point_Y = (int)*CameraY;
+                       //              distance = 0;
+                       //              Follow = false;
+
+                       //              colliding = true;
+                       //      }
+                       // }
+
+                       // for (int i = 0; i < Maps[i]->GetTableNum(); i++)
+                       // {
+                       //      if (playerSprite->isColliding(Maps[i]->GetWallOutline_Top()->GetCollisionRect()) || playerSprite->isColliding(Maps[i]->GetWallOutline_Left()->GetCollisionRect())
+                       //              || playerSprite->isColliding(Maps[i]->GetWallOutline_Bottom()->GetCollisionRect()) || playerSprite->isColliding(Maps[i]->GetWallOutline_Right()->GetCollisionRect()))
+                       //      {
+                       //              cout << "Player sprite is colliding with outside wall" << endl;
+                       //              if (*CameraX > Follow_Point_X)
+                       //              {
+                       //                      *CameraX = *CameraX + 5;
+                       //              }
+                       //              if (*CameraX < Follow_Point_X)
+                       //              {
+                       //                      *CameraX = *CameraX - 5;
+                       //              }
+                       //              if (*CameraY > Follow_Point_Y)
+                       //              {
+                       //                      *CameraY = *CameraY + 5;
+                       //              }
+                       //              if (*CameraY < Follow_Point_Y)
+                       //              {
+                       //                      *CameraY = *CameraY - 5;
+                       //              }
+                       //              Follow_Point_X = (int)*CameraX;
+                       //              Follow_Point_Y = (int)*CameraY;
+                       //              distance = 0;
+                       //              Follow = false;
+
+                       //              colliding = true;
+                       //      }
+                       // }
+
+                       if (!colliding)
+                       {
+                               if (*CameraX != Follow_Point_X)
+                               {
+                                       *CameraX = *CameraX - (((*CameraX-Follow_Point_X)/distance) * 1.5f ) ;
+                               }
+
+                               if (*CameraY != Follow_Point_Y)
+                               {
+                                       *CameraY = *CameraY - (((*CameraY-Follow_Point_Y)/distance) * 1.5f ) ;
+                               }
+                       }
+               }
+               else 
+                       Follow = false;
+
+               timeCheck = SDL_GetTicks();
+       }
+}
+
+
+void MainCharacter::Update(vector<CEnemy*>Enemies, vector<CMap*>Maps){
+       UpdateAnimation(playerSprite);
+       UpdateControls(Enemies, Maps);
+
+       
+}
+
+Sprite* MainCharacter::GetPlayerSprite(){
+       return playerSprite;
+}
+
+//Stops player at the current camera position as the follow point is where you have clicked.
+void MainCharacter::StopMove(){
+       Follow_Point_X = (int)*CameraX;
+       Follow_Point_Y = (int)*CameraY;
+}
+double MainCharacter::GetDistance(int X1, int Y1, int X2, int Y2){
+       double DifferenceX = X1 - X2;
+       double DifferenceY = Y1 - Y2;
+       double distance = sqrt((DifferenceX * DifferenceX) + (DifferenceY * DifferenceY));
+       return distance;
+}
diff --git a/src/MainCharacter.h b/src/MainCharacter.h
new file mode 100644 (file)
index 0000000..2f45fc4
--- /dev/null
@@ -0,0 +1,78 @@
+#pragma once
+
+#ifndef MAINCHARACTER_H
+#define MAINCHARACTER_H
+
+#include "Sprite.h"
+#include "SDL_Setup.h"
+#include <math.h>
+#include "stdafx.h"
+#include "Environment.h"
+#include "Enemy.h"
+
+class MainCharacter{
+public:
+       MainCharacter(CSDL_Setup* passed_SDL_Setup, int *passed_MouseX, int *passed_MouseY, float *passed_CameraX, float *passed_CameraY, CEnvironment* passed_Environment);
+       MainCharacter(void);
+       ~MainCharacter(void);
+       double GetDistance(int X1, int Y1, int X2, int Y2);
+
+       void Update(vector<CEnemy*>Enemies, vector<CMap*>Maps);
+       void Draw();
+       void StopMove();
+
+       int GetHP();
+       int GetDamage();
+       int GetXP();
+       int GetLevel();
+       void SetHP(int p_hp);
+       void SetDamage(int p_damage);
+       void SetXP(int p_xp);
+       void SetLevel(int p_level);
+       void AddXP(int p_xp);
+       void CheckLevelUp();
+       int GetLevelStats();
+       
+       void DisplayAttackAnim();
+
+       Sprite* GetPlayerSprite();
+
+private:
+       //player stats
+       int hp;
+       int xp;
+       int damage;
+       int level;
+       int dex;
+
+
+       //for checking level/setting stats
+       int threshold;
+protected:
+       CEnvironment* Environment;
+
+       void UpdateAnimation(Sprite* some_sprite);
+       void UpdateControls(vector<CEnemy*>Enemies, vector<CMap*>Maps);
+       float *CameraX;
+       float *CameraY;
+
+       int *MouseX;
+       int *MouseY;
+       CSDL_Setup* csdl_setup;
+
+       Sprite* chest;
+       Sprite* playerSprite;
+       Sprite* playerStats;
+       int timeCheck;
+       bool keyDown;
+       bool Follow;
+       int Follow_Point_X;
+       int Follow_Point_Y;
+
+       float distance;
+       bool stopAnimation;
+       bool canPlayerMove;
+};
+
+
+#endif
diff --git a/src/MainMenu.cpp b/src/MainMenu.cpp
new file mode 100644 (file)
index 0000000..7a21038
--- /dev/null
@@ -0,0 +1,179 @@
+#include "MainMenu.h"
+
+
+MainMenu::MainMenu()
+{
+}
+
+MainMenu::MainMenu(CSDL_Setup* passed_SDL_Setup, int *passed_MouseX, int *passed_MouseY, int passed_ScreenWidth,
+                                  int passed_ScreenHeight, float *passed_CameraX, float *passed_CameraY)
+{
+       CameraX = passed_CameraX;
+       CameraY = passed_CameraY;
+
+       ScreenWidth = passed_ScreenWidth;
+       ScreenHeight = passed_ScreenHeight;
+
+       csdl_setup = passed_SDL_Setup;
+
+       MouseX = passed_MouseX;
+       MouseY = passed_MouseY;
+
+
+       mainMenu = new Sprite(csdl_setup->GetRenderer(), "res/data/menu/mainmenu.gif", 0,0, ScreenWidth, ScreenHeight, CameraX, CameraY, CollisionRect());
+
+       PlayButton = new Sprite(csdl_setup->GetRenderer(), "res/data/menu/play-but.png", 230,140, 237, 74, CameraX, CameraY, CollisionRect());
+       PlayButton_Scroll = new Sprite(csdl_setup->GetRenderer(), "res/data/menu/play-but-scroll.png", 230,140, 237, 74, CameraX, CameraY, CollisionRect());
+       OptionButton = new Sprite(csdl_setup->GetRenderer(), "res/data/menu/option-but.png", 230,240, 237, 74, CameraX, CameraY, CollisionRect());
+       OptionButton_Scroll = new Sprite(csdl_setup->GetRenderer(), "res/data/menu/option-but-scroll.png", 230,240, 237, 74, CameraX, CameraY, CollisionRect());
+       AboutButton = new Sprite(csdl_setup->GetRenderer(), "res/data/menu/about-but.png", 230,340, 237, 74, CameraX, CameraY, CollisionRect());
+       AboutButton_Scroll = new Sprite(csdl_setup->GetRenderer(), "res/data/menu/about-but-scroll.png", 230,340, 237, 74, CameraX, CameraY, CollisionRect());
+       AboutPage = new Sprite(csdl_setup->GetRenderer(), "res/data/menu/about-page.png", 0,0, 640,480, CameraX, CameraY, CollisionRect());
+       AboutPage_Scroll = new Sprite(csdl_setup->GetRenderer(), "res/data/menu/about-page-hover.png", 0,0, 640, 480, CameraX, CameraY, CollisionRect());
+
+       /*timeCheck = SDL_GetTicks();Follow = false;*/
+       /*distance = 0;
+       stopAnimation = false;*/
+       start = false;
+}
+MainMenu::~MainMenu()
+{
+       delete mainMenu;
+       delete PlayButton;
+       delete PlayButton_Scroll;
+       delete OptionButton;
+       delete OptionButton_Scroll;
+       delete AboutButton;
+       delete AboutButton_Scroll;
+       delete AboutPage;
+       delete AboutPage_Scroll;
+}
+
+void MainMenu::Draw()
+{
+       mainMenu->Draw();
+       PlayButton->Draw();
+       OptionButton->Draw();
+       AboutButton->Draw();
+       // cout << "Mouse X = " << *MouseX;
+       // cout << "\tMouse Y = " << *MouseY;
+}
+
+bool MainMenu::AboutMenu()
+{
+       cout << "Mouse X = " << *MouseX;
+       cout << "\tMouse Y = " << *MouseY;
+       AboutPage->Draw();
+       start = false;
+               if (csdl_setup->GetMainEvent()->type == SDL_MOUSEMOTION)
+               {
+                       if (*MouseX > 110 && *MouseX <= 540 && *MouseY > 310 && *MouseY <= 360)
+                       {
+                               AboutPage_Scroll->Draw();
+                               //get anim for mouseclick, run gameloop
+                               // cout << "You have scrolled over the return to menu button!" << endl;
+                               /*system("pause");*/
+                       }
+               }
+               if (csdl_setup->GetMainEvent()->type == SDL_MOUSEBUTTONDOWN)
+               {
+                       if (csdl_setup->GetMainEvent()->button.button == SDL_BUTTON_LEFT)
+                       {
+                               if (*MouseX > 110 && *MouseX <= 540 && *MouseY > 310 && *MouseY <= 360)
+                               {
+                                       AboutPage_Scroll->Draw();
+                                       //get anim for mouseclick, run gameloop
+                                       // cout << "You have clicked the return to menu button!" << endl;
+                                       start = true;
+                                       return start;
+                               }
+                       }
+               }
+       return start;
+}
+
+int MainMenu::GetButtonClick()
+{
+       //for mouse motion
+       /*do
+       {*/
+
+       //Playbutton code for scroll
+               if (csdl_setup->GetMainEvent()->type == SDL_MOUSEMOTION)
+               {
+                       if (*MouseX > 230 && *MouseX <= 400 && *MouseY > 140 && *MouseY <= 214)
+                       {
+                               PlayButton_Scroll->Draw();
+                               //get anim for mouseclick, run gameloop
+                               // cout << "You have scrolled over the start game button!" << endl;
+                               /*system("pause");*/
+                       }
+               }
+               //Playbutton code for clicking
+               if (csdl_setup->GetMainEvent()->type == SDL_MOUSEBUTTONDOWN)
+               {
+                       if (csdl_setup->GetMainEvent()->button.button == SDL_BUTTON_LEFT)
+                       {
+                               if (*MouseX > 230 && *MouseX <= 466 && *MouseY > 140 && *MouseY <= 214)
+                               {
+                                       PlayButton_Scroll->Draw();
+                                       //get anim for mouseclick, run gameloop
+                                       // cout << "You have clicked the start game button!" << endl;
+                                       return 1;
+                               }
+                       }
+               }
+
+               if (csdl_setup->GetMainEvent()->type == SDL_MOUSEMOTION)
+               {
+                       if (*MouseX > 230 && *MouseX <= 460 && *MouseY > 240 && *MouseY <= 340)
+                       {
+                               OptionButton_Scroll->Draw();
+                               //get anim for mouseclick, run gameloop
+                               // cout << "You have scrolled over the option button!" << endl;
+                               /*system("pause");*/
+                       }
+               }
+               if (csdl_setup->GetMainEvent()->type == SDL_MOUSEBUTTONDOWN)
+               {
+                       if (csdl_setup->GetMainEvent()->button.button == SDL_BUTTON_LEFT)
+                       {
+                               if (*MouseX > 230 && *MouseX <= 466 && *MouseY > 240 && *MouseY <= 340)
+                               {
+                                       OptionButton_Scroll->Draw();
+                                       //get anim for mouseclick, run gameloop
+                                       // cout << "You have clicked the option button!" << endl;
+                                       return 2;
+                               }
+                       }
+               }
+
+               if (csdl_setup->GetMainEvent()->type == SDL_MOUSEMOTION)
+               {
+                       if (*MouseX > 230 && *MouseX <= 400 && *MouseY > 340 && *MouseY <= 440)
+                       {
+                               AboutButton_Scroll->Draw();
+                               //get anim for mouseclick, run gameloop
+                               // cout << "You have scrolled over the about button!" << endl;
+                               /*system("pause");*/
+                       }
+               }
+               if (csdl_setup->GetMainEvent()->type == SDL_MOUSEBUTTONDOWN)
+               {
+                       if (csdl_setup->GetMainEvent()->button.button == SDL_BUTTON_LEFT)
+                       {
+                               if (*MouseX > 230 && *MouseX <= 466 && *MouseY > 320 && *MouseY <= 420)
+                               {
+                                       AboutButton_Scroll->Draw();
+                                       //get anim for mouseclick, run gameloop
+                                       // cout << "You have clicked the about button!" << endl;
+                                       return 3;
+                               }
+                       }
+               }
+
+               return 0;
+       } /*while (start==false);*/
+       
+
+
diff --git a/src/MainMenu.h b/src/MainMenu.h
new file mode 100644 (file)
index 0000000..ef882da
--- /dev/null
@@ -0,0 +1,42 @@
+#pragma once
+#ifndef MAINMENU_H
+#define MAINMENU_H
+
+#include "Items.h"
+#include "Sprite.h"
+#include "SDL_Setup.h"
+#include <math.h>
+#include "stdafx.h"
+//#include "Main.h"
+#include "CollissionRect.h"
+
+class MainMenu:public Items
+{
+public:
+       MainMenu(CSDL_Setup* passed_SDL_Setup, int *passed_MouseX, int *passed_MouseY, int passed_ScreenWidth,
+                                int passed_ScreenHeight, float *passed_CameraX, float *passed_CameraY);
+       MainMenu();
+       ~MainMenu();
+       void Draw();
+       int GetButtonClick();
+       bool AboutMenu();
+private:
+       Sprite* mainMenu;
+       Sprite* PlayButton;
+       Sprite* PlayButton_Scroll;
+       Sprite* OptionButton;
+       Sprite* OptionButton_Scroll;
+       Sprite* AboutButton;
+       Sprite* AboutButton_Scroll;
+       Sprite* AboutPage;
+       Sprite* AboutPage_Scroll;
+       CSDL_Setup* csdl_setup;
+
+
+       int ScreenWidth;
+       int ScreenHeight;
+
+       bool start;
+};
+
+#endif
diff --git a/src/Map.cpp b/src/Map.cpp
new file mode 100644 (file)
index 0000000..f298404
--- /dev/null
@@ -0,0 +1,72 @@
+#include "Map.h"
+
+CMap::CMap(int x_count, int y_count, int p_tile_size_x, int p_tile_size_y, int texture_size_x, int texture_size_y, 
+                  string map_file_loc, float *camera_x, float *camera_y, CSDL_Setup* csdl_setup, bool tables, bool trees, int p_stool_y){
+       tile_size_x = p_tile_size_x;
+       tile_size_y = p_tile_size_y;
+       stool_y = p_stool_y;
+       map_texture = new Sprite(csdl_setup->GetRenderer(),map_file_loc, texture_size_x*x_count, texture_size_y*y_count, texture_size_x,
+                                                        texture_size_y, camera_x, camera_y, CollisionRect(0,0,0,0));
+       if (tables == true){
+               tables = false;
+               table = new Sprite(csdl_setup->GetRenderer(),"res/data/environment/pub/table.png", 200, 300, 100, 300, camera_x,
+                                                  camera_y, CollisionRect(0,0,100,300));
+
+               stool = new Sprite(csdl_setup->GetRenderer(),"res/data/environment/pub/stool.png", 300,stool_y, 30,30, camera_x,
+                                                  camera_y, CollisionRect(0,0,30,30));
+       }
+               //make objects for outside walls to get drawn by SDL
+               for (int i = 0; i < 5; i++){
+                       wall_out_left = new Sprite(csdl_setup->GetRenderer(),"res/data/environment/pub/wall_outline.png", -30,0, 30,480*i, camera_x,
+                                                                          camera_y, CollisionRect(0,0,30,480*i));
+                       wall_out_right = new Sprite(csdl_setup->GetRenderer(),"res/data/environment/pub/wall_outline.png",
+                                                                               texture_size_x*tile_size_x,0, 30,480*i, camera_x, camera_y, CollisionRect(0,0,30,480*i));
+               }
+               for (int i = 0; i < 5; i++){
+                       wall_out_top = new Sprite(csdl_setup->GetRenderer(),"res/data/environment/pub/wall_outline_w.png", -30,0, 640*i,30,
+                                                                         camera_x, camera_y, CollisionRect(0,0,640*i,30));
+                       wall_out_bottom = new Sprite(csdl_setup->GetRenderer(),"res/data/environment/pub/wall_outline_w.png", -30,
+                                                                                texture_size_y*tile_size_y, 640*i,30, camera_x, camera_y, CollisionRect(0,0,640*i,30));
+               }
+
+}
+
+CMap::~CMap(){
+       for (int i = 0; i < tile_size_x; i++){
+               for (int j = 0; j < tile_size_y; j++){
+                       delete map_texture;
+               }
+       }
+       for (int i = 0; i < 5; i++){
+               delete wall_out_bottom;
+               delete wall_out_left;
+               delete wall_out_right;
+               delete wall_out_top;
+       }
+       delete map_texture;
+       delete table;
+       delete stool;
+}
+
+void CMap::DrawTexture(){
+       //draw floor
+       map_texture->Draw();
+       //draw walls
+       wall_out_bottom->Draw();
+       wall_out_top->Draw();
+       wall_out_left->Draw();
+       wall_out_right->Draw();
+}
+
+void CMap::DrawTable(){
+       table->Draw();
+}
+
+void CMap::DrawStool(){
+       stool->Draw();
+}
+
+int CMap::GetTableNum(){
+       return 1;
+}
+
diff --git a/src/Map.h b/src/Map.h
new file mode 100644 (file)
index 0000000..1003c06
--- /dev/null
+++ b/src/Map.h
@@ -0,0 +1,46 @@
+#pragma once
+#ifndef MAP_H
+#define MAP_H
+
+#include "Sprite.h"
+#include "stdafx.h"
+#include "SDL_Setup.h"
+
+class CMap
+{
+public:
+       CMap(int xCount, int yCount, int passed_TileSizeX, int passed_TileSizeY, int TextureSizeX, int TextureSizeY, 
+                  string MapFileLoc, float *CameraX, float *CameraY, CSDL_Setup* csdl_setup, bool tables, bool trees, int StoolY);
+       ~CMap();
+
+       void DrawTable();
+       void DrawTexture();
+       void DrawStool();
+       Sprite* GetMapTexture() {return map_texture;}
+       Sprite* GetTable() {return table;}
+
+       //return wall sprites
+       Sprite* GetWallOutline_Left() {return wall_out_left;}
+       Sprite* GetWallOutline_Right() {return wall_out_right;}
+       Sprite* GetWallOutline_Top() {return wall_out_top;}
+       Sprite* GetWallOutline_Bottom() {return wall_out_bottom;}
+
+
+       int GetTableNum();
+private:
+       Sprite* map_texture;
+       Sprite* table;
+       Sprite* stool;
+       Sprite* wall_out_left;
+       Sprite* wall_out_right;
+       Sprite* wall_out_top;
+       Sprite* wall_out_bottom;
+
+       int stool_y;
+       int tile_size_x;
+       int tile_size_y;
+       int screen_width;
+       int screen_height;
+};
+
+#endif
diff --git a/src/MapManager.cpp b/src/MapManager.cpp
new file mode 100644 (file)
index 0000000..36f47a3
--- /dev/null
@@ -0,0 +1,101 @@
+#include "stdafx.h"
+#include "MapManager.h"
+
+
+MapManager::MapManager(void)
+{
+}
+
+
+MapManager::~MapManager(void)
+{
+}
+
+//split into LoadQuestFile() & ReadQuestFile()
+//read a file called quests.txt
+//the file should take the npc's location, the spritesheet file location, the qeust type (kill, speak to, collect, go to , multiple)LoadQuests(){
+void MapManager::LoadQuests(){
+       ifstream LoadedFile ("data/quests.txt");
+       string line;
+
+       int currentType = TypeNone;
+       if (LoadedFile.is_open())
+       {
+               while (LoadedFile.good() )
+               {
+                       getline(LoadedFile, line);
+                       if (line == "---BEGIN QUESTS---")
+                       {
+                               currentType = TypeQuest;
+                       }
+
+                       else if (line == "---END QUESTS---")
+                       {
+                               currentType = TypeNone;
+                       }
+                       else {
+                               if (currentType == TypeQuest)
+                               {
+                                       //start reading in the quest data.
+                                       istringstream iss(line);
+
+                                       int npc_x = 0; 
+                                       int npc_y = 0; 
+                                       string spritesheet_loc;
+                                       int npc_id;
+                                       //QuestType questType;
+                                       int gold_earned;
+                                       int xp_earned;
+                                       string quest_text;
+                                       string PreviousWord = ""; 
+                                       //check for X/Y loc, spritesheet loc, npc num, quest type, gold earned and xp earned. get quest text.
+                                       //store them in variables to init quest objects.
+                                       while (iss) 
+                                       { 
+                                               string word; 
+                                               iss >> word; 
+
+                                               if (PreviousWord == "x:") { 
+                                                       npc_x = atoi( word.c_str() ); 
+                                               } 
+
+                                               if (PreviousWord == "y:") { 
+                                                       npc_y = atoi( word.c_str() ); 
+                                               } 
+                                               if (PreviousWord == "spritesheet_loc:"){
+                                                       spritesheet_loc = word;
+                                               }
+                                               if (PreviousWord == "npc_id:"){
+                                                       npc_id = atoi( word.c_str() ); 
+                                               }
+                                               if (PreviousWord == "quest_text:"){
+                                                       quest_text = word;
+                                               }
+                                               if (PreviousWord == "quest_type:"){
+                                                       //TODO:
+                                               }
+                                               if (PreviousWord == "gold_earned:"){
+                                                       gold_earned = atoi( word.c_str() );
+                                               }
+                                               if (PreviousWord == "xp_earned:"){
+                                                       xp_earned = atoi( word.c_str() );
+                                                       // Quests *quest = new Quests(xp_earned, gold_earned, quest_text);
+                                                       //NPC *npc = new NPC(npc_x, npc_y, CameraX, CameraY, csdl_setup, *quest, npc_id, NPCAssets);
+                                                       //npcs.push_back(npc);
+                                               }
+                                               PreviousWord = word; 
+                                       } 
+
+
+                               } 
+                       }
+
+               }
+       }
+}
+
+void MapManager::LoadNPCs(){
+       
+       
+
+}
diff --git a/src/MapManager.h b/src/MapManager.h
new file mode 100644 (file)
index 0000000..f65cb3e
--- /dev/null
@@ -0,0 +1,23 @@
+#pragma once
+
+#include <sstream>
+#include <fstream>
+#include "Quests.h"
+#include "NPC.h"
+
+
+
+class MapManager
+{
+public:
+       MapManager(void);
+       ~MapManager(void);
+       enum Obj_Type {
+               TypeNone,
+               TypeQuest
+       };
+
+       void LoadQuests();
+       void LoadNPCs();
+};
+
diff --git a/src/NPC.cpp b/src/NPC.cpp
new file mode 100644 (file)
index 0000000..dd9261c
--- /dev/null
@@ -0,0 +1,226 @@
+#include "stdafx.h"
+#include "NPC.h"
+
+//need to determine what NPC png to load
+//Not sure if we need cameraX/cameraY as these are set to 0 in gameloop.cpp..
+NPC::NPC(int p_x, int p_y, int p_npc_id, string p_npc_sprite_loc, string p_name, float* p_camera_x, float* p_camera_y, CSDL_Setup* p_csdl_setup, vector<Quests*>quests){
+       x = p_x;
+       y = p_y;
+       csdl_setup = p_csdl_setup;
+       const int NPCSPRITEWIDTH = 50;
+       const int NPCSPRITEHEIGHT = 50;
+       const int NPCINTERACTSYMBOLX = x+40;
+       const int NPCINTERACTSYMBOLY = y-20;
+       CameraX = p_camera_x;
+       CameraY = p_camera_y;
+       file_loc = p_npc_sprite_loc;
+       npcSprite = new Sprite(csdl_setup->GetRenderer(),file_loc,x,y,NPCSPRITEWIDTH,NPCSPRITEHEIGHT,CameraX, CameraY,CollisionRect());
+       npc_hover_interact = new Sprite(csdl_setup->GetRenderer(),"res/data/NPCS/npc_hover_interact.png",NPCINTERACTSYMBOLX,NPCINTERACTSYMBOLY,6,23,CameraX, CameraY,CollisionRect());
+       NPCTextObj = new Text();
+       numNPC = p_npc_id;
+       NPCQuest = *quests[numNPC];
+       hasKeyBeenReleased = false;
+       optSelect = 0;
+       isQuestAdded = false;
+       firstPress = false;
+       isPlayerClose = false;
+       exitNPCDialog = false;
+       countEnterPress = 0;
+}
+
+NPC::NPC(int x_passed, int y_passed, int *passed_MouseX, int *passed_MouseY, float *passed_CameraX, float *passed_CameraY, int passed_screenWidth, int passed_screenHeight, CSDL_Setup* passed_csdl_setup, int NPCref){
+       x = x_passed;
+       y = y_passed;
+       CameraX = passed_CameraX;
+       CameraY = passed_CameraY;
+       MouseX = passed_MouseX;
+       MouseY = passed_MouseY;
+       csdl_setup = passed_csdl_setup;
+       screenWidth = passed_screenWidth;
+       screenHeight = passed_screenHeight;
+       numNPC = NPCref;
+       GetNpcFileLocation();
+       npcSprite = new Sprite(csdl_setup->GetRenderer(),NPCAssets[NPCref],300,350,50,50,CameraX,CameraY, CollisionRect());
+
+       hasKeyBeenReleased = false;
+       optSelect = 0;
+       isQuestAdded = false;
+       firstPress = false;
+       isPlayerClose = false;
+       exitNPCDialog = false;
+       countEnterPress = 0;
+       NPCTextObj = new Text();
+}
+
+NPC::~NPC(void){
+       delete npcSprite;
+       delete npc_hover_interact;
+}
+
+int NPC::GetNPCX(){
+       return npcSprite->GetSpriteCameraX();
+}
+
+int NPC::GetNPCY(){
+       return npcSprite->GetSpriteCameraY();
+}
+string NPC::GetQuestDesc(){
+       return NPCQuest.GetQuest();
+}
+
+Quests NPC::GetQuest(){
+       return NPCQuest;
+}
+
+void NPC::Draw(){
+       npcSprite->Draw();
+       npc_hover_interact->Draw();
+}
+
+Sprite NPC::GetNPSprite(){
+       return *npcSprite;
+}
+
+bool NPC::isPlayerCloseToGetQuest(Quests *objOfQuests, vector<NPC> vectOfNPCS, Sprite* player){
+       for (unsigned int i = 0; i < vectOfNPCS.size(); i++)
+       {
+               int playerLocX = player->GetSpriteCameraX();
+               int playerLocY = player->GetSpriteCameraY();
+               int NPCLocX = vectOfNPCS[i].npcSprite->GetSpriteCameraX();
+               int NPCLocY = vectOfNPCS[i].npcSprite->GetSpriteCameraY();
+
+               if (player->GetSpriteCameraX() - vectOfNPCS[i].npcSprite->GetSpriteCameraX() < 60 && player->GetSpriteCameraX() - vectOfNPCS[i].npcSprite->GetSpriteCameraX() > -60 
+                       && player->GetSpriteCameraY() - vectOfNPCS[i].npcSprite->GetSpriteCameraY() < 60 && player->GetSpriteCameraY() - vectOfNPCS[i].npcSprite->GetSpriteCameraY() > -60 && !exitNPCDialog){
+                               //get quest, pick NPC by identifying who is closest (current i identifies this!), then give user option to accept or decline the quest in a menu.
+                               InitialiseQuestMenu(i, objOfQuests);
+                               isPlayerClose = true;
+                               return isPlayerClose;
+               }
+
+       }
+       return isPlayerClose;
+}
+
+
+void NPC::GetNpcFileLocation(){
+       //set for testing purposes.
+       level_num = 1;
+       if (level_num == 1 && numNPC == 0){
+               NPCAssets.push_back("res/data/environment/pub/NPCs/NPC1.png");
+
+               //meant for another function
+               ///*Quests quest01;
+               //quest01.setQuestDesc("Kill 5 enemies");
+               //NPC Joe_Pub(200,200,CameraX, CameraY, csdl_setup, quest01,  NPCAssets, 0);
+               //vectOfNPCS.push_back(Joe_Pub); */
+
+
+       }
+       if (NPCAssets.size() == 0){
+               cout << "Failed to add NPC File location, vector size is 0" << endl;
+       }
+}
+
+//this function should inititalise a generic quest menu.
+void NPC::InitialiseQuestMenu(int npc_id, Quests *quest){
+               NPCTextObj->eraseAllMessagesInVector();
+               Text menuItem1(50, 400, quest->GetQuest());
+               Text menuItem2(50, 420, "Accept Quest");
+               Text menuItem3(50, 440, "Decline Quest");
+               NPCTextObj->addToTextVector(menuItem1);
+               NPCTextObj->addToTextVector(menuItem2);
+               NPCTextObj->addToTextVector(menuItem3);
+       }
+
+//take a group of sprites to draw later along with npc id/quest vector to get the menu dialog.
+void NPC::DisplayQuestMenu(int npc_id, vector<Quests*>quests, MainCharacter* player, Sprite* playerSprite, Sprite* diaBoxSprite,
+                                                  Sprite* enHP, CInteraction* interaction, CEnvironment* pub, Sprite* dialogIcon, vector<CEnemy*>Enemies){
+                                                          if (quests.size() != 0){
+                                                                  InitialiseQuestMenu(npc_id, quests[npc_id-1]);
+
+                                                                  //while the quest has not been added, display the quest menu.
+                                                                  while (!exitNPCDialog){
+
+                                                                          EventManager event(csdl_setup, MouseX, MouseY);
+                                                                          event.DrawGame(player, playerSprite, enHP, pub, Enemies);
+
+                                                                          //displays the text.
+                                                                          event.NPCDialogEvent(NPCTextObj->getTextVect(), interaction, dialogIcon, diaBoxSprite, npcSprite);   
+
+                                                                          //get option
+                                                                          CheckUserPress(dialogIcon, npc_id, quests[npc_id-1]);
+                                                                  }
+                                                          }
+}
+
+//check the user input, i.e. has the user pressed down or up through the menus, enter to get through the selections.
+int NPC::CheckUserPress(Sprite* menu_arrow_sprite, int NPCRefNumber, Quests* quest){
+       //disable the option to move up/down dependent on whether you have pressed accept for second opt.
+       optSelect = 0;
+       switch (csdl_setup->GetMainEvent()->type)
+       {
+       case SDL_KEYDOWN:
+
+               switch(csdl_setup->GetMainEvent()->key.keysym.sym){
+               case SDLK_RETURN:
+
+                       cout << "You have pressed enter : " << countEnterPress << " times" << endl;
+                       if (menu_arrow_sprite->GetY() == FIRSTCHOICE)
+                       {
+                               cout << "You have pressed enter on first option" << endl;
+                               optSelect = 1;
+                       }
+
+                       if (menu_arrow_sprite->GetY() == SECONDCHOICE && countEnterPress == 0)// && !hasKeyBeenReleased)
+                       {                               
+                               cout << "You have pressed enter on second option" << endl;
+                               Text questAccepted(50, 430, "Quest was added to list of quests.");
+                               Text pressEnterToContinue(50, 445, "Press enter to continue.");
+                               NPCTextObj->eraseAllMessagesInVector();
+                               NPCTextObj->addToTextVector(questAccepted);
+                               NPCTextObj->addToTextVector(pressEnterToContinue);
+                               isQuestAdded = true;
+                               //Edit the vector that contains all quests saying a quest has been accepted from an NPC.
+                               quest->SetQuestAccept(true);
+                               optSelect = 2;
+                       }
+                       if (hasKeyBeenReleased){
+                               countEnterPress++;}
+                       //While the user has not pressed enter to close menu, keep it open. Set a flag to make sure user has to press enter to close.
+                       if (csdl_setup->GetMainEvent()->key.keysym.sym == SDLK_RETURN && countEnterPress == 1)
+                       {
+                               exitNPCDialog = true;
+                       }
+                       if (menu_arrow_sprite->GetY() == THIRDCHOICE && countEnterPress == 0)
+                       {
+                               cout << "You have pressed enter on third option" << endl;
+                               Text questDeclined(50, 430, "You declined the quest");
+                               Text pressEnterToContinue(50, 445, "Press enter to continue.");;
+                               NPCTextObj->eraseAllMessagesInVector();
+                               NPCTextObj->addToTextVector(questDeclined);
+                               NPCTextObj->addToTextVector(pressEnterToContinue);
+                               optSelect = 3;
+                       }
+                       break;
+               }
+
+
+
+       case SDL_KEYUP:
+               switch(csdl_setup->GetMainEvent()->key.keysym.sym)
+               {
+               case SDLK_RETURN:
+                       hasKeyBeenReleased = true;
+                       break;
+               case SDLK_DOWN:
+                       hasKeyBeenReleased = true;
+                       break;
+               case SDLK_UP:
+                       hasKeyBeenReleased = true;
+                       break;
+               }
+               break;
+       }
+
+       return optSelect;
+}
diff --git a/src/NPC.h b/src/NPC.h
new file mode 100644 (file)
index 0000000..87b59bd
--- /dev/null
+++ b/src/NPC.h
@@ -0,0 +1,96 @@
+#pragma once
+#ifndef NPC_H
+#define NPC_H
+
+#include "Sprite.h"
+#include <vector>
+#include "Quests.h"
+#include "SDL_Setup.h"
+#include "Text.h"
+#include "EventManager.h"
+#include "TextManager.h"
+#include "Point.h"
+
+using namespace std;
+
+class NPC
+{
+public:
+       NPC(int x, int y, int npc_id, string npc_sprite_loc, string name, float* p_camera_x, float* p_camera_y, CSDL_Setup* p_csdl_setup, vector<Quests*>quests);
+
+       NPC(int x_passed, int y_passed, int *passed_MouseX, int *passed_MouseY, float *passed_CameraX, float *passed_CameraY, int passed_screenWidth, 
+               int passed_screenHeight, CSDL_Setup* passed_csdl_setup, int NPCref);
+
+       ~NPC(void);
+
+       void Draw();
+       bool isPlayerCloseToGetQuest(Quests *objOfQuests, vector<NPC> vectOfNPCS, Sprite* player);
+       void DisplayQuestMenu(int npc_id, vector<Quests*>quests, MainCharacter* player, Sprite* playerSprite, Sprite* diaBoxSprite,
+                                               Sprite* enHP, CInteraction* interaction, CEnvironment* pub, Sprite* dialogIcon, vector<CEnemy*>Enemies);
+       void GetNpcFileLocation();
+       void InitialiseQuestMenu(int npc_id, Quests *quest);
+       int GetNPCX();
+       int GetNPCY();
+       int CheckUserPress(Sprite* menu_arrow_sprite, int npc_id, Quests* quests);
+       string GetQuestDesc();
+       Quests GetQuest();
+
+       Sprite GetNPSprite();
+
+       enum YPointsForMenuChoice{
+               FIRSTCHOICE = 406,
+               SECONDCHOICE = 426,
+               THIRDCHOICE = 446
+       };      
+
+private:
+       int numNPC;
+       int level_num;
+       int x;
+       int y;
+       int optSelect;
+
+       bool hasKeyBeenReleased;
+       bool isPlayerClose;
+       bool isQuestAdded;
+       bool firstPress;
+       bool exitNPCDialog;
+
+       int countEnterPress;
+       int screenWidth;
+       int screenHeight;
+
+       int* MouseX;
+       int* MouseY;
+
+       float* CameraX;
+       float* CameraY;
+
+       string file_loc;
+
+       Sprite* npcSprite;
+       Sprite* npc_hover_interact;
+       Sprite* mainPlayer;
+       Sprite* Menu_Select;
+       Sprite* DiaBox;
+
+       MainCharacter* mc;
+
+       vector<string>NPCAssets;
+
+
+       Quests NPCQuest;
+
+       Text* NPCTextObj;
+       CSDL_Setup* csdl_setup;
+
+       string questDesc;
+       bool isQuestCompleted;
+
+       TextManager* PrintText;
+       
+       Point* point;
+
+};
+
+#endif
diff --git a/src/NPCManager.cpp b/src/NPCManager.cpp
new file mode 100644 (file)
index 0000000..f922a74
--- /dev/null
@@ -0,0 +1,32 @@
+#include "stdafx.h"
+#include "NPCManager.h"
+
+
+NPCManager::NPCManager(void)
+{
+}
+
+
+NPCManager::~NPCManager(void)
+{
+}
+
+//idea here is to set the file location based on the npc id.
+//so id 0 = npc_0.jpg
+//id 1 = npc_1.jpg
+//etc
+void NPCManager::SetFileLocation(int npc_id){
+       string npc_fileloc = "res/data/npcs/npc_" + to_string(npc_id) + ".png";
+}
+
+
+////void NPCManager::LoadNPCS(){
+////   //FileManagement filemanagement;
+////   if (filemanagement.OpenFile("res/data/npcs.txt")){
+////           string start_line = "--BEGIN NPC LOAD--";
+////           //getline(LoadedFile, line)
+////
+////   }
+////
+////
+////}
\ No newline at end of file
diff --git a/src/NPCManager.h b/src/NPCManager.h
new file mode 100644 (file)
index 0000000..2fadd65
--- /dev/null
@@ -0,0 +1,22 @@
+#pragma once
+
+using namespace std;
+
+#include <string>
+#include <vector>
+#include "NPC.h"
+#include "FileManagement.h"
+
+//this class manages the vector of NPCs
+//should have a load NPC's public routine that reads an npcs.txt file and creates all of the npc objects and pushes back into an vector of npcs.
+class NPCManager
+{
+public:
+       NPCManager(void);
+       ~NPCManager(void);
+       void SetFileLocation(int npc_id);
+       void LoadNPCS();
+private:
+       vector<NPC*>npcs;
+};
+
diff --git a/src/PlayerManager.cpp b/src/PlayerManager.cpp
new file mode 100644 (file)
index 0000000..fee9144
--- /dev/null
@@ -0,0 +1,29 @@
+#include "stdafx.h"
+#include "PlayerManager.h"
+
+
+PlayerManager::PlayerManager(CSDL_Setup* passed_csdl_setup, float *CameraX, float *CameraY)
+{
+       csdl_setup = passed_csdl_setup;
+       player = new Sprite(csdl_setup->GetRenderer(),"res/data/new_mc_spritesheet.png",300,250,50,50,CameraX,CameraY, CollisionRect(0,0,50,50));
+}
+
+PlayerManager::PlayerManager(){
+
+}
+PlayerManager::~PlayerManager(void)
+{
+       delete player;
+}
+
+bool PlayerManager::IsClose(Sprite* sprite, float rangeSpecified){
+       float playerX = (float)(player->GetSpriteCameraX() - 20);
+       float playerY = (float)(player->GetSpriteCameraY() - 40);
+
+       if (playerX - sprite->GetSpriteCameraX() >= -rangeSpecified && playerX - sprite->GetSpriteCameraX() <= rangeSpecified && 
+               playerY - sprite->GetSpriteCameraY() >= -rangeSpecified && playerY - sprite->GetSpriteCameraY() <= rangeSpecified)
+               return true;
+       else 
+               return false;
+}
+
diff --git a/src/PlayerManager.h b/src/PlayerManager.h
new file mode 100644 (file)
index 0000000..2c73177
--- /dev/null
@@ -0,0 +1,19 @@
+#pragma once
+
+#include "Sprite.h"
+#include "SDL_Setup.h"
+#include "CollissionRect.h"
+
+class PlayerManager
+{
+public:
+       PlayerManager();
+       PlayerManager(CSDL_Setup* csdl_setup, float *CameraX, float *CameraY);
+       bool IsClose(Sprite* sprite, float rangeSpecified);
+       ~PlayerManager(void);
+
+private:
+       Sprite* player;
+       CSDL_Setup* csdl_setup;
+};
+
diff --git a/src/Point.cpp b/src/Point.cpp
new file mode 100644 (file)
index 0000000..599e78a
--- /dev/null
@@ -0,0 +1,38 @@
+#include "Point.h"
+#include <stdarg.h>
+
+
+Point::Point(){
+
+}
+
+Point::~Point(){
+
+
+}
+
+void Point::setPointVect(int i, ...){
+
+       double total = 0; /* initialize total */ 
+       int j; 
+       va_list ap; /* for storing information needed by va_start */ 
+
+       va_start( ap, i ); /* initialize ap for use in va_arg and va_end */ 
+
+       /* process variable length argument list */ 
+       for ( j = 1; j <= i; j++ ) { 
+               
+               total = va_arg( ap, int ); 
+               pointVect.push_back(total);
+       } /* end for */ 
+
+       va_end( ap ); /* end the va_start */ 
+       
+
+}
+
+vector<int> Point::getPointVect(){
+
+       return pointVect;
+
+}
diff --git a/src/Point.h b/src/Point.h
new file mode 100644 (file)
index 0000000..f238653
--- /dev/null
@@ -0,0 +1,23 @@
+#ifndef POINT_H
+#define POINT_H
+
+#include "stdafx.h"
+#include <vector>
+
+using namespace std;
+
+class Point{
+
+public:
+       Point();
+       ~Point();
+       void setPointVect(int i, ...);
+       vector<int> getPointVect();
+
+private:
+       vector<int> pointVect;
+
+
+};
+
+#endif
\ No newline at end of file
diff --git a/src/Quests.cpp b/src/Quests.cpp
new file mode 100644 (file)
index 0000000..0dd7d5e
--- /dev/null
@@ -0,0 +1,103 @@
+#include "stdafx.h"
+#include "Quests.h"
+
+Quests::Quests(string p_quest_type, string p_quest_desc, int p_gold, int p_xp, int p_level_threshold, int p_item_threshold){
+       quest_type = p_quest_type;
+       quest_desc = p_quest_desc;
+       gold = p_gold;
+       xp = p_xp;
+       level_threshold = p_level_threshold;
+       item_threshold = p_item_threshold;
+       quest_accepted = false;
+       quest_display = true;
+}
+
+Quests::Quests(void){
+       quest_accepted = false;
+       quest_display = true;
+}
+
+
+Quests::~Quests(void){
+
+}
+
+void Quests::SetQuestXP (int p_xp){
+       xp = p_xp;
+}
+
+void Quests::SetQuestGold(int p_gold){
+       gold = p_gold;
+}
+
+void Quests::SetQuestDesc(string p_quest_desc){
+       quest_desc = p_quest_desc;
+}
+void Quests::SetQuestAccept(bool accept){
+       quest_accepted = accept;
+}
+
+int Quests::GetQuestGold(){
+       return gold;
+}
+
+int Quests::GetQuestXP(){
+       return xp;
+}
+
+string Quests::GetQuest(){
+       return quest_desc;
+}
+
+bool Quests::GetQuestAccept(){
+       return quest_accepted;
+}
+
+Text Quests::makeTextObj(int questRef, int x, int y){
+       quest_text = new Text(x, y, GetQuest());
+       return *quest_text;
+}
+
+//a file should be read to check the completion features of a quest, for example
+//a file should read: kills:5, collect:sword_red, etc.
+bool Quests::CheckQuestComplete(int questRef, BattleManager *battlemanager){
+       if (questRef == 1){
+               //Found out how many enemies have been killed.
+               if (battlemanager->GetKillCount() >= 5 && quest_display == true){
+                       quest_accepted = false;
+                       //remove quest from questlist, display message saying you have completed a quest, 
+                       //make player stop and bring up dialog box that acknowledges the success!
+                       quest_complete = true;
+
+                       return quest_complete;
+               }
+               else quest_complete = false;
+               return quest_complete;
+       }
+
+       return false;
+}
+
+void Quests::QuestSuccess(vector<Quests*>quests, int quest_id, MainCharacter* player, Sprite* player_sprite, Sprite* dia_box_sprite,
+                                                               Sprite* en_hp, CInteraction* interaction, CEnvironment* pub, Sprite* dialog_icon, vector<CEnemy*>enemies, EventManager* events){
+                                                                       vector<Text>text;
+                                                                       int temp_xp = quests[quest_id]->GetQuestXP();
+                                                                       int temp_gold = quests[quest_id]->GetQuestXP();
+                                                                       string quest_reward =+"You earned " + to_string(temp_xp) + " XP and " + to_string(temp_gold) + " gold";
+                                                                       Text first_dialog(60, 400, "Quest complete!");
+                                                                       Text second_dialog(60,420, quest_reward);
+
+                                                                       Text third_dialog(60,440, "Press enter to continue.");
+                                                                       text.push_back(first_dialog);
+                                                                       text.push_back(second_dialog);
+                                                                       
+                                                                       //need an event that waits for an enter to be pressed, once done. Stop drawing this and stop this routine from being executed.
+                                                                       //while interaction->WaitForEnter() draw the game and the quest success dialog, once user presses enter, set quest_display to false.
+                                                                       while(!interaction->EnterPress()){
+                                                                               events->DrawGame(player, player_sprite, en_hp, pub, enemies);
+                                                                               events->QuestSuccessEvent(text, interaction, dialog_icon, dia_box_sprite, 10);
+                                                                       }
+                                                                       quest_display = false;
+                                                                       
+}
+
diff --git a/src/Quests.h b/src/Quests.h
new file mode 100644 (file)
index 0000000..6befb40
--- /dev/null
@@ -0,0 +1,51 @@
+#pragma once
+#ifndef QUESTS_H
+#define QUESTS_H
+
+#include <vector>
+#include <string>
+#include "Text.h"
+#include "BattleManager.h"
+#include "EventManager.h"
+
+using namespace std;
+
+class Quests
+{
+public:
+       Quests(string p_quest_type, string p_quest_desc, int p_gold, int p_xp, int p_level_threshold, int p_item_threshold);
+       Quests(void);
+       ~Quests(void);
+       
+
+       void SetQuestXP (int p_xp);
+       void SetQuestGold(int p_gold);
+       void SetQuestDesc(string p_quest_desc);
+       void SetQuestAccept(bool accept);
+       int GetQuestGold();
+       int GetQuestXP();
+       bool GetQuestAccept();
+       string GetQuest();
+       Text makeTextObj(int questRef, int x, int y);
+       bool CheckQuestComplete(int questRef, BattleManager *battlemanager);
+       void QuestSuccess(vector<Quests*>quests, int quest_id, MainCharacter* player, Sprite* player_sprite, Sprite* dia_box_sprite,
+                                         Sprite* en_hp, CInteraction* interaction, CEnvironment* pub, Sprite* dialog_icon,
+                                         vector<CEnemy*>enemies, EventManager* events);
+
+private:
+       int xp;
+       int gold;
+       int level_threshold;
+       int item_threshold;
+       string quest_type;
+
+       bool quest_complete;
+       bool quest_accepted;
+       bool quest_display;
+       bool questAlreadyCompleted;
+
+       Text* quest_text;
+       string quest_desc;
+};
+
+#endif
diff --git a/src/SDL_Font_Setup.cpp b/src/SDL_Font_Setup.cpp
new file mode 100644 (file)
index 0000000..eef374a
--- /dev/null
@@ -0,0 +1,108 @@
+#include "SDL_Font_Setup.h"
+
+
+CSDLFont_Setup::CSDLFont_Setup(CSDL_Setup* passed_csdlsetup)
+{
+       csdl_setup = passed_csdlsetup;
+       //inits TTF
+       if (TTF_Init() != 0){
+               std::cout << TTF_GetError() << std::endl;
+               cout << "TTF ERROR" << endl;
+       }
+
+       SDL_Color color = { 255,255,255 };
+
+       blend = false;
+       shade = false;
+
+       SDL_Surface *surf = NULL;
+}
+
+CSDLFont_Setup::~CSDLFont_Setup()
+{
+
+}
+
+void CSDLFont_Setup::getText(string message, string fontFile, int passed_x, int passed_y, 
+                                                        SDL_Color color, int fontSize, bool passed_blend, bool passed_shade, SDL_Renderer *renderer){
+       SDL_Texture *image = renderText(message, fontFile,
+               color, fontSize, passed_blend, passed_shade, csdl_setup->GetRenderer());
+       if (image == nullptr){
+               cout << "image is null" << endl;
+       }
+       //Get the texture w/h so we can center it in the screen
+       int iW, iH;
+       iW = 0;
+       iH = 0;
+       SDL_QueryTexture(image, NULL, NULL, &iW, &iH);
+       int SCREEN_WIDTH = 640;
+       int SCREEN_HEIGHT = 480;
+       //centers text
+       int x = passed_x;
+       int y = passed_y;
+
+       renderTexture(image, csdl_setup->GetRenderer(), x, y,message.size() * 8, fontSize * 2);
+       SDL_DestroyTexture(image);
+       /*SDL_RenderPresent(csdl_setup->GetRenderer());*/
+       //delete image;
+}
+
+SDL_Texture* CSDLFont_Setup::renderText(const std::string message, const std::string &fontFile,
+                                                                               SDL_Color color, int fontSize, bool blend, bool shade, SDL_Renderer *renderer)
+{
+       //Open the font
+       TTF_Font *font = TTF_OpenFont(fontFile.c_str(), fontSize);
+       if (font == nullptr){
+               cout << "Could not find " << fontFile.c_str() << endl;
+               return nullptr;
+       }       
+       //We need to first render to a surface as that's what TTF_RenderText
+       //returns, then load that surface into a texture
+       SDL_Surface *surf = TTF_RenderText_Blended(font, message.c_str(), color);
+        if (blend == true)
+        {
+                surf = TTF_RenderText_Blended(font, message.c_str(), color);
+        }
+
+       if (shade == true)
+       {
+               SDL_Color bg = {0,0,0};
+               surf = TTF_RenderText_Shaded(font, message.c_str(), color, bg);
+       }
+
+       if (surf == nullptr){
+               TTF_CloseFont(font);
+               return nullptr;
+       }
+       SDL_Texture *texture = SDL_CreateTextureFromSurface(renderer, surf);
+
+       //Clean up the surface and font
+       SDL_FreeSurface(surf);
+       TTF_CloseFont(font);
+       return texture;
+}
+
+
+
+void CSDLFont_Setup::renderTexture(SDL_Texture *tex, SDL_Renderer *ren, int x, int y, int w, int h){
+       //Setup the destination rectangle to be at the position we want
+       SDL_Rect dst;
+       dst.x = x;
+       dst.y = y;
+       //lol wrong func
+       dst.w = w;
+       dst.h = h;
+       SDL_RenderCopy(ren, tex, NULL, &dst);
+}
+
+SDL_Color CSDLFont_Setup::getColor()
+{
+       return color;
+}
+
+SDL_Color CSDLFont_Setup::setColor(int r, int g, int b)
+{
+       SDL_Color color = { r,g,b };
+       return color;
+}
+
diff --git a/src/SDL_Font_Setup.h b/src/SDL_Font_Setup.h
new file mode 100644 (file)
index 0000000..2234f71
--- /dev/null
@@ -0,0 +1,46 @@
+#pragma once
+#include "stdafx.h"
+#include <SDL.h>
+#include <SDL_image.h>
+#include <SDL_ttf.h>
+#include <stdexcept>
+#include <string>
+#include <iostream>
+#include "SDL_Setup.h"
+
+using namespace std;
+
+class CSDLFont_Setup
+{
+public:
+       CSDLFont_Setup(CSDL_Setup* passed_renderer);
+       ~CSDLFont_Setup();
+
+       //perhaps because it returns on a public function, it fucks up
+       SDL_Texture* renderText(const std::string message, const std::string &fontFile,
+               SDL_Color color, int fontSize, bool blend, bool shade, SDL_Renderer *renderer);
+
+       void renderTexture(SDL_Texture *tex, SDL_Renderer *ren, int x, int y, int w, int h);
+       
+       void getText(string message, string fontFile, int passed_x, int passed_y, 
+                                                        SDL_Color color, int fontSize, bool passed_blend, bool passed_shade, SDL_Renderer *renderer);
+
+       bool quit;
+       SDL_Color getColor();
+       SDL_Color setColor(int r, int g, int b);
+
+
+private:
+       /*SDL_Texture *texture;*/
+       bool blend;
+       bool shade; 
+
+       SDL_Color color;
+       TTF_Font *font;
+       SDL_Texture *image;
+       CSDL_Setup* csdl_setup;
+       SDL_Window* window;
+       SDL_Renderer* renderer;
+       SDL_Surface *surf;
+};
+
diff --git a/src/SDL_Keyboard.cpp b/src/SDL_Keyboard.cpp
new file mode 100644 (file)
index 0000000..ddacee4
--- /dev/null
@@ -0,0 +1,21 @@
+#include "stdafx.h"
+#include "SDL_Keyboard.h"
+
+
+
+SDL_Keyboard::SDL_Keyboard(void)
+{
+}
+
+
+SDL_Keyboard::~SDL_Keyboard(void)
+{
+}
+
+const Uint8* keyboard;
+
+void update()
+{
+    SDL_PumpEvents();
+    keyboard = SDL_GetKeyboardState(NULL);
+}
diff --git a/src/SDL_Keyboard.h b/src/SDL_Keyboard.h
new file mode 100644 (file)
index 0000000..6ff2cac
--- /dev/null
@@ -0,0 +1,8 @@
+#pragma once
+class SDL_Keyboard
+{
+public:
+       SDL_Keyboard(void);
+       ~SDL_Keyboard(void);
+};
+
diff --git a/src/SDL_Setup.cpp b/src/SDL_Setup.cpp
new file mode 100644 (file)
index 0000000..c156410
--- /dev/null
@@ -0,0 +1,45 @@
+#include "SDL_Setup.h"
+
+CSDL_Setup::CSDL_Setup(bool* quit, int ScreenWidth, int ScreenHeight){
+       SDL_Init(SDL_INIT_VIDEO);
+
+       window = NULL;
+       window = SDL_CreateWindow("Forged Memories v2.3", 100, 100, ScreenWidth, ScreenHeight, SDL_WINDOW_SHOWN);
+       if (window == NULL){
+               cout << "Window couldn't be created" << endl;
+               *quit = true;
+       }
+
+       renderer = NULL;
+       renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC); 
+
+       mainEvent = new SDL_Event();
+}
+
+CSDL_Setup::~CSDL_Setup(){
+       SDL_DestroyWindow(window);
+       SDL_DestroyRenderer(renderer);
+       delete mainEvent;
+}
+
+SDL_Renderer* CSDL_Setup::GetRenderer(){
+       return renderer;
+}
+
+SDL_Event* CSDL_Setup::GetMainEvent(){
+       return mainEvent;
+}
+
+void CSDL_Setup::Begin(){
+       SDL_PollEvent(mainEvent);
+       SDL_RenderClear(renderer);
+}
+
+void CSDL_Setup::End(){
+       SDL_RenderPresent(renderer);
+
+}
+
+SDL_Window* CSDL_Setup::GetWindow(){
+       return window;
+}
\ No newline at end of file
diff --git a/src/SDL_Setup.h b/src/SDL_Setup.h
new file mode 100644 (file)
index 0000000..4a5b37b
--- /dev/null
@@ -0,0 +1,27 @@
+#pragma once
+//#include "Main.h"
+using namespace std;
+#include "stdafx.h"
+
+class CSDL_Setup
+{
+public:
+CSDL_Setup(bool* quit, int ScreenWidth, int ScreenHeight);
+~CSDL_Setup(void);
+
+SDL_Renderer* GetRenderer();
+SDL_Event* GetMainEvent();
+SDL_Window* GetWindow();
+
+void Begin();
+void End();
+
+
+
+private:
+       SDL_Window* window;
+       SDL_Renderer* renderer;
+       SDL_Event* mainEvent;
+
+};
+
diff --git a/src/SDL_Sound.cpp b/src/SDL_Sound.cpp
new file mode 100644 (file)
index 0000000..c3cf32c
--- /dev/null
@@ -0,0 +1,66 @@
+#include "stdafx.h"
+#include "SDL_Sound.h"
+
+
+SDL_Sound::SDL_Sound(void)
+{
+       //The music that will be played
+       gMusic = NULL;
+       ////Initialize SDL
+       if( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_AUDIO ) < 0 )
+       {
+               printf( "SDL could not initialize! SDL Error: %s\n", SDL_GetError() );
+               success = false;
+       }
+       //Initialize SDL_mixer
+       if( Mix_OpenAudio( 44100, MIX_DEFAULT_FORMAT, 2, 2048 ) < 0 )
+       {
+               printf( "SDL_mixer could not initialize! SDL_mixer Error: %s\n", Mix_GetError() );
+               success = false;
+       }
+}
+
+SDL_Sound::~SDL_Sound(void)
+{
+}
+
+bool SDL_Sound::LoadMedia(const char *media_loc, bool isBGMusic)
+{
+       //Loading success flag
+       bool success = true;
+
+       //Load music, if it is a piece of background music, 
+       //let's pass in that background music, otherwise, set a normal gameplay sound that doesn't last long or need to be looped.
+       if (!isBGMusic) {
+               gMusic = Mix_LoadWAV(media_loc);
+               if( gMusic == NULL )
+               {
+                       cout << "Failed to load " << media_loc << endl;
+                       success = false;
+               }
+       }
+       else
+               gBGMusic = Mix_LoadWAV(media_loc);
+
+       return success;
+}
+
+void SDL_Sound::PlayMedia(bool loop){
+       //Play the music
+       if (loop)
+               Mix_PlayChannel(1, gBGMusic, -1);
+       else{
+               Mix_PlayChannel(2, gMusic, 0);
+               
+       }
+}
+
+void SDL_Sound::Close()
+{
+    //Free the music
+    Mix_FreeChunk( gMusic );
+    gMusic = NULL;
+
+    //Quit SDL subsystems
+    Mix_Quit();
+}
diff --git a/src/SDL_Sound.h b/src/SDL_Sound.h
new file mode 100644 (file)
index 0000000..3467f7c
--- /dev/null
@@ -0,0 +1,23 @@
+#pragma once
+#include "stdafx.h"
+#include <stdio.h>
+#include <string>
+#include <vector>
+
+using namespace std;
+
+class SDL_Sound
+{
+public:
+       SDL_Sound(void);
+       ~SDL_Sound(void);
+       void Close();
+       bool LoadMedia(const char *media_loc, bool isBGMusic);
+       void PlayMedia(bool loop);
+private:
+       bool success;
+       Mix_Chunk *gBGMusic;
+       Mix_Chunk *gMusic;
+       //Mix_Music *gBGMusic;
+};
+
diff --git a/src/SFXManager.cpp b/src/SFXManager.cpp
new file mode 100644 (file)
index 0000000..44e0957
--- /dev/null
@@ -0,0 +1,33 @@
+#include "stdafx.h"
+#include "SFXManager.h"
+
+
+SFXManager::SFXManager(void)
+{
+       is_loop_sound = false;
+       play_once = true;
+}
+
+
+SFXManager::~SFXManager(void)
+{
+}
+
+void SFXManager::SwordAttack(){
+       SDL_Sound *sounds = new SDL_Sound();
+       is_loop_sound = false;
+       sounds->LoadMedia("res/sfx/sword_attack_1.wav", is_loop_sound);
+       sounds->PlayMedia(false);
+       delete sounds;
+}
+
+void SFXManager::GetSceneMusic(){
+       is_loop_sound = true;
+       if (play_once){
+       SDL_Sound *sounds = new SDL_Sound();
+       sounds->LoadMedia("res/sfx/pub_01.wav", is_loop_sound);
+       sounds->PlayMedia(true);
+       play_once = false;
+       delete sounds;
+       }
+}
diff --git a/src/SFXManager.h b/src/SFXManager.h
new file mode 100644 (file)
index 0000000..b473161
--- /dev/null
@@ -0,0 +1,16 @@
+#pragma once
+#include "SDL_Sound.h"
+
+class SFXManager
+{
+public:
+       SFXManager(void);
+       ~SFXManager(void);
+       void SwordAttack();
+       void GetSceneMusic();
+
+private:
+       bool play_once;
+       bool is_loop_sound;
+};
+
diff --git a/src/Sprite.cpp b/src/Sprite.cpp
new file mode 100644 (file)
index 0000000..bf50f4b
--- /dev/null
@@ -0,0 +1,285 @@
+#include "Sprite.h"
+
+Sprite::Sprite(){
+       filepath = "";
+}
+
+Sprite::Sprite(SDL_Renderer* passed_renderer, std::string FilePath, int x, int y, int w, int h,
+                                float *passed_CameraX, float *passed_CameraY, CollisionRect passed_collisionRect){
+       collisionRect = passed_collisionRect;
+
+       renderer = passed_renderer;
+       image = NULL;
+       image = IMG_LoadTexture(renderer,FilePath.c_str());
+       filepath = FilePath;
+       if (image == NULL){
+               std::cout << "Couldn't Load " << FilePath.c_str() << std::endl;
+       }
+
+       // CollisionImage = NULL;
+
+       // CollisionImage = IMG_LoadTexture(renderer, "res/data/Debug/CollisionBox.png");
+
+       // if (CollisionImage == NULL){
+       //      std::cout << "Couldn't Load " << "CollisionImage" << std::endl;
+       // }
+
+       rect.x = x;
+       rect.y = y;
+       rect.w = w;
+       rect.h = h;
+
+       SDL_QueryTexture(image,NULL,NULL, &img_width, &img_height);
+
+       crop.x = 0;
+       crop.y = 0;
+       crop.w = img_width;
+       crop.h = img_height;
+
+       X_pos = (float)x;
+       Y_pos = (float)y;
+
+       Orgin_X = 0;
+       Orgin_Y = 0;
+
+       CurrentFrame = 0;
+       Amount_Frame_X = 0;
+       Amount_Frame_X = 0;
+
+       CameraX = passed_CameraX;
+       CameraY = passed_CameraY;
+
+       Camera.x = (int)(rect.x + *CameraX);
+       Camera.y = (int)(rect.y + *CameraY);
+       Camera.w = rect.w;
+       Camera.h = rect.h;
+
+       previousTime = 0;
+       animateFinish = false;
+}
+
+Sprite::~Sprite(void){
+       SDL_DestroyTexture(image);
+       SDL_DestroyTexture(CollisionImage);
+}
+
+void Sprite::SetUpAnimation(int passed_Amount_X, int passed_Amount_Y){
+       Amount_Frame_X = passed_Amount_X;
+       Amount_Frame_Y = passed_Amount_Y;
+}
+
+void Sprite::TestWidthChange(int widthChange){
+       Camera.w = widthChange;
+}
+
+int Sprite::GetCameraDrawWidth(){
+       return Camera.w;
+}
+
+
+
+void Sprite::PlayAnimation(int BeginFrame, int EndFrame, int Row, float Speed){
+       if (animationDelay+Speed < SDL_GetTicks()){
+               //if the endframe has not been reached, set the frame.
+               if (EndFrame <= CurrentFrame)
+                       CurrentFrame = BeginFrame;
+               else 
+                       CurrentFrame++;
+
+               crop.x = CurrentFrame * (img_width/Amount_Frame_X);
+               crop.y = Row * (img_height/Amount_Frame_Y);
+               crop.w = img_width/Amount_Frame_X;
+               crop.h = img_height/Amount_Frame_Y;
+
+               animationDelay = SDL_GetTicks();
+       }
+}
+
+//if the animation has not yet run, create a delay so that animation runs smoothly by specifying a speed. 
+//if (the current time - previous update time > desired frame time) increment frame()
+void Sprite::AnimateOnce(int BeginFrame, int EndFrame, int Row, float speed){
+       if(!animateFinish){
+               int currentTime = SDL_GetTicks();
+               if (currentTime - previousTime > speed){
+                       //if currentframe exceeds endframe, animation has completed.
+                       if (EndFrame <= CurrentFrame)
+                               animateFinish = true;
+                       else 
+                               CurrentFrame++;
+
+                       crop.x = CurrentFrame * (img_width/Amount_Frame_X);
+                       crop.y = Row * (img_height/Amount_Frame_Y);
+                       crop.w = img_width/Amount_Frame_X;
+                       crop.h = img_height/Amount_Frame_Y;
+
+                       previousTime = SDL_GetTicks();
+               }
+       }
+}
+
+//if the animation has finished, return a true val.
+bool Sprite::HasAnimationFinished(){
+       return animateFinish;
+}
+
+bool Sprite::IsSpriteClose(Sprite* player, Sprite* enemy, float range){
+       float enemyX = (float)enemy->GetSpriteCameraX();
+       float enemyY = (float)enemy->GetSpriteCameraY();
+       float playerX = (float)player->GetSpriteCameraX();
+       float playerY = (float)player->GetSpriteCameraY();
+
+       playerX = playerX - 30;
+       playerY = playerY - 50;
+
+       //if they are in range specified, move them towards the player.
+       if ((enemyX - playerX < range) && (enemyX - playerX > -range) && (enemyY - playerY < range) && (enemyY - playerY > -range))
+       {
+               return true;
+       }
+       else
+       {
+               return false;
+       }
+               
+}
+
+void Sprite::MoveSpriteTowardsEntity(Sprite* player, Sprite* enemy){
+       float enemyX = (float)enemy->GetSpriteCameraX();
+       float enemyY = (float)enemy->GetSpriteCameraY();
+       float playerX = (float)(player->GetSpriteCameraX() - 30); //recenter playerX camera.
+       float playerY = (float)(player->GetSpriteCameraY() - 30); //recenter playerY camera.
+       float diffX = enemyX - playerX;
+       float diffY = enemyY - playerY; 
+
+       //move the enemy towards the player.
+       //determine where player is in relation to enemy.
+       if ((diffX > 0) && (enemyX > playerX)){
+               //player is to the left of enemy.
+               enemy->SetX(enemy->GetX() - 0.2f);
+       }
+       //player to the right of enemy.
+       if (diffX <= 0) {
+               enemy->SetX(enemy->GetX() + 0.2f);
+       }
+       //if player is below, move enemy down.
+       if ((diffY > 0) && (enemyY > playerY)){
+               enemy->SetY(enemy->GetY() - 0.2f);
+       }
+       //player above, move enemy up
+       else{
+               enemy->SetY(enemy->GetY() + 0.2f);
+       }
+}
+
+
+
+void Sprite::Draw()
+{
+
+       //offsets camera based on image.
+       Camera.x = (int)(rect.x + *CameraX);
+       Camera.y = (int)(rect.y + *CameraY);
+
+       collisionRect.SetX(Camera.x);
+       collisionRect.SetY(Camera.y);
+
+       SDL_RenderCopy(renderer,image, &crop, &Camera);
+
+       /*SDL_RenderCopy(renderer,CollisionImage, NULL, &collisionRect.GetRectangle());*/
+}
+//when  called, character won't be affected by camera.
+void Sprite::DrawSteady()
+{
+       SDL_RenderCopy(renderer,image, &crop, &rect);
+       // SDL_RenderCopy(renderer,CollisionImage, NULL, &collisionRect.GetRectangle());
+}
+
+void Sprite::SetX(float X)
+{
+       X_pos = X;
+
+       rect.x = int(X_pos - Orgin_X);
+}
+
+void Sprite::SetY(float Y)
+{
+       Y_pos = Y;
+
+       rect.y = int(Y_pos - Orgin_Y);
+}
+
+float Sprite::GetXTest(){
+       return rect.x + *CameraX;
+}
+
+float Sprite::GetYTest(){
+       return rect.y + *CameraY;
+}
+
+
+
+void Sprite::SetPosition(float X, float Y)
+{
+       X_pos = X;
+       Y_pos = Y;
+
+       rect.x = int(X_pos - Orgin_X);
+       rect.y = int(Y_pos - Orgin_Y);
+}
+
+float Sprite::GetX()
+{
+       return X_pos;
+}
+
+float Sprite::GetY()
+{
+       return Y_pos;
+}
+
+void Sprite::SetOrgin(float X, float Y)
+{
+       Orgin_X = X;
+       Orgin_Y = Y;
+
+       SetPosition(GetX(), GetY());
+
+}
+
+void Sprite::SetWidth(int W)
+{
+       rect.w = W;
+}
+
+void Sprite::SetHeight(int H)
+{
+       rect.h = H;
+}
+
+int Sprite::GetWidth()
+{
+       return rect.w;
+}
+
+int Sprite::GetHeight()
+{
+       return rect.h;
+}
+
+int Sprite::GetSpriteCameraX()
+{
+       return Camera.x;
+}
+int Sprite::GetSpriteCameraY()
+{
+       return Camera.y;
+}
+
+bool Sprite::isColliding(CollisionRect obj)
+{
+       //checks the four corners of collision rectangle.
+       return !(collisionRect.GetRectangle().x + collisionRect.GetRectangle().w < obj.GetRectangle().x ||
+               collisionRect.GetRectangle().y + collisionRect.GetRectangle().h < obj.GetRectangle().y ||
+               collisionRect.GetRectangle().x > obj.GetRectangle().x + obj.GetRectangle().w ||
+               collisionRect.GetRectangle().y > obj.GetRectangle().y + obj.GetRectangle().h);
+}
diff --git a/src/Sprite.h b/src/Sprite.h
new file mode 100644 (file)
index 0000000..88f9d5c
--- /dev/null
@@ -0,0 +1,89 @@
+#pragma once
+#include "stdafx.h"
+#include "SDL_Font_Setup.h"
+#include "CollissionRect.h"
+ // #include <windows.h>
+
+
+class Sprite
+{
+public:
+       Sprite(SDL_Renderer* passed_renderer, std::string FilePath, int x, int y, int w, int h, float *CameraX, float *CameraY, CollisionRect passed_CollisionRect);
+       Sprite();
+       ~Sprite(void);
+
+       void DrawSteady();
+       void Draw();
+
+       void SetX(float X);
+       void SetY(float Y);
+       void SetPosition(float X, float Y);
+
+       float GetX();
+       float GetY();
+
+       int GetSpriteCameraX();
+       int GetSpriteCameraY();
+
+       void SetWidth(int W);
+       void SetHeight(int H);
+
+       float GetXTest();
+       float GetYTest();
+       // 
+
+       bool IsSpriteClose(Sprite* player, Sprite* enemy, float range);
+       void MoveSpriteTowardsEntity(Sprite* player, Sprite* enemy);
+
+       int GetWidth();
+       int GetHeight();
+       int GetCameraDrawWidth();
+
+       void SetOrgin(float X, float Y);
+       void PlayAnimation(int BeginFrame, int EndFrame, int Row, float Speed);
+       void SetUpAnimation(int passed_Amount_X, int passed_Amount_Y);
+       void TestWidthChange(int widthChange);
+
+       void AnimateOnce(int BeginFrame, int EndFrame, int Row, float Speed);
+       bool HasAnimationFinished();
+
+
+       CollisionRect GetCollisionRect() {return collisionRect;}
+
+       bool isColliding(CollisionRect theCollider);
+private:
+       CollisionRect collisionRect;
+
+       SDL_Rect Camera;
+       float *CameraX;
+       float *CameraY;
+
+       float Orgin_X;
+       float Orgin_Y;
+
+       float X_pos;
+       float Y_pos;
+
+       SDL_Texture* CollisionImage;
+       SDL_Texture* image;
+       SDL_Rect rect;
+
+       SDL_Rect crop;
+
+       int img_width;
+       int img_height;
+       int CurrentFrame;
+       int animationDelay;
+       int previousTime;
+       int Amount_Frame_X;
+       int Amount_Frame_Y;
+
+       bool animateFinish;
+       string filepath;
+
+       SDL_Renderer* renderer;
+
+       
+};
+
+
diff --git a/src/Text.cpp b/src/Text.cpp
new file mode 100644 (file)
index 0000000..4c88696
--- /dev/null
@@ -0,0 +1,47 @@
+#include "stdafx.h"
+#include "Text.h"
+
+
+Text::Text(int x1, int y1, string msg)
+{
+       x = x1;
+       y = y1;
+       message = msg;
+}
+
+Text::Text(void)
+{
+}
+
+Text::~Text(void)
+{
+}
+
+void Text::editAllMessagesInVector(int amountOfSlotsToEdit, vector<string>StringMessages, vector<int>yValues){
+       for (int i = 0; i < amountOfSlotsToEdit; i++){
+
+       textVect[i].setMessage(StringMessages[i]);
+       textVect[i].setX(263);
+       textVect[i].setY(yValues[i]);
+       }
+}
+
+void Text::eraseAllMessagesInVector(){
+       for (unsigned int i = 0; i < textVect.size(); i++){
+               textVect.erase (textVect.begin(),textVect.begin()+textVect.size());
+       }
+}
+
+void Text::ResizeVector(int size){
+       eraseAllMessagesInVector();
+       Text text1;
+       Text text2;
+       Text text3;
+       Text text4;
+       Text text5;
+       textVect.push_back(text1);
+       textVect.push_back(text2);
+       textVect.push_back(text3);
+       textVect.push_back(text4);
+       textVect.push_back(text5);
+}
\ No newline at end of file
diff --git a/src/Text.h b/src/Text.h
new file mode 100644 (file)
index 0000000..c41535c
--- /dev/null
@@ -0,0 +1,39 @@
+#pragma once
+
+#include <vector>
+
+using namespace std;
+
+class Text
+{
+public:
+       Text(int x1, int y1, string msg);
+       Text(void);
+       ~Text(void);
+
+       void setX(int x1){x = x1;};
+       void setY(int y1){y = y1;};
+
+       void setMessage(string msg){message = msg;};
+
+       int getX(){return x;};
+       int getY(){return y;};
+
+       void editAllMessagesInVector(int amountOfSlotsToEdit, vector<string>StringMessages, vector<int>yValues);
+
+       string getMessage(){return message;};
+
+       void addToTextVector(Text text){textVect.push_back(text);};
+       void eraseAllMessagesInVector();
+       void ResizeVector(int size);
+
+       vector<Text>getTextVect(){return textVect;};
+
+
+private:
+       int x;
+       int y;
+       string message;
+       vector<Text>textVect;
+};
+
diff --git a/src/TextManager.cpp b/src/TextManager.cpp
new file mode 100644 (file)
index 0000000..8f7745f
--- /dev/null
@@ -0,0 +1,19 @@
+#include "TextManager.h"
+
+TextManager::TextManager(CSDL_Setup* passed_SDL_Setup){
+       csdl_setup = passed_SDL_Setup;
+       font = new CSDLFont_Setup(csdl_setup);
+}
+
+TextManager::~TextManager(void){
+       delete font;
+}
+
+//should print text
+void TextManager::DrawDialog(vector<Text>textWithCoordAndStringMsg, string fontFile, CSDLFont_Setup* text, int fontSize){
+       text->setColor(255,255,255);
+       for (unsigned int i = 0; i < textWithCoordAndStringMsg.size(); i++){
+               text->getText(textWithCoordAndStringMsg[i].getMessage(), fontFile, textWithCoordAndStringMsg[i].getX(), 
+               textWithCoordAndStringMsg[i].getY(), text->getColor(), fontSize, true, false , csdl_setup->GetRenderer());
+       }
+}
\ No newline at end of file
diff --git a/src/TextManager.h b/src/TextManager.h
new file mode 100644 (file)
index 0000000..f15bdbe
--- /dev/null
@@ -0,0 +1,27 @@
+#pragma once
+#ifndef DIALOG_H
+#define DIALOG_H
+#include "SDL_Setup.h"
+#include "SDL_Font_Setup.h"
+#include <vector>
+#include "Text.h"
+
+class TextManager
+{
+public:
+       TextManager(CSDL_Setup* passed_SDL_Setup);
+       ~TextManager(void);
+       void DrawDialog(vector<Text>textWithCoordAndStringMsg, string fontFile, CSDLFont_Setup* text, int fontSize);
+
+
+
+
+private:
+       CSDL_Setup* csdl_setup;
+       CSDLFont_Setup* font;
+};
+
+#endif
+
+
+
diff --git a/src/Tree.cpp b/src/Tree.cpp
new file mode 100644 (file)
index 0000000..a4286d8
--- /dev/null
@@ -0,0 +1,36 @@
+#include "Tree.h"
+
+Tree::Tree(int x_passed, int y_passed, float *CameraX, float *CameraY, CSDL_Setup* csdl_setup)
+{
+       x = x_passed;
+       y = y_passed;
+
+       Trunk = new Sprite(csdl_setup->GetRenderer(),"res/data/environment/trunk.png", x, y, 43, 145, CameraX, CameraY, CollisionRect(0,0,43,145));
+       Crown = new Sprite(csdl_setup->GetRenderer(),"res/data/environment/crown.png", x-72, y-115, 183, 165, CameraX, CameraY, CollisionRect(0,0,0,0));
+}
+
+Tree::~Tree()
+{
+       delete Trunk;
+       delete Crown;
+}
+
+int Tree::GetX()
+{
+       return x;
+}
+
+int Tree::GetY()
+{
+       return y;
+}
+
+void Tree::DrawCrown()
+{
+       Crown->Draw();
+}
+
+void Tree::DrawTrunk()
+{
+       Trunk->Draw();
+}
diff --git a/src/Tree.h b/src/Tree.h
new file mode 100644 (file)
index 0000000..a2a527e
--- /dev/null
@@ -0,0 +1,24 @@
+#pragma once
+#include "stdafx.h"
+#include "SDL_Setup.h"
+#include "Sprite.h"
+class Tree
+{
+public:
+       Tree(int x_passed, int y_passed, float *CameraX, float *CameraY, CSDL_Setup* csdl_setup);
+       ~Tree();
+
+       void DrawCrown();
+       void DrawTrunk();
+
+       int GetX();
+       int GetY();
+
+       Sprite* GetCrown() {return Crown;}
+       Sprite* GetTrunk() {return Trunk;}
+
+private:
+       int x, y;
+       Sprite* Crown;
+       Sprite* Trunk;
+};
diff --git a/src/resource.h b/src/resource.h
new file mode 100644 (file)
index 0000000..24355ea
Binary files /dev/null and b/src/resource.h differ
diff --git a/src/stdafx.cpp b/src/stdafx.cpp
new file mode 100644 (file)
index 0000000..fd4f341
--- /dev/null
@@ -0,0 +1 @@
+#include "stdafx.h"
diff --git a/src/stdafx.h b/src/stdafx.h
new file mode 100644 (file)
index 0000000..ce91034
--- /dev/null
@@ -0,0 +1,14 @@
+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+//
+
+#pragma once
+
+#include <SDL.h>
+#include <SDL_image.h>
+#include <SDL_mixer.h>
+// #include <sdl_ttf.h>
+#include <iostream>
+#include <stdio.h>
+// #include <tchar.h>