Johan is love, Johan is life

This commit is contained in:
2016-05-19 14:25:03 +02:00
parent a38a6d3c5f
commit 7c4ee37867
82 changed files with 550 additions and 1250 deletions
-235
View File
@@ -1,235 +0,0 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# DNX
project.lock.json
artifacts/
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# NuGet v3's project.json files produces more ignoreable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Microsoft Azure ApplicationInsights config file
ApplicationInsights.config
# Windows Store app package directory
AppPackages/
BundleArtifacts/
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.pfx
*.publishsettings
node_modules/
orleans.codegen.cs
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
# FAKE - F# Make
.fake/
Binary file not shown.
-12
View File
@@ -1,12 +0,0 @@
#include "Controller.h"
Controller::Controller()
{
}
Controller::~Controller()
{
}
-10
View File
@@ -1,10 +0,0 @@
#pragma once
#include "Header.h"
class Controller
{
public:
Controller();
~Controller();
};
+62
View File
@@ -0,0 +1,62 @@
#include "CrystalJohan.h"
#include <GL/freeglut.h>
#include "World.h"
void CrystalJohan::init()
{
world = new World();
lastFrameTime = 0;
glClearColor(0.7, 0.7, 1.0, 1.0);
glEnable(GL_DEPTH_TEST);
}
void CrystalJohan::draw()
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(70, width / (float)height, 0.1f, 100);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
world->draw();
}
void CrystalJohan::update()
{
float frameTime = glutGet(GLUT_ELAPSED_TIME) / 1000.0f;
float deltaTime = frameTime - lastFrameTime;
lastFrameTime = frameTime;
// if(keyboardState.special[GLUT_KEY_LEFT] && !prevKeyboardState.special[GLUT_KEY_LEFT])
if (keyboardState.keys[27])
exit(0);
world->player.rotation.y += mouseOffset.x/10.0f;
world->player.rotation.x += mouseOffset.y/10.0f;
if (world->player.rotation.x > 90)
world->player.rotation.x = 90;
if (world->player.rotation.x < -90)
world->player.rotation.x = -90;
mouseOffset = Vec2f(0, 0);
prevKeyboardState = keyboardState;
glutPostRedisplay();
}
KeyboardState::KeyboardState()
{
memset(keys, 0, sizeof(keys));
memset(special, 0, sizeof(special));
}
+33
View File
@@ -0,0 +1,33 @@
#pragma once
class World;
#include "vector.h"
class KeyboardState
{
public:
bool keys[256];
bool special[256];
bool control, shift, alt;
KeyboardState();
};
class CrystalJohan
{
public:
void init();
void draw();
void update();
World* world;
int width, height;
KeyboardState keyboardState;
KeyboardState prevKeyboardState;
Vec2f mouseOffset;
float lastFrameTime;
};
BIN
View File
Binary file not shown.
+28
View File
@@ -0,0 +1,28 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.24720.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CrystalJohan", "CrystalJohan.vcxproj", "{98776A7C-CD7A-4C62-946A-2263C27E9690}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{98776A7C-CD7A-4C62-946A-2263C27E9690}.Debug|x64.ActiveCfg = Debug|x64
{98776A7C-CD7A-4C62-946A-2263C27E9690}.Debug|x64.Build.0 = Debug|x64
{98776A7C-CD7A-4C62-946A-2263C27E9690}.Debug|x86.ActiveCfg = Debug|Win32
{98776A7C-CD7A-4C62-946A-2263C27E9690}.Debug|x86.Build.0 = Debug|Win32
{98776A7C-CD7A-4C62-946A-2263C27E9690}.Release|x64.ActiveCfg = Release|x64
{98776A7C-CD7A-4C62-946A-2263C27E9690}.Release|x64.Build.0 = Release|x64
{98776A7C-CD7A-4C62-946A-2263C27E9690}.Release|x86.ActiveCfg = Release|Win32
{98776A7C-CD7A-4C62-946A-2263C27E9690}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
+28 -44
View File
@@ -19,11 +19,10 @@
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{4986BEC0-4362-46E4-A18D-65587FA97967}</ProjectGuid>
<ProjectGuid>{98776A7C-CD7A-4C62-946A-2263C27E9690}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>CrystalPoint</RootNamespace>
<RootNamespace>CrystalJohan</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
<ProjectName>CrystalPoint</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
@@ -84,11 +83,11 @@
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeaderFile />
<AdditionalIncludeDirectories>freeglut/include</AdditionalIncludeDirectories>
</ClCompile>
<Link>
@@ -99,11 +98,11 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeaderFile />
<AdditionalIncludeDirectories>freeglut/include</AdditionalIncludeDirectories>
</ClCompile>
<Link>
@@ -115,12 +114,12 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeaderFile />
<AdditionalIncludeDirectories>freeglut/include</AdditionalIncludeDirectories>
</ClCompile>
<Link>
@@ -134,12 +133,12 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeaderFile />
<AdditionalIncludeDirectories>freeglut/include</AdditionalIncludeDirectories>
</ClCompile>
<Link>
@@ -151,46 +150,31 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="Controller.h" />
<ClInclude Include="Enemy.h" />
<ClInclude Include="Header.h" />
<ClInclude Include="InitState.h" />
<ClInclude Include="Keyboard.h" />
<ClInclude Include="LoadingState.h" />
<ClInclude Include="MenuState.h" />
<ClInclude Include="Model.h" />
<ClInclude Include="ModelHandler.h" />
<ClInclude Include="ModelInstance.h" />
<ClInclude Include="Mouse.h" />
<ClInclude Include="Player.h" />
<ClInclude Include="SettingsState.h" />
<ClInclude Include="State.h" />
<ClInclude Include="StateHandler.h" />
<ClInclude Include="Vector.h" />
<ClInclude Include="Weapon.h" />
<ClInclude Include="WorldModel.h" />
<ClInclude Include="WorldState.h" />
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="Controller.cpp" />
<ClCompile Include="CrystalJohan.cpp" />
<ClCompile Include="Enemy.cpp" />
<ClCompile Include="InitState.cpp" />
<ClCompile Include="Keyboard.cpp" />
<ClCompile Include="LoadingState.cpp" />
<ClCompile Include="Entity.cpp" />
<ClCompile Include="LevelObject.cpp" />
<ClCompile Include="Main.cpp" />
<ClCompile Include="MenuState.cpp" />
<ClCompile Include="Model.cpp" />
<ClCompile Include="ModelHandler.cpp" />
<ClCompile Include="ModelInstance.cpp" />
<ClCompile Include="Mouse.cpp" />
<ClCompile Include="Player.cpp" />
<ClCompile Include="SettingsState.cpp" />
<ClCompile Include="State.cpp" />
<ClCompile Include="StateHandler.cpp" />
<ClCompile Include="Vector.cpp" />
<ClCompile Include="Weapon.cpp" />
<ClCompile Include="WorldModel.cpp" />
<ClCompile Include="WorldState.cpp" />
<ClCompile Include="World.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="CrystalJohan.h" />
<ClInclude Include="Enemy.h" />
<ClInclude Include="Entity.h" />
<ClInclude Include="LevelObject.h" />
<ClInclude Include="Main.h" />
<ClInclude Include="Model.h" />
<ClInclude Include="Player.h" />
<ClInclude Include="Singleton.h" />
<ClInclude Include="stb_image.h" />
<ClInclude Include="vector.h" />
<ClInclude Include="World.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
+84
View File
@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="CrystalJohan.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="World.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Entity.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Enemy.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="LevelObject.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Model.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Vector.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Player.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="CrystalJohan.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="World.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Entity.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Enemy.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="LevelObject.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="vector.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Model.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="stb_image.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Player.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Singleton.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Main.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
-28
View File
@@ -1,28 +0,0 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.24720.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CrystalPoint", "CrystalPoint.vcxproj", "{4986BEC0-4362-46E4-A18D-65587FA97967}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4986BEC0-4362-46E4-A18D-65587FA97967}.Debug|x64.ActiveCfg = Debug|x64
{4986BEC0-4362-46E4-A18D-65587FA97967}.Debug|x64.Build.0 = Debug|x64
{4986BEC0-4362-46E4-A18D-65587FA97967}.Debug|x86.ActiveCfg = Debug|Win32
{4986BEC0-4362-46E4-A18D-65587FA97967}.Debug|x86.Build.0 = Debug|Win32
{4986BEC0-4362-46E4-A18D-65587FA97967}.Release|x64.ActiveCfg = Release|x64
{4986BEC0-4362-46E4-A18D-65587FA97967}.Release|x64.Build.0 = Release|x64
{4986BEC0-4362-46E4-A18D-65587FA97967}.Release|x86.ActiveCfg = Release|Win32
{4986BEC0-4362-46E4-A18D-65587FA97967}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
-150
View File
@@ -1,150 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="Source Files\State">
<UniqueIdentifier>{6c99658e-2c17-469b-a3d1-2c4d3d61d440}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Control">
<UniqueIdentifier>{e444364a-17f6-4464-a98c-6bd34d3e6263}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Model">
<UniqueIdentifier>{842778c9-ff0f-4a6d-9c86-0a178ad40fcc}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Model\Enemy">
<UniqueIdentifier>{1be14b84-6fa7-4cfb-94b9-666f3ee14198}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Handler">
<UniqueIdentifier>{1b39afb7-b64b-458a-bba3-755631986211}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Model.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Header.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="StateHandler.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="State.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="MenuState.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="LoadingState.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Keyboard.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Mouse.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Controller.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="WorldModel.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="WorldState.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Enemy.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Player.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Weapon.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Vector.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ModelInstance.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ModelHandler.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="SettingsState.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="InitState.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="State.cpp">
<Filter>Source Files\State</Filter>
</ClCompile>
<ClCompile Include="MenuState.cpp">
<Filter>Source Files\State</Filter>
</ClCompile>
<ClCompile Include="Keyboard.cpp">
<Filter>Source Files\Control</Filter>
</ClCompile>
<ClCompile Include="Mouse.cpp">
<Filter>Source Files\Control</Filter>
</ClCompile>
<ClCompile Include="Controller.cpp">
<Filter>Source Files\Control</Filter>
</ClCompile>
<ClCompile Include="LoadingState.cpp">
<Filter>Source Files\State</Filter>
</ClCompile>
<ClCompile Include="Model.cpp">
<Filter>Source Files\Model</Filter>
</ClCompile>
<ClCompile Include="WorldModel.cpp">
<Filter>Source Files\Model</Filter>
</ClCompile>
<ClCompile Include="WorldState.cpp">
<Filter>Source Files\State</Filter>
</ClCompile>
<ClCompile Include="Enemy.cpp">
<Filter>Source Files\Model\Enemy</Filter>
</ClCompile>
<ClCompile Include="Player.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Weapon.cpp">
<Filter>Source Files\Model</Filter>
</ClCompile>
<ClCompile Include="Vector.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ModelInstance.cpp">
<Filter>Source Files\Model</Filter>
</ClCompile>
<ClCompile Include="StateHandler.cpp">
<Filter>Source Files\Handler</Filter>
</ClCompile>
<ClCompile Include="ModelHandler.cpp">
<Filter>Source Files\Handler</Filter>
</ClCompile>
<ClCompile Include="SettingsState.cpp">
<Filter>Source Files\State</Filter>
</ClCompile>
<ClCompile Include="InitState.cpp">
<Filter>Source Files\State</Filter>
</ClCompile>
</ItemGroup>
</Project>
Binary file not shown.
Binary file not shown.
+3
View File
@@ -0,0 +1,3 @@
World.cpp
d:\code\c++\crystaljohan\world.cpp(7): warning C4305: '=': truncation from 'double' to 'float'
CrystalJohan.vcxproj -> D:\Code\C++\CrystalJohan\Debug\CrystalJohan.exe
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,2 @@
#TargetFrameworkVersion=v4.0:PlatformToolSet=v140:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=8.1
Debug|Win32|D:\Code\C++\CrystalJohan\|
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
-2
View File
@@ -1,6 +1,4 @@
#pragma once
#include "Header.h"
class Enemy
{
public:
+36
View File
@@ -0,0 +1,36 @@
#include "Entity.h"
#include <GL/freeglut.h>
#include "Model.h"
Entity::Entity()
{
model = NULL;
}
Entity::~Entity()
{
}
void Entity::draw()
{
if (model)
{
glPushMatrix();
glTranslatef(position.x, position.y, position.z);
glRotatef(rotation.x, 1, 0, 0);
glRotatef(rotation.y, 0, 1, 0);
glRotatef(rotation.z, 0, 0, 1);
glScalef(scale, scale, scale);
model->draw();
glPopMatrix();
}
}
+20
View File
@@ -0,0 +1,20 @@
#pragma once
#include "Vector.h"
class Model;
class Entity
{
public:
Entity();
~Entity();
Model* model;
virtual void draw();
virtual void update(float elapsedTime) {};
Vec3f position;
Vec3f rotation;
float scale;
};
-22
View File
@@ -1,22 +0,0 @@
#pragma once
#include <GL/freeglut.h>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
#include <string>
#include <vector>
#include <list>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <vector>
#include <windows.h>
#include <gl/GL.h>
#include "Vector.h"
using namespace std;
-12
View File
@@ -1,12 +0,0 @@
#include "InitState.h"
InitState::InitState()
{
}
InitState::~InitState()
{
}
-11
View File
@@ -1,11 +0,0 @@
#pragma once
#include "Header.h"
#include "State.h"
class InitState : public State
{
public:
InitState();
~InitState();
};
-12
View File
@@ -1,12 +0,0 @@
#include "Keyboard.h"
Keyboard::Keyboard()
{
}
Keyboard::~Keyboard()
{
}
-10
View File
@@ -1,10 +0,0 @@
#pragma once
#include "Header.h"
class Keyboard
{
public:
Keyboard();
~Keyboard();
};
+12
View File
@@ -0,0 +1,12 @@
#include "LevelObject.h"
LevelObject::LevelObject()
{
}
LevelObject::~LevelObject()
{
}
+8
View File
@@ -0,0 +1,8 @@
#pragma once
class LevelObject
{
public:
LevelObject();
~LevelObject();
};
-12
View File
@@ -1,12 +0,0 @@
#include "LoadingState.h"
LoadingState::LoadingState()
{
}
LoadingState::~LoadingState()
{
}
-11
View File
@@ -1,11 +0,0 @@
#pragma once
#include "Header.h"
#include "State.h"
class LoadingState : public State
{
public:
LoadingState();
~LoadingState();
};
+34 -166
View File
@@ -1,142 +1,17 @@
#include "Header.h"
#include "Model.h"
#include "Player.h"
#include "StateHandler.h"
#include "State.h"
#include <GL/freeglut.h>
//Prototypes
void bindFuncOpenGL(void);
void configureOpenGL(void);
void loadModels(void);
#include "CrystalJohan.h"
#include <stdio.h>
#include "vector.h"
static int Width;
static int Height;
CrystalJohan* app;
float lastFrameTime = 0;
bool keys[255];
//vector<Model*> models;
//int currentModel = 0;
StateHandler *statehandler;
void display()
{
glClearColor(0.6f, 0.6f, 1, 1);
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0f, (float)Width / Height, 0.5, 300);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
/*glRotatef(player.eyes.rotX, 1, 0, 0);
glRotatef(player.eyes.rotY, 0, 1, 0);
glTranslatef(player.eyes.posX, player.eyes.posY, player.eyes.posZ);
glPushMatrix();
glScalef(0.5f, 0.5f, 0.5f);
glRotatef(180, 1, 0, 0);
glRotatef(45, 0, 0, 1);
glRotatef(90, 0, 1, 0);
models[currentModel]->draw();
glPopMatrix();*/
//Draw here
statehandler->GetCurrentState()->Display();
//player->Display();
//glutSolidCube(10.0);
glDisable(GL_TEXTURE_2D);
glutSwapBuffers();
}
void idle()
{
float frameTime = glutGet(GLUT_ELAPSED_TIME) / 1000.0f;
float deltaTime = frameTime - lastFrameTime;
lastFrameTime = frameTime;
statehandler->GetCurrentState()->Keyboard(keys,deltaTime);
statehandler->GetCurrentState()->Idle(deltaTime);
glutPostRedisplay();
}
void mousemotion(int x, int y)
{
int dx = x - Width / 2;
int dy = y - Height / 2;
if ((dx != 0 || dy != 0) && abs(dx) < 400 && abs(dy) < 400)
{
statehandler->GetCurrentState()->MouseMove(x, y, dx, dy);
glutWarpPointer(Width / 2, Height / 2);
}
}
void mouse(int button, int type, int x, int y)
{
statehandler->GetCurrentState()->MouseClick(button, type, x, y);
}
void keyboard(unsigned char key, int, int)
{
if (key == 27)
exit(0);
//std::cout << key << std::endl;
keys[key] = true;
}
void keyboardup(unsigned char key, int, int)
{
keys[key] = false;
}
bool justMoved = false;
int main(int argc, char* argv[])
{
//Init GLUT
app = new CrystalJohan();
glutInit(&argc, argv);
//Configre OpenGL and FreeGLut
configureOpenGL();
//Bind functions
bindFuncOpenGL();
//Init models
loadModels();
//Start the main loop
glutMainLoop();
return 0;
}
void bindFuncOpenGL()
{
glutDisplayFunc(display);
glutIdleFunc(idle);
glutReshapeFunc([](int w, int h) { Width = w; Height= h; glViewport(0, 0, w, h); });
//Keyboard
glutKeyboardFunc(keyboard);
glutKeyboardUpFunc(keyboardup);
//Mouse
glutMouseFunc(mouse);
glutPassiveMotionFunc(mousemotion);
}
void configureOpenGL()
{
//Init window and glut display mode
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowSize(800, 600);
@@ -144,44 +19,37 @@ void configureOpenGL()
glutFullScreen();
//glutPositionWindow((glutGet(GLUT_SCREEN_WIDTH) / 2) - (glutGet(GLUT_WINDOW_WIDTH) / 2), (glutGet(GLUT_SCREEN_HEIGHT) / 2) - (glutGet(GLUT_WINDOW_HEIGHT) / 2));
//Depth testing
glEnable(GL_DEPTH_TEST);
app->init();
//Alpha blending
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//Alpha testing
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0.01f);
glutDisplayFunc([]() { app->draw(); } );
glutIdleFunc([]() { app->update(); } );
glutReshapeFunc([](int w, int h) { app->width = w; app->height = h; glViewport(0, 0, w, h); });
//Lighting
GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
GLfloat mat_shininess[] = { 20.0 };
GLfloat light_position[] = { 30.0, 30.0, 30.0, 1.0 };
GLfloat light_diffuse[] = { 2.0, 2.0, 2.0, 1.0 };
GLfloat light_ambient[] = { 2.0, 2.0, 2.0, 1.0 };
glClearColor(0.0, 0.0, 0.0, 0.0);
glShadeModel(GL_SMOOTH);
//Keyboard
glutKeyboardFunc([](unsigned char c, int, int) { app->keyboardState.keys[c] = true; });
glutKeyboardUpFunc([](unsigned char c, int, int) { app->keyboardState.keys[c] = false; });
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
//Mouse
// glutMouseFunc(mouse);
glutPassiveMotionFunc([](int x, int y)
{
if (justMoved)
{
justMoved = false;
return;
}
int dx = x - app->width / 2;
int dy = y - app->height / 2;
if ((dx != 0 || dy != 0) && abs(dx) < 400 && abs(dy) < 400)
{
app->mouseOffset = app->mouseOffset + Vec2f(dx,dy);
glutWarpPointer(app->width / 2, app->height / 2);
justMoved = true;
}
});
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glutMainLoop();
//Cursor
glutWarpPointer(Width / 2, Height / 2);
glutSetCursor(GLUT_CURSOR_CROSSHAIR);
}
void loadModels()
{
statehandler = new StateHandler();
statehandler->Navigate(statehandler->WORLD_STATE);
//models.push_back(new Model("models/weapons/ZwaardMetTextures/TextureZwaard.obj"));
return 0;
}
View File
-12
View File
@@ -1,12 +0,0 @@
#include "MenuState.h"
MenuState::MenuState()
{
}
MenuState::~MenuState()
{
}
-10
View File
@@ -1,10 +0,0 @@
#pragma once
#include "Header.h"
#include "State.h"
class MenuState : public State
{
public:
MenuState();
~MenuState();
};
+44 -37
View File
@@ -3,12 +3,17 @@
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
//Prototypes
vector<string> split(string str, string sep);
string replace(string str, string toReplace, string replacement);
string toLower(string data);
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
Model::Model(string fileName)
//Prototypes
std::vector<std::string> split(std::string str, std::string sep);
std::string replace(std::string str, std::string toReplace, std::string replacement);
std::string toLower(std::string data);
Model::Model(std::string fileName)
{
std::string dirName = fileName;
if (dirName.rfind("/") != std::string::npos)
@@ -117,20 +122,11 @@ Model::Model(string fileName)
groups.push_back(currentGroup);
}
Model::Model(void)
{
Model("models/TextureZwaard.obj");
}
Model::~Model(void)
{
}
void Model::AddInstance(ModelInstance* inst)
{
instances.push_back(inst);
}
void Model::draw()
{
for (auto &g : groups)
@@ -163,30 +159,18 @@ void Model::draw()
}
}
for (auto &instance : instances)
glBegin(GL_TRIANGLES);
for (auto &f : g->faces)
{
glBegin(GL_TRIANGLES);
for (auto &f : g->faces)
for (auto &v : f.vertices)
{
for (auto &v : f.vertices)
{
glPushMatrix();
glTranslatef(instance->translation.x, instance->translation.y, instance->translation.z);
glRotatef(instance->rotation.x, 1, 0, 0);
glRotatef(instance->rotation.y, 0, 1, 0);
glRotatef(instance->rotation.z, 0, 0, 1);
glScalef(instance->scale.x, instance->scale.y, instance->scale.z);
glNormal3f(normals[v.normal].x, normals[v.normal].y, normals[v.normal].z);
glTexCoord2f(texcoords[v.texcoord].x, texcoords[v.texcoord].y);
glVertex3f(vertices[v.position].x, vertices[v.position].y, vertices[v.position].z);
}
glNormal3f(normals[v.normal].x, normals[v.normal].y, normals[v.normal].z);
glTexCoord2f(texcoords[v.texcoord].x, texcoords[v.texcoord].y);
glVertex3f(vertices[v.position].x, vertices[v.position].y, vertices[v.position].z);
}
glEnd();
}
glEnd();
}
}
@@ -295,7 +279,7 @@ void Model::Texture::bind()
glBindTexture(GL_TEXTURE_2D, index);
}
string replace(string str, string toReplace, string replacement)
std::string replace(std::string str, std::string toReplace, std::string replacement)
{
size_t index = 0;
while (true)
@@ -309,7 +293,7 @@ string replace(string str, string toReplace, string replacement)
return str;
}
vector<string> split(string str, string sep)
std::vector<std::string> split(std::string str, std::string sep)
{
std::vector<std::string> ret;
size_t index;
@@ -325,8 +309,31 @@ vector<string> split(string str, string sep)
return ret;
}
inline string toLower(string data)
inline std::string toLower(std::string data)
{
std::transform(data.begin(), data.end(), data.begin(), ::tolower);
return data;
}
std::map<std::string, std::pair<Model*, int>> Model::cache;
Model* Model::load(const std::string &fileName)
{
if (cache.find(fileName) == cache.end())
cache[fileName] = std::pair<Model*, int>(new Model(fileName), 0);
cache[fileName].second++;
return cache[fileName].first;
}
void Model::unload(const std::string & fileName)
{
assert(cache.find(fileName) != cache.end());
cache[fileName].second--;
if (cache[fileName].second == 0)
{
delete cache[fileName].first;
cache.erase(cache.find(fileName));
}
}
+14 -9
View File
@@ -1,6 +1,10 @@
#pragma once
#include "Header.h"
#include "ModelInstance.h"
#include <GL/freeglut.h>
#include <list>
#include <vector>
#include <map>
#include "vector.h"
class Model
{
@@ -16,7 +20,7 @@ private:
class Face
{
public:
list<Vertex> vertices;
std::list<Vertex> vertices;
};
class Texture
@@ -49,7 +53,7 @@ private:
public:
std::string name;
int materialIndex;
list<Face> faces;
std::list<Face> faces;
};
std::vector<Vec3f> vertices;
@@ -58,15 +62,16 @@ private:
std::vector<ObjGroup*> groups;
std::vector<MaterialInfo*> materials;
std::vector<ModelInstance*> instances;
void loadMaterialFile(std::string fileName, std::string dirName);
public:
Model(std::string filename);
Model(void);
~Model(void);
void AddInstance(ModelInstance* inst);
public:
static std::map<std::string, std::pair<Model*, int> > cache;
static Model* load(const std::string &fileName);
static void unload(const std::string &fileName);
void draw();
};
-12
View File
@@ -1,12 +0,0 @@
#include "ModelHandler.h"
ModelHandler::ModelHandler()
{
}
ModelHandler::~ModelHandler()
{
}
-8
View File
@@ -1,8 +0,0 @@
#pragma once
class ModelHandler
{
public:
ModelHandler();
~ModelHandler();
};
-10
View File
@@ -1,10 +0,0 @@
#include "ModelInstance.h"
ModelInstance::ModelInstance()
{
}
ModelInstance::~ModelInstance()
{
}
-16
View File
@@ -1,16 +0,0 @@
#pragma once
#include "Header.h"
class ModelInstance
{
private:
public:
ModelInstance();
~ModelInstance();
Vec3f translation;
Vec3f rotation;
Vec3f scale;
};
-12
View File
@@ -1,12 +0,0 @@
#include "Mouse.h"
Mouse::Mouse()
{
}
Mouse::~Mouse()
{
}
-10
View File
@@ -1,10 +0,0 @@
#pragma once
#include "Header.h"
class Mouse
{
public:
Mouse();
~Mouse();
};
+7 -69
View File
@@ -1,77 +1,15 @@
#include "Player.h"
#include <GL/freeglut.h>
Player::Player()
{
}
Player::~Player()
void Player::setCamera()
{
if(right != nullptr)
delete right;
if(left != nullptr)
delete left;
/*if (player != nullptr)
delete player;*/
glRotatef(rotation.x, 1, 0, 0);
glRotatef(rotation.y, 0, 1, 0);
glTranslatef(-position.x, -position.y, -position.z);
}
void Player::Display(void)
{
if (right != nullptr)
{
right->draw_weapon();
}
if (left != nullptr)
{
left->draw_weapon();
}
/*glRotatef(player->eyes.rotX, 1, 0, 0);
glRotatef(player->eyes.rotY, 0, 1, 0);
glTranslatef(player->eyes.posX, player->eyes.posY, player->eyes.posZ);*/
glRotatef(eyes.rotX, 1, 0, 0);
glRotatef(eyes.rotY, 0, 1, 0);
glTranslatef(eyes.posX, eyes.posY, eyes.posZ);
}
Player & Player::GetInstance(void)
{
static Player instance;
return instance;
}
//Player * Player::GetInstance(void)
//{
// if (player == nullptr)
// player = new Player();
// return player;
//}
void Player::PlayerMoveEyes(float angle, float fac, bool heigth)
{
//player movement
/*if (heigth)
player->eyes.posY += angle*fac;
else
{
player->eyes.posX += (float)cos((player->eyes.rotY + angle) / 180 * M_PI) * fac;
player->eyes.posZ += (float)sin((player->eyes.rotY + angle) / 180 * M_PI) * fac;
}*/
if (heigth)
eyes.posY += angle*fac;
else
{
eyes.posX += (float)cos((eyes.rotY + angle) / 180 * M_PI) * fac;
eyes.posZ += (float)sin((eyes.rotY + angle) / 180 * M_PI) * fac;
}
}
void Player::PlayerRotateEyes(int dx, int dy)
{
eyes.rotY += dx / 10.0f;
eyes.rotX += dy / 10.0f;
}
+14 -31
View File
@@ -1,38 +1,21 @@
#pragma once
#include "Header.h"
#include "Weapon.h"
class Player
#include "Singleton.h"
#include "vector.h"
class Model;
class Player : public Singleton<Player>
{
public:
~Player();
struct Eyes
{
float posX = 0;
float posY = 0;
float posZ = 0;
float rotX = 0;
float rotY = 0;
} eyes;
void Display(void);
//static Player* GetInstance(void);
static Player& GetInstance(void);
void PlayerMoveEyes(const float angle, const float fac, const bool heigth);
void PlayerRotateEyes(const int dx, const int dy);
private:
int level;
int xp;
Weapon* right = nullptr;
Weapon* left = nullptr;
vector<Weapon> weapons;
Player();
Player(Player const&);
void operator=(Player const&);
//static Player* player;
};
void setCamera();
Vec3f position;
Vec2f rotation;
Model* leftWeapon;
Model* rightWeapon;
};
-2
View File
@@ -1,2 +0,0 @@
# CrystalPoint
Crystal Point: The Elemental Labyrinth
+40
View File
@@ -0,0 +1,40 @@
========================================================================
CONSOLE APPLICATION : CrystalJohan Project Overview
========================================================================
AppWizard has created this CrystalJohan application for you.
This file contains a summary of what you will find in each of the files that
make up your CrystalJohan application.
CrystalJohan.vcxproj
This is the main project file for VC++ projects generated using an Application Wizard.
It contains information about the version of Visual C++ that generated the file, and
information about the platforms, configurations, and project features selected with the
Application Wizard.
CrystalJohan.vcxproj.filters
This is the filters file for VC++ projects generated using an Application Wizard.
It contains information about the association between the files in your project
and the filters. This association is used in the IDE to show grouping of files with
similar extensions under a specific node (for e.g. ".cpp" files are associated with the
"Source Files" filter).
CrystalJohan.cpp
This is the main application source file.
/////////////////////////////////////////////////////////////////////////////
Other standard files:
StdAfx.h, StdAfx.cpp
These files are used to build a precompiled header (PCH) file
named CrystalJohan.pch and a precompiled types file named StdAfx.obj.
/////////////////////////////////////////////////////////////////////////////
Other notes:
AppWizard uses "TODO:" comments to indicate parts of the source code you
should add to or customize.
/////////////////////////////////////////////////////////////////////////////
-12
View File
@@ -1,12 +0,0 @@
#include "SettingsState.h"
SettingsState::SettingsState()
{
}
SettingsState::~SettingsState()
{
}
-11
View File
@@ -1,11 +0,0 @@
#pragma once
#include "Header.h"
#include "State.h"
class SettingsState : public State
{
public:
SettingsState();
~SettingsState();
};
+13
View File
@@ -0,0 +1,13 @@
#pragma once
template <class T>
class Singleton
{
public:
static T& getInstance()
{
static T* t = new T();
return *t;
}
};
-40
View File
@@ -1,40 +0,0 @@
#include "State.h"
State::State()
{
}
State::~State()
{
}
void State::Entry()
{
}
void State::Exit()
{
}
void State::Idle(float delta)
{
}
void State::Display()
{
}
void State::Keyboard(bool keys[255],float deltaTime)
{
}
void State::MouseMove(int x, int y, int dx, int dy)
{
}
void State::MouseClick(int button, int type, int x, int y)
{
}
-26
View File
@@ -1,26 +0,0 @@
#pragma once
#include "Header.h"
class State
{
public:
State();
~State();
virtual void Entry();
virtual void Exit();
virtual void Idle(float delta);
virtual void Display();
virtual void Keyboard(bool keys[255],float deltaTime);
virtual void MouseMove(int x, int y, int dx, int dy);
virtual void MouseClick(int button, int type, int x, int y);
};
#include "InitState.h"
#include "LoadingState.h"
#include "MenuState.h"
#include "SettingsState.h"
#include "WorldState.h"
-33
View File
@@ -1,33 +0,0 @@
#include "StateHandler.h"
StateHandler::StateHandler()
{
StateList.push_back(new InitState()); //INIT_STATE
StateList.push_back(new LoadingState()); //LOADING_STATE
StateList.push_back(new MenuState()); //MENU_STATE
StateList.push_back(new SettingsState()); //SETTINGS_STATE
StateList.push_back(new WorldState()); //WORLD_STATE
//CurrentState = INIT_STATE;
CurrentState = WORLD_STATE;
}
StateHandler::~StateHandler()
{
}
void StateHandler::Navigate(EState state)
{
if (CurrentState == state)
return;
StateList.at(CurrentState)->Exit();
CurrentState = state;
StateList.at(CurrentState)->Entry();
}
State* StateHandler::GetCurrentState()
{
return StateList.at(CurrentState);
}
-19
View File
@@ -1,19 +0,0 @@
#pragma once
#include "Header.h"
#include "State.h"
class StateHandler
{
public:
enum EState { INIT_STATE = 0, LOADING_STATE = 1, MENU_STATE = 2, SETTINGS_STATE = 3, WORLD_STATE = 4 };
StateHandler();
~StateHandler();
void Navigate(EState state);
State* GetCurrentState();
private:
EState CurrentState;
vector<State*> StateList;
};
+5
View File
@@ -46,3 +46,8 @@ float& Vec2f::operator [](int index)
{
return v[index];
}
Vec2f Vec2f::operator+(const Vec2f & other)
{
return Vec2f(x + other.x, y+other.y);
}
+1 -1
View File
@@ -1,5 +1,4 @@
#pragma once
#include "Header.h"
class Vec3f
{
@@ -33,5 +32,6 @@ public:
Vec2f(float x, float y);
Vec2f(Vec2f &other);
float& operator [](int);
Vec2f operator + (const Vec2f &other);
};
-28
View File
@@ -1,28 +0,0 @@
#include "Weapon.h"
Weapon::Weapon(const string &filename)
{
weaponModel = new Model(filename);
}
Weapon::Weapon()
{
}
Weapon::~Weapon()
{
}
void Weapon::draw_weapon(void)
{
if (weaponModel != nullptr)
{
glScalef(scale,scale,scale);
glRotatef(135, 1, 0, 0);
weaponModel->draw();
}
}
-16
View File
@@ -1,16 +0,0 @@
#pragma once
#include "Header.h"
#include "Model.h"
class Weapon
{
public:
Weapon(const string &filename);
Weapon();
~Weapon();
void draw_weapon(void);
private:
Model *weaponModel = nullptr;
float scale = 0.5f;
};
+40
View File
@@ -0,0 +1,40 @@
#include "World.h"
#include <GL/freeglut.h>
#include "Entity.h"
World::World() : player(Player::getInstance())
{
player.position.y = 1.7;
//entities.push_back(new LevelObject("tree"));
}
World::~World()
{
}
void World::draw()
{
player.setCamera();
glColor3f(0.5f, 0.9f, 0.5f);
glBegin(GL_QUADS);
glVertex3f(-50, 0, -50);
glVertex3f(-50, 0, 50);
glVertex3f(50, 0, 50);
glVertex3f(50, 0, -50);
glEnd();
for (auto e : entities)
e->draw();
glutSwapBuffers();
}
void World::update(float elapsedTime)
{
for (auto e : entities)
e->update(elapsedTime);
}
+22
View File
@@ -0,0 +1,22 @@
#pragma once
#include <vector>
#include "Player.h"
class Entity;
class World
{
public:
World();
~World();
Player& player;
std::vector<Entity*> entities;
void draw();
void update(float elapsedTime);
};
-12
View File
@@ -1,12 +0,0 @@
#include "WorldModel.h"
WorldModel::WorldModel()
{
}
WorldModel::~WorldModel()
{
}
-10
View File
@@ -1,10 +0,0 @@
#pragma once
#include "Header.h"
class WorldModel
{
public:
WorldModel();
~WorldModel();
};
-49
View File
@@ -1,49 +0,0 @@
#include "WorldState.h"
#include "Player.h"
WorldState::WorldState()
{
/*player = Player::GetInstance();*/
}
WorldState::~WorldState()
{
//if (player != nullptr)
//delete player;
}
void WorldState::Keyboard(bool keys[255],float deltaTime)
{
float speed = 10;
std::cout << "Keyboard doet het in de world state" << std::endl;
/*if (keys['a']) player->PlayerMoveEyes(0, deltaTime*speed, false);
if (keys['d']) player->PlayerMoveEyes(180, deltaTime*speed, false);
if (keys['w']) player->PlayerMoveEyes(90, deltaTime*speed, false);
if (keys['s']) player->PlayerMoveEyes(270, deltaTime*speed, false);
if (keys['q']) player->PlayerMoveEyes(1, deltaTime*speed, true);
if (keys['e']) player->PlayerMoveEyes(-1, deltaTime*speed, true); */
if (keys['a']) Player::GetInstance().PlayerMoveEyes(0, deltaTime*speed, false);
if (keys['d']) Player::GetInstance().PlayerMoveEyes(180, deltaTime*speed, false);
if (keys['w']) Player::GetInstance().PlayerMoveEyes(90, deltaTime*speed, false);
if (keys['s']) Player::GetInstance().PlayerMoveEyes(270, deltaTime*speed, false);
if (keys['q']) Player::GetInstance().PlayerMoveEyes(1, deltaTime*speed, true);
if (keys['e']) Player::GetInstance().PlayerMoveEyes(-1, deltaTime*speed, true);
}
void WorldState::MouseMove(int x, int y, int dx, int dy)
{
//player->PlayerRotateEyes(dx, dy);
Player::GetInstance().PlayerRotateEyes(dx, dy);
}
void WorldState::Display()
{
Player::GetInstance().Display();
glutSolidCube(10.0);
}
-18
View File
@@ -1,18 +0,0 @@
#pragma once
#include "Header.h"
#include "State.h"
#include "Player.h"
class WorldState : public State
{
public:
WorldState();
~WorldState();
void Keyboard(bool keys[255],float deltaTime);
void MouseMove(int x, int y, int dx, int dy);
void Display();
private:
//Player* player;
};
Binary file not shown.
Binary file not shown.
Binary file not shown.