lot of changes in floors
This commit is contained in:
@@ -48,7 +48,7 @@ void Camera::update(Pad &t_pad, Mesh &t_mesh)
|
|||||||
*/
|
*/
|
||||||
void Camera::rotate(Pad &t_pad)
|
void Camera::rotate(Pad &t_pad)
|
||||||
{
|
{
|
||||||
if (t_pad.rJoyH <= 50)
|
if (t_pad.rJoyH <= 100)
|
||||||
horizontalLevel -= 0.08;
|
horizontalLevel -= 0.08;
|
||||||
else if (t_pad.rJoyH >= 200)
|
else if (t_pad.rJoyH >= 200)
|
||||||
horizontalLevel += 0.08;
|
horizontalLevel += 0.08;
|
||||||
|
|||||||
@@ -36,14 +36,15 @@ Floors::~Floors()
|
|||||||
|
|
||||||
void Floors::onInit()
|
void Floors::onInit()
|
||||||
{
|
{
|
||||||
|
setBgColorAndAmbientColor();
|
||||||
engine->renderer->setCameraDefinitions(&camera.worldView, &camera.unitCirclePosition, camera.planes);
|
engine->renderer->setCameraDefinitions(&camera.worldView, &camera.unitCirclePosition, camera.planes);
|
||||||
engine->audio.addSongListener(this);
|
engine->audio.addSongListener(this);
|
||||||
engine->audio.loadSong("nob-else.wav");
|
engine->audio.loadSong("mafikizolo-loot.wav");
|
||||||
engine->audio.playSong();
|
engine->audio.playSong();
|
||||||
texRepo = engine->renderer->getTextureRepository();
|
texRepo = engine->renderer->getTextureRepository();
|
||||||
enemy = new Enemy(texRepo);
|
enemy = new Enemy(texRepo);
|
||||||
ui = new Ui(texRepo);
|
ui = new Ui(texRepo);
|
||||||
engine->audio.setSongVolume(20);
|
engine->audio.setSongVolume(80);
|
||||||
|
|
||||||
texRepo->addByMesh("warrior/", player.mesh, BMP);
|
texRepo->addByMesh("warrior/", player.mesh, BMP);
|
||||||
texRepo->addByMesh("floor/", floorManager.floors[0].mesh, BMP);
|
texRepo->addByMesh("floor/", floorManager.floors[0].mesh, BMP);
|
||||||
@@ -55,6 +56,7 @@ void Floors::onInit()
|
|||||||
void Floors::onUpdate()
|
void Floors::onUpdate()
|
||||||
{
|
{
|
||||||
ui->update(player);
|
ui->update(player);
|
||||||
|
enemy->update(floorManager);
|
||||||
lightManager.update();
|
lightManager.update();
|
||||||
camera.update(engine->pad, player.mesh);
|
camera.update(engine->pad, player.mesh);
|
||||||
floorManager.update(player);
|
floorManager.update(player);
|
||||||
@@ -68,7 +70,7 @@ void Floors::onUpdate()
|
|||||||
|
|
||||||
void Floors::onAudioTick()
|
void Floors::onAudioTick()
|
||||||
{
|
{
|
||||||
if ((++audioTicks + 20) % 28 == 0)
|
if ((++audioTicks + 20) % 21 == 0)
|
||||||
{
|
{
|
||||||
if (skip1Beat)
|
if (skip1Beat)
|
||||||
floorManager.onAudioTick();
|
floorManager.onAudioTick();
|
||||||
@@ -79,6 +81,17 @@ void Floors::onAudioTick()
|
|||||||
audioTicks = 0;
|
audioTicks = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Floors::setBgColorAndAmbientColor()
|
||||||
|
{
|
||||||
|
color_t bgColor;
|
||||||
|
bgColor.r = 0x20;
|
||||||
|
bgColor.g = 0x20;
|
||||||
|
bgColor.b = 0x20;
|
||||||
|
engine->renderer->setWorldColor(bgColor);
|
||||||
|
Vector3 ambient = Vector3(0.003F, 0.003F, 0.003F);
|
||||||
|
engine->renderer->setAmbientLight(ambient);
|
||||||
|
}
|
||||||
|
|
||||||
void Floors::onAudioFinish()
|
void Floors::onAudioFinish()
|
||||||
{
|
{
|
||||||
audioTicks = 0;
|
audioTicks = 0;
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ public:
|
|||||||
Engine *engine;
|
Engine *engine;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void setBgColorAndAmbientColor();
|
||||||
u32 audioTicks;
|
u32 audioTicks;
|
||||||
u8 skip1Beat;
|
u8 skip1Beat;
|
||||||
TextureRepository *texRepo;
|
TextureRepository *texRepo;
|
||||||
|
|||||||
@@ -27,6 +27,10 @@ FloorManager::FloorManager(int t_floorAmount)
|
|||||||
int floorSpiralMaxOffset = (int)Math::sqrt(t_floorAmount);
|
int floorSpiralMaxOffset = (int)Math::sqrt(t_floorAmount);
|
||||||
calcSpiral(floorSpiralMaxOffset, floorSpiralMaxOffset);
|
calcSpiral(floorSpiralMaxOffset, floorSpiralMaxOffset);
|
||||||
initFloors();
|
initFloors();
|
||||||
|
trick = 0.0F;
|
||||||
|
trickMode = 0;
|
||||||
|
isTimeForChangeTriggerColor = true;
|
||||||
|
isTimeForChangeDefaultColor = true;
|
||||||
audioOffset = audioMode = audioTick = 0;
|
audioOffset = audioMode = audioTick = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,15 +96,65 @@ void FloorManager::initFloors()
|
|||||||
*/
|
*/
|
||||||
void FloorManager::update(Player &t_player)
|
void FloorManager::update(Player &t_player)
|
||||||
{
|
{
|
||||||
|
if (isTimeForChangeTriggerColor)
|
||||||
|
{
|
||||||
|
isTimeForChangeTriggerColor = false;
|
||||||
|
trigColor.r = rand() % (128 - 64 + 1) + 64;
|
||||||
|
trigColor.g = rand() % (128 - 64 + 1) + 64;
|
||||||
|
trigColor.b = rand() % (128 - 64 + 1) + 64;
|
||||||
|
}
|
||||||
|
if (isTimeForChangeDefaultColor)
|
||||||
|
{
|
||||||
|
isTimeForChangeDefaultColor = false;
|
||||||
|
defaultColor.r = rand() % (64 + 1);
|
||||||
|
defaultColor.g = rand() % (64 + 1);
|
||||||
|
defaultColor.b = rand() % (64 + 1);
|
||||||
|
}
|
||||||
|
doTheTrick();
|
||||||
for (u16 i = 0; i < floorAmount; i++)
|
for (u16 i = 0; i < floorAmount; i++)
|
||||||
{
|
{
|
||||||
floors[i].animate(t_player);
|
floors[i].animate(t_player);
|
||||||
|
|
||||||
if (floors[i].isByAudioTriggered)
|
if (floors[i].isByAudioTriggered)
|
||||||
floors[i].mesh.color.a = 0x20;
|
{
|
||||||
else
|
floors[i].mesh.color.r = trigColor.r;
|
||||||
floors[i].mesh.color.a = 0x80;
|
floors[i].mesh.color.g = trigColor.g;
|
||||||
|
floors[i].mesh.color.b = trigColor.b;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
floors[i].mesh.color.r = defaultColor.r;
|
||||||
|
floors[i].mesh.color.g = defaultColor.g;
|
||||||
|
floors[i].mesh.color.b = defaultColor.b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FloorManager::doTheTrick()
|
||||||
|
{
|
||||||
|
if (trickMode == 0)
|
||||||
|
{
|
||||||
|
if (trick > 3.0F)
|
||||||
|
{
|
||||||
|
isTimeForChangeTriggerColor = true;
|
||||||
|
trickMode = 1;
|
||||||
|
}
|
||||||
|
trick += 0.01F;
|
||||||
|
}
|
||||||
|
else if (trickMode == 1)
|
||||||
|
{
|
||||||
|
if (trick <= 0.1F)
|
||||||
|
{
|
||||||
|
isTimeForChangeTriggerColor = true;
|
||||||
|
trickMode = 0;
|
||||||
|
}
|
||||||
|
trick -= 0.01F;
|
||||||
|
}
|
||||||
|
floors[0].mesh.getFrames()[0].getST(1).set(trick, trick);
|
||||||
|
floors[0].mesh.getFrames()[0].getST(4).set(trick, trick);
|
||||||
|
floors[0].mesh.getFrames()[0].getST(7).set(trick, trick);
|
||||||
|
floors[0].mesh.getFrames()[0].getST(10).set(trick, trick);
|
||||||
|
floors[0].mesh.getFrames()[0].getST(13).set(trick, trick);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Called by audio thread */
|
/** Called by audio thread */
|
||||||
@@ -120,6 +174,7 @@ void FloorManager::onAudioTick()
|
|||||||
if (++audioOffset > 3)
|
if (++audioOffset > 3)
|
||||||
{
|
{
|
||||||
audioOffset = 0;
|
audioOffset = 0;
|
||||||
|
isTimeForChangeDefaultColor = true;
|
||||||
audioMode = 1;
|
audioMode = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -135,6 +190,7 @@ void FloorManager::onAudioTick()
|
|||||||
if (++audioOffset > 3)
|
if (++audioOffset > 3)
|
||||||
{
|
{
|
||||||
audioOffset = 0;
|
audioOffset = 0;
|
||||||
|
isTimeForChangeDefaultColor = true;
|
||||||
audioMode = 2;
|
audioMode = 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -150,6 +206,7 @@ void FloorManager::onAudioTick()
|
|||||||
if (++audioOffset > 3)
|
if (++audioOffset > 3)
|
||||||
{
|
{
|
||||||
audioOffset = 0;
|
audioOffset = 0;
|
||||||
|
isTimeForChangeDefaultColor = true;
|
||||||
audioMode = 3;
|
audioMode = 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -165,6 +222,7 @@ void FloorManager::onAudioTick()
|
|||||||
if (++audioOffset > 3)
|
if (++audioOffset > 3)
|
||||||
{
|
{
|
||||||
audioOffset = 0;
|
audioOffset = 0;
|
||||||
|
isTimeForChangeDefaultColor = true;
|
||||||
audioMode = 0;
|
audioMode = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,8 +34,13 @@ public:
|
|||||||
private:
|
private:
|
||||||
u8 audioOffset, audioMode;
|
u8 audioOffset, audioMode;
|
||||||
u32 audioTick;
|
u32 audioTick;
|
||||||
|
float trick;
|
||||||
|
u8 isTimeForChangeTriggerColor, isTimeForChangeDefaultColor;
|
||||||
|
color_t trigColor, defaultColor;
|
||||||
|
u8 trickMode;
|
||||||
Point *spirals;
|
Point *spirals;
|
||||||
void calcSpiral(int X, int Y);
|
void calcSpiral(int X, int Y);
|
||||||
|
void doTheTrick();
|
||||||
void initFloors();
|
void initFloors();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ void LightManager::onAudioTick()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bulbs[0].intensity += 6;
|
bulbs[0].intensity += 9;
|
||||||
bulbs[1].intensity += 6;
|
bulbs[1].intensity += 9;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "enemy.hpp"
|
#include "enemy.hpp"
|
||||||
|
#include "../utils.hpp"
|
||||||
|
|
||||||
#include <loaders/md2_loader.hpp>
|
#include <loaders/md2_loader.hpp>
|
||||||
#include <loaders/bmp_loader.hpp>
|
#include <loaders/bmp_loader.hpp>
|
||||||
@@ -27,20 +28,20 @@ Enemy::Enemy(TextureRepository *t_texRepo)
|
|||||||
meshes = new Mesh[getMeshesCount()];
|
meshes = new Mesh[getMeshesCount()];
|
||||||
|
|
||||||
meshes[0].loadMD2("poss/", "poss_head", 0.3F, false);
|
meshes[0].loadMD2("poss/", "poss_head", 0.3F, false);
|
||||||
meshes[0].position.set(0.00F, 40.00F, 0.00F);
|
|
||||||
meshes[0].rotation.x = -1.566F;
|
meshes[0].rotation.x = -1.566F;
|
||||||
meshes[0].rotation.z = 1.566F;
|
meshes[0].rotation.z = 1.566F;
|
||||||
|
|
||||||
meshes[1].loadMD2("poss/", "poss_body", 0.3F, false);
|
meshes[1].loadMD2("poss/", "poss_body", 0.3F, false);
|
||||||
meshes[1].position.set(0.00F, 40.00F, 0.00F);
|
|
||||||
meshes[1].rotation.x = -1.566F;
|
meshes[1].rotation.x = -1.566F;
|
||||||
meshes[1].rotation.z = 1.566F;
|
meshes[1].rotation.z = 1.566F;
|
||||||
|
|
||||||
meshes[2].loadMD2("poss/", "poss_weapon", 0.3F, false);
|
meshes[2].loadMD2("poss/", "poss_weapon", 0.3F, false);
|
||||||
meshes[2].position.set(0.00F, 40.00F, 0.00F);
|
|
||||||
meshes[2].rotation.x = -1.566F;
|
meshes[2].rotation.x = -1.566F;
|
||||||
meshes[2].rotation.z = 1.566F;
|
meshes[2].rotation.z = 1.566F;
|
||||||
|
|
||||||
|
Vector3 initPos = Vector3(0.00F, 40.00F, 0.00F);
|
||||||
|
setPosition(initPos);
|
||||||
|
|
||||||
t_texRepo->addByMesh("poss/", meshes[0], PNG);
|
t_texRepo->addByMesh("poss/", meshes[0], PNG);
|
||||||
t_texRepo->addByMesh("poss/", meshes[1], PNG);
|
t_texRepo->addByMesh("poss/", meshes[1], PNG);
|
||||||
t_texRepo->addByMesh("poss/", meshes[2], PNG);
|
t_texRepo->addByMesh("poss/", meshes[2], PNG);
|
||||||
@@ -49,6 +50,8 @@ Enemy::Enemy(TextureRepository *t_texRepo)
|
|||||||
meshes[1].playAnimation(1, 6);
|
meshes[1].playAnimation(1, 6);
|
||||||
meshes[2].playAnimation(1, 6);
|
meshes[2].playAnimation(1, 6);
|
||||||
|
|
||||||
|
isKilled = true;
|
||||||
|
|
||||||
PRINT_LOG("Enemy object created!");
|
PRINT_LOG("Enemy object created!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,12 +64,40 @@ Enemy::~Enemy()
|
|||||||
// Methods
|
// Methods
|
||||||
// ----
|
// ----
|
||||||
|
|
||||||
/** Called by player class. */
|
void Enemy::setPosition(const Vector3 &t_vec)
|
||||||
void Enemy::kill(const Player &player) const
|
|
||||||
{
|
{
|
||||||
printf("killed!\n");
|
position.set(t_vec);
|
||||||
|
for (u8 i = 0; i < getMeshesCount(); i++)
|
||||||
|
meshes[i].position.set(t_vec);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Enemy::setPosition(const float &t_y)
|
||||||
|
{
|
||||||
|
position.y = t_y;
|
||||||
|
for (u8 i = 0; i < getMeshesCount(); i++)
|
||||||
|
meshes[i].position.y = t_y;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Called by player class. */
|
||||||
|
void Enemy::kill(const Player &player)
|
||||||
|
{
|
||||||
|
isKilled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Enemy::update(const FloorManager &floorManager)
|
void Enemy::update(const FloorManager &floorManager)
|
||||||
{
|
{
|
||||||
|
if (isKilled)
|
||||||
|
{
|
||||||
|
isKilled = false;
|
||||||
|
int randFloor = rand() % (floorManager.floorAmount + 1);
|
||||||
|
currentFloor = &floorManager.floors[randFloor];
|
||||||
|
setPosition(currentFloor->mesh.position);
|
||||||
|
}
|
||||||
|
updateGravity();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Enemy::updateGravity()
|
||||||
|
{
|
||||||
|
Utils::getMinMax(currentFloor->mesh, currFloorMin, currFloorMax);
|
||||||
|
setPosition(currFloorMax.y);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,13 +26,19 @@ public:
|
|||||||
|
|
||||||
inline Mesh *getMeshes() const { return meshes; }
|
inline Mesh *getMeshes() const { return meshes; }
|
||||||
inline u8 getMeshesCount() const { return 3; }
|
inline u8 getMeshesCount() const { return 3; }
|
||||||
inline Vector3 &getPosition() const { return meshes[1].position; }
|
inline Vector3 getPosition() const { return position; }
|
||||||
void kill(const Player &player) const;
|
void setPosition(const Vector3 &t_vec);
|
||||||
|
void setPosition(const float &t_y);
|
||||||
|
void kill(const Player &player);
|
||||||
void update(const FloorManager &t_floorManager);
|
void update(const FloorManager &t_floorManager);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** 0 - head, 1 - body, 2 - weapon */
|
/** 0 - head, 1 - body, 2 - weapon */
|
||||||
Mesh *meshes;
|
Mesh *meshes;
|
||||||
|
const Floor *currentFloor;
|
||||||
|
Vector3 position, currFloorMin, currFloorMax;
|
||||||
|
u8 isKilled;
|
||||||
|
void updateGravity();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "player.hpp"
|
#include "player.hpp"
|
||||||
|
#include "../utils.hpp"
|
||||||
|
|
||||||
#include <loaders/md2_loader.hpp>
|
#include <loaders/md2_loader.hpp>
|
||||||
#include <loaders/bmp_loader.hpp>
|
#include <loaders/bmp_loader.hpp>
|
||||||
@@ -27,6 +28,7 @@ Player::Player(Audio *t_audio)
|
|||||||
gravity = 0.1F;
|
gravity = 0.1F;
|
||||||
lift = -1.0F;
|
lift = -1.0F;
|
||||||
jumpCounter = 0;
|
jumpCounter = 0;
|
||||||
|
speed = 1.0F;
|
||||||
killedEnemies = 0;
|
killedEnemies = 0;
|
||||||
isWalking = false;
|
isWalking = false;
|
||||||
isFighting = false;
|
isFighting = false;
|
||||||
@@ -45,6 +47,7 @@ Player::Player(Audio *t_audio)
|
|||||||
|
|
||||||
walkAdpcm = audio->loadADPCM("walk.adpcm");
|
walkAdpcm = audio->loadADPCM("walk.adpcm");
|
||||||
jumpAdpcm = audio->loadADPCM("jump.adpcm");
|
jumpAdpcm = audio->loadADPCM("jump.adpcm");
|
||||||
|
boomAdpcm = audio->loadADPCM("boom.adpcm");
|
||||||
audio->setADPCMVolume(60, 0);
|
audio->setADPCMVolume(60, 0);
|
||||||
|
|
||||||
PRINT_LOG("Player object created!");
|
PRINT_LOG("Player object created!");
|
||||||
@@ -59,7 +62,7 @@ Player::~Player()
|
|||||||
// ----
|
// ----
|
||||||
|
|
||||||
/** Update player position and control gravity */
|
/** Update player position and control gravity */
|
||||||
void Player::update(const Pad &t_pad, const Camera &t_camera, const FloorManager &floorManager, const Enemy &enemy)
|
void Player::update(const Pad &t_pad, const Camera &t_camera, const FloorManager &floorManager, Enemy &enemy)
|
||||||
{
|
{
|
||||||
Vector3 *nextPos = getNextPosition(t_pad, t_camera);
|
Vector3 *nextPos = getNextPosition(t_pad, t_camera);
|
||||||
FloorsCheck *floorsCheck = checkFloors(floorManager, *nextPos);
|
FloorsCheck *floorsCheck = checkFloors(floorManager, *nextPos);
|
||||||
@@ -76,6 +79,7 @@ Vector3 *Player::getNextPosition(const Pad &t_pad, const Camera &t_camera)
|
|||||||
Vector3 *result = new Vector3(mesh.position);
|
Vector3 *result = new Vector3(mesh.position);
|
||||||
Vector3 normalizedCamera = Vector3(t_camera.unitCirclePosition);
|
Vector3 normalizedCamera = Vector3(t_camera.unitCirclePosition);
|
||||||
normalizedCamera.normalize();
|
normalizedCamera.normalize();
|
||||||
|
normalizedCamera *= speed;
|
||||||
if (t_pad.lJoyV <= 100)
|
if (t_pad.lJoyV <= 100)
|
||||||
{
|
{
|
||||||
result->x += -normalizedCamera.x;
|
result->x += -normalizedCamera.x;
|
||||||
@@ -100,7 +104,7 @@ Vector3 *Player::getNextPosition(const Pad &t_pad, const Camera &t_camera)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Move player when pad move buttons are pressed and is not blocked by any floor side */
|
/** Move player when pad move buttons are pressed and is not blocked by any floor side */
|
||||||
void Player::updatePosition(const Pad &t_pad, const Camera &t_camera, const FloorManager &t_floorManager, const FloorsCheck &t_floorsCheck, const Vector3 &t_nextPos, const Enemy &enemy)
|
void Player::updatePosition(const Pad &t_pad, const Camera &t_camera, const FloorManager &t_floorManager, const FloorsCheck &t_floorsCheck, const Vector3 &t_nextPos, Enemy &enemy)
|
||||||
{
|
{
|
||||||
if (t_pad.rJoyH >= 200)
|
if (t_pad.rJoyH >= 200)
|
||||||
mesh.rotation.z += 0.08;
|
mesh.rotation.z += 0.08;
|
||||||
@@ -121,9 +125,11 @@ void Player::updatePosition(const Pad &t_pad, const Camera &t_camera, const Floo
|
|||||||
if (fightTimer.getTimeDelta() > 25000)
|
if (fightTimer.getTimeDelta() > 25000)
|
||||||
{ // end of fighting
|
{ // end of fighting
|
||||||
float distance = getPosition().distanceTo(enemy.getPosition());
|
float distance = getPosition().distanceTo(enemy.getPosition());
|
||||||
if (12.0F > distance)
|
if (16.0F > distance)
|
||||||
{
|
{
|
||||||
enemy.kill(*this);
|
enemy.kill(*this);
|
||||||
|
audio->playADPCM(boomAdpcm);
|
||||||
|
speed += .5F;
|
||||||
killedEnemies++;
|
killedEnemies++;
|
||||||
}
|
}
|
||||||
isFightingAnimationSet = false;
|
isFightingAnimationSet = false;
|
||||||
@@ -207,7 +213,7 @@ FloorsCheck *Player::checkFloors(const FloorManager &t_floorManager, const Vecto
|
|||||||
Vector3 max = Vector3();
|
Vector3 max = Vector3();
|
||||||
for (u32 i = 0; i < t_floorManager.floorAmount; i++)
|
for (u32 i = 0; i < t_floorManager.floorAmount; i++)
|
||||||
{
|
{
|
||||||
getMinMax(t_floorManager.floors[i].mesh, min, max);
|
Utils::getMinMax(t_floorManager.floors[i].mesh, min, max);
|
||||||
if (result->currentFloor == NULL && this->mesh.position.isOnSquare(min, max))
|
if (result->currentFloor == NULL && this->mesh.position.isOnSquare(min, max))
|
||||||
{
|
{
|
||||||
result->currentFloor = &t_floorManager.floors[i];
|
result->currentFloor = &t_floorManager.floors[i];
|
||||||
@@ -225,39 +231,3 @@ FloorsCheck *Player::checkFloors(const FloorManager &t_floorManager, const Vecto
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Calculates minimum and maximum X, Y, Z of mesh vertices + current position */
|
|
||||||
void Player::getMinMax(const Mesh &t_mesh, Vector3 &t_min, Vector3 &t_max)
|
|
||||||
{
|
|
||||||
Vector3 calc = Vector3();
|
|
||||||
u8 isInitialized = 0;
|
|
||||||
Vector3 *boundingBox = t_mesh.getCurrentBoundingBox();
|
|
||||||
for (u32 i = 0; i < 8; i++)
|
|
||||||
{
|
|
||||||
calc.set(
|
|
||||||
boundingBox[i].x + t_mesh.position.x,
|
|
||||||
boundingBox[i].y + t_mesh.position.y,
|
|
||||||
boundingBox[i].z + t_mesh.position.z);
|
|
||||||
if (isInitialized == 0)
|
|
||||||
{
|
|
||||||
isInitialized = 1;
|
|
||||||
t_min.set(calc);
|
|
||||||
t_max.set(calc);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (t_min.x > calc.x)
|
|
||||||
t_min.x = calc.x;
|
|
||||||
if (calc.x > t_max.x)
|
|
||||||
t_max.x = calc.x;
|
|
||||||
|
|
||||||
if (t_min.y > calc.y)
|
|
||||||
t_min.y = calc.y;
|
|
||||||
if (calc.y > t_max.y)
|
|
||||||
t_max.y = calc.y;
|
|
||||||
|
|
||||||
if (t_min.z > calc.z)
|
|
||||||
t_min.z = calc.z;
|
|
||||||
if (calc.z > t_max.z)
|
|
||||||
t_max.z = calc.z;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -36,9 +36,10 @@ public:
|
|||||||
Player(Audio *t_audio);
|
Player(Audio *t_audio);
|
||||||
~Player();
|
~Player();
|
||||||
|
|
||||||
void update(const Pad &t_pad, const Camera &t_camera, const FloorManager &t_floorManager, const Enemy &enemy);
|
void update(const Pad &t_pad, const Camera &t_camera, const FloorManager &t_floorManager, Enemy &enemy);
|
||||||
void onBeforePlayerFloorMove(Floor *t_floor, float &t_newY);
|
void onBeforePlayerFloorMove(Floor *t_floor, float &t_newY);
|
||||||
const inline u32 &getJumpCount() const { return jumpCounter; }
|
const inline u32 &getJumpCount() const { return jumpCounter; }
|
||||||
|
const inline u32 &getKilledEnemiesCount() const { return killedEnemies; }
|
||||||
inline const Vector3 &getPosition() const { return mesh.position; }
|
inline const Vector3 &getPosition() const { return mesh.position; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -49,9 +50,10 @@ private:
|
|||||||
u8 isFighting, isWalking;
|
u8 isFighting, isWalking;
|
||||||
Audio *audio;
|
Audio *audio;
|
||||||
Timer walkTimer, fightTimer;
|
Timer walkTimer, fightTimer;
|
||||||
audsrv_adpcm_t *walkAdpcm, *jumpAdpcm;
|
audsrv_adpcm_t *walkAdpcm, *jumpAdpcm, *boomAdpcm;
|
||||||
|
float speed;
|
||||||
void getMinMax(const Mesh &t_mesh, Vector3 &t_min, Vector3 &t_max);
|
void getMinMax(const Mesh &t_mesh, Vector3 &t_min, Vector3 &t_max);
|
||||||
void updatePosition(const Pad &t_pad, const Camera &t_camera, const FloorManager &t_floorManager, const FloorsCheck &t_floorsCheck, const Vector3 &nextPos, const Enemy &enemy);
|
void updatePosition(const Pad &t_pad, const Camera &t_camera, const FloorManager &t_floorManager, const FloorsCheck &t_floorsCheck, const Vector3 &nextPos, Enemy &enemy);
|
||||||
void updateGravity(FloorsCheck *t_floorsCheck);
|
void updateGravity(FloorsCheck *t_floorsCheck);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -60,6 +60,12 @@ void Ui::update(const Player &player)
|
|||||||
grayCheckboxTex->removeLinkBySprite(task1Checkbox.getId());
|
grayCheckboxTex->removeLinkBySprite(task1Checkbox.getId());
|
||||||
blueCheckboxTex->addLink(task1Checkbox.getId());
|
blueCheckboxTex->addLink(task1Checkbox.getId());
|
||||||
}
|
}
|
||||||
|
if (!isTask2Done && player.getKilledEnemiesCount() >= 10)
|
||||||
|
{
|
||||||
|
isTask2Done = true;
|
||||||
|
grayCheckboxTex->removeLinkBySprite(task2Checkbox.getId());
|
||||||
|
blueCheckboxTex->addLink(task2Checkbox.getId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ui::render(Renderer *t_renderer)
|
void Ui::render(Renderer *t_renderer)
|
||||||
|
|||||||
@@ -32,3 +32,39 @@ float Utils::expoEaseInOut(float t, float b, float c, float d)
|
|||||||
|
|
||||||
return c / 2 * (-powf(2, -10 * --t) + 2) + b;
|
return c / 2 * (-powf(2, -10 * --t) + 2) + b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Calculates minimum and maximum X, Y, Z of mesh vertices + current position */
|
||||||
|
void Utils::getMinMax(const Mesh &t_mesh, Vector3 &t_min, Vector3 &t_max)
|
||||||
|
{
|
||||||
|
Vector3 calc = Vector3();
|
||||||
|
u8 isInitialized = 0;
|
||||||
|
Vector3 *boundingBox = t_mesh.getCurrentBoundingBox();
|
||||||
|
for (u32 i = 0; i < 8; i++)
|
||||||
|
{
|
||||||
|
calc.set(
|
||||||
|
boundingBox[i].x + t_mesh.position.x,
|
||||||
|
boundingBox[i].y + t_mesh.position.y,
|
||||||
|
boundingBox[i].z + t_mesh.position.z);
|
||||||
|
if (isInitialized == 0)
|
||||||
|
{
|
||||||
|
isInitialized = 1;
|
||||||
|
t_min.set(calc);
|
||||||
|
t_max.set(calc);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (t_min.x > calc.x)
|
||||||
|
t_min.x = calc.x;
|
||||||
|
if (calc.x > t_max.x)
|
||||||
|
t_max.x = calc.x;
|
||||||
|
|
||||||
|
if (t_min.y > calc.y)
|
||||||
|
t_min.y = calc.y;
|
||||||
|
if (calc.y > t_max.y)
|
||||||
|
t_max.y = calc.y;
|
||||||
|
|
||||||
|
if (t_min.z > calc.z)
|
||||||
|
t_min.z = calc.z;
|
||||||
|
if (calc.z > t_max.z)
|
||||||
|
t_max.z = calc.z;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -12,12 +12,15 @@
|
|||||||
#define _TYRA_UTILS_
|
#define _TYRA_UTILS_
|
||||||
|
|
||||||
#include <tamtypes.h>
|
#include <tamtypes.h>
|
||||||
|
#include <models/mesh.hpp>
|
||||||
|
#include <models/math/vector3.hpp>
|
||||||
|
|
||||||
class Utils
|
class Utils
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static float expoEaseInOut(float t, float b, float c, float d);
|
static float expoEaseInOut(float t, float b, float c, float d);
|
||||||
|
static void getMinMax(const Mesh &t_mesh, Vector3 &t_min, Vector3 &t_max);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user