Skip to content

Commit

Permalink
optimized moving
Browse files Browse the repository at this point in the history
  • Loading branch information
russellxie7 committed Dec 14, 2017
1 parent 9e60d97 commit 228edc1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
14 changes: 9 additions & 5 deletions CSE167StarterCodeFinal-master/Boat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void Boat::update() {
}

// update orit translate, wave
pos += speed * dir;
pos += speed * 0.1f * dir;

translate = glm::translate(glm::mat4(1.0f), pos);

Expand Down Expand Up @@ -91,14 +91,18 @@ void Boat::update() {
if (selfY > -2.0f) {
glm::vec3 xxx =Window::cam_pos;
xxx.y = 0.0f;
pos += 2 * speed * glm::normalize(glm::vec3(0.0f, 0.0f, 0.0f) - xxx);
pos += 0.2 * speed * glm::normalize(glm::vec3(0.0f, 0.0f, 0.0f) - xxx);
angle += 3.1416f /2.0f;
orbit = glm::rotate(glm::mat4(1.0f), angle, glm::vec3(0.0f, 1.0f, 0.0f));
dir = glm::vec3(orbit * glm::vec4(0.0f, 0.0f, 1.0f, 1.0f));
//orbit = glm::rotate(glm::mat4(1.0f), angle, glm::vec3(0.0f, 1.0f, 0.0f));
//dir = glm::vec3(orbit * glm::vec4(0.0f, 0.0f, 1.0f, 1.0f));
}
}

speed -= 0.001f;
if (speed > 0.2) {
speed = 0.2;
}

speed -= 0.005f;
if (speed < 0.0f)
speed = 0.0f;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\Boat.h" />
<ClInclude Include="..\boundingBox.h" />
<ClInclude Include="..\CameraTexture.h" />
<ClInclude Include="..\DofEffect.h" />
Expand All @@ -36,6 +37,7 @@
<ClInclude Include="..\Window.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\Boat.cpp" />
<ClCompile Include="..\boundingBox.cpp" />
<ClCompile Include="..\CameraTexture.cpp" />
<ClCompile Include="..\DofEffect.cpp" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@
<ClInclude Include="..\SnowEffect.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\Boat.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\main.cpp">
Expand Down Expand Up @@ -110,6 +113,9 @@
<ClCompile Include="..\SnowEffect.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\Boat.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
Expand Down

0 comments on commit 228edc1

Please sign in to comment.