Moved some files around
This commit is contained in:
@@ -1,67 +0,0 @@
|
||||
/* 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;
|
||||
}
|
||||
#ifdef GRAPHICS
|
||||
sprite.Update(delta);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef GRAPHICS
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,79 +0,0 @@
|
||||
/* 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_
|
||||
|
||||
#include "vector2.hpp"
|
||||
#include "statistics.hpp"
|
||||
|
||||
//graphics
|
||||
#ifdef GRAPHICS
|
||||
#include "sprite_sheet.hpp"
|
||||
#endif
|
||||
|
||||
//std namespace
|
||||
#include <string>
|
||||
#include <cmath>
|
||||
|
||||
//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;
|
||||
|
||||
struct CharacterData {
|
||||
//metadata
|
||||
int owner;
|
||||
std::string handle;
|
||||
std::string avatar;
|
||||
|
||||
//world position
|
||||
int roomIndex = 0;
|
||||
Vector2 origin = {0.0,0.0};
|
||||
Vector2 motion = {0.0,0.0};
|
||||
|
||||
//base statistics
|
||||
Statistics stats;
|
||||
|
||||
//TODO: gameplay components: equipment, items, buffs, debuffs
|
||||
|
||||
//methods
|
||||
void Update(double delta);
|
||||
#ifdef GRAPHICS
|
||||
void DrawTo(SDL_Surface* const, int camX, int camY);
|
||||
void CorrectSprite();
|
||||
#endif
|
||||
|
||||
//active gameplay members
|
||||
//NOTE: these are lost when unloaded
|
||||
#ifdef GRAPHICS
|
||||
Vector2 bounds = {0.0,0.0};
|
||||
SpriteSheet sprite;
|
||||
#endif
|
||||
bool inCombat = false;
|
||||
int atbGauge = 0;
|
||||
//TODO: stored command
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -19,39 +19,15 @@
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
*/
|
||||
#ifndef ENEMYDATA_HPP_
|
||||
#define ENEMYDATA_HPP_
|
||||
#ifndef CHARACTERDEFINES_HPP_
|
||||
#define CHARACTERDEFINES_HPP_
|
||||
|
||||
#include "vector2.hpp"
|
||||
#include "statistics.hpp"
|
||||
//the speeds that the characters move
|
||||
constexpr double CHARACTER_WALKING_SPEED = 140.0;
|
||||
constexpr double CHARACTER_WALKING_MOD = 1.0/sqrt(2.0);
|
||||
|
||||
//graphics
|
||||
#ifdef GRAPHICS
|
||||
#include "sprite_sheet.hpp"
|
||||
#endif
|
||||
|
||||
//std namespace
|
||||
#include <string>
|
||||
|
||||
struct EnemyData {
|
||||
//metadata
|
||||
std::string handle;
|
||||
std::string avatar;
|
||||
|
||||
//gameplay
|
||||
Statistics stats;
|
||||
|
||||
//TODO: gameplay components: equipment, items, buffs, debuffs, rewards
|
||||
|
||||
//active gameplay members
|
||||
//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 atbGauge = 0;
|
||||
};
|
||||
//the bounding boxes for the characters
|
||||
constexpr double CHARACTER_BOUNDS_WIDTH = 32.0;
|
||||
constexpr double CHARACTER_BOUNDS_HEIGHT = 32.0;
|
||||
|
||||
#endif
|
||||
@@ -1,70 +0,0 @@
|
||||
/* 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 COMBATDATA_HPP_
|
||||
#define COMBATDATA_HPP_
|
||||
|
||||
#include "vector2.hpp"
|
||||
|
||||
//gameplay members
|
||||
#include "character_data.hpp"
|
||||
#include "enemy_data.hpp"
|
||||
|
||||
//graphics
|
||||
#ifdef GRAPHICS
|
||||
#include "sprite_sheet.hpp"
|
||||
#endif
|
||||
|
||||
//std namespace
|
||||
#include <chrono>
|
||||
#include <array>
|
||||
#include <utility>
|
||||
|
||||
#define COMBAT_MAX_CHARACTERS 12
|
||||
#define COMBAT_MAX_ENEMIES 12
|
||||
|
||||
struct CombatData {
|
||||
enum class Terrain {
|
||||
//TODO: types of combat terrains
|
||||
NONE = 0,
|
||||
GRASSLANDS,
|
||||
};
|
||||
|
||||
typedef std::chrono::steady_clock Clock;
|
||||
|
||||
std::array<CharacterData, COMBAT_MAX_CHARACTERS> characterArray;
|
||||
std::array<EnemyData, COMBAT_MAX_ENEMIES> enemyArray;
|
||||
|
||||
//world interaction
|
||||
int mapIndex = 0;
|
||||
Vector2 origin = {0.0,0.0};
|
||||
Vector2 bounds = {0.0,0.0};
|
||||
|
||||
//time interval
|
||||
Clock::time_point lastTick = Clock::now();
|
||||
|
||||
//graphics
|
||||
#ifdef GRAPHICS
|
||||
SpriteSheet sprite;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -19,13 +19,15 @@
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
*/
|
||||
#include "character_data.hpp"
|
||||
#include "combat_data.hpp"
|
||||
#include "enemy_data.hpp"
|
||||
#include "statistics.hpp"
|
||||
#ifndef COMBATDEFINES_HPP_
|
||||
#define COMBATDEFINES_HPP_
|
||||
|
||||
/* DOCS: Sanity check, read more
|
||||
* Since most/all of the files in this directory are header files, I've created
|
||||
* this source file as a "sanity check", to ensure that the above header files
|
||||
* are written correctly via make.
|
||||
*/
|
||||
#define COMBAT_MAX_CHARACTERS 16
|
||||
#define COMBAT_MAX_ENEMIES 16
|
||||
|
||||
enum class TerrainType {
|
||||
NONE = 0,
|
||||
GRASSLANDS,
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,7 +1,7 @@
|
||||
#config
|
||||
INCLUDES+=. ../utilities ../graphics
|
||||
INCLUDES+=.
|
||||
LIBS+=
|
||||
CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES)) -DGRAPHICS
|
||||
CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES))
|
||||
|
||||
#source
|
||||
CXXSRC=$(wildcard *.cpp)
|
||||
|
||||
@@ -24,13 +24,13 @@
|
||||
|
||||
#include "serial_packet_base.hpp"
|
||||
|
||||
#include "combat_data.hpp"
|
||||
#include "combat_defines.hpp"
|
||||
|
||||
struct CombatPacket : SerialPacketBase {
|
||||
//identify the combat instance
|
||||
int combatIndex;
|
||||
int difficulty;
|
||||
CombatData::Terrain terrainType;
|
||||
TerrainType terrainType;
|
||||
|
||||
//combatants
|
||||
int characterArray[COMBAT_MAX_CHARACTERS];
|
||||
|
||||
@@ -29,7 +29,7 @@ void serializeCombat(CombatPacket* packet, void* buffer) {
|
||||
//identify the combat instance
|
||||
SERIALIZE(buffer, &packet->combatIndex, sizeof(int));
|
||||
SERIALIZE(buffer, &packet->difficulty, sizeof(int));
|
||||
SERIALIZE(buffer, &packet->terrainType, sizeof(CombatData::Terrain));
|
||||
SERIALIZE(buffer, &packet->terrainType, sizeof(TerrainType));
|
||||
|
||||
//combatants
|
||||
SERIALIZE(buffer, &packet->characterArray, sizeof(int) * COMBAT_MAX_CHARACTERS);
|
||||
@@ -49,7 +49,7 @@ void deserializeCombat(CombatPacket* packet, void* buffer) {
|
||||
//identify the combat instance
|
||||
DESERIALIZE(buffer, &packet->combatIndex, sizeof(int));
|
||||
DESERIALIZE(buffer, &packet->difficulty, sizeof(int));
|
||||
DESERIALIZE(buffer, &packet->terrainType, sizeof(CombatData::Terrain));
|
||||
DESERIALIZE(buffer, &packet->terrainType, sizeof(TerrainType));
|
||||
|
||||
//combatants
|
||||
DESERIALIZE(buffer, &packet->characterArray, sizeof(int) * COMBAT_MAX_CHARACTERS);
|
||||
|
||||
Reference in New Issue
Block a user