This commit is contained in:
2025-05-13 02:46:21 +03:00
parent 143e16692e
commit 86914b7fcc
610 changed files with 92343 additions and 2 deletions
+171
View File
@@ -0,0 +1,171 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClInclude Include="include\MyGame.h" />
<ClInclude Include="include\states\StateGame.h" />
<ClInclude Include="include\states\StateSettings.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\states\StateGame.cpp" />
<ClCompile Include="src\states\StateSettings.cpp" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{55D99FD8-2A69-48FD-A060-D04D5A4A705D}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>MyGame</RootNamespace>
<SccProjectName>&lt;Project Location In Database&gt;</SccProjectName>
<SccAuxPath>&lt;Source Control Database&gt;</SccAuxPath>
<SccLocalPath>&lt;Local Binding Root of Project&gt;</SccLocalPath>
<SccProvider>Mercurial Source Control Package</SccProvider>
<VCTargetsPath Condition="'$(VCTargetsPath11)' != '' and '$(VSVersion)' == '' and $(VisualStudioVersion) == ''">$(VCTargetsPath11)</VCTargetsPath>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(REPO_DIR)/angelscript/include;.\include;$(REPO_DIR)\ois-v1-3\includes;$(REPO_DIR)\bullet-2.78\src;..\LifeEngine\include;..\LifeGame\include;$(SolutionDir)\LifeCore\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<Lib>
<OutputFile>lib\Crysis_d.lib</OutputFile>
<AdditionalDependencies>LifeEngine_d.lib;LifeGame_d.lib;LifeCore_d.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>$(REPO_DIR)\ois-v1-3\lib;$(REPO_DIR)\bullet-2.78\lib;..\LifeEngine\lib;..\LifeGame\lib;$(SolutionDir)\LifeCore\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(REPO_DIR)/angelscript/include;.\include;$(REPO_DIR)\ois-v1-3\includes;$(REPO_DIR)\bullet-2.78\src;..\LifeEngine\include;..\LifeGame\include;$(SolutionDir)\LifeCore\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<Lib>
<OutputFile>lib\Crysis_d.lib</OutputFile>
<AdditionalDependencies>LifeEngine_d.lib;LifeGame_d.lib;LifeCore_d.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>$(REPO_DIR)\ois-v1-3\lib;$(REPO_DIR)\bullet-2.78\lib;..\LifeEngine\lib;..\LifeGame\lib;$(SolutionDir)\LifeCore\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(REPO_DIR)/angelscript/include;.\include;$(REPO_DIR)\ois-v1-3\includes;$(REPO_DIR)\bullet-2.78\src;..\LifeEngine\include;..\LifeGame\include;$(SolutionDir)\LifeCore\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<Lib>
<OutputFile>lib\Crysis.lib</OutputFile>
<AdditionalDependencies>LifeEngine.lib;LifeGame.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>$(REPO_DIR)\ois-v1-3\lib;$(REPO_DIR)\freetype-2.4.3\objs\win32\vc2008;$(REPO_DIR)\bullet-2.78\lib;..\LifeEngine\lib;..\LifeGame\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(REPO_DIR)/angelscript/include;.\include;$(REPO_DIR)\ois-v1-3\includes;$(REPO_DIR)\bullet-2.78\src;..\LifeEngine\include;..\LifeGame\include;$(SolutionDir)\LifeCore\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<Lib>
<OutputFile>lib\Crysis.lib</OutputFile>
<AdditionalDependencies>LifeEngine.lib;LifeGame.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>$(REPO_DIR)\ois-v1-3\lib;$(REPO_DIR)\freetype-2.4.3\objs\win32\vc2008;$(REPO_DIR)\bullet-2.78\lib;..\LifeEngine\lib;..\LifeGame\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Lib>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
+382
View File
@@ -0,0 +1,382 @@
#ifndef MyGame_h__
#define MyGame_h__
#include "Game.h"
#include "Actor.h"
#include <Player.h>
#include "InputSystemOIS.h"
#include "states/StateGame.h"
#include <states/StateSettings.h>
#include "EntityFactory.h"
#include "gui/GUIButton.h"
#include "gui/GUIText.h"
#include "gui/GUITextInput.h"
#include "gui/GUIFont.h"
#include "Spectator.h"
static const Vec3f colors[6] =
{
Vec3f(0,1,0),
Vec3f(1, 0, 1),
Vec3f(1, 0, 0),
Vec3f(0,0,1),
Vec3f(1,1,0),
Vec3f(1,1,1)
};
class MyGame : public Game
{
public:
Light* l;
Light* l2;
Light* l3;
MyGame()
{
}
~MyGame()
{
}
void Load(int _mainWindow, IRenderWindow* _outWindow)
{
if(_mainWindow)
{
customWindow = true;
output = _outWindow;
mainWindow = _mainWindow;
}
Video::Timer t;
Camera cam;
cam.setPosition(Vec3f(0.0f,0.0f,0.0f));
cam.setDirection(Vec3f(-100.0f,0.0f,0.0f));
Matrix4x4 v = cam.getView();
Vec3f vector(0.0f, 10.0f, 10.0f);
Vec3f rs;
Vec3TransformCoordinate(vector, v, rs);
Range<unsigned long> r(0x0410, 0x04ff);
// GUIFont* fnt = new GUIFont(&r,1);
//CLog::me()->LogToConsole(true);
//CLog::me()->Write(AS_STRING("Creating new game"));
//SetResourcesPath(AS_STRING("C:\\development\\Programming\\Projects\\Data\\"));
//IPakFileContentProvider pp( _text("C:\\Data.pak"));
//IPakFileContentProvider pp( _text("Data.pak"));
//String mp(_text("root"));
//ResourceManager::me()->MountContentProvider(&pp, mp);
t.Start();
if(!customWindow)
{
SetWindow(1200, 700);
mainWindow = output->GetWindowHandle();
}
GetWindow()->SetCaption(STR("Crysis 4. DirectX11. over9000 fps"));
t.Stop();
printf("Window creation: %f\n", t.getTimeElapsed());
t.Start();
InitVideo(RT_DIRECTX_11);
t.Stop();
printf("Video creation: %f\n", t.getTimeElapsed());
t.Start();
InitInput();
t.Stop();
printf("Input creation: %f\n", t.getTimeElapsed());
gameWorld = new World(this, pGraphics->GetSceneManager()->GetActiveScene(), physicsWorld);
/*int modeCount = GetGraphics()->GetMainRenderer()->GetDisplayModes(&modes);
for(int i = 0; i < modeCount; i++)
{
printf("Mode ID: %i\n", i);
printf("Mode width: %i\n", modes[i].width);
printf("Mode height: %i\n", modes[i].height);
printf("Mode rate: %i\n", modes[i].refreshRate);
}*/
t.Start();
int ci = 0;
/*float fieldSize = 3.5f;
int cnt = 4;
Vec3f offset(-fieldSize/2.0f,1.05f, fieldSize / 2.0f);
float step = fieldSize / (float)cnt;*/
/*for(int z = 0; z < cnt; z++)
{
for(int x = 0; x < cnt; x++)
{
Light* l = pGraphics->GetResourceManager()->CreatePointLight(offset + Vec3f(step * (float)x, 0, -step * float(z)), 4.35f);
l->color = colors[ci];
l->intensity = 2.0f;
l->specularPower = 28.0f;
pGraphics->GetSceneManager()->GetActiveScene()->PushNode(l);
//Light* l = pGraphics->GetResourceManager()->CreateSpotLight(offset + Vec3f(step * (float)x, 0, -step * (float)z),offset + Vec3f(step * (float)x, -1.0f, -step * (float)z),5.0f,1.0f, 1.2f);
//l->color = colors[ci];
//l->intensity = 2.0f;
//l->specularPower = 28.0f;
//l->castShadows = false;
//pGraphics->GetSceneManager()->GetActiveScene()->PushNode(l);
ci++;
if(ci>=6) ci = 0;
}
}*/
/*
l2 = pGraphics->GetResourceManager()->CreatePointLight(Vec3f(0.5f,0.4f,0), 3.0f);
l2->color = colors[2];
l2->intensity = 1.0f;
l2->specularPower = 28.0f;
l2->castShadows = true;
pGraphics->GetSceneManager()->GetActiveScene()->PushNode(l2);
l3 = pGraphics->GetResourceManager()->CreatePointLight(Vec3f(1.5f,0.4f,0), 3.0f);
l3->color = colors[3];
l3->intensity = 1.0f;
l3->specularPower = 28.0f;
l3->castShadows = true;
pGraphics->GetSceneManager()->GetActiveScene()->PushNode(l3);
*/
l = pGraphics->GetResourceManager()->CreatePointLight(Vec3f(0.0f,0.4f,0), 3.0f);
l->color = colors[0];
l->intensity = 1.0f;
l->specularPower = 28.0f;
l->castShadows = true;
pGraphics->GetSceneManager()->GetActiveScene()->PushNode(l);
Light* l2 = pGraphics->GetResourceManager()->CreateSpotLight(Vec3f(0.2f,1.0f,0.0f),Vec3f(0.0f,0.5f,1.6f),5.0f,1.3f, 1.40f);
l2->color = Vec3f(1.0f,1.0f,1.0f);
l2->intensity = 1.0f;
l2->specularPower = 28.0f;
l2->castShadows = true;
pGraphics->GetSceneManager()->GetActiveScene()->PushNode(l2);
t.Stop();
printf("Light creation: %f\n", t.getTimeElapsed());
IMaterial* mat2 = new IMaterial();
mat2->castShadows = false;
mat2->shininess = 0.3f;
mat2->specularPower = 20.0f;
mat2->normalMapping = true;
mat2->diffuseMap = ResourceManager::me()->GetTexture("root/Data/Textures/Rock/rock.jpg");
mat2->normalMap = ResourceManager::me()->GetTexture("root/Data/Textures/Rock/rockNormal.jpg");
Entity* floor = new Entity();
IGraphicsEntity* floorVisual = new IGraphicsEntity(GetGraphics());
IMesh* mesh = ResourceManager::me()->GetMesh("root/Data/Objects/House_opt.vmf");
IObjectMesh* go = new IObjectMesh(mesh);
IMaterial* mat = new IMaterial();
mat->castShadows = false;
mat->shininess = 1;
mat->specularPower = 50.0f;
mat->normalMapping = true;
mat->diffuseMap = ResourceManager::me()->GetTexture("root/Data/Textures/basic_floor_s.BMP");
mat->normalMap = ResourceManager::me()->GetTexture("root/Data/Textures/basic_floor_s_ddn.BMP");
go->setMaterial(mat, 0);
floorVisual->SetBody(go);
floor->SetGraphicalEntity(floorVisual);
IPhysicsEntity* pe = new IPhysicsEntity(floor);
pe->CreateRigidBodyPhysics(Vec3f(0, 0, 0), go->getBoundingBox(), 0, NULL);
floor->SetPhysicsEntity(pe);
gameWorld->AddEntity(floor);
float fieldSize = 3.5f;
int cnt = 4;
Vec3f offset(-fieldSize/2.0f,1.05f, fieldSize / 2.0f);
float step = fieldSize / (float)cnt;
for(int z = 0; z < cnt; z++)
{
for(int x = 0; x < cnt; x++)
{
Entity* thing = new Entity();
IGraphicsEntity* thingVisual = new IGraphicsEntity(GetGraphics());
thingVisual->Load("root/Data/Objects/Tower_opt.vmf");
thingVisual->GetBody()->setMaterial(mat2, 0);
thing->SetGraphicalEntity(thingVisual);
IPhysicsEntity* pe2 = new IPhysicsEntity(thing);
pe2->CreateRigidBodyPhysics(Vec3f(0, 0, 0), thingVisual->GetBody()->getBoundingBox(), 0, NULL);
thing->SetPhysicsEntity(pe2);
gameWorld->AddEntity(thing);
thing->GetTransform()->SetPosition(Vec3f((float)x * step - 0.8f,0.2f,(float)z*step -1.5f));
}
}
/*
Light* l = pGraphics->GetResourceManager()->CreateSpotLight(Vec3f(1.2f,2.2f,1.2f),Vec3f(1.4f,0.0f,1.4f),5.0f,1.3f, 1.99f);
l->color = Vec3f(1.0f,1.0f,1.0f);
l->intensity = 1.0f;
l->specularPower = 28.0f;
l->castShadows = true;
pGraphics->GetSceneManager()->GetActiveScene()->PushNode(l);*/
/*Light* l2 = pGraphics->GetResourceManager()->CreateSpotLight(Vec3f(-1.6f,2.2f,0.4f),Vec3f(-1.6f,0.0f,0.4f),4.0f,1.0f, 1.5f);
l2->color = Vec3f(0.0f,0.0f,1.0f);
l2->intensity = 2.0f;
l2->specularPower = 28.0f;
l2->castShadows = false;
pGraphics->GetSceneManager()->GetActiveScene()->PushNode(l2);*/
/*player = (Player*)EntityFactory::me()->BuildEntity(AS_STRING("root/Data/Entities/thing.xml"), this);
player->GetTransform()->SetPosition(Vec3f(0.3f,0.5f,0.2f));
player->GetTransform()->SetRotation(Vec3f(0.0f,1.0f,0.0f), 1.0f);
player->GetGraphicalEntity()->pMesh->getMaterial(0)->shininess = 0.5f;
player->GetGraphicalEntity()->pMesh->getMaterial(0)->specularPower = 15.0f;*/
/*t.Start();
Entity* hall = EntityFactory::me()->BuildEntity(AS_STRING("root/Data/Entities/level_0_p0.xml"), this);
gameWorld->AddEntity(hall);
t.Stop();
printf("Hall creation: %f\n", t.getTimeElapsed());
t.Start();
Entity* crate = EntityFactory::me()->BuildEntity(AS_STRING("root/Data/Entities/crate_small.xml"), this);
crate->GetTransform()->SetPosition(Vec3f(-1.0f, 0.8f, 0.0f));
gameWorld->AddEntity(crate);
t.Stop();
printf("Crate creation: %f\n", t.getTimeElapsed());
t.Start();
Entity* tv = EntityFactory::me()->BuildEntity(AS_STRING("root/Data/Entities/tv_flat.xml"), this);
tv->GetTransform()->SetPosition(Vec3f(-4.0f, 1.6f, -1.4f));
tv->GetTransform()->SetRotation(Vec3f(0.0f,1.0f,0.0f), 3.1415926535f);
gameWorld->AddEntity(tv);
t.Stop();
printf("TV creation: %f\n", t.getTimeElapsed());*/
//miranda->Save();
StateGame* gs = new StateGame(AS_STRING("gameplay"), this);
stateManager.AddState(gs->GetName(), gs);
StateSettings* sm = new StateSettings("settings_menu", this);
stateManager.AddState(sm->GetName(), sm);
actionMap.MapAction(ACTION_FORWARD, KEY_W);
actionMap.MapAction(ACTION_BACKWARD, KEY_S);
actionMap.MapAction(ACTION_LEFT, KEY_A);
actionMap.MapAction(ACTION_RIGHT, KEY_D);
actionMap.MapAction(ACTION_JUMP, KEY_SPACE);
actionMap.MapAction(ACTION_ACCELERATION, KEY_LSHIFT);
actionMap.MapAction(ACTION_FIRE, KEY_MOUSE_LEFT);
actionMap.MapAction(ACTION_USE, KEY_F);
actionMap.MapAction(ACTION_TURNLR, KEY_AXIS_X);
actionMap.MapAction(ACTION_TURNUD, KEY_AXIS_Y);
//Spectator* sp = new Spectator(this);
//sp->GetTransform()->SetPosition(Vec3f(0,1,0));
Player* p = new Player(this);
gameWorld->AddEntity(p);
SetPlayer(p);
/* GUIManager* gui = GetGraphics()->GetGUI();
GUIManager::me()->AddOverlay(AS_STRING("main_menu"));
GUIOverlay* mainMenu = GUIManager::me()->GetOverlay(AS_STRING("main_menu"));
//add button
GUIButton* button = new GUIButton(gui);
button->SetPosition(Vec2i(50,50));
button->SetWidth(200);
button->SetHeight(50);
button->SetBackColor(Vec4f(1.0f,0.0f,0.0f,0.99f));
mainMenu->AddChild(button);
//add button
GUIButton* button2 = new GUIButton(gui);
button2->SetPosition(Vec2i(50,110));
button2->SetWidth(200);
button2->SetHeight(50);
button2->SetBackColor(Vec4f(0.0f,1.0f,0.0f,0.99f));
mainMenu->AddChild(button2);
//add button
GUIButton* button3 = new GUIButton(gui);
button3->SetPosition(Vec2i(50,170));
button3->SetWidth(200);
button3->SetHeight(50);
button3->SetBackColor(Vec4f(0.0f,0.0f,1.0f,0.99f));
mainMenu->AddChild(button3);
button->Event_MouseEnter+=NewDelegate(this, &CrysisGame::BT1Entered);
button->Event_MouseLeave+=NewDelegate(this, &CrysisGame::BT1Leaved);
button->Event_MouseClick+=NewDelegate(this, &CrysisGame::BT1Click);
button->Event_MouseRightClick+=NewDelegate(this, &CrysisGame::BT1RightClick);
button->Event_MouseMiddleClick+=NewDelegate(this, &CrysisGame::BT1MiddleClick);
GUITextInput* ti = new GUITextInput(gui);
ti->SetPosition(Vec2i(320,50));
mainMenu->AddChild(ti);
GUITextInput* ti2 = new GUITextInput(gui);
ti2->SetPosition(Vec2i(320,100));
mainMenu->AddChild(ti2);
//add text
GUIText* text = new GUIText(gui);
mainMenu->AddChild(text);
text->SetPosition(Vec2i(50,5));
text->SetWidth(200);
text->SetText(STR("Ýòî êíîïêè! ÊÝÝÝÏ"));
text->SetBackColor(Vec4f(0.2f,0.2f,0.3f,0.9f));;
text->SetHAlign(HA_LEFT);
text->SetVAlign(VA_CENTER);
//add text
GUIText* text2 = new GUIText(gui);
mainMenu->AddChild(text2);
text2->SetPosition(Vec2i(320,5));
text2->SetWidth(200);
text2->SetText(STR("EditBox-û!"));
text2->SetBackColor(Vec4f(0.2f,0.2f,0.3f,0.9f));
text2->SetHAlign(HA_LEFT);
text2->SetVAlign(VA_CENTER);*/
}
void DoMainLoop()
{
bRunning = true;
while(bRunning)
{
//l = pGraphics->GetResourceManager()->CreatePointLight(Vec3f(-0.5f,0.4f,0), 3.0f);
/*l->intensity = cosf(GetGraphics()->appTime) * 0.5f + 1.2f;
l->getTransform()->SetPosition(Vec3f(sinf(GetGraphics()->appTime) * 0.5f, 0.4f, cosf(GetGraphics()->appTime) * 0.5f));
//l2 = pGraphics->GetResourceManager()->CreatePointLight(Vec3f(0.5f,0.4f,0), 3.0f);
l2->intensity = sinf(GetGraphics()->appTime + 0.25f) * 0.5f + 1.2f;
l2->getTransform()->SetPosition(Vec3f(0.5f, 0.4f, cosf(GetGraphics()->appTime) * 1.5f));
//l3 = pGraphics->GetResourceManager()->CreatePointLight(Vec3f(1.5f,0.4f,0), 3.0f);
l3->intensity = cosf(GetGraphics()->appTime + 0.75f) * 0.5f + 1.2f;
l3->getTransform()->SetPosition(Vec3f(1.5f, 0.4f, sinf(GetGraphics()->appTime) * 1.5f));*/
this->process();
}
}
};
#endif // MyGame_h__
+27
View File
@@ -0,0 +1,27 @@
#ifndef StateGame_h__
#define StateGame_h__
#include "IGameState.h"
#include "ActionBuffer.h"
class MyGame;
class StateGame : public IGameState
{
public:
StateGame(const String& name, MyGame* engine);
void Update();
void Render();
void OnEnter();
void OnLeave();
void ProcessCmd(const String& cmd, void* params);
bool KeyDown( Core::Key key, unsigned int text, const std::string& str );
bool KeyUp( Core::Key key, unsigned int text, const std::string& str );
bool MouseMove( int absX, int relX, int absY, int relY);
bool MousePressed(int buttonId);
bool MouseReleased(int buttonId);
private:
MyGame* pGame;
ActionBuffer playerActions;
};
#endif // StateGame_h__
+33
View File
@@ -0,0 +1,33 @@
#ifndef StateSettings_h__
#define StateSettings_h__
#include "IGameState.h"
#include "ActionBuffer.h"
#include <gui/GUIManager.h>
#include <gui/GUIOverlay.h>
#include <gui/GUIComboBox.h>
#include <gui/GUIPlane.h>
class MyGame;
class StateSettings : public IGameState
{
public:
StateSettings(const String& name, MyGame* engine);
void Update();
void Render();
void OnEnter();
void OnLeave();
void ProcessCmd(const String& cmd, void* params);
bool KeyDown( Key key, unsigned int text, const std::string& str );
bool KeyUp( Key key, unsigned int text, const std::string& str );
bool MouseMove( int absX, int relX, int absY, int relY);
bool MousePressed(int buttonId);
bool MouseReleased(int buttonId);
private:
MyGame* pGame;
GUIOverlay* pMenu;
};
#endif // StateSettings_h__
+156
View File
@@ -0,0 +1,156 @@
#include "states/StateGame.h"
#include "MyGame.h"
StateGame::StateGame(const String& name, MyGame* engine) : IGameState(name)
{
pGame = engine;
pGame->GetInput()->AddListener(pGame->GetGraphics()->GetGUI());
}
void StateGame::Update()
{
playerActions.Reset();
//grab input actions
int num = pGame->GetActionMap()->Size();
pGame->GetActionMap()->ResetIterator();
for(int i = 0; i< num; i++)
{
Key k = pGame->GetActionMap()->CurrentKey();
GameAction a = pGame->GetActionMap()->CurrentAction();
if(k == KEY_WHEEL_UP | k == KEY_WHEEL_DOWN)
{
int state = pGame->GetInput()->GetMouseWheel();
if(state > 0 && k == KEY_WHEEL_UP)
{
playerActions.AddAction(a);
}
else if(state < 0 && k == KEY_WHEEL_DOWN)
{
playerActions.AddAction(a);
}
}
else if(k == KEY_AXIS_X)
{
int i = pGame->GetInput()->GetMouseRelativeX();
if(i)
playerActions.AddAction(a);
}
else if(k == KEY_AXIS_Y)
{
int i = pGame->GetInput()->GetMouseRelativeY();
if(i)
playerActions.AddAction(a);
}
else if(k > KEY_MOUSE_OFFSET)
{
if(pGame->GetInput()->MouseButtonPressed(k))
playerActions.AddAction(a);
}
else
{
if(pGame->GetInput()->KeyPressed(k))
{
playerActions.AddAction(a);
}
}
pGame->GetActionMap()->MoveNext();
}
if(pGame->player)
pGame->player->ProcessActions(&playerActions);
float moveSpeed = 7.0f;
if(pGame->GetInput()->KeyPressed(KEY_ESCAPE))
{
pGame->Exit();
}
pGame->GetWorld()->Update(pGame->GetGraphics()->GetTimeElapsed());
pGame->GetGraphics()->GetGUI()->Update(pGame->GetGraphics()->GetTimeElapsed());
pGame->GetPhysics()->Tick(pGame->GetGraphics()->GetTimeElapsed());
pGame->GetGraphics()->GetSceneManager()->GetActiveScene()->Update(pGame->GetGraphics()->GetTimeElapsed());
/*if(pGame->GetInput()->KeyPressed(KEY_W))
{
Vec3f pos = pGame->cam.getPosition();
Vec3f dir = pGame->cam.getDirection();
pos += dir * pGame->GetGraphics()->getTimeElapsed() * moveSpeed;
pGame->cam.setPosition(pos);
}
if(pGame->GetInput()->KeyPressed(KEY_S))
{
Vec3f pos = pGame->cam.getPosition();
Vec3f dir = pGame->cam.getDirection();
pos += dir * -pGame->GetGraphics()->getTimeElapsed() * moveSpeed;
pGame->cam.setPosition(pos);
}
if(pGame->GetInput()->KeyPressed(KEY_A))
{
Vec3f pos = pGame->cam.getPosition();
Vec3f dir = pGame->cam.getRight();
pos += dir * -pGame->GetGraphics()->getTimeElapsed()* moveSpeed;
pGame->cam.setPosition(pos);
}
if(pGame->GetInput()->KeyPressed(KEY_D))
{
Vec3f pos = pGame->cam.getPosition();
Vec3f dir = pGame->cam.getRight();
pos += dir * pGame->GetGraphics()->getTimeElapsed()* moveSpeed;
pGame->cam.setPosition(pos);
}
if(pGame->GetInput()->GetMouseRelativeX() != 0)
{
pGame->cam.Yaw((float)pGame->GetInput()->GetMouseRelativeX() / 300.0f);
}
if(pGame->GetInput()->GetMouseRelativeY() != 0)
{
pGame->cam.Pitch((float)pGame->GetInput()->GetMouseRelativeY() / 300.0f);
}*/
}
bool StateGame::KeyDown( Key key, unsigned int text, const std::string& str )
{
return true;
}
bool StateGame::KeyUp( Key key, unsigned int text, const std::string& str )
{
if(key == KEY_M)
{
pGame->GetStateManager()->SelectState(AS_STRING("settings_menu"));
}
return true;
}
bool StateGame::MouseMove( int absX, int relX, int absY, int relY)
{
return true;
}
bool StateGame::MousePressed(int buttonId)
{
return true;
}
bool StateGame::MouseReleased(int buttonId)
{
return true;
}
void StateGame::Render()
{
//
//
pGame->GetGraphics()->GetSceneManager()->GetActiveScene()->Render();
//render physics debug info
pGame->DrawDebug();
//pGame->GetGraphics()->GetGUI()->Render();
}
void StateGame::ProcessCmd(const String& cmd, void* params)
{
}
void StateGame::OnEnter()
{
}
void StateGame::OnLeave()
{
}
+70
View File
@@ -0,0 +1,70 @@
#include "states/StateSettings.h"
#include "MyGame.h"
StateSettings::StateSettings(const String& name, MyGame* engine) : IGameState(name)
{
pGame = engine;
pGame->GetGraphics()->GetGUI()->AddOverlay(AS_STRING("settings_menu"));
pMenu = pGame->GetGraphics()->GetGUI()->GetOverlay(AS_STRING("settings_menu"));
pMenu->drawBackground = true;
/*GUIButton* button2 = new GUIButton(pGame->GetGraphics()->GetGUI());
button2->SetPosition(Vec2i(50,110));
button2->SetWidth(200);
button2->SetHeight(50);
button2->SetBackColor(Vec4f(0.0f,1.0f,0.0f,0.99f));
pMenu->AddChild(button2);*/
GUIComboBox* res = new GUIComboBox(pGame->GetGraphics()->GetGUI());
res->SetPosition(Vec2i(100,10));
pMenu->AddChild(res);
/* GUIPlane* plane = new GUIPlane(pGame->GetGraphics()->GetGUI());
plane->SetBorderEnabled(true);
plane->SetWidth(300);
pMenu->AddChild(plane);*/
}
void StateSettings::Update()
{
pGame->GetGraphics()->GetGUI()->Update(pGame->GetGraphics()->GetTimeElapsed());
}
void StateSettings::Render()
{
pGame->GetGraphics()->GetGUI()->Render();
}
void StateSettings::OnEnter()
{
pGame->GetGraphics()->GetGUI()->SelectOverlay(AS_STRING("settings_menu"));
}
void StateSettings::OnLeave()
{
}
void StateSettings::ProcessCmd(const String& cmd, void* params)
{
}
bool StateSettings::KeyDown( Key key, unsigned int text, const std::string& str )
{
return true;
}
bool StateSettings::KeyUp( Key key, unsigned int text, const std::string& str )
{
if(key == KEY_M)
{
pGame->GetStateManager()->SelectState(AS_STRING("gameplay"));
}
return true;
}
bool StateSettings::MouseMove( int absX, int relX, int absY, int relY)
{
return true;
}
bool StateSettings::MousePressed(int buttonId)
{
return true;
}
bool StateSettings::MouseReleased(int buttonId)
{
return true;
}