diff --git a/CrystalPoint.cpp b/CrystalPoint.cpp index 6758fe8..65f7e41 100644 --- a/CrystalPoint.cpp +++ b/CrystalPoint.cpp @@ -64,7 +64,7 @@ void CrystalPoint::update() lastFrameTime = frameTime; if (keyboardState.keys[27] && !prevKeyboardState.keys[27]) - state = !state; + state = !state; Controller *rightcontroller = controller.getRightController(); Controller *leftcontroller = controller.getLeftController(); @@ -78,7 +78,7 @@ void CrystalPoint::update() if (keyboardState.special[GLUT_KEY_RIGHT] && !prevKeyboardState.special[GLUT_KEY_RIGHT]) worldhandler->NextWorld(); if (keyboardState.special[GLUT_KEY_UP] && !prevKeyboardState.special[GLUT_KEY_UP]) - player->NextLeftWeapon(); + player->NextRightWeapon(); if (keyboardState.special[GLUT_KEY_DOWN] && !prevKeyboardState.special[GLUT_KEY_DOWN]) player->PreviousLeftWeapon(); if (keyboardState.keys[27]) @@ -149,7 +149,7 @@ void CrystalPoint::update() controller.rumble(rightcontroller->controllerId, 100, 200); player->NextRightWeapon(); } - + player->rightWeapon->rotateWeapon(Vec3f(rightcontroller->ypr.y + 140, 0, -rightcontroller->ypr.z)); } @@ -162,9 +162,6 @@ void CrystalPoint::update() if (!worldhandler->isPlayerPositionValid()) player->position = oldPosition; - /*else if (player->position.y > oldPosition.y + 1.2) - player->position = oldPosition; - */ worldhandler->update(deltaTime); } else diff --git a/Main.cpp b/Main.cpp index 4ac85b1..e9abf25 100644 --- a/Main.cpp +++ b/Main.cpp @@ -80,7 +80,7 @@ void configureOpenGL() { //Init window and glut display mode glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); - glutInitWindowSize(800, 600); + glutInitWindowSize(1440, 900); //glutInitWindowPosition(glutGet(GLUT_WINDOW_WIDTH) / 2 - 800/2, glutGet(GLUT_WINDOW_HEIGHT) / 2 - 600/2); glutCreateWindow("Crystal Point"); //glutFullScreen(); diff --git a/Player.cpp b/Player.cpp index 54888ad..83559ed 100644 --- a/Player.cpp +++ b/Player.cpp @@ -150,6 +150,7 @@ void Player::loadWeapons() std::string name = w["name"].asString(); std::string fileN = w["file"].asString(); float damage = w["damage"].asFloat(); + float scale = w["scale"].asFloat(); Weapon::Element e = Weapon::FIRE; @@ -174,8 +175,8 @@ void Player::loadWeapons() Vec2f maxRot = Vec2f(w["maxRotation"][0].asFloat(), w["maxRotation"][1].asFloat()); Vec2f minRot = Vec2f(w["minRotation"][0].asFloat(), w["minRotation"][1].asFloat()); - lweapon = new Weapon(name, damage, e, fileN, 1, position, rotation, leftoffset, anchor, maxRot, minRot, collision); - rweapon = new Weapon(name, damage, e, fileN, 1, position, rotation, rightoffset, anchor, maxRot, minRot, collision); + lweapon = new Weapon(name, damage, e, fileN, scale, position, rotation, leftoffset, anchor, maxRot, minRot, collision); + rweapon = new Weapon(name, damage, e, fileN, scale, position, rotation, rightoffset, anchor, maxRot, minRot, collision); leftweapons.push_back(lweapon); rightweapons.push_back(rweapon); @@ -191,6 +192,8 @@ void Player::PreviousRightWeapon() currentrightweapon = (rightweapons.size() > level ? level - 1 : rightweapons.size() - 1); rightWeapon = rightweapons[currentrightweapon]; + rightWeapon->move(position); + rightWeapon->rotate(rotation); } void Player::NextRightWeapon(void) { @@ -200,6 +203,8 @@ void Player::NextRightWeapon(void) currentrightweapon = 0; rightWeapon = rightweapons[currentrightweapon]; + rightWeapon->move(position); + rightWeapon->rotate(rotation); } void Player::PreviousLeftWeapon(void) { @@ -209,6 +214,8 @@ void Player::PreviousLeftWeapon(void) currentleftweapon = (leftweapons.size() > level ? level - 1 : leftweapons.size() - 1); leftWeapon = leftweapons[currentleftweapon]; + leftWeapon->move(position); + leftWeapon->rotate(rotation); } void Player::NextLeftWeapon(void) { @@ -218,4 +225,6 @@ void Player::NextLeftWeapon(void) currentleftweapon = 0; leftWeapon = leftweapons[currentleftweapon]; + leftWeapon->move(position); + leftWeapon->rotate(rotation); } \ No newline at end of file diff --git a/Weapon.cpp b/Weapon.cpp index 76882a0..5c78e92 100644 --- a/Weapon.cpp +++ b/Weapon.cpp @@ -29,7 +29,6 @@ Weapon::Weapon(std::string name, int damage, Element e, std::string modelFilenam this->minRotation = minRotation; this->collisionPoint = collisionPoint; - this->damage = 1; }; Weapon::~Weapon(){ @@ -75,6 +74,7 @@ void Weapon::draw(){ { glPushMatrix(); + //Player position and rotation glTranslatef(position.x, position.y, position.z); glRotatef(rotation.x, 1, 0, 0); @@ -84,13 +84,23 @@ void Weapon::draw(){ //offset from player glTranslatef(offsetPlayer.x, offsetPlayer.y, offsetPlayer.z); + glScalef(scale, scale, scale); + //Rotate weapon itself, from specific anker point glTranslatef(ankerPoint.x, ankerPoint.y, ankerPoint.z); glRotatef(rotationWeapon.z, 0, 0, 1); glRotatef(rotationWeapon.y, 0, 1, 0); glRotatef(rotationWeapon.x, 1, 0, 0); - glTranslatef(-ankerPoint.x, -ankerPoint.y, -ankerPoint.z); +/* + glColor3ub(255, 255, 0); + glBegin(GL_LINES); + glVertex2f(0, 4); + glVertex2f(0, -4); + glVertex2f(4, 0); + glVertex2f(-4, 0); + glEnd();*/ + glTranslatef(-ankerPoint.x, -ankerPoint.y, -ankerPoint.z); weaponmodel->draw(); @@ -103,21 +113,11 @@ void Weapon::draw(){ Vec3f point = multiply(matrix, Vec3f(1,1,1)); - glScalef(scale, scale, scale); - - glPopMatrix(); glPushMatrix(); - glTranslatef(point.x, point.y, point.z); - glColor3ub(255, 255, 0); - glBegin(GL_LINES); - glVertex2f(0, 4); - glVertex2f(0, -4); - glVertex2f(4, 0); - glVertex2f(-4, 0); - glEnd(); + glPopMatrix(); } diff --git a/World.cpp b/World.cpp index d992820..172ed4d 100644 --- a/World.cpp +++ b/World.cpp @@ -249,6 +249,7 @@ float World::getHeight(float x, float y) void World::draw() { + player->setCamera(); float lightPosition[4] = { 0, 2, 1, 0 }; glLightfv(GL_LIGHT0, GL_POSITION, lightPosition); @@ -260,7 +261,6 @@ void World::draw() skybox->draw(); - player->setCamera(); player->draw(); heightmap->Draw(); diff --git a/weapons.json b/weapons.json index 77177a9..264dd33 100644 --- a/weapons.json +++ b/weapons.json @@ -10,12 +10,13 @@ "collision": [ 0, 0, 0 ], "maxRotation": [ 170, 70 ], "minRotation": [ 20, -80 ], + "scale": 0.3, "left": { - "offset": [ 4.5, -8, -1 ] + "offset": [ 1.5, -2.6, 0 ] }, "right": { - "offset": [ 0.5, -8, -1 ] + "offset": [ -0.1, -2.6, 0 ] } }, { @@ -28,12 +29,13 @@ "collision": [ 0, 0, 0 ], "maxRotation": [ 170, 70 ], "minRotation": [ 20, -80 ], + "scale": 0.3, "left": { - "offset": [ 4.5, -8, -1 ] + "offset": [ 1.5, -2.6, 0 ] }, "right": { - "offset": [ 0.5, -8, -1 ] + "offset": [ -0.1, -2.6, 0 ] } } ] diff --git a/worlds/small.json b/worlds/small.json index 3bcbb48..62d5ddf 100644 --- a/worlds/small.json +++ b/worlds/small.json @@ -12,7 +12,7 @@ "music": "WAVE/world1.wav" }, "player": { - "startposition": [ 20, 0, 20 ] + "startposition": [ -10, -10, -10 ] }, "objects": [ ], "portal": {