diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 56567d9..0000000 --- a/.gitignore +++ /dev/null @@ -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/ diff --git a/.vs/CrystalPoint/v14/.suo b/.vs/CrystalPoint/v14/.suo new file mode 100644 index 0000000..a7c5419 Binary files /dev/null and b/.vs/CrystalPoint/v14/.suo differ diff --git a/Controller.cpp b/Controller.cpp deleted file mode 100644 index 02235ff..0000000 --- a/Controller.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "Controller.h" - - - -Controller::Controller() -{ -} - - -Controller::~Controller() -{ -} diff --git a/Controller.h b/Controller.h deleted file mode 100644 index 0de45f5..0000000 --- a/Controller.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once -#include "Header.h" - -class Controller -{ -public: - Controller(); - ~Controller(); -}; - diff --git a/CrystalJohan.cpp b/CrystalJohan.cpp new file mode 100644 index 0000000..e3fc234 --- /dev/null +++ b/CrystalJohan.cpp @@ -0,0 +1,62 @@ + +#include "CrystalJohan.h" +#include +#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)); +} diff --git a/CrystalJohan.h b/CrystalJohan.h new file mode 100644 index 0000000..1a5864f --- /dev/null +++ b/CrystalJohan.h @@ -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; + +}; \ No newline at end of file diff --git a/CrystalJohan.sdf b/CrystalJohan.sdf new file mode 100644 index 0000000..2e06fa9 Binary files /dev/null and b/CrystalJohan.sdf differ diff --git a/CrystalJohan.sln b/CrystalJohan.sln new file mode 100644 index 0000000..c3d3c5b --- /dev/null +++ b/CrystalJohan.sln @@ -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 diff --git a/CrystalPoint.vcxproj b/CrystalJohan.vcxproj similarity index 82% rename from CrystalPoint.vcxproj rename to CrystalJohan.vcxproj index e67e882..4abd2f9 100644 --- a/CrystalPoint.vcxproj +++ b/CrystalJohan.vcxproj @@ -19,11 +19,10 @@ - {4986BEC0-4362-46E4-A18D-65587FA97967} + {98776A7C-CD7A-4C62-946A-2263C27E9690} Win32Proj - CrystalPoint + CrystalJohan 8.1 - CrystalPoint @@ -84,11 +83,11 @@ - - + NotUsing Level3 Disabled WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + freeglut/include @@ -99,11 +98,11 @@ - - + NotUsing Level3 Disabled _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + freeglut/include @@ -115,12 +114,12 @@ Level3 - - + NotUsing MaxSpeed true true WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + freeglut/include @@ -134,12 +133,12 @@ Level3 - - + NotUsing MaxSpeed true true NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + freeglut/include @@ -151,46 +150,31 @@ - - - - - - - - - - - - - - - - - - - + - + - - - + + - - - - - - - - - - + + + + + + + + + + + + + + diff --git a/CrystalJohan.vcxproj.filters b/CrystalJohan.vcxproj.filters new file mode 100644 index 0000000..9a7325d --- /dev/null +++ b/CrystalJohan.vcxproj.filters @@ -0,0 +1,84 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + \ No newline at end of file diff --git a/CrystalPoint.sln b/CrystalPoint.sln deleted file mode 100644 index c52ddab..0000000 --- a/CrystalPoint.sln +++ /dev/null @@ -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 diff --git a/CrystalPoint.vcxproj.filters b/CrystalPoint.vcxproj.filters deleted file mode 100644 index 6e949e9..0000000 --- a/CrystalPoint.vcxproj.filters +++ /dev/null @@ -1,150 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - {6c99658e-2c17-469b-a3d1-2c4d3d61d440} - - - {e444364a-17f6-4464-a98c-6bd34d3e6263} - - - {842778c9-ff0f-4a6d-9c86-0a178ad40fcc} - - - {1be14b84-6fa7-4cfb-94b9-666f3ee14198} - - - {1b39afb7-b64b-458a-bba3-755631986211} - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Source Files - - - Source Files\State - - - Source Files\State - - - Source Files\Control - - - Source Files\Control - - - Source Files\Control - - - Source Files\State - - - Source Files\Model - - - Source Files\Model - - - Source Files\State - - - Source Files\Model\Enemy - - - Source Files - - - Source Files\Model - - - Source Files - - - Source Files\Model - - - Source Files\Handler - - - Source Files\Handler - - - Source Files\State - - - Source Files\State - - - \ No newline at end of file diff --git a/Debug/CrystalJohan.exe b/Debug/CrystalJohan.exe new file mode 100644 index 0000000..52e01d7 Binary files /dev/null and b/Debug/CrystalJohan.exe differ diff --git a/Debug/CrystalJohan.ilk b/Debug/CrystalJohan.ilk new file mode 100644 index 0000000..f91141e Binary files /dev/null and b/Debug/CrystalJohan.ilk differ diff --git a/Debug/CrystalJohan.log b/Debug/CrystalJohan.log new file mode 100644 index 0000000..86b6ae9 --- /dev/null +++ b/Debug/CrystalJohan.log @@ -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 diff --git a/Debug/CrystalJohan.obj b/Debug/CrystalJohan.obj new file mode 100644 index 0000000..1d932f8 Binary files /dev/null and b/Debug/CrystalJohan.obj differ diff --git a/Debug/CrystalJohan.pdb b/Debug/CrystalJohan.pdb new file mode 100644 index 0000000..e27c1e0 Binary files /dev/null and b/Debug/CrystalJohan.pdb differ diff --git a/Debug/CrystalJohan.tlog/CL.command.1.tlog b/Debug/CrystalJohan.tlog/CL.command.1.tlog new file mode 100644 index 0000000..e14ae46 Binary files /dev/null and b/Debug/CrystalJohan.tlog/CL.command.1.tlog differ diff --git a/Debug/CrystalJohan.tlog/CL.read.1.tlog b/Debug/CrystalJohan.tlog/CL.read.1.tlog new file mode 100644 index 0000000..b844df5 Binary files /dev/null and b/Debug/CrystalJohan.tlog/CL.read.1.tlog differ diff --git a/Debug/CrystalJohan.tlog/CL.write.1.tlog b/Debug/CrystalJohan.tlog/CL.write.1.tlog new file mode 100644 index 0000000..68e06ff Binary files /dev/null and b/Debug/CrystalJohan.tlog/CL.write.1.tlog differ diff --git a/Debug/CrystalJohan.tlog/CrystalJohan.lastbuildstate b/Debug/CrystalJohan.tlog/CrystalJohan.lastbuildstate new file mode 100644 index 0000000..3770311 --- /dev/null +++ b/Debug/CrystalJohan.tlog/CrystalJohan.lastbuildstate @@ -0,0 +1,2 @@ +#TargetFrameworkVersion=v4.0:PlatformToolSet=v140:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=8.1 +Debug|Win32|D:\Code\C++\CrystalJohan\| diff --git a/Debug/CrystalJohan.tlog/link.command.1.tlog b/Debug/CrystalJohan.tlog/link.command.1.tlog new file mode 100644 index 0000000..f74a15a Binary files /dev/null and b/Debug/CrystalJohan.tlog/link.command.1.tlog differ diff --git a/Debug/CrystalJohan.tlog/link.read.1.tlog b/Debug/CrystalJohan.tlog/link.read.1.tlog new file mode 100644 index 0000000..c57c96b Binary files /dev/null and b/Debug/CrystalJohan.tlog/link.read.1.tlog differ diff --git a/Debug/CrystalJohan.tlog/link.write.1.tlog b/Debug/CrystalJohan.tlog/link.write.1.tlog new file mode 100644 index 0000000..bf9779f Binary files /dev/null and b/Debug/CrystalJohan.tlog/link.write.1.tlog differ diff --git a/Debug/Enemy.obj b/Debug/Enemy.obj new file mode 100644 index 0000000..ff3e8b8 Binary files /dev/null and b/Debug/Enemy.obj differ diff --git a/Debug/Entity.obj b/Debug/Entity.obj new file mode 100644 index 0000000..0f26f0d Binary files /dev/null and b/Debug/Entity.obj differ diff --git a/Debug/LevelObject.obj b/Debug/LevelObject.obj new file mode 100644 index 0000000..7d242ff Binary files /dev/null and b/Debug/LevelObject.obj differ diff --git a/Debug/Main.obj b/Debug/Main.obj new file mode 100644 index 0000000..3f6c3a6 Binary files /dev/null and b/Debug/Main.obj differ diff --git a/Debug/Model.obj b/Debug/Model.obj new file mode 100644 index 0000000..78f425f Binary files /dev/null and b/Debug/Model.obj differ diff --git a/Debug/Player.obj b/Debug/Player.obj new file mode 100644 index 0000000..20ef8f6 Binary files /dev/null and b/Debug/Player.obj differ diff --git a/Debug/Vector.obj b/Debug/Vector.obj new file mode 100644 index 0000000..13e856c Binary files /dev/null and b/Debug/Vector.obj differ diff --git a/Debug/World.obj b/Debug/World.obj new file mode 100644 index 0000000..cb09dd1 Binary files /dev/null and b/Debug/World.obj differ diff --git a/Debug/vc140.idb b/Debug/vc140.idb new file mode 100644 index 0000000..293317a Binary files /dev/null and b/Debug/vc140.idb differ diff --git a/Debug/vc140.pdb b/Debug/vc140.pdb new file mode 100644 index 0000000..567ab70 Binary files /dev/null and b/Debug/vc140.pdb differ diff --git a/Enemy.h b/Enemy.h index 97075b6..c7dfadf 100644 --- a/Enemy.h +++ b/Enemy.h @@ -1,6 +1,4 @@ #pragma once -#include "Header.h" - class Enemy { public: diff --git a/Entity.cpp b/Entity.cpp new file mode 100644 index 0000000..d04b625 --- /dev/null +++ b/Entity.cpp @@ -0,0 +1,36 @@ +#include "Entity.h" + +#include + +#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(); + } + +} + diff --git a/Entity.h b/Entity.h new file mode 100644 index 0000000..68e48ec --- /dev/null +++ b/Entity.h @@ -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; +}; + diff --git a/Header.h b/Header.h deleted file mode 100644 index c1a99be..0000000 --- a/Header.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once - -#include - -#define _USE_MATH_DEFINES -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "Vector.h" - -using namespace std; \ No newline at end of file diff --git a/InitState.cpp b/InitState.cpp deleted file mode 100644 index ccaebd6..0000000 --- a/InitState.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "InitState.h" - - - -InitState::InitState() -{ -} - - -InitState::~InitState() -{ -} diff --git a/InitState.h b/InitState.h deleted file mode 100644 index 5537e67..0000000 --- a/InitState.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once -#include "Header.h" -#include "State.h" - -class InitState : public State -{ -public: - InitState(); - ~InitState(); -}; - diff --git a/Keyboard.cpp b/Keyboard.cpp deleted file mode 100644 index 3a1ccf9..0000000 --- a/Keyboard.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "Keyboard.h" - - - -Keyboard::Keyboard() -{ -} - - -Keyboard::~Keyboard() -{ -} diff --git a/Keyboard.h b/Keyboard.h deleted file mode 100644 index fcfdc55..0000000 --- a/Keyboard.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once -#include "Header.h" - -class Keyboard -{ -public: - Keyboard(); - ~Keyboard(); -}; - diff --git a/LevelObject.cpp b/LevelObject.cpp new file mode 100644 index 0000000..e054f2c --- /dev/null +++ b/LevelObject.cpp @@ -0,0 +1,12 @@ +#include "LevelObject.h" + + + +LevelObject::LevelObject() +{ +} + + +LevelObject::~LevelObject() +{ +} diff --git a/LevelObject.h b/LevelObject.h new file mode 100644 index 0000000..c0f7770 --- /dev/null +++ b/LevelObject.h @@ -0,0 +1,8 @@ +#pragma once +class LevelObject +{ +public: + LevelObject(); + ~LevelObject(); +}; + diff --git a/LoadingState.cpp b/LoadingState.cpp deleted file mode 100644 index 77015e6..0000000 --- a/LoadingState.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "LoadingState.h" - - - -LoadingState::LoadingState() -{ -} - - -LoadingState::~LoadingState() -{ -} diff --git a/LoadingState.h b/LoadingState.h deleted file mode 100644 index b4c292f..0000000 --- a/LoadingState.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once -#include "Header.h" -#include "State.h" - -class LoadingState : public State -{ -public: - LoadingState(); - ~LoadingState(); -}; - diff --git a/Main.cpp b/Main.cpp index e5533a4..aca6afe 100644 --- a/Main.cpp +++ b/Main.cpp @@ -1,142 +1,17 @@ -#include "Header.h" -#include "Model.h" -#include "Player.h" -#include "StateHandler.h" -#include "State.h" +#include -//Prototypes -void bindFuncOpenGL(void); -void configureOpenGL(void); -void loadModels(void); +#include "CrystalJohan.h" +#include +#include "vector.h" -static int Width; -static int Height; +CrystalJohan* app; -float lastFrameTime = 0; -bool keys[255]; - -//vector 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; } \ No newline at end of file diff --git a/Main.h b/Main.h new file mode 100644 index 0000000..e69de29 diff --git a/MenuState.cpp b/MenuState.cpp deleted file mode 100644 index 02505b5..0000000 --- a/MenuState.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "MenuState.h" - - - -MenuState::MenuState() -{ -} - - -MenuState::~MenuState() -{ -} diff --git a/MenuState.h b/MenuState.h deleted file mode 100644 index 8a36cc1..0000000 --- a/MenuState.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once -#include "Header.h" -#include "State.h" - -class MenuState : public State -{ -public: - MenuState(); - ~MenuState(); -}; \ No newline at end of file diff --git a/Model.cpp b/Model.cpp index a4edc9b..0e32a46 100644 --- a/Model.cpp +++ b/Model.cpp @@ -3,12 +3,17 @@ #define STB_IMAGE_IMPLEMENTATION #include "stb_image.h" -//Prototypes -vector split(string str, string sep); -string replace(string str, string toReplace, string replacement); -string toLower(string data); +#include +#include +#include +#include -Model::Model(string fileName) +//Prototypes +std::vector 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 split(string str, string sep) +std::vector split(std::string str, std::string sep) { std::vector ret; size_t index; @@ -325,8 +309,31 @@ vector 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> Model::cache; + +Model* Model::load(const std::string &fileName) +{ + if (cache.find(fileName) == cache.end()) + cache[fileName] = std::pair(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)); + } +} diff --git a/Model.h b/Model.h index 0ff281e..1e3ba91 100644 --- a/Model.h +++ b/Model.h @@ -1,6 +1,10 @@ #pragma once -#include "Header.h" -#include "ModelInstance.h" + +#include +#include +#include +#include +#include "vector.h" class Model { @@ -16,7 +20,7 @@ private: class Face { public: - list vertices; + std::list vertices; }; class Texture @@ -49,7 +53,7 @@ private: public: std::string name; int materialIndex; - list faces; + std::list faces; }; std::vector vertices; @@ -58,15 +62,16 @@ private: std::vector groups; std::vector materials; - std::vector 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 > cache; + static Model* load(const std::string &fileName); + static void unload(const std::string &fileName); void draw(); }; diff --git a/ModelHandler.cpp b/ModelHandler.cpp deleted file mode 100644 index 60edb27..0000000 --- a/ModelHandler.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "ModelHandler.h" - - - -ModelHandler::ModelHandler() -{ -} - - -ModelHandler::~ModelHandler() -{ -} diff --git a/ModelHandler.h b/ModelHandler.h deleted file mode 100644 index 028afd5..0000000 --- a/ModelHandler.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once -class ModelHandler -{ -public: - ModelHandler(); - ~ModelHandler(); -}; - diff --git a/ModelInstance.cpp b/ModelInstance.cpp deleted file mode 100644 index bed0f80..0000000 --- a/ModelInstance.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "ModelInstance.h" - -ModelInstance::ModelInstance() -{ -} - - -ModelInstance::~ModelInstance() -{ -} diff --git a/ModelInstance.h b/ModelInstance.h deleted file mode 100644 index 6287a2e..0000000 --- a/ModelInstance.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once -#include "Header.h" - -class ModelInstance -{ -private: -public: - ModelInstance(); - ~ModelInstance(); - - Vec3f translation; - Vec3f rotation; - Vec3f scale; - -}; - diff --git a/Mouse.cpp b/Mouse.cpp deleted file mode 100644 index 5722b7b..0000000 --- a/Mouse.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "Mouse.h" - - - -Mouse::Mouse() -{ -} - - -Mouse::~Mouse() -{ -} diff --git a/Mouse.h b/Mouse.h deleted file mode 100644 index 9504022..0000000 --- a/Mouse.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once -#include "Header.h" - -class Mouse -{ -public: - Mouse(); - ~Mouse(); -}; - diff --git a/Player.cpp b/Player.cpp index fc74ffa..e02106a 100644 --- a/Player.cpp +++ b/Player.cpp @@ -1,77 +1,15 @@ #include "Player.h" +#include 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; -} - diff --git a/Player.h b/Player.h index 80a9d21..66159ad 100644 --- a/Player.h +++ b/Player.h @@ -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 { 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 weapons; Player(); - Player(Player const&); - void operator=(Player const&); - //static Player* player; -}; + void setCamera(); + Vec3f position; + Vec2f rotation; + + Model* leftWeapon; + Model* rightWeapon; +}; \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index 36331e4..0000000 --- a/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# CrystalPoint -Crystal Point: The Elemental Labyrinth diff --git a/ReadMe.txt b/ReadMe.txt new file mode 100644 index 0000000..09d0ceb --- /dev/null +++ b/ReadMe.txt @@ -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. + +///////////////////////////////////////////////////////////////////////////// diff --git a/SettingsState.cpp b/SettingsState.cpp deleted file mode 100644 index 6378ddf..0000000 --- a/SettingsState.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "SettingsState.h" - - - -SettingsState::SettingsState() -{ -} - - -SettingsState::~SettingsState() -{ -} diff --git a/SettingsState.h b/SettingsState.h deleted file mode 100644 index 4469361..0000000 --- a/SettingsState.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once -#include "Header.h" -#include "State.h" - -class SettingsState : public State -{ -public: - SettingsState(); - ~SettingsState(); -}; - diff --git a/Singleton.h b/Singleton.h new file mode 100644 index 0000000..fd9236c --- /dev/null +++ b/Singleton.h @@ -0,0 +1,13 @@ +#pragma once + + +template +class Singleton +{ +public: + static T& getInstance() + { + static T* t = new T(); + return *t; + } +}; \ No newline at end of file diff --git a/State.cpp b/State.cpp deleted file mode 100644 index 1e3fd94..0000000 --- a/State.cpp +++ /dev/null @@ -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) -{ -} diff --git a/State.h b/State.h deleted file mode 100644 index 8ef236f..0000000 --- a/State.h +++ /dev/null @@ -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" - diff --git a/StateHandler.cpp b/StateHandler.cpp deleted file mode 100644 index 02bef5b..0000000 --- a/StateHandler.cpp +++ /dev/null @@ -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); -} diff --git a/StateHandler.h b/StateHandler.h deleted file mode 100644 index 712b1d7..0000000 --- a/StateHandler.h +++ /dev/null @@ -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 StateList; -}; - diff --git a/Vector.cpp b/Vector.cpp index 1fa5114..3a3bb8d 100644 --- a/Vector.cpp +++ b/Vector.cpp @@ -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); +} diff --git a/Vector.h b/Vector.h index c578d84..7272adb 100644 --- a/Vector.h +++ b/Vector.h @@ -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); }; diff --git a/Weapon.cpp b/Weapon.cpp deleted file mode 100644 index 559062a..0000000 --- a/Weapon.cpp +++ /dev/null @@ -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(); - } -} - - diff --git a/Weapon.h b/Weapon.h deleted file mode 100644 index c76c473..0000000 --- a/Weapon.h +++ /dev/null @@ -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; -}; - diff --git a/World.cpp b/World.cpp new file mode 100644 index 0000000..f987ce3 --- /dev/null +++ b/World.cpp @@ -0,0 +1,40 @@ +#include "World.h" +#include +#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); +} diff --git a/World.h b/World.h new file mode 100644 index 0000000..0eb5f56 --- /dev/null +++ b/World.h @@ -0,0 +1,22 @@ +#pragma once + +#include +#include "Player.h" + +class Entity; + +class World +{ +public: + World(); + ~World(); + + + Player& player; + std::vector entities; + + void draw(); + void update(float elapsedTime); + +}; + diff --git a/WorldModel.cpp b/WorldModel.cpp deleted file mode 100644 index 61f45cb..0000000 --- a/WorldModel.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "WorldModel.h" - - - -WorldModel::WorldModel() -{ -} - - -WorldModel::~WorldModel() -{ -} diff --git a/WorldModel.h b/WorldModel.h deleted file mode 100644 index 0f7044b..0000000 --- a/WorldModel.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once -#include "Header.h" - -class WorldModel -{ -public: - WorldModel(); - ~WorldModel(); -}; - diff --git a/WorldState.cpp b/WorldState.cpp deleted file mode 100644 index 5aba070..0000000 --- a/WorldState.cpp +++ /dev/null @@ -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); -} - diff --git a/WorldState.h b/WorldState.h deleted file mode 100644 index b6aa04f..0000000 --- a/WorldState.h +++ /dev/null @@ -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; -}; - diff --git a/freeglut/bin/freeglut.dll b/freeglut/bin/freeglut.dll new file mode 100644 index 0000000..c768c15 Binary files /dev/null and b/freeglut/bin/freeglut.dll differ diff --git a/freeglut/bin/x64/freeglut.dll b/freeglut/bin/x64/freeglut.dll new file mode 100644 index 0000000..2fe3a23 Binary files /dev/null and b/freeglut/bin/x64/freeglut.dll differ diff --git a/freeglut/lib/x64/freeglut.lib b/freeglut/lib/x64/freeglut.lib new file mode 100644 index 0000000..69e682f Binary files /dev/null and b/freeglut/lib/x64/freeglut.lib differ