when collected all crystals it is possible to move to the next level, by stepping in the portal
This commit is contained in:
@@ -165,6 +165,7 @@
|
|||||||
<ClCompile Include="LevelObject.cpp" />
|
<ClCompile Include="LevelObject.cpp" />
|
||||||
<ClCompile Include="Main.cpp" />
|
<ClCompile Include="Main.cpp" />
|
||||||
<ClCompile Include="Model.cpp" />
|
<ClCompile Include="Model.cpp" />
|
||||||
|
<ClCompile Include="Portal.cpp" />
|
||||||
<ClCompile Include="Sound.cpp" />
|
<ClCompile Include="Sound.cpp" />
|
||||||
<ClCompile Include="SoundSystem.cpp" />
|
<ClCompile Include="SoundSystem.cpp" />
|
||||||
<ClCompile Include="Player.cpp" />
|
<ClCompile Include="Player.cpp" />
|
||||||
@@ -186,6 +187,7 @@
|
|||||||
<ClInclude Include="LevelObject.h" />
|
<ClInclude Include="LevelObject.h" />
|
||||||
<ClInclude Include="Main.h" />
|
<ClInclude Include="Main.h" />
|
||||||
<ClInclude Include="Model.h" />
|
<ClInclude Include="Model.h" />
|
||||||
|
<ClInclude Include="Portal.h" />
|
||||||
<ClInclude Include="Sound.h" />
|
<ClInclude Include="Sound.h" />
|
||||||
<ClInclude Include="SoundSystem.h" />
|
<ClInclude Include="SoundSystem.h" />
|
||||||
<ClInclude Include="Player.h" />
|
<ClInclude Include="Player.h" />
|
||||||
|
|||||||
@@ -79,10 +79,13 @@
|
|||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="Sound.cpp">
|
<ClCompile Include="Sound.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="Crystal.cpp">
|
<ClCompile Include="Crystal.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Portal.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -138,7 +141,7 @@
|
|||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="Sound.h">
|
<ClInclude Include="Sound.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="Crystal.h">
|
<ClInclude Include="Crystal.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
@@ -146,6 +149,9 @@
|
|||||||
<ClInclude Include="Skybox.h">
|
<ClInclude Include="Skybox.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="Portal.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="worlds\worlds.json">
|
<None Include="worlds\worlds.json">
|
||||||
|
|||||||
@@ -64,7 +64,8 @@ void configureOpenGL()
|
|||||||
//Init window and glut display mode
|
//Init window and glut display mode
|
||||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||||
glutInitWindowSize(800, 600);
|
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();
|
glutFullScreen();
|
||||||
|
|
||||||
//Depth testing
|
//Depth testing
|
||||||
|
|||||||
+34
@@ -0,0 +1,34 @@
|
|||||||
|
#include "Portal.h"
|
||||||
|
#include "Model.h"
|
||||||
|
#include <iostream>
|
||||||
|
#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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Entity.h"
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
|
||||||
@@ -181,6 +181,30 @@ World::World(const std::string &fileName):
|
|||||||
music->Play();
|
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;
|
enemy->position.y = getHeight(enemy->position.x, enemy->position.z) + 2.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (portal->mayEnter)
|
||||||
|
WorldHandler::getInstance()->NextWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::addLevelObject(LevelObject* obj)
|
void World::addLevelObject(LevelObject* obj)
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include "Interface.h"
|
#include "Interface.h"
|
||||||
#include "Crystal.h"
|
#include "Crystal.h"
|
||||||
#include "Skybox.h"
|
#include "Skybox.h"
|
||||||
|
#include "Portal.h"
|
||||||
|
|
||||||
class Entity;
|
class Entity;
|
||||||
|
|
||||||
@@ -20,6 +21,7 @@ private:
|
|||||||
HeightMap* heightmap;
|
HeightMap* heightmap;
|
||||||
Interface* interface;
|
Interface* interface;
|
||||||
Skybox* skybox;
|
Skybox* skybox;
|
||||||
|
Portal* portal;
|
||||||
|
|
||||||
int music_id,maxCrystals;
|
int music_id,maxCrystals;
|
||||||
|
|
||||||
|
|||||||
+34
-24
@@ -1,33 +1,43 @@
|
|||||||
{
|
{
|
||||||
"world": {
|
"world": {
|
||||||
"heightmap": "worlds/hmcs.png",
|
"heightmap": "worlds/hmcs.png",
|
||||||
"texture": "worlds/hmcstexture.png",
|
"texture": "hmcstexture.png",
|
||||||
|
"skybox": "skyboxes/peaceful/",
|
||||||
"object-templates": [
|
"object-templates": [
|
||||||
{
|
{
|
||||||
"color":100,
|
"color": 100,
|
||||||
"file": "models/boom/Boom.obj",
|
"file": "models/boom/Boom.obj",
|
||||||
"collision": false
|
"collision": true
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
},
|
"music": "WAVE/bond.wav"
|
||||||
|
},
|
||||||
"player": {
|
"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": [
|
"enemies": [
|
||||||
{
|
{
|
||||||
"file": "models/squid/Blooper.obj",
|
"file": "models/squid/Blooper.obj",
|
||||||
"pos": [ 10, 2, -10 ],
|
"pos": [ 20, 5, 10 ],
|
||||||
"scale": 0.01
|
"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 ]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+5
-6
@@ -14,12 +14,11 @@
|
|||||||
"player": {
|
"player": {
|
||||||
"startposition": [ 20, 5, 20 ]
|
"startposition": [ 20, 5, 20 ]
|
||||||
},
|
},
|
||||||
"objects": [
|
"objects": [ ],
|
||||||
{
|
"portal": {
|
||||||
"file": "models/Teleporter/Teleporter.obj",
|
"file": "models/Teleporter/Teleporter.obj",
|
||||||
"pos": [ 10, 5, 10 ]
|
"pos": [ 10, 5, 10 ]
|
||||||
}
|
},
|
||||||
],
|
|
||||||
"enemies": [
|
"enemies": [
|
||||||
{
|
{
|
||||||
"file": "models/squid/Blooper.obj",
|
"file": "models/squid/Blooper.obj",
|
||||||
|
|||||||
Reference in New Issue
Block a user