Implemented a few minor changes from the monster branch

This commit is contained in:
Kayne Ruse
2014-10-19 00:53:38 +11:00
parent bd2fd4ee97
commit 40c76b4285
5 changed files with 22 additions and 11 deletions
+2 -2
View File
@@ -26,8 +26,8 @@
class BaseMonster {
public:
BaseMonster();
virtual ~BaseMonster();
BaseMonster() = default;
virtual ~BaseMonster() = default;
private:
//
+4
View File
@@ -30,9 +30,13 @@ public:
LocalCharacter() = default;
~LocalCharacter() = default;
int SetRoomIndex(int i) { return roomIndex = i; }
int GetRoomIndex() { return roomIndex; }
Statistics* GetBaseStats() { return &baseStats; }
private:
int roomIndex = -1;
Statistics baseStats;
//TODO: weapons, armour, buffs, debuffs, etc.
};
+5 -4
View File
@@ -138,7 +138,7 @@ void InWorld::Update() {
}
}
//update the camera
//update the camera (following the player)
camera.x = localCharacter->GetOrigin().x - camera.marginX;
camera.y = localCharacter->GetOrigin().y - camera.marginY;
@@ -179,6 +179,7 @@ void InWorld::Render(SDL_Surface* const screen) {
//draw characters
for (auto& it : characterMap) {
//BUG: #29 drawing order according to Y origin
//TODO: use a list of renderable objects
it.second.DrawTo(screen, camera.x, camera.y);
}
@@ -209,10 +210,10 @@ void InWorld::MouseButtonDown(SDL_MouseButtonEvent const& button) {
}
void InWorld::MouseButtonUp(SDL_MouseButtonEvent const& button) {
if (disconnectButton.MouseButtonUp(button) == Button::State::HOVER) {
if (disconnectButton.MouseButtonUp(button) == Button::State::HOVER && button.button == SDL_BUTTON_LEFT) {
RequestDisconnect();
}
if (shutDownButton.MouseButtonUp(button) == Button::State::HOVER) {
if (shutDownButton.MouseButtonUp(button) == Button::State::HOVER && button.button == SDL_BUTTON_LEFT) {
RequestShutDown();
}
}
@@ -326,7 +327,7 @@ void InWorld::HandlePing(ServerPacket* const argPacket) {
void InWorld::HandlePong(ServerPacket* const argPacket) {
if (network.GetIPAddress(Channels::SERVER)->host != argPacket->srcAddress.host) {
throw(std::runtime_error("Heartbeat message received from unknown source"));
throw(std::runtime_error("Heartbeat message received from an unknown source"));
}
attemptedBeats = 0;
+9 -5
View File
@@ -39,6 +39,7 @@
#include "frame_rate.hpp"
#include "base_character.hpp"
#include "base_monster.hpp"
#include "local_character.hpp"
//client
@@ -92,12 +93,13 @@ protected:
//utilities
void UpdateMap();
//shared parameters
//singleton shortcut
UDPNetworkUtility& network = UDPNetworkUtility::GetSingleton();
//indexes
int& clientIndex;
int& accountIndex;
int characterIndex = -1;
std::map<int, BaseCharacter> characterMap;
//graphics
Image buttonImage;
@@ -110,6 +112,7 @@ protected:
//UI
Button disconnectButton;
Button shutDownButton;
FrameRate fps;
//the camera structure
struct {
@@ -117,12 +120,13 @@ protected:
int width = 0, height = 0;
int marginX = 0, marginY = 0;
} camera;
FrameRate fps;
//game
//game components
BaseCharacter* localCharacter = nullptr;
std::map<int, BaseCharacter> characterMap;
std::map<int, BaseMonster> monsterMap;
//connections
//heartbeat
//TODO: This needs it's own utility, for both InWorld and InCombat
typedef std::chrono::steady_clock Clock;
Clock::time_point lastBeat = Clock::now();
+2
View File
@@ -1,5 +1,7 @@
TODO: Get the rooms working, even if only via hotkeys
TODO: SerialPacketType::CHARACTER_LOCATION, CHARACTER_MOVE, CHARACTER_TELEPORT, ROOM_CHANGE, etc.
TODO: Fix shoddy movement
TODO: Handle statistics server-side
TODO: Remove the big "Shut Down" button
TODO: Make a way for the server owner to control the server directly