diff --git a/CrystalPoint.cpp b/CrystalPoint.cpp index 65f7e41..17f2cf7 100644 --- a/CrystalPoint.cpp +++ b/CrystalPoint.cpp @@ -125,6 +125,9 @@ void CrystalPoint::update() leftcontroller->lastButton = leftcontroller->button; controller.rumble(leftcontroller->controllerId, 100, 200); player->NextLeftWeapon(); + }else if(!leftcontroller->lastJoystickButton && leftcontroller->joystickButton){ + leftcontroller->lastJoystickButton = leftcontroller->joystickButton; + player->hit = true; } } diff --git a/Matrix.cpp b/Matrix.cpp deleted file mode 100644 index 97d91c3..0000000 --- a/Matrix.cpp +++ /dev/null @@ -1,89 +0,0 @@ -// -// Created by janco on 6/21/16. -// - -#include "Matrix.h" - - Matrix::Matrix(int size = 4) - { - data = new float[size][size]; - } - - Matrix Matrix::identity() - { - Matrix m = new Matrix(4); - m.data[0,0] = 1; - m.data[1,1] = 1; - m.data[2,2] = 1; - m.data[3,3] = 1; - return m; - } - - Matrix Matrix::rotation(float angle, Vector3 axis) - { - Matrix m = Matrix.identity(); - - float c = (float) Math.Cos((double) angle); - float s = (float) Math.Sin((double) angle); - - m.data[0, 0] = (float) Math.Pow(axis.x, 2) * (1 - c) + c; - m.data[0, 1] = axis.x * axis.y * (1 - c) - axis.z * s; - m.data[0, 2] = axis.x * axis.z * (1 - c) - axis.y * s; - m.data[1, 0] = axis.x * axis.y * (1 - c) + axis.z * s; - m.data[1, 1] = (float)Math.Pow(axis.y, 2) * (1 - c) + c; - m.data[1, 2] = axis.y * axis.z * (1 - c) + axis.x * s; - m.data[2, 0] = axis.x * axis.z * (1 - c) + axis.y * s; - m.data[2, 1] = axis.y * axis.z * (1 - c) - axis.x * s; - m.data[2, 2] = (float)Math.Pow(axis.z, 2) * (1 - c) + c; - - return m; - } - Matrix Matrix::translate(Vector3 offset) - { - Matrix m = Matrix.identity(); - - for(int i = 0; i < 3; i++) - { - m.data[i, 3] = offset.data[i]; - } - - return m; - } - - Vec3f Matrix::operator * (Matrix mat, Vec3f vec) - { - Vec3f v = Vec3f(0,0,0); - - for(int i = 0; i < 4; i++) - { - v.data[i] = 0; - - for(int p = 0; p < 4; p++) - { - v.data[i] += mat.data[i, p] * vec.data[p]; - } - } - - return v; - } - - Matrix Matrix::operator * (Matrix mat1, Matrix mat2) - { - Matrix m = Matrix.identity(); - - for (int i = 0; i < 4; i++) - { - for (int p = 0; p < 4; p++) - { - m.data[i, p] = 0; - - for (int q = 0; q < 4; q++) - { - m.data[i, p] += mat1.data[i, q] * mat2.data[q, p]; - } - } - } - - return m; - } -}; \ No newline at end of file diff --git a/Matrix.h b/Matrix.h deleted file mode 100644 index 9e631ea..0000000 --- a/Matrix.h +++ /dev/null @@ -1,26 +0,0 @@ -// -// Created by janco on 6/21/16. -// - -#ifndef CRYSTALPOINT_MATRIX_H -#define CRYSTALPOINT_MATRIX_H - - -class Matrix { -private: -public: - float *data; - - Matrix(int i = 4); - ~Matrix(); - - static Matrix rotation(int angle, Vec3f axis); - static Matrix identity(void); - static Matrix translate(Vec3f offset); - - Matrix operator * (Matrix m1, Matrix m2); - Vec3f operator * (Matrix m, Vec3f v); -} - - -#endif //CRYSTALPOINT_MATRIX_H diff --git a/Player.cpp b/Player.cpp index 83559ed..d650a02 100644 --- a/Player.cpp +++ b/Player.cpp @@ -18,6 +18,7 @@ Player::Player() maxXp = 100; level = 5; crystals = 0; + hit = false; loadWeapons(); diff --git a/Player.h b/Player.h index b843153..17bbe49 100644 --- a/Player.h +++ b/Player.h @@ -40,6 +40,8 @@ public: int level; int crystals; + bool hit; + float speed; void HpUp(int); diff --git a/World.cpp b/World.cpp index 172ed4d..f7259ad 100644 --- a/World.cpp +++ b/World.cpp @@ -304,6 +304,9 @@ void World::update(float elapsedTime) enemy->update(elapsedTime); if (enemy->hasTarget) { + if(player->hit) + enemy->hit(player->leftWeapon->damage); + for (auto e : entities) { if (e->canCollide && e->inObject(enemy->position)) @@ -315,8 +318,7 @@ void World::update(float elapsedTime) if (enemy->attack) { - remove = true; - continue; + player->HpDown(enemy->damage / 4); } } enemy->position.y = getHeight(enemy->position.x, enemy->position.z) + 2.0f; @@ -330,7 +332,7 @@ void World::update(float elapsedTime) if (remove) { delete enemies[count]; - player->XpUp(enemies[count]->xp); + player->XpUp(enemies[count]->xp*2); enemies.erase(enemies.begin() + count); player->HpUp(10); } @@ -342,6 +344,8 @@ void World::update(float elapsedTime) if (portal->enter(elapsedTime)) nextworld = true; } + + player->hit = false; }