diff --git a/CrystalPoint.vcxproj b/CrystalPoint.vcxproj index a14f55a..65167a2 100644 --- a/CrystalPoint.vcxproj +++ b/CrystalPoint.vcxproj @@ -165,6 +165,7 @@ + @@ -186,6 +187,7 @@ + diff --git a/CrystalPoint.vcxproj.filters b/CrystalPoint.vcxproj.filters index df8bece..b76db86 100644 --- a/CrystalPoint.vcxproj.filters +++ b/CrystalPoint.vcxproj.filters @@ -79,10 +79,13 @@ Source Files - Source Files + Source Files - Source Files + Source Files + + + Source Files @@ -138,7 +141,7 @@ Header Files - Header Files + Header Files Header Files @@ -146,6 +149,9 @@ Header Files + + Header Files + diff --git a/Main.cpp b/Main.cpp index 2660258..53ea361 100644 --- a/Main.cpp +++ b/Main.cpp @@ -64,7 +64,8 @@ void configureOpenGL() //Init window and glut display mode glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); glutInitWindowSize(800, 600); - glutCreateWindow("Crystal Point"); + //glutInitWindowPosition(glutGet(GLUT_WINDOW_WIDTH) / 2 - 800/2, glutGet(GLUT_WINDOW_HEIGHT) / 2 - 600/2); + glutCreateWindow("Crystal Point"); glutFullScreen(); //Depth testing diff --git a/Portal.cpp b/Portal.cpp new file mode 100644 index 0000000..3f689fe --- /dev/null +++ b/Portal.cpp @@ -0,0 +1,34 @@ +#include "Portal.h" +#include "Model.h" +#include +#include "Player.h" +#include "WorldHandler.h" + +Portal::Portal(const std::string &fileName, + const Vec3f &position, + Vec3f &rotation, + const float &scale) +{ + model = Model::load(fileName); + this->position = position; + this->rotation = rotation; + this->scale = scale; + this->canCollide = true; + + mayEnter = false; + maxCrystals = 0; +} + + +Portal::~Portal() +{ +} + +void Portal::collide() +{ + if (maxCrystals == (Player::getInstance()->crystals) && !mayEnter) + { + canCollide = false; + mayEnter = true; + } +} diff --git a/Portal.h b/Portal.h new file mode 100644 index 0000000..5f5c330 --- /dev/null +++ b/Portal.h @@ -0,0 +1,19 @@ +#pragma once +#include "Entity.h" +#include + +class Portal : + public Entity +{ +public: + Portal(const std::string &fileName, + const Vec3f &position, + Vec3f &rotation, + const float &scale); + ~Portal(); + + void collide(); + int maxCrystals; + bool mayEnter; +}; + diff --git a/World.cpp b/World.cpp index 3db2f3d..a89cc56 100644 --- a/World.cpp +++ b/World.cpp @@ -181,6 +181,30 @@ World::World(const std::string &fileName): music->Play(); } + if (!v["portal"].isNull()) + { + Vec3f pos(0, 0, 0); + if (!v["portal"]["pos"].isNull()) + pos = Vec3f(v["portal"]["pos"][0].asFloat(), + v["portal"]["pos"][1].asFloat(), + v["portal"]["pos"][0].asFloat()); + + pos.y = getHeight(pos.x, pos.z); + + Vec3f rot(0, 0, 0); + if (!v["portal"]["rot"].isNull()) + pos = Vec3f(v["portal"]["rot"][0].asFloat(), + v["portal"]["rot"][1].asFloat(), + v["portal"]["rot"][0].asFloat()); + + float scale = 1.0f; + if (!v["portal"]["scale"].isNull()) + scale = !v["portal"]["scale"].asFloat(); + + portal = new Portal(v["portal"]["file"], pos, rot, scale); + entities.push_back(portal); + portal->maxCrystals = maxCrystals; + } } @@ -256,6 +280,9 @@ void World::update(float elapsedTime) } enemy->position.y = getHeight(enemy->position.x, enemy->position.z) + 2.0f; } + + if (portal->mayEnter) + WorldHandler::getInstance()->NextWorld(); } void World::addLevelObject(LevelObject* obj) diff --git a/World.h b/World.h index 17d362a..06df243 100644 --- a/World.h +++ b/World.h @@ -8,6 +8,7 @@ #include "Interface.h" #include "Crystal.h" #include "Skybox.h" +#include "Portal.h" class Entity; @@ -20,6 +21,7 @@ private: HeightMap* heightmap; Interface* interface; Skybox* skybox; + Portal* portal; int music_id,maxCrystals; diff --git a/worlds/ice.json b/worlds/ice.json index 201b269..fec0051 100644 --- a/worlds/ice.json +++ b/worlds/ice.json @@ -1,33 +1,43 @@ { - "world": { + "world": { "heightmap": "worlds/hmcs.png", - "texture": "worlds/hmcstexture.png", + "texture": "hmcstexture.png", + "skybox": "skyboxes/peaceful/", "object-templates": [ - { - "color":100, - "file": "models/boom/Boom.obj", - "collision": false - } - ] - }, + { + "color": 100, + "file": "models/boom/Boom.obj", + "collision": true + } + ], + "music": "WAVE/bond.wav" + }, "player": { - "startposition": [ 0, 1.7, 0] + "startposition": [ 1, 5, 20 ] + }, + "objects": [ ], + "portal": { + "file": "models/Teleporter/Teleporter.obj", + "pos": [ 10, 5, 10 ] }, - "objects": [ - { - "file": "models/boom/Boom.obj", - "pos": [ 10, 0, -4 ] - }, - { - "file": "models/Teleporter/Teleporter.obj", - "pos": [ 0, 0, -4 ] - } - ], "enemies": [ - { + { "file": "models/squid/Blooper.obj", - "pos": [ 10, 2, -10 ], + "pos": [ 20, 5, 10 ], "scale": 0.01 - } - ] + }], + "crystal": { + "full texture": "models/crystal/Crystal.obj", + "empty texture": "models/crystal/PickedUpCrystal.obj", + "instances": [ + { + "pos": [ 31, 5, 33 ], + "rot": [ 0, 0, 0 ] + }, + { + "pos": [ 40, 5, 40 ], + "rot": [ 0, 0, 0 ] + } + ] + } } \ No newline at end of file diff --git a/worlds/small.json b/worlds/small.json index 826848b..6566982 100644 --- a/worlds/small.json +++ b/worlds/small.json @@ -14,12 +14,11 @@ "player": { "startposition": [ 20, 5, 20 ] }, - "objects": [ - { - "file": "models/Teleporter/Teleporter.obj", - "pos": [ 10, 5, 10 ] - } - ], + "objects": [ ], + "portal": { + "file": "models/Teleporter/Teleporter.obj", + "pos": [ 10, 5, 10 ] + }, "enemies": [ { "file": "models/squid/Blooper.obj",