Merge branch 'developer' into feature/Menu
This commit is contained in:
+4
-3
@@ -10,6 +10,7 @@ add_executable(CrystalPoint ${SOURCE_FILES})
|
||||
|
||||
find_package(OpenGL REQUIRED)
|
||||
find_package(GLUT REQUIRED)
|
||||
include_directories( ${OPENGL_INCLUDE_DIRS} ${GLUT_INCLUDE_DIRS} )
|
||||
target_link_libraries(CrystalPoint ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} )
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall ")
|
||||
find_package(OpenAL REQUIRED)
|
||||
include_directories( ${OPENGL_INCLUDE_DIRS} ${GLUT_INCLUDE_DIRS} ${OPENAL_INCLUDE_DIRS} )
|
||||
target_link_libraries(CrystalPoint ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${OPENAL_LIBRARY} )
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -lpthread")
|
||||
@@ -211,12 +211,14 @@
|
||||
<ItemGroup>
|
||||
<None Include="worlds\fire.json" />
|
||||
<None Include="worlds\ice.json" />
|
||||
<None Include="worlds\rock.json" />
|
||||
<None Include="worlds\small.json" />
|
||||
<None Include="worlds\worlds.json" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Media Include="WAVE\bond.wav" />
|
||||
<Media Include="WAVE\Sound.wav" />
|
||||
<Media Include="WAVE\enemy.wav" />
|
||||
<Media Include="WAVE\test1.wav" />
|
||||
<Media Include="WAVE\test2.wav" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
||||
@@ -195,12 +195,18 @@
|
||||
<None Include="worlds\small.json">
|
||||
<Filter>Source Files\json</Filter>
|
||||
</None>
|
||||
<None Include="worlds\rock.json">
|
||||
<Filter>Source Files\json</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Media Include="WAVE\Sound.wav">
|
||||
<Media Include="WAVE\test1.wav">
|
||||
<Filter>Resource Files</Filter>
|
||||
</Media>
|
||||
<Media Include="WAVE\bond.wav">
|
||||
<Media Include="WAVE\test2.wav">
|
||||
<Filter>Resource Files</Filter>
|
||||
</Media>
|
||||
<Media Include="WAVE\enemy.wav">
|
||||
<Filter>Resource Files</Filter>
|
||||
</Media>
|
||||
</ItemGroup>
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#include "Cursor.h"
|
||||
#include <GL\freeglut.h>
|
||||
#include <GL/freeglut.h>
|
||||
#include <cmath>
|
||||
#include "CrystalPoint.h"
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#include <cmath>
|
||||
#include "Enemy.h"
|
||||
#include "Model.h"
|
||||
#include "CrystalPoint.h"
|
||||
#include <iostream>
|
||||
|
||||
Enemy::Enemy(const std::string &fileName,
|
||||
@@ -19,7 +18,8 @@ Enemy::Enemy(const std::string &fileName,
|
||||
speed = 1;
|
||||
radius = 10;
|
||||
hasTarget = false;
|
||||
hit_sound_id = CrystalPoint::GetSoundSystem().LoadSound("WAVE/Sound.wav", false);
|
||||
hit_sound_id = CrystalPoint::GetSoundSystem().LoadSound("WAVE/enemy.wav", false);
|
||||
music = CrystalPoint::GetSoundSystem().GetSound(hit_sound_id);
|
||||
attack = false;
|
||||
}
|
||||
|
||||
@@ -72,9 +72,14 @@ void Enemy::collide(const Entity * entity)
|
||||
|
||||
void Enemy::update(float delta)
|
||||
{
|
||||
music->SetPos(position, Vec3f());
|
||||
|
||||
if (hasTarget)
|
||||
{
|
||||
|
||||
if (music->IsPlaying() == false)
|
||||
{
|
||||
music->Play();
|
||||
}
|
||||
//just 2d walking
|
||||
float dx, dz, length;
|
||||
|
||||
@@ -98,15 +103,14 @@ void Enemy::update(float delta)
|
||||
else
|
||||
{
|
||||
attack = true;
|
||||
if (music->IsPlaying() == true)
|
||||
{
|
||||
// music->Pause();
|
||||
music->Stop();
|
||||
}
|
||||
}
|
||||
|
||||
rotation.y = atan2f(dx, dz) * 180 / M_PI;
|
||||
}
|
||||
|
||||
if (false)
|
||||
{
|
||||
Sound* sound = CrystalPoint::GetSoundSystem().GetSound(hit_sound_id);
|
||||
sound->SetPos(position, Vec3f());
|
||||
sound->Play();
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "Entity.h"
|
||||
#include <string>
|
||||
#include "Vector.h"
|
||||
#include "CrystalPoint.h"
|
||||
|
||||
class Enemy : public Entity
|
||||
{
|
||||
@@ -10,6 +11,8 @@ public:
|
||||
Enemy(const std::string &fileName,const Vec3f &position,Vec3f &rotation,const float &scale);
|
||||
~Enemy();
|
||||
|
||||
Sound* music;
|
||||
|
||||
bool hasTarget;
|
||||
Vec3f target;
|
||||
float speed,radius;
|
||||
|
||||
+2
-1
@@ -1,6 +1,6 @@
|
||||
#include "HeightMap.h"
|
||||
#include "stb_image.h"
|
||||
#include "vector.h"
|
||||
#include "Vector.h"
|
||||
|
||||
#include "LevelObject.h"
|
||||
|
||||
@@ -127,6 +127,7 @@ float HeightMap::GetHeight(float x, float y)
|
||||
float labda3 = 1 - labda1 - labda2;
|
||||
|
||||
Vertex z = a * labda1 + b * labda2 + c * labda3;
|
||||
// Vertex z = (a * labda1) + (b * labda2) ;
|
||||
|
||||
return z.y;
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#include "Interface.h"
|
||||
#include <GL\freeglut.h>
|
||||
#include <GL/freeglut.h>
|
||||
#include "CrystalPoint.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
@@ -137,7 +137,7 @@ Model::Model(std::string fileName)
|
||||
radius = fmax(radius, (center.x - v.x) * (center.x - v.x) + (center.z - v.z) * (center.z - v.z));
|
||||
radius = sqrt(radius);
|
||||
|
||||
for each(ObjGroup *group in groups)
|
||||
for (ObjGroup *group : groups)
|
||||
{
|
||||
Optimise(group);
|
||||
}
|
||||
@@ -147,7 +147,7 @@ void Model::Optimise(ObjGroup *t)
|
||||
{
|
||||
for (Face &face : t->faces)
|
||||
{
|
||||
for each(auto &vertex in face.vertices)
|
||||
for (auto &vertex : face.vertices)
|
||||
{
|
||||
t->VertexArray.push_back(Vertex(vertices[vertex.position].x, vertices[vertex.position].y, vertices[vertex.position].z,
|
||||
normals[vertex.normal].x, normals[vertex.normal].y, normals[vertex.normal].z,
|
||||
|
||||
@@ -1,14 +1,22 @@
|
||||
#include "Sound.h"
|
||||
|
||||
#include <iostream>
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#include <al.h>
|
||||
#else
|
||||
#include <AL/al.h>
|
||||
typedef unsigned long DWORD;
|
||||
typedef unsigned short WORD;
|
||||
typedef unsigned int UNINT32;
|
||||
typedef unsigned char BYTE;
|
||||
#endif
|
||||
|
||||
|
||||
Sound::Sound(const char* inWavPath, bool inLooping):
|
||||
buffer_id(0),
|
||||
source_id(0),
|
||||
is_looping(inLooping)
|
||||
|
||||
{
|
||||
const char* path = inWavPath;
|
||||
|
||||
@@ -137,3 +145,12 @@ void Sound::Stop()
|
||||
alSourceStop(source_id);
|
||||
}
|
||||
|
||||
bool Sound::IsPlaying()
|
||||
{
|
||||
ALenum state;
|
||||
|
||||
alGetSourcei(source_id, AL_SOURCE_STATE, &state);
|
||||
|
||||
return (state == AL_PLAYING);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "vector.h"
|
||||
#include "Vector.h"
|
||||
|
||||
class Sound
|
||||
{
|
||||
@@ -13,6 +13,7 @@ public:
|
||||
void Play();
|
||||
void Pause();
|
||||
void Stop();
|
||||
bool IsPlaying();
|
||||
|
||||
private:
|
||||
unsigned int buffer_id;
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
#include "SoundSystem.h"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
|
||||
SoundSystem::SoundSystem():
|
||||
device(nullptr),
|
||||
context(nullptr)
|
||||
|
||||
+8
-1
@@ -1,9 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <al.h>
|
||||
#include <alc.h>
|
||||
#include "vector.h"
|
||||
#else
|
||||
#include <AL/al.h>
|
||||
#include <AL/alc.h>
|
||||
#endif
|
||||
|
||||
#include "Vector.h"
|
||||
#include "Sound.h"
|
||||
|
||||
|
||||
|
||||
+4
-4
@@ -18,22 +18,22 @@ Vertex::~Vertex()
|
||||
{
|
||||
}
|
||||
|
||||
Vertex Vertex::operator/(float &other)
|
||||
Vertex Vertex::operator/(const float &other) const
|
||||
{
|
||||
return Vertex(x / other, y / other, z / other, normalX, normalY, normalZ, texX, texY);
|
||||
}
|
||||
|
||||
Vertex Vertex::operator*(Vertex & other)
|
||||
Vertex Vertex::operator*(const Vertex & other) const
|
||||
{
|
||||
return Vertex(x*other.x, y*other.y, z*other.z, normalX, normalY, normalZ, texX, texY);
|
||||
}
|
||||
|
||||
Vertex Vertex::operator*(float & other)
|
||||
Vertex Vertex::operator*(const float & other) const
|
||||
{
|
||||
return Vertex(x*other, y*other, z*other, normalX, normalY, normalZ, texX, texY);
|
||||
}
|
||||
|
||||
Vertex Vertex::operator+(Vertex & other)
|
||||
Vertex Vertex::operator+(const Vertex & other) const
|
||||
{
|
||||
return Vertex(x+other.x, y+other.y, z+other.z, normalX, normalY, normalZ, texX, texY);
|
||||
}
|
||||
|
||||
@@ -16,9 +16,9 @@ public:
|
||||
float texX;
|
||||
float texY;
|
||||
|
||||
Vertex operator/(float &other);
|
||||
Vertex operator*(Vertex &other);
|
||||
Vertex operator*(float &other);
|
||||
Vertex operator+(Vertex &other);
|
||||
Vertex operator/(const float &other) const;
|
||||
Vertex operator*(const Vertex &other) const;
|
||||
Vertex operator*(const float &other) const;
|
||||
Vertex operator+(const Vertex &other) const;
|
||||
};
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -3,7 +3,6 @@
|
||||
#include "Entity.h"
|
||||
#include "json.h"
|
||||
#include "Model.h"
|
||||
#include "CrystalPoint.h"
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
@@ -179,9 +178,7 @@ World::World(const std::string &fileName):
|
||||
if (!v["world"]["music"].isNull())
|
||||
{
|
||||
music_id = CrystalPoint::GetSoundSystem().LoadSound(v["world"]["music"].asString().c_str(), true);
|
||||
Sound* music = CrystalPoint::GetSoundSystem().GetSound(music_id);
|
||||
music->SetPos(Vec3f(), Vec3f());
|
||||
music->Play();
|
||||
music = CrystalPoint::GetSoundSystem().GetSound(music_id);
|
||||
}
|
||||
|
||||
if (!v["portal"].isNull())
|
||||
@@ -214,6 +211,8 @@ World::World(const std::string &fileName):
|
||||
World::~World()
|
||||
{
|
||||
delete heightmap;
|
||||
music->Stop();
|
||||
delete music;
|
||||
delete skybox;
|
||||
delete portal;
|
||||
}
|
||||
@@ -258,6 +257,12 @@ void World::draw()
|
||||
|
||||
void World::update(float elapsedTime)
|
||||
{
|
||||
music->SetPos(player->position, Vec3f());
|
||||
|
||||
if (music->IsPlaying() == false)
|
||||
{
|
||||
music->Play();
|
||||
}
|
||||
for (auto &entity : entities)
|
||||
entity->update(elapsedTime);
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "Interface.h"
|
||||
#include "Crystal.h"
|
||||
#include "Skybox.h"
|
||||
#include "CrystalPoint.h"
|
||||
#include "Portal.h"
|
||||
|
||||
class Entity;
|
||||
@@ -16,6 +17,7 @@ class World
|
||||
{
|
||||
private:
|
||||
std::vector<std::pair<int, std::pair<std::string, bool>>> objecttemplates;
|
||||
Sound* music;
|
||||
|
||||
Player* player;
|
||||
HeightMap* heightmap;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
"heightmap": "worlds/rockHeightmap.png",
|
||||
"texture": "worlds/rockStone2.png",
|
||||
"skybox": "skyboxes/water/",
|
||||
"music": "WAVE/test2.wav",
|
||||
"object-templates": [
|
||||
{
|
||||
"color": 50,
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@
|
||||
"collision": true
|
||||
}
|
||||
],
|
||||
"music": "WAVE/bond.wav"
|
||||
"music": "WAVE/test1.wav"
|
||||
},
|
||||
"player": {
|
||||
"startposition": [ 20, 5, 20 ]
|
||||
|
||||
Reference in New Issue
Block a user