Moved some files around
This commit is contained in:
@@ -0,0 +1,61 @@
|
|||||||
|
/* Copyright: (c) Kayne Ruse 2014
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from any source
|
||||||
|
* distribution.
|
||||||
|
*/
|
||||||
|
#include "character_data.hpp"
|
||||||
|
|
||||||
|
void CharacterData::Update(double delta) {
|
||||||
|
if (motion.x && motion.y) {
|
||||||
|
origin += motion * delta * CHARACTER_WALKING_MOD;
|
||||||
|
}
|
||||||
|
else if (motion != 0) {
|
||||||
|
origin += motion * delta;
|
||||||
|
}
|
||||||
|
sprite.Update(delta);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CharacterData::DrawTo(SDL_Surface* const dest, int camX, int camY) {
|
||||||
|
sprite.DrawTo(dest, origin.x - camX, origin.y - camY);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CharacterData::CorrectSprite() {
|
||||||
|
//NOTE: These must correspond to the sprite sheet in use
|
||||||
|
if (motion.y > 0) {
|
||||||
|
sprite.SetYIndex(0);
|
||||||
|
}
|
||||||
|
else if (motion.y < 0) {
|
||||||
|
sprite.SetYIndex(1);
|
||||||
|
}
|
||||||
|
else if (motion.x > 0) {
|
||||||
|
sprite.SetYIndex(3);
|
||||||
|
}
|
||||||
|
else if (motion.x < 0) {
|
||||||
|
sprite.SetYIndex(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
//animation
|
||||||
|
if (motion != 0) {
|
||||||
|
sprite.SetDelay(0.1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sprite.SetDelay(0);
|
||||||
|
sprite.SetXIndex(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
/* Copyright: (c) Kayne Ruse 2014
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from any source
|
||||||
|
* distribution.
|
||||||
|
*/
|
||||||
|
#ifndef CHARACTERDATA_HPP_
|
||||||
|
#define CHARACTERDATA_HPP_
|
||||||
|
|
||||||
|
//components
|
||||||
|
#include "character_defines.hpp"
|
||||||
|
#include "vector2.hpp"
|
||||||
|
#include "statistics.hpp"
|
||||||
|
|
||||||
|
//graphics
|
||||||
|
#include "sprite_sheet.hpp"
|
||||||
|
|
||||||
|
//std namespace
|
||||||
|
#include <string>
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
//TODO: encapsulate this
|
||||||
|
struct CharacterData {
|
||||||
|
//metadata
|
||||||
|
int owner;
|
||||||
|
std::string handle;
|
||||||
|
std::string avatar;
|
||||||
|
|
||||||
|
//members
|
||||||
|
SpriteSheet sprite;
|
||||||
|
|
||||||
|
//world position
|
||||||
|
int roomIndex = 0;
|
||||||
|
Vector2 origin = {0.0,0.0};
|
||||||
|
Vector2 motion = {0.0,0.0};
|
||||||
|
Vector2 bounds = {0.0,0.0};
|
||||||
|
|
||||||
|
//base statistics
|
||||||
|
Statistics stats;
|
||||||
|
|
||||||
|
//TODO: gameplay components: equipment, items, buffs, debuffs
|
||||||
|
|
||||||
|
//methods
|
||||||
|
void Update(double delta);
|
||||||
|
|
||||||
|
void DrawTo(SDL_Surface* const, int camX, int camY);
|
||||||
|
void CorrectSprite();
|
||||||
|
|
||||||
|
//active gameplay members
|
||||||
|
//NOTE: these are lost when unloaded
|
||||||
|
bool inCombat = false;
|
||||||
|
int atbGauge = 0;
|
||||||
|
//TODO: stored command
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
#config
|
#config
|
||||||
INCLUDES+=. ../common/gameplay ../common/graphics ../common/map ../common/network ../common/network/packet ../common/network/serial ../common/ui ../common/utilities
|
INCLUDES+=. ../common/gameplay ../common/graphics ../common/map ../common/network ../common/network/packet ../common/network/serial ../common/ui ../common/utilities
|
||||||
LIBS+=../libcommon.a -lSDL_net -lwsock32 -liphlpapi -lmingw32 -lSDLmain -lSDL -llua
|
LIBS+=../libcommon.a -lSDL_net -lwsock32 -liphlpapi -lmingw32 -lSDLmain -lSDL -llua
|
||||||
CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES)) -DGRAPHICS
|
CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES))
|
||||||
|
|
||||||
#source
|
#source
|
||||||
CXXSRC=$(wildcard *.cpp)
|
CXXSRC=$(wildcard *.cpp)
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
/* Copyright: (c) Kayne Ruse 2014
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from any source
|
||||||
|
* distribution.
|
||||||
|
*/
|
||||||
|
#ifndef CHARACTERDEFINES_HPP_
|
||||||
|
#define CHARACTERDEFINES_HPP_
|
||||||
|
|
||||||
|
//the speeds that the characters move
|
||||||
|
constexpr double CHARACTER_WALKING_SPEED = 140.0;
|
||||||
|
constexpr double CHARACTER_WALKING_MOD = 1.0/sqrt(2.0);
|
||||||
|
|
||||||
|
//the bounding boxes for the characters
|
||||||
|
constexpr double CHARACTER_BOUNDS_WIDTH = 32.0;
|
||||||
|
constexpr double CHARACTER_BOUNDS_HEIGHT = 32.0;
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -19,13 +19,15 @@
|
|||||||
* 3. This notice may not be removed or altered from any source
|
* 3. This notice may not be removed or altered from any source
|
||||||
* distribution.
|
* distribution.
|
||||||
*/
|
*/
|
||||||
#include "character_data.hpp"
|
#ifndef COMBATDEFINES_HPP_
|
||||||
#include "combat_data.hpp"
|
#define COMBATDEFINES_HPP_
|
||||||
#include "enemy_data.hpp"
|
|
||||||
#include "statistics.hpp"
|
|
||||||
|
|
||||||
/* DOCS: Sanity check, read more
|
#define COMBAT_MAX_CHARACTERS 16
|
||||||
* Since most/all of the files in this directory are header files, I've created
|
#define COMBAT_MAX_ENEMIES 16
|
||||||
* this source file as a "sanity check", to ensure that the above header files
|
|
||||||
* are written correctly via make.
|
enum class TerrainType {
|
||||||
*/
|
NONE = 0,
|
||||||
|
GRASSLANDS,
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#config
|
#config
|
||||||
INCLUDES+=. ../utilities ../graphics
|
INCLUDES+=.
|
||||||
LIBS+=
|
LIBS+=
|
||||||
CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES)) -DGRAPHICS
|
CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES))
|
||||||
|
|
||||||
#source
|
#source
|
||||||
CXXSRC=$(wildcard *.cpp)
|
CXXSRC=$(wildcard *.cpp)
|
||||||
|
|||||||
@@ -24,13 +24,13 @@
|
|||||||
|
|
||||||
#include "serial_packet_base.hpp"
|
#include "serial_packet_base.hpp"
|
||||||
|
|
||||||
#include "combat_data.hpp"
|
#include "combat_defines.hpp"
|
||||||
|
|
||||||
struct CombatPacket : SerialPacketBase {
|
struct CombatPacket : SerialPacketBase {
|
||||||
//identify the combat instance
|
//identify the combat instance
|
||||||
int combatIndex;
|
int combatIndex;
|
||||||
int difficulty;
|
int difficulty;
|
||||||
CombatData::Terrain terrainType;
|
TerrainType terrainType;
|
||||||
|
|
||||||
//combatants
|
//combatants
|
||||||
int characterArray[COMBAT_MAX_CHARACTERS];
|
int characterArray[COMBAT_MAX_CHARACTERS];
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ void serializeCombat(CombatPacket* packet, void* buffer) {
|
|||||||
//identify the combat instance
|
//identify the combat instance
|
||||||
SERIALIZE(buffer, &packet->combatIndex, sizeof(int));
|
SERIALIZE(buffer, &packet->combatIndex, sizeof(int));
|
||||||
SERIALIZE(buffer, &packet->difficulty, sizeof(int));
|
SERIALIZE(buffer, &packet->difficulty, sizeof(int));
|
||||||
SERIALIZE(buffer, &packet->terrainType, sizeof(CombatData::Terrain));
|
SERIALIZE(buffer, &packet->terrainType, sizeof(TerrainType));
|
||||||
|
|
||||||
//combatants
|
//combatants
|
||||||
SERIALIZE(buffer, &packet->characterArray, sizeof(int) * COMBAT_MAX_CHARACTERS);
|
SERIALIZE(buffer, &packet->characterArray, sizeof(int) * COMBAT_MAX_CHARACTERS);
|
||||||
@@ -49,7 +49,7 @@ void deserializeCombat(CombatPacket* packet, void* buffer) {
|
|||||||
//identify the combat instance
|
//identify the combat instance
|
||||||
DESERIALIZE(buffer, &packet->combatIndex, sizeof(int));
|
DESERIALIZE(buffer, &packet->combatIndex, sizeof(int));
|
||||||
DESERIALIZE(buffer, &packet->difficulty, sizeof(int));
|
DESERIALIZE(buffer, &packet->difficulty, sizeof(int));
|
||||||
DESERIALIZE(buffer, &packet->terrainType, sizeof(CombatData::Terrain));
|
DESERIALIZE(buffer, &packet->terrainType, sizeof(TerrainType));
|
||||||
|
|
||||||
//combatants
|
//combatants
|
||||||
DESERIALIZE(buffer, &packet->characterArray, sizeof(int) * COMBAT_MAX_CHARACTERS);
|
DESERIALIZE(buffer, &packet->characterArray, sizeof(int) * COMBAT_MAX_CHARACTERS);
|
||||||
|
|||||||
@@ -23,31 +23,18 @@
|
|||||||
#define COMBATDATA_HPP_
|
#define COMBATDATA_HPP_
|
||||||
|
|
||||||
#include "vector2.hpp"
|
#include "vector2.hpp"
|
||||||
|
#include "combat_defines.hpp"
|
||||||
|
|
||||||
//gameplay members
|
//gameplay members
|
||||||
#include "character_data.hpp"
|
#include "character_data.hpp"
|
||||||
#include "enemy_data.hpp"
|
#include "enemy_data.hpp"
|
||||||
|
|
||||||
//graphics
|
|
||||||
#ifdef GRAPHICS
|
|
||||||
#include "sprite_sheet.hpp"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//std namespace
|
//std namespace
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#define COMBAT_MAX_CHARACTERS 12
|
|
||||||
#define COMBAT_MAX_ENEMIES 12
|
|
||||||
|
|
||||||
struct CombatData {
|
struct CombatData {
|
||||||
enum class Terrain {
|
|
||||||
//TODO: types of combat terrains
|
|
||||||
NONE = 0,
|
|
||||||
GRASSLANDS,
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef std::chrono::steady_clock Clock;
|
typedef std::chrono::steady_clock Clock;
|
||||||
|
|
||||||
std::array<CharacterData, COMBAT_MAX_CHARACTERS> characterArray;
|
std::array<CharacterData, COMBAT_MAX_CHARACTERS> characterArray;
|
||||||
@@ -60,11 +47,6 @@ struct CombatData {
|
|||||||
|
|
||||||
//time interval
|
//time interval
|
||||||
Clock::time_point lastTick = Clock::now();
|
Clock::time_point lastTick = Clock::now();
|
||||||
|
|
||||||
//graphics
|
|
||||||
#ifdef GRAPHICS
|
|
||||||
SpriteSheet sprite;
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -25,11 +25,6 @@
|
|||||||
#include "vector2.hpp"
|
#include "vector2.hpp"
|
||||||
#include "statistics.hpp"
|
#include "statistics.hpp"
|
||||||
|
|
||||||
//graphics
|
|
||||||
#ifdef GRAPHICS
|
|
||||||
#include "sprite_sheet.hpp"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//std namespace
|
//std namespace
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@@ -45,11 +40,6 @@ struct EnemyData {
|
|||||||
|
|
||||||
//active gameplay members
|
//active gameplay members
|
||||||
//NOTE: these are lost when unloaded
|
//NOTE: these are lost when unloaded
|
||||||
#ifdef GRAPHICS
|
|
||||||
SpriteSheet sprite;
|
|
||||||
Vector2 origin = {0.0,0.0};
|
|
||||||
Vector2 bounds = {0.0,0.0};
|
|
||||||
#endif
|
|
||||||
int tableIndex;
|
int tableIndex;
|
||||||
int atbGauge = 0;
|
int atbGauge = 0;
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user