Added rumble on enemy hit, added try for teleport

This commit is contained in:
jancoow
2016-06-22 02:58:45 +02:00
parent c9e5be2573
commit 2230682a85
8 changed files with 42 additions and 2 deletions
+17
View File
@@ -130,6 +130,14 @@ void CrystalPoint::update()
player->hit = true;
}
if(player->isHit){
controller.rumble(leftcontroller->controllerId, 50, 250);
}
if(!leftcontroller->lastMagetSwitch && leftcontroller->magnetSwitch){
worldhandler -> teleportRandom();
}
}
if(rightcontroller != nullptr){
Vec2f *rightControllerJoystick = &rightcontroller->joystick;
@@ -153,6 +161,15 @@ void CrystalPoint::update()
player->NextRightWeapon();
}
if(player->isHit){
controller.rumble(rightcontroller->controllerId, 50, 250);
player->isHit = false;
}
if(!rightcontroller->lastMagetSwitch && rightcontroller->magnetSwitch){
worldhandler -> teleportRandom();
}
player->rightWeapon->rotateWeapon(Vec3f(rightcontroller->ypr.y + 140, 0, -rightcontroller->ypr.z));
}
+6 -1
View File
@@ -6,7 +6,8 @@
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
#include <stdlib.h>
#include <time.h>
#include "Cursor.h"
void configureOpenGL(void);
@@ -15,11 +16,15 @@ CrystalPoint* app;
bool justMoved = false;
int main(int argc, char* argv[])
{
app = new CrystalPoint();
glutInit(&argc, argv);
srand (time(NULL));
configureOpenGL();
app->init();
+1
View File
@@ -86,6 +86,7 @@ void Player::draw() {
void Player::HpDown(int damage)
{
int newHealth = health - damage;
isHit = true;
if (newHealth <= 0)
{
exit(0);
+1
View File
@@ -41,6 +41,7 @@ public:
int crystals;
bool hit;
bool isHit;
float speed;
+8 -1
View File
@@ -6,6 +6,8 @@
#include <fstream>
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <cstdlib>
#include "WorldHandler.h"
World::World(const std::string &fileName)
@@ -220,7 +222,12 @@ World::World(const std::string &fileName)
}
}
Vec2f World::randomPosition(void){
int randNum = rand()%(entities.size() + 1);
Vec3f position = entities[randNum]->position;
Vec2f position2 = Vec2f(position.x+100, position.y+100);
return position2;
}
World::~World()
{
delete heightmap;
+1
View File
@@ -41,6 +41,7 @@ public:
bool isPlayerPositionValid();
float getHeight(float x, float y);
void addLevelObject(LevelObject* obj);
Vec2f randomPosition(void);
std::pair<std::string, bool> getObjectFromValue(int i);
};
+7
View File
@@ -93,6 +93,13 @@ void WorldHandler::update(float deltaTime)
world->update(deltaTime);
}
void WorldHandler::teleportRandom(){
Vec2f randomposition = world->randomPosition();
printf("test %d %d", randomposition.x, randomposition.y);
Player::getInstance()->position = Vec3f(randomposition.x, randomposition.y, world->getHeight(randomposition.x, randomposition.y));
Player::getInstance()->setPosition(50,50,true);
}
bool WorldHandler::isPlayerPositionValid(void)
{
if(!loadingWorld)
+1
View File
@@ -23,6 +23,7 @@ public:
void draw(void);
void update(float deltaTime);
void teleportRandom();
bool isPlayerPositionValid(void);
float getHeight(float x, float y);