# HG changeset patch # User koryspansel # Date 1317657488 25200 # Node ID b0f642ee22d3a832767bbf5ed83127c4937d5442 # Parent 63806b850aa523231c0dd6cfcfca16a92cfa794e Additional maps diff -r 63806b850aa5 -r b0f642ee22d3 Assets/Maps/map04.def --- a/Assets/Maps/map04.def Fri Sep 30 22:48:03 2011 -0700 +++ b/Assets/Maps/map04.def Mon Oct 03 08:58:08 2011 -0700 @@ -3,11 +3,11 @@ # 7,7 -1,0 +0,0 0 (1,1)(1,1)(1,1)(1,1)(1,1)(1,1)(1,1) -(1,0)(1,0)(1,0)(1,0)(1,0)(1,0)(1,1) +(1,1)(1,0)(1,0)(1,0)(1,0)(1,0)(1,1) (1,1)(1,0)(1,0)(1,0)(1,0)(1,0)(1,1) (1,1)(1,0)(1,0)(1,0)(1,0)(1,0)(1,1) (1,1)(1,0)(1,0)(1,0)(1,0)(1,0)(1,1) diff -r 63806b850aa5 -r b0f642ee22d3 Assets/Maps/map05.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Assets/Maps/map05.def Mon Oct 03 08:58:08 2011 -0700 @@ -0,0 +1,15 @@ +# +# map05 +# + +7,7 +3,1 +1 + +(1,0)(1,0)(1,0)(1,0)(1,0)(1,0)(1,0) +(1,0)(1,0)(1,0)(1,0)(2,0)(1,0)(1,0) +(1,0)(1,0)(1,0)(1,0)(2,0)(1,0)(1,0) +(1,0)(1,0)(1,0)(1,0)(2,0)(1,0)(1,0) +(1,0)(1,0)(5,1)(4,0)(3,0)(1,0)(1,0) +(1,0)(1,0)(1,0)(1,0)(1,0)(1,0)(1,0) +(1,0)(1,0)(1,0)(1,0)(1,0)(1,0)(1,0) diff -r 63806b850aa5 -r b0f642ee22d3 Assets/Maps/map06.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Assets/Maps/map06.def Mon Oct 03 08:58:08 2011 -0700 @@ -0,0 +1,15 @@ +# +# map05 +# + +7,7 +3,1 +0 + +(1,0)(1,0)(1,0)(1,0)(1,0)(1,0)(1,0) +(1,0)(1,0)(4,1)(1,0)(2,0)(1,0)(1,0) +(1,0)(1,0)(3,0)(1,0)(2,0)(1,0)(1,0) +(1,0)(1,0)(2,0)(1,0)(2,0)(1,0)(1,0) +(1,0)(1,0)(2,0)(1,0)(3,0)(1,0)(1,0) +(1,0)(1,0)(2,0)(1,0)(4,1)(1,0)(1,0) +(1,0)(1,0)(1,0)(1,0)(1,0)(1,0)(1,0) diff -r 63806b850aa5 -r b0f642ee22d3 Assets/UI/Background04.PSD Binary file Assets/UI/Background04.PSD has changed diff -r 63806b850aa5 -r b0f642ee22d3 Assets/UI/Bot.PSD Binary file Assets/UI/Bot.PSD has changed diff -r 63806b850aa5 -r b0f642ee22d3 Assets/UI/Button2D.PSD Binary file Assets/UI/Button2D.PSD has changed diff -r 63806b850aa5 -r b0f642ee22d3 Assets/UI/Button2H.PSD Binary file Assets/UI/Button2H.PSD has changed diff -r 63806b850aa5 -r b0f642ee22d3 Assets/UI/Button2N.PSD Binary file Assets/UI/Button2N.PSD has changed diff -r 63806b850aa5 -r b0f642ee22d3 Data/Maps/map04.map Binary file Data/Maps/map04.map has changed diff -r 63806b850aa5 -r b0f642ee22d3 Data/Maps/map05.map Binary file Data/Maps/map05.map has changed diff -r 63806b850aa5 -r b0f642ee22d3 Data/Maps/map06.map Binary file Data/Maps/map06.map has changed diff -r 63806b850aa5 -r b0f642ee22d3 Data/Shaders/Environment.fx --- a/Data/Shaders/Environment.fx Fri Sep 30 22:48:03 2011 -0700 +++ b/Data/Shaders/Environment.fx Mon Oct 03 08:58:08 2011 -0700 @@ -7,8 +7,8 @@ sampler TextureSampler = sampler_state { Texture = ; - MinFilter = ANISOTROPIC; - MagFilter = ANISOTROPIC; + MinFilter = LINEAR; + MagFilter = LINEAR; AddressU = CLAMP; AddressV = CLAMP; }; @@ -24,23 +24,36 @@ * kTextureCoords */ float2 kTextureCoords : TEXCOORD0; + + /* + * kNormal + */ + float3 kColor : COLOR0; }; VertexOutput EnvironmentVS(float3 kVertexPosition : POSITION0, float3 kVertexNormal : NORMAL, float2 kTextureCoords : TEXCOORD0) { float4x4 kWorldViewProjection = mul(mul(kWorld, kView), kProjection); + + float4 kDiffuse = float4(0.8f, 0.8f, 0.8f, 1.0f); + float4 kAmbient = float4(0.4f, 0.4f, 0.4f, 1.0f); + float3 kDirection = normalize(float3(-1.0f, -0.60f, -0.3f)); + + float3 kNormal = normalize(mul(kVertexNormal, (float3x3)kWorld)); VertexOutput kOutput; kOutput.kPosition = mul(float4(kVertexPosition, 1.0f), kWorldViewProjection); kOutput.kTextureCoords = kTextureCoords; + kOutput.kColor = kAmbient + kDiffuse * saturate(dot(-kDirection, kNormal)); return kOutput; } -float4 EnvironmentPS(float2 kTextureCoords : TEXCOORD0) : COLOR0 +float4 EnvironmentPS(float4 kDiffuseColor : COLOR0, float2 kTextureCoords : TEXCOORD0) : COLOR0 { float4 kTexture = tex2D(TextureSampler, kTextureCoords); - return float4(kTexture.rgb * kColor.rgb, kTexture.a); + + return float4(kTexture.rgb * kDiffuseColor.rgb * kColor.rgb, kTexture.a); } technique Default diff -r 63806b850aa5 -r b0f642ee22d3 Data/Textures/Background04.TGA Binary file Data/Textures/Background04.TGA has changed diff -r 63806b850aa5 -r b0f642ee22d3 Data/Textures/Bot.tga Binary file Data/Textures/Bot.tga has changed diff -r 63806b850aa5 -r b0f642ee22d3 Data/Textures/Button2D.png Binary file Data/Textures/Button2D.png has changed diff -r 63806b850aa5 -r b0f642ee22d3 Data/Textures/Button2H.png Binary file Data/Textures/Button2H.png has changed diff -r 63806b850aa5 -r b0f642ee22d3 Data/Textures/Button2N.png Binary file Data/Textures/Button2N.png has changed diff -r 63806b850aa5 -r b0f642ee22d3 LightClone/LightClone.vcproj --- a/LightClone/LightClone.vcproj Fri Sep 30 22:48:03 2011 -0700 +++ b/LightClone/LightClone.vcproj Mon Oct 03 08:58:08 2011 -0700 @@ -525,7 +525,7 @@ Name="VCCustomBuildTool" Description="Building $(InputName)..." CommandLine="$(SolutionDir)LightTools\Build.py $(InputName).def " - AdditionalDependencies="$(SolutionDir)Assets\Maps\$(InputName).def" + AdditionalDependencies="" Outputs="$(SolutionDir)Data\Maps\$(InputName).map" /> @@ -536,7 +536,7 @@ Name="VCCustomBuildTool" Description="Building $(InputName)..." CommandLine="$(SolutionDir)LightTools\Build.py $(InputName).def " - AdditionalDependencies="$(SolutionDir)Assets\Maps\$(InputName).def" + AdditionalDependencies="" Outputs="$(SolutionDir)Data\Maps\$(InputName).map" /> @@ -551,7 +551,7 @@ Name="VCCustomBuildTool" Description="Building $(InputName)..." CommandLine="$(SolutionDir)LightTools\Build.py $(InputName).def " - AdditionalDependencies="$(SolutionDir)Assets\Maps\$(InputName).def" + AdditionalDependencies="" Outputs="$(SolutionDir)Data\Maps\$(InputName).map" /> @@ -562,7 +562,7 @@ Name="VCCustomBuildTool" Description="Building $(InputName)..." CommandLine="$(SolutionDir)LightTools\Build.py $(InputName).def " - AdditionalDependencies="$(SolutionDir)Assets\Maps\$(InputName).def" + AdditionalDependencies="" Outputs="$(SolutionDir)Data\Maps\$(InputName).map" /> @@ -577,7 +577,7 @@ Name="VCCustomBuildTool" Description="Building $(InputName)..." CommandLine="$(SolutionDir)LightTools\Build.py $(InputName).def " - AdditionalDependencies="$(SolutionDir)Assets\Maps\$(InputName).def" + AdditionalDependencies="" Outputs="$(SolutionDir)Data\Maps\$(InputName).map" /> @@ -588,7 +588,7 @@ Name="VCCustomBuildTool" Description="Building $(InputName)..." CommandLine="$(SolutionDir)LightTools\Build.py $(InputName).def " - AdditionalDependencies="$(SolutionDir)Assets\Maps\$(InputName).def" + AdditionalDependencies="" Outputs="$(SolutionDir)Data\Maps\$(InputName).map" /> @@ -603,7 +603,7 @@ Name="VCCustomBuildTool" Description="Building $(InputName)..." CommandLine="$(SolutionDir)LightTools\Build.py $(InputName).def " - AdditionalDependencies="$(SolutionDir)Assets\Maps\$(InputName).def" + AdditionalDependencies="" Outputs="$(SolutionDir)Data\Maps\$(InputName).map" /> @@ -614,7 +614,7 @@ Name="VCCustomBuildTool" Description="Building $(InputName)..." CommandLine="$(SolutionDir)LightTools\Build.py $(InputName).def " - AdditionalDependencies="$(SolutionDir)Assets\Maps\$(InputName).def" + AdditionalDependencies="" Outputs="$(SolutionDir)Data\Maps\$(InputName).map" /> @@ -629,7 +629,7 @@ Name="VCCustomBuildTool" Description="Building $(InputName)..." CommandLine="$(SolutionDir)LightTools\Build.py $(InputName).def " - AdditionalDependencies="$(SolutionDir)Assets\Maps\$(InputName).def" + AdditionalDependencies="" Outputs="$(SolutionDir)Data\Maps\$(InputName).map" /> @@ -640,7 +640,55 @@ Name="VCCustomBuildTool" Description="Building $(InputName)..." CommandLine="$(SolutionDir)LightTools\Build.py $(InputName).def " - AdditionalDependencies="$(SolutionDir)Assets\Maps\$(InputName).def" + AdditionalDependencies="" + Outputs="$(SolutionDir)Data\Maps\$(InputName).map" + /> + + + + + + + + + + + + + + + + diff -r 63806b850aa5 -r b0f642ee22d3 LightClone/Source/Bot.cpp --- a/LightClone/Source/Bot.cpp Fri Sep 30 22:48:03 2011 -0700 +++ b/LightClone/Source/Bot.cpp Mon Oct 03 08:58:08 2011 -0700 @@ -13,16 +13,6 @@ const float DirectionAngle[] = {-1.0f * D3DX_PI / 2.0f, -4.0f * D3DX_PI / 2.0f, -3.0f * D3DX_PI / 2.0f, -2.0f * D3DX_PI / 2.0f}; /* - * DirectionStepX - */ -const int32 DirectionStepX[] = {0, 1, 0, -1}; - -/* - * DirectionStepY - */ -const int32 DirectionStepY[] = {1, 0, -1, 0}; - -/* * Bot */ Bot::Bot() @@ -44,7 +34,7 @@ ErrorCode eCode = pResourceManager->CreateEffectFromFile("Data\\Shaders\\Environment.fx", &pEffect); if(eCode == Error_Success) { - //eCode = pResourceManager->CreateTextureFromFile("Data\\Textures\\Block02.tga", &pTexture); + eCode = pResourceManager->CreateTextureFromFile("Data\\Textures\\Bot.tga", &pTexture); if(eCode == Error_Success) { eCode = pResourceManager->CreateVertexBuffer(VerticesPerBlock * sizeof(Vertex::Block), D3DUSAGE_WRITEONLY, D3DPOOL_MANAGED, &pVertexBuffer); @@ -77,9 +67,7 @@ { pEnvironment = pInstance; nState = BotState_Idle; - nColor = D3DCOLOR_XRGB(0, 255, 0); - - //kMachine.RemoveAllFunctions(); + nColor = D3DCOLOR_XRGB(255, 255, 255); } /* @@ -208,8 +196,8 @@ { if(pEnvironment->IsMovementValid(nAction, kPosition.X, kPosition.Y, kDirection)) { - kSequencer.kPosition.X = (int32)kPosition.X + DirectionStepX[kDirection]; - kSequencer.kPosition.Y = (int32)kPosition.Y + DirectionStepY[kDirection]; + kSequencer.kPosition.X = (int32)kPosition.X + GetOffsetFromDirectionX(kDirection); + kSequencer.kPosition.Y = (int32)kPosition.Y + GetOffsetFromDirectionY(kDirection); kSequencer.nSequence = BotSequence_Forward; kSequencer.fTimer = 0.0f; kSequencer.fSpeed = 1.5f; @@ -242,8 +230,8 @@ { if(pEnvironment->IsMovementValid(nAction, kPosition.X, kPosition.Y, kDirection)) { - kSequencer.kPosition.X = (int32)kPosition.X + DirectionStepX[kDirection]; - kSequencer.kPosition.Y = (int32)kPosition.Y + DirectionStepY[kDirection]; + kSequencer.kPosition.X = (int32)kPosition.X + GetOffsetFromDirectionX(kDirection); + kSequencer.kPosition.Y = (int32)kPosition.Y + GetOffsetFromDirectionY(kDirection); } else { @@ -401,13 +389,62 @@ const float fU1 = 0.66f; const float fV1 = 0.66f; + const float fScaleU = 64.0f / 320.0f; + const float fScaleV = 128.0f / 128.0f; + + // + // front - pVertices[0] = Vertex::Block(-0.5f, 0.0f, -0.5f, 0.0f, 0.0f, -1.0f, 0.00f, 1.00f); - pVertices[1] = Vertex::Block(-0.5f, 1.0f, -0.5f, 0.0f, 0.0f, -1.0f, 0.00f, 0.66f); - pVertices[2] = Vertex::Block(+0.5f, 1.0f, -0.5f, 0.0f, 0.0f, -1.0f, 1.00f, 0.66f); - pVertices[3] = Vertex::Block(-0.5f, 0.0f, -0.5f, 0.0f, 0.0f, -1.0f, 0.00f, 1.00f); - pVertices[4] = Vertex::Block(+0.5f, 1.0f, -0.5f, 0.0f, 0.0f, -1.0f, 1.00f, 0.66f); - pVertices[5] = Vertex::Block(+0.5f, 0.0f, -0.5f, 0.0f, 0.0f, -1.0f, 1.00f, 1.00f); + pVertices[0] = Vertex::Block(-0.5f, 0.0f, -0.5f, 0.0f, 0.0f, -1.0f, 0 * fScaleU + 0 * fScaleU, 1 * fScaleV); // lower left + pVertices[1] = Vertex::Block(-0.5f, 1.0f, -0.5f, 0.0f, 0.0f, -1.0f, 0 * fScaleU + 0 * fScaleU, 0 * fScaleV); // upper left + pVertices[2] = Vertex::Block(+0.5f, 1.0f, -0.5f, 0.0f, 0.0f, -1.0f, 0 * fScaleU + 1 * fScaleU, 0 * fScaleV); // upper right + pVertices[3] = Vertex::Block(-0.5f, 0.0f, -0.5f, 0.0f, 0.0f, -1.0f, 0 * fScaleU + 0 * fScaleU, 1 * fScaleV); // lower left + pVertices[4] = Vertex::Block(+0.5f, 1.0f, -0.5f, 0.0f, 0.0f, -1.0f, 0 * fScaleU + 1 * fScaleU, 0 * fScaleV); // upper right + pVertices[5] = Vertex::Block(+0.5f, 0.0f, -0.5f, 0.0f, 0.0f, -1.0f, 0 * fScaleU + 1 * fScaleU, 1 * fScaleV); // lower right + // back + pVertices[6] = Vertex::Block(+0.5f, 0.0f, +0.5f, 0.0f, 0.0f, +1.0f, 1 * fScaleU + 0 * fScaleU, 1 * fScaleV); + pVertices[7] = Vertex::Block(+0.5f, 1.0f, +0.5f, 0.0f, 0.0f, +1.0f, 1 * fScaleU + 0 * fScaleU, 0 * fScaleV); + pVertices[8] = Vertex::Block(-0.5f, 1.0f, +0.5f, 0.0f, 0.0f, +1.0f, 1 * fScaleU + 1 * fScaleU, 0 * fScaleV); + pVertices[9] = Vertex::Block(+0.5f, 0.0f, +0.5f, 0.0f, 0.0f, +1.0f, 1 * fScaleU + 0 * fScaleU, 1 * fScaleV); + pVertices[10] = Vertex::Block(-0.5f, 1.0f, +0.5f, 0.0f, 0.0f, +1.0f, 1 * fScaleU + 1 * fScaleU, 0 * fScaleV); + pVertices[11] = Vertex::Block(-0.5f, 0.0f, +0.5f, 0.0f, 0.0f, +1.0f, 1 * fScaleU + 1 * fScaleU, 1 * fScaleV); + // left + pVertices[12] = Vertex::Block(-0.5f, 0.0f, +0.5f, -1.0f, 0.0f, 0.0f, 2 * fScaleU + 0 * fScaleU, 1 * fScaleV); + pVertices[13] = Vertex::Block(-0.5f, 1.0f, +0.5f, -1.0f, 0.0f, 0.0f, 2 * fScaleU + 0 * fScaleU, 0 * fScaleV); + pVertices[14] = Vertex::Block(-0.5f, 1.0f, -0.5f, -1.0f, 0.0f, 0.0f, 2 * fScaleU + 1 * fScaleU, 0 * fScaleV); + pVertices[15] = Vertex::Block(-0.5f, 0.0f, +0.5f, -1.0f, 0.0f, 0.0f, 2 * fScaleU + 0 * fScaleU, 1 * fScaleV); + pVertices[16] = Vertex::Block(-0.5f, 1.0f, -0.5f, -1.0f, 0.0f, 0.0f, 2 * fScaleU + 1 * fScaleU, 0 * fScaleV); + pVertices[17] = Vertex::Block(-0.5f, 0.0f, -0.5f, -1.0f, 0.0f, 0.0f, 2 * fScaleU + 1 * fScaleU, 1 * fScaleV); + // right + pVertices[18] = Vertex::Block(+0.5f, 0.0f, -0.5f, +1.0f, 0.0f, 0.0f, 3 * fScaleU + 0 * fScaleU, 1 * fScaleV); + pVertices[19] = Vertex::Block(+0.5f, 1.0f, -0.5f, +1.0f, 0.0f, 0.0f, 3 * fScaleU + 0 * fScaleU, 0 * fScaleV); + pVertices[20] = Vertex::Block(+0.5f, 1.0f, +0.5f, +1.0f, 0.0f, 0.0f, 3 * fScaleU + 1 * fScaleU, 0 * fScaleV); + pVertices[21] = Vertex::Block(+0.5f, 0.0f, -0.5f, +1.0f, 0.0f, 0.0f, 3 * fScaleU + 0 * fScaleU, 1 * fScaleV); + pVertices[22] = Vertex::Block(+0.5f, 1.0f, +0.5f, +1.0f, 0.0f, 0.0f, 3 * fScaleU + 1 * fScaleU, 0 * fScaleV); + pVertices[23] = Vertex::Block(+0.5f, 0.0f, +0.5f, +1.0f, 0.0f, 0.0f, 3 * fScaleU + 1 * fScaleU, 1 * fScaleV); + // top + pVertices[24] = Vertex::Block(-0.5f, 1.0f, -0.5f, 0.0f, +1.0f, 0.0f, 4 * fScaleU + 0 * fScaleU, 0.0f * fScaleV + 0.5f * fScaleV); + pVertices[25] = Vertex::Block(-0.5f, 1.0f, +0.5f, 0.0f, +1.0f, 0.0f, 4 * fScaleU + 0 * fScaleU, 0.0f * fScaleV + 0.0f * fScaleV); + pVertices[26] = Vertex::Block(+0.5f, 1.0f, +0.5f, 0.0f, +1.0f, 0.0f, 4 * fScaleU + 1 * fScaleU, 0.0f * fScaleV + 0.0f * fScaleV); + pVertices[27] = Vertex::Block(-0.5f, 1.0f, -0.5f, 0.0f, +1.0f, 0.0f, 4 * fScaleU + 0 * fScaleU, 0.0f * fScaleV + 0.5f * fScaleV); + pVertices[28] = Vertex::Block(+0.5f, 1.0f, +0.5f, 0.0f, +1.0f, 0.0f, 4 * fScaleU + 1 * fScaleU, 0.0f * fScaleV + 0.0f * fScaleV); + pVertices[29] = Vertex::Block(+0.5f, 1.0f, -0.5f, 0.0f, +1.0f, 0.0f, 4 * fScaleU + 1 * fScaleU, 0.0f * fScaleV + 0.5f * fScaleV); + // bottom + pVertices[30] = Vertex::Block(-0.5f, 0.0f, +0.5f, 0.0f, -1.0f, 0.0f, 5 * fScaleU + 0 * fScaleU, 0.5f * fScaleV + 0.5f * fScaleV); + pVertices[31] = Vertex::Block(-0.5f, 0.0f, -0.5f, 0.0f, -1.0f, 0.0f, 5 * fScaleU + 0 * fScaleU, 0.5f * fScaleV + 0.0f * fScaleV); + pVertices[32] = Vertex::Block(+0.5f, 0.0f, -0.5f, 0.0f, -1.0f, 0.0f, 5 * fScaleU + 1 * fScaleU, 0.5f * fScaleV + 0.0f * fScaleV); + pVertices[33] = Vertex::Block(-0.5f, 0.0f, +0.5f, 0.0f, -1.0f, 0.0f, 5 * fScaleU + 0 * fScaleU, 0.5f * fScaleV + 0.5f * fScaleV); + pVertices[34] = Vertex::Block(+0.5f, 0.0f, -0.5f, 0.0f, -1.0f, 0.0f, 5 * fScaleU + 1 * fScaleU, 0.5f * fScaleV + 0.0f * fScaleV); + pVertices[35] = Vertex::Block(+0.5f, 0.0f, +0.5f, 0.0f, -1.0f, 0.0f, 5 * fScaleU + 1 * fScaleU, 0.5f * fScaleV + 0.5f * fScaleV); + + /* + // front + pVertices[0] = Vertex::Block(-0.5f, 0.0f, -0.5f, 0.0f, 0.0f, -1.0f, 0.00f, 1.00f); // lower left + pVertices[1] = Vertex::Block(-0.5f, 1.0f, -0.5f, 0.0f, 0.0f, -1.0f, 0.00f, 0.66f); // upper left + pVertices[2] = Vertex::Block(+0.5f, 1.0f, -0.5f, 0.0f, 0.0f, -1.0f, 1.00f, 0.66f); // upper right + pVertices[3] = Vertex::Block(-0.5f, 0.0f, -0.5f, 0.0f, 0.0f, -1.0f, 0.00f, 1.00f); // lower left + pVertices[4] = Vertex::Block(+0.5f, 1.0f, -0.5f, 0.0f, 0.0f, -1.0f, 1.00f, 0.66f); // upper right + pVertices[5] = Vertex::Block(+0.5f, 0.0f, -0.5f, 0.0f, 0.0f, -1.0f, 1.00f, 1.00f); // lower right // back pVertices[6] = Vertex::Block(+0.5f, 0.0f, +0.5f, 0.0f, 0.0f, +1.0f, 0.00f, 1.00f); pVertices[7] = Vertex::Block(+0.5f, 1.0f, +0.5f, 0.0f, 0.0f, +1.0f, 0.00f, 0.66f); @@ -443,6 +480,7 @@ pVertices[33] = Vertex::Block(-0.5f, 0.0f, +0.5f, 0.0f, -1.0f, 0.0f, 0.00f, 0.66f); pVertices[34] = Vertex::Block(+0.5f, 0.0f, -0.5f, 0.0f, -1.0f, 0.0f, 1.00f, 0.00f); pVertices[35] = Vertex::Block(+0.5f, 0.0f, +0.5f, 0.0f, -1.0f, 0.0f, 1.00f, 0.66f); + */ pVertexBuffer->Unlock(); diff -r 63806b850aa5 -r b0f642ee22d3 LightClone/Source/CameraController.h --- a/LightClone/Source/CameraController.h Fri Sep 30 22:48:03 2011 -0700 +++ b/LightClone/Source/CameraController.h Mon Oct 03 08:58:08 2011 -0700 @@ -64,7 +64,7 @@ /* * CameraController */ - CameraController(float fInitialDistance = 10.0f, float fInitialYaw = 0.150f, float fInitialPitch = 0.575f); + CameraController(float fInitialDistance = 10.0f, float fInitialYaw = 0.46f, float fInitialPitch = 0.57f); /* * SetMode diff -r 63806b850aa5 -r b0f642ee22d3 LightClone/Source/Core.cpp --- a/LightClone/Source/Core.cpp Fri Sep 30 22:48:03 2011 -0700 +++ b/LightClone/Source/Core.cpp Mon Oct 03 08:58:08 2011 -0700 @@ -5,6 +5,32 @@ #include "Core.h" /* + * DirectionOffsetX + */ +const int32 DirectionOffsetX[] = {0, 1, 0, -1}; + +/* + * DirectionOffsetY + */ +const int32 DirectionOffsetY[] = {1, 0, -1, 0}; + +/* + * GetOffsetFromDirectionX + */ +int32 GetOffsetFromDirectionX(uint32 nDirection) +{ + return DirectionOffsetX[nDirection]; +} + +/* + * GetOffsetFromDirectionY + */ +int32 GetOffsetFromDirectionY(uint32 nDirection) +{ + return DirectionOffsetY[nDirection]; +} + +/* * InterpolateDirection */ float InterpolateDirection(uint32 nStart, uint32 nEnd, float fParameter) diff -r 63806b850aa5 -r b0f642ee22d3 LightClone/Source/Core.h --- a/LightClone/Source/Core.h Fri Sep 30 22:48:03 2011 -0700 +++ b/LightClone/Source/Core.h Mon Oct 03 08:58:08 2011 -0700 @@ -246,6 +246,16 @@ } /* + * GetOffsetFromDirectionX + */ +int32 GetOffsetFromDirectionX(uint32 nDirection); + +/* + * GetOffsetFromDirectionY + */ +int32 GetOffsetFromDirectionY(uint32 nDirection); + +/* * InterpolateDirection */ float InterpolateDirection(uint32 nStart, uint32 nEnd, float fParameter); diff -r 63806b850aa5 -r b0f642ee22d3 LightClone/Source/Environment.cpp --- a/LightClone/Source/Environment.cpp Fri Sep 30 22:48:03 2011 -0700 +++ b/LightClone/Source/Environment.cpp Mon Oct 03 08:58:08 2011 -0700 @@ -116,8 +116,8 @@ D3DXMATRIX kScaleMatrix; D3DXMatrixScaling(&kScaleMatrix, kScale.x, kScale.y, kScale.z); - const float fOffsetX = -0.5f * ((nWidth - 1) * kScale.x); - const float fOffsetZ = -0.5f * ((nHeight - 1) * kScale.z); + const float fOffsetX = -0.5f * ((nWidth - 1) * kScale.x); + const float fOffsetZ = -0.5f * ((nHeight - 1) * kScale.z); for(uint32 nZ = 0; nZ < nHeight; ++nZ) { @@ -128,12 +128,7 @@ uint32 nState = GetState(nX, nZ); uint32 nColor = D3DCOLOR_XRGB(0x80, 0x80, 0x80); - if(nType == 1) - { - nColor = nState ? D3DCOLOR_XRGB(0, 0, 255) : D3DCOLOR_XRGB(255, 0, 0); - } - - for(uint32 i = 0; i < GetAltitude(nX, nZ); ++i) + for(uint32 i = 0; i < nHeight; ++i) { D3DXMATRIX kTranslateMatrix; D3DXMatrixTranslation(&kTranslateMatrix, fOffsetX + nX * kScale.x, i * kScale.y, fOffsetZ + nZ * kScale.z); @@ -141,6 +136,11 @@ D3DXMATRIX kWorldMatrix; D3DXMatrixMultiply(&kWorldMatrix, &kScaleMatrix, &kTranslateMatrix); + if(nType == TowerType_Light && i == nHeight - 1) + { + nColor = nState ? D3DCOLOR_XRGB(0, 0, 192) : D3DCOLOR_XRGB(192, 0, 0); + } + const float fAlpha = ((nColor >> 24) & 0xFF) / 255.0f; const float fRed = ((nColor >> 16) & 0xFF) / 255.0f; const float fGreen = ((nColor >> 8 ) & 0xFF) / 255.0f; @@ -161,7 +161,7 @@ pEffect->EndPass(); pEffect->End(); - if(false) // wireframe + if(true) // wireframe { pEffect->SetTechnique(pEffect->GetTechniqueByName("Wire")); pEffect->Begin(&nPasses, 0); @@ -174,7 +174,7 @@ for(uint32 i = 0; i < GetAltitude(nX, nZ); ++i) { D3DXMATRIX kTranslateMatrix; - D3DXMatrixTranslation(&kTranslateMatrix, nX * kScale.x, i * kScale.y, nZ * kScale.z); + D3DXMatrixTranslation(&kTranslateMatrix, fOffsetX + nX * kScale.x, i * kScale.y, fOffsetZ + nZ * kScale.z); D3DXMATRIX kWorldMatrix; D3DXMatrixMultiply(&kWorldMatrix, &kScaleMatrix, &kTranslateMatrix); @@ -263,89 +263,29 @@ /* * IsMovementValid */ -bool Environment::IsMovementValid(uint32 nAction, uint32 nX, uint32 nY, uint32 nDirection) +bool Environment::IsMovementValid(uint32 nAction, int32 nSourceX, int32 nSourceY, uint32 nDirection) { - if(nAction == Action_Forward) + const int32 nDestinationX = nSourceX + GetOffsetFromDirectionX(nDirection); + const int32 nDestinationY = nSourceY + GetOffsetFromDirectionY(nDirection); + + if(0 <= nDestinationX && nDestinationX < (int32)nWidth) { - const uint32 nGridHeight = pGrid[nY * nWidth + nX].Height; - - if(nDirection == Direction_North) + if(0 <= nDestinationY && nDestinationY < (int32)nHeight) { - if(nY + 1 < nHeight) - { - return nGridHeight == pGrid[(nY + 1) * nWidth + nX].Height; - } - } - else + const int32 nSourceHeight = (int32)pGrid[nSourceY * nWidth + nSourceX].Height; + const int32 nDestinationHeight = (int32)pGrid[nDestinationY * nWidth + nDestinationX].Height; - if(nDirection == Direction_East) - { - if(nX + 1 < nWidth) + if(nAction == Action_Forward) { - return nGridHeight == pGrid[nY * nWidth + nX + 1].Height; - } - } - else - - if(nDirection == Direction_South) - { - if(nY - 1 >= 0) - { - return nGridHeight == pGrid[(nY - 1) * nWidth + nX].Height; - } - } - else - - if(nDirection == Direction_West) - { - if(nX - 1 >= 0) - { - return nGridHeight == pGrid[nY * nWidth + nX - 1].Height; + // forward moves must be at the same height + return nSourceHeight == nDestinationHeight; } - } - } - else - - if(nAction == Action_Jump) - { - const int32 nGridHeight = (int32)pGrid[nY * nWidth + nX].Height; + else - if(nDirection == Direction_North) - { - if(nY + 1 < nHeight) - { - const int32 nDelta = nGridHeight - (int32)pGrid[(nY + 1) * nWidth + nX].Height; - return nDelta == 1 || nDelta < 0; - } - } - else - - if(nDirection == Direction_East) - { - if(nX + 1 < nWidth) + if(nAction == Action_Jump) { - const int32 nDelta = nGridHeight - (int32)pGrid[nY * nWidth + nX + 1].Height; - return nDelta == 1 || nDelta < 0; - } - } - else - - if(nDirection == Direction_South) - { - if(nY - 1 >= 0) - { - const int32 nDelta = nGridHeight - (int32)pGrid[(nY - 1) * nWidth + nX].Height; - return nDelta == 1 || nDelta < 0; - } - } - else - - if(nDirection == Direction_West) - { - if(nX - 1 >= 0) - { - const int32 nDelta = nGridHeight - (int32)pGrid[nY * nWidth + nX - 1].Height; - return nDelta == 1 || nDelta < 0; + // allow jumping up one level or down any number of levels + return nSourceHeight > nDestinationHeight || (nDestinationHeight - nSourceHeight) == 1; } } } diff -r 63806b850aa5 -r b0f642ee22d3 LightClone/Source/Environment.h --- a/LightClone/Source/Environment.h Fri Sep 30 22:48:03 2011 -0700 +++ b/LightClone/Source/Environment.h Mon Oct 03 08:58:08 2011 -0700 @@ -169,7 +169,7 @@ /* * IsMovementValid */ - bool IsMovementValid(uint32 nAction, uint32 nX, uint32 nY, uint32 nDirection); + bool IsMovementValid(uint32 nAction, int32 nX, int32 nY, uint32 nDirection); /* * RequirementsMet diff -r 63806b850aa5 -r b0f642ee22d3 LightClone/Source/GuiElement.cpp --- a/LightClone/Source/GuiElement.cpp Fri Sep 30 22:48:03 2011 -0700 +++ b/LightClone/Source/GuiElement.cpp Mon Oct 03 08:58:08 2011 -0700 @@ -45,6 +45,10 @@ */ void GuiElement::Terminate() { + for(uint32 i = 0; i < kChildren.Size(); ++i) + { + kChildren[i]->Terminate(); + } } /* diff -r 63806b850aa5 -r b0f642ee22d3 LightClone/Source/World.cpp --- a/LightClone/Source/World.cpp Fri Sep 30 22:48:03 2011 -0700 +++ b/LightClone/Source/World.cpp Mon Oct 03 08:58:08 2011 -0700 @@ -167,6 +167,13 @@ { } + const D3DXVECTOR3& kCameraPosition = kCameraController.GetLocation(); + + + char kBuffer[256]; + sprintf_s(kBuffer, "Camera: <%.2f, %.2f, %.2f> (%.2f, %.2f, %.2f)", kCameraPosition.x, kCameraPosition.y, kCameraPosition.z, kCameraController.fCameraDistance, kCameraController.fCameraYaw, kCameraController.fCameraPitch); + pDebugText->SetText(kBuffer); + kInterface.Update(fElapsed); } @@ -217,7 +224,7 @@ { pBackground = new GuiImage(); pBackground->Initialize(pResourceManager); - pBackground->SetTexture("Data\\Textures\\Background03.tga", true); + pBackground->SetTexture("Data\\Textures\\Background04.tga", true); pBackground->SetPosition(ScreenSizeX - pBackground->GetWidth(), 0.0f); pBackground->SetDepth(512.0f); @@ -282,9 +289,9 @@ pButtonPlay = new GuiButton(); pButtonPlay->Initialize(pResourceManager); - pButtonPlay->SetTexture(GuiButtonState_Normal, "Data\\Textures\\Button1N.png", true); - pButtonPlay->SetTexture(GuiButtonState_Hover, "Data\\Textures\\Button1H.png", true); - pButtonPlay->SetTexture(GuiButtonState_Down, "Data\\Textures\\Button1D.png", true); + pButtonPlay->SetTexture(GuiButtonState_Normal, "Data\\Textures\\Button2N.png", true); + pButtonPlay->SetTexture(GuiButtonState_Hover, "Data\\Textures\\Button2H.png", true); + pButtonPlay->SetTexture(GuiButtonState_Down, "Data\\Textures\\Button2D.png", true); pButtonPlay->SetFont("Courier New", 16, FW_BOLD); pButtonPlay->SetText("Play"); pButtonPlay->SetColor(D3DCOLOR_XRGB(0, 0, 0)); @@ -293,9 +300,9 @@ pButtonStop = new GuiButton(); pButtonStop->Initialize(pResourceManager); - pButtonStop->SetTexture(GuiButtonState_Normal, "Data\\Textures\\Button1N.png", true); - pButtonStop->SetTexture(GuiButtonState_Hover, "Data\\Textures\\Button1H.png", true); - pButtonStop->SetTexture(GuiButtonState_Down, "Data\\Textures\\Button1D.png", true); + pButtonStop->SetTexture(GuiButtonState_Normal, "Data\\Textures\\Button2N.png", true); + pButtonStop->SetTexture(GuiButtonState_Hover, "Data\\Textures\\Button2H.png", true); + pButtonStop->SetTexture(GuiButtonState_Down, "Data\\Textures\\Button2D.png", true); pButtonStop->SetFont("Courier New", 16, FW_BOLD); pButtonStop->SetText("Stop"); pButtonStop->SetColor(D3DCOLOR_XRGB(0, 0, 0)); @@ -304,9 +311,9 @@ pButtonReset = new GuiButton(); pButtonReset->Initialize(pResourceManager); - pButtonReset->SetTexture(GuiButtonState_Normal, "Data\\Textures\\Button1N.png", true); - pButtonReset->SetTexture(GuiButtonState_Hover, "Data\\Textures\\Button1H.png", true); - pButtonReset->SetTexture(GuiButtonState_Down, "Data\\Textures\\Button1D.png", true); + pButtonReset->SetTexture(GuiButtonState_Normal, "Data\\Textures\\Button2N.png", true); + pButtonReset->SetTexture(GuiButtonState_Hover, "Data\\Textures\\Button2H.png", true); + pButtonReset->SetTexture(GuiButtonState_Down, "Data\\Textures\\Button2D.png", true); pButtonReset->SetFont("Courier New", 16, FW_BOLD); pButtonReset->SetText("Reset"); pButtonReset->SetColor(D3DCOLOR_XRGB(0, 0, 0)); @@ -315,9 +322,9 @@ pButtonExit = new GuiButton(); pButtonExit->Initialize(pResourceManager); - pButtonExit->SetTexture(GuiButtonState_Normal, "Data\\Textures\\Button1N.png", true); - pButtonExit->SetTexture(GuiButtonState_Hover, "Data\\Textures\\Button1H.png", true); - pButtonExit->SetTexture(GuiButtonState_Down, "Data\\Textures\\Button1D.png", true); + pButtonExit->SetTexture(GuiButtonState_Normal, "Data\\Textures\\Button2N.png", true); + pButtonExit->SetTexture(GuiButtonState_Hover, "Data\\Textures\\Button2H.png", true); + pButtonExit->SetTexture(GuiButtonState_Down, "Data\\Textures\\Button2D.png", true); pButtonExit->SetFont("Courier New", 16, FW_BOLD); pButtonExit->SetText("Exit"); pButtonExit->SetColor(D3DCOLOR_XRGB(0, 0, 0)); @@ -350,10 +357,18 @@ const D3DXVECTOR2& kConfigSize = pConfirmDialog->GetDimensions(); pConfirmDialog->SetPosition(0.5f * ((ScreenSizeX - pBackground->GetWidth()) - kConfigSize.x), 0.5f * (ScreenSizeY - kConfigSize.y)); + pDebugText = new GuiLabel(); + pDebugText->Initialize(pResourceManager); + pDebugText->SetFont("Courier New", 16); + pDebugText->SetPosition(10.0f, 10.0f); + pDebugText->SetText("Debug"); + pDebugText->SetColor(D3DCOLOR_XRGB(255, 255, 255)); + //pHud = new GuiElement(); //pHud->Add(pBackground); kInterface.Add(pBackground); + kInterface.Add(pDebugText); kInterface.Add(pMessageDialog); kInterface.Add(pConfirmDialog); } diff -r 63806b850aa5 -r b0f642ee22d3 LightClone/Source/World.h --- a/LightClone/Source/World.h Fri Sep 30 22:48:03 2011 -0700 +++ b/LightClone/Source/World.h Mon Oct 03 08:58:08 2011 -0700 @@ -155,6 +155,11 @@ */ ChoiceDialog* pConfirmDialog; + /* + * pDebugText + */ + GuiLabel* pDebugText; + public: /* diff -r 63806b850aa5 -r b0f642ee22d3 LightClone/ToDo.txt --- a/LightClone/ToDo.txt Fri Sep 30 22:48:03 2011 -0700 +++ b/LightClone/ToDo.txt Mon Oct 03 08:58:08 2011 -0700 @@ -1,10 +1,10 @@ 1. Button tool tips 2. Main menu 3. Pause menu -4. Robot model & texture +4. Robot model & texture (.x format) 5. Help interface 6. Add asserts 7. Move resource manager into a service provider container -8. Rename CodePanel to ProgramPanel -9. Rename CodeSlot to ActionSlot -10. Refactor CodePanel/CodeSlot to read/write data to/from Program \ No newline at end of file +8. Fix gui element destruction +9. Add sound and music +10. Additional maps \ No newline at end of file