浏览代码

Doing some cleanup and relocation.

Sam Jaffe 6 年之前
父节点
当前提交
39ca9537fc

+ 4 - 4
engine/engine.xcodeproj/project.pbxproj

@@ -7,7 +7,6 @@
 	objects = {
 
 /* Begin PBXBuildFile section */
-		CD2973951D7B117E00E37217 /* time.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD2973931D7B117E00E37217 /* time.cpp */; };
 		CD62D8462251A94C0023219A /* libgraphics.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CD62D8452251A94C0023219A /* libgraphics.dylib */; };
 		CD62D8482251A9500023219A /* libmath.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CD62D8472251A9500023219A /* libmath.dylib */; };
 		CD62FCCE22904A8900376440 /* libengine.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CDB1F8AE1D7A30CD00700C6B /* libengine.dylib */; };
@@ -15,6 +14,7 @@
 		CD62FD35229364DB00376440 /* entity.cxx in Sources */ = {isa = PBXBuildFile; fileRef = CD62FD33229364DB00376440 /* entity.cxx */; };
 		CD62FD3C229370E200376440 /* libjsoncpp.1.8.4.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CD62FD3922936E9C00376440 /* libjsoncpp.1.8.4.dylib */; };
 		CD62FD402293746900376440 /* serial.cxx in Sources */ = {isa = PBXBuildFile; fileRef = CD62FD3E2293746900376440 /* serial.cxx */; };
+		CD7E87792295FAB400D877FE /* libgameutils.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CD7E87782295FAB400D877FE /* libgameutils.dylib */; };
 		CDB1F8C81D7A312B00700C6B /* game_dispatch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDB1F8C61D7A312B00700C6B /* game_dispatch.cpp */; };
 		CDB1F8CC1D7A319A00700C6B /* scene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDB1F8CA1D7A319A00700C6B /* scene.cpp */; };
 		CDB1F8D21D7A32A300700C6B /* events.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDB1F8D01D7A32A300700C6B /* events.cpp */; };
@@ -66,7 +66,6 @@
 /* End PBXContainerItemProxy section */
 
 /* Begin PBXFileReference section */
-		CD2973931D7B117E00E37217 /* time.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = time.cpp; sourceTree = "<group>"; };
 		CD62D8452251A94C0023219A /* libgraphics.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; path = libgraphics.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
 		CD62D8472251A9500023219A /* libmath.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; path = libmath.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
 		CD62FCB622904A7B00376440 /* GoogleMock.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = GoogleMock.xcodeproj; path = "../../gmock-xcode-master/GoogleMock.xcodeproj"; sourceTree = "<group>"; };
@@ -75,6 +74,7 @@
 		CD62FD33229364DB00376440 /* entity.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = entity.cxx; sourceTree = "<group>"; };
 		CD62FD3922936E9C00376440 /* libjsoncpp.1.8.4.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libjsoncpp.1.8.4.dylib; path = ../../../../../../../opt/local/lib/libjsoncpp.1.8.4.dylib; sourceTree = "<group>"; };
 		CD62FD3E2293746900376440 /* serial.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = serial.cxx; sourceTree = "<group>"; };
+		CD7E87782295FAB400D877FE /* libgameutils.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; path = libgameutils.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
 		CDA34D8422515C99008036A7 /* game */ = {isa = PBXFileReference; lastKnownFileType = folder; name = game; path = include/game; sourceTree = "<group>"; };
 		CDB1F8AE1D7A30CD00700C6B /* libengine.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libengine.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
 		CDB1F8C61D7A312B00700C6B /* game_dispatch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = game_dispatch.cpp; sourceTree = "<group>"; };
@@ -96,6 +96,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				CD7E87792295FAB400D877FE /* libgameutils.dylib in Frameworks */,
 				CD62FD3C229370E200376440 /* libjsoncpp.1.8.4.dylib in Frameworks */,
 				CD62D8482251A9500023219A /* libmath.dylib in Frameworks */,
 				CD62D8462251A94C0023219A /* libgraphics.dylib in Frameworks */,
@@ -108,6 +109,7 @@
 		CD62D8442251A94C0023219A /* Frameworks */ = {
 			isa = PBXGroup;
 			children = (
+				CD7E87782295FAB400D877FE /* libgameutils.dylib */,
 				CD62FD3922936E9C00376440 /* libjsoncpp.1.8.4.dylib */,
 				CD62D8452251A94C0023219A /* libgraphics.dylib */,
 				CD62D8472251A9500023219A /* libmath.dylib */,
@@ -171,7 +173,6 @@
 				CDB1F8C61D7A312B00700C6B /* game_dispatch.cpp */,
 				CDB1F8CA1D7A319A00700C6B /* scene.cpp */,
 				CD62FD3E2293746900376440 /* serial.cxx */,
-				CD2973931D7B117E00E37217 /* time.cpp */,
 			);
 			path = src;
 			sourceTree = "<group>";
@@ -343,7 +344,6 @@
 			buildActionMask = 2147483647;
 			files = (
 				CD62FD35229364DB00376440 /* entity.cxx in Sources */,
-				CD2973951D7B117E00E37217 /* time.cpp in Sources */,
 				CDB1F8D21D7A32A300700C6B /* events.cpp in Sources */,
 				CDB1F8CC1D7A319A00700C6B /* scene.cpp in Sources */,
 				CDB1F8C81D7A312B00700C6B /* game_dispatch.cpp in Sources */,

+ 1 - 1
engine/include/game/engine/game_dispatch.hpp

@@ -16,7 +16,7 @@
 
 #include "engine_fwd.hpp"
 #include "events.hpp"
-#include "time.hpp"
+#include "game/util/time.hpp"
 
 namespace engine {
   class game_dispatch {

+ 1 - 0
engine/include/game/engine/scene.hpp

@@ -8,6 +8,7 @@
 #pragma once
 
 #include <memory>
+#include <unordered_map>
 #include <vector>
 
 #include "game/math/math_fwd.hpp"

+ 1 - 1
engine/src/entity.cxx

@@ -11,8 +11,8 @@
 #include <json/json.h>
 
 #include "game/engine/serial.hpp"
-#include "game/engine/time.hpp"
 #include "game/graphics/material.hpp"
+#include "game/util/time.hpp"
 
 using namespace engine;
 

+ 25 - 26
engine/src/scene.cpp

@@ -13,42 +13,41 @@
 #include "game/graphics/renderer.hpp"
 #include "game/math/common.hpp"
 
-namespace engine {
+using namespace engine;
 
-  scene::~scene() {}
+scene::~scene() {}
 
-  void scene::update(float delta) {
-    for (auto & ent : entities) {
-      ent.update(delta);
-    }
-    for (auto & pair : colliders) {
-      auto & collidable = collidables[pair.first];
-      for (auto & ent : pair.second) {
-        for (auto & hit : collidable) {
-          if (math::intersects(ent->render_info().points,
-                               hit->render_info().points)) {
-            ent->collide(*hit);
-          }
+void scene::update(float delta) {
+  for (auto & ent : entities) {
+    ent.update(delta);
+  }
+  for (auto & pair : colliders) {
+    auto & collidable = collidables[pair.first];
+    for (auto & ent : pair.second) {
+      for (auto & hit : collidable) {
+        if (math::intersects(ent->render_info().points,
+                             hit->render_info().points)) {
+          ent->collide(*hit);
         }
       }
     }
   }
+}
 
-  void scene::render() {
-    for (auto & ent : entities) {
-      renderer->draw(ent.render_info());
-    }
+void scene::render() {
+  for (auto & ent : entities) {
+    renderer->draw(ent.render_info());
   }
+}
 
-  void scene::handle_key_event(event::key_event evt) {
-    if (evt.type & event::PRESSED_MASK && evt.key == key::QUIT) {
-      dispatch_.lock()->quit();
-    }
+void scene::handle_key_event(event::key_event evt) {
+  if (evt.type & event::PRESSED_MASK && evt.key == key::QUIT) {
+    dispatch_.lock()->quit();
   }
+}
 
-  void scene::handle_mouse_event(event::mouse_event evt) {}
+void scene::handle_mouse_event(event::mouse_event evt) {}
 
-  math::vec2 scene::size() const { return local_scene_dimension_; }
+math::vec2 scene::size() const { return local_scene_dimension_; }
 
-  key_binding const & scene::keys() const { return keys_; }
-}
+key_binding const & scene::keys() const { return keys_; }

+ 4 - 0
util/gameutils.xcodeproj/project.pbxproj

@@ -9,6 +9,7 @@
 /* Begin PBXBuildFile section */
 		CD62FD04229195FF00376440 /* files.cxx in Sources */ = {isa = PBXBuildFile; fileRef = CD62FD02229195FF00376440 /* files.cxx */; };
 		CD62FD082291988F00376440 /* osx_env.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD62FD072291988F00376440 /* osx_env.mm */; };
+		CD7E87772295FA1F00D877FE /* time.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD7E876F2295FA1F00D877FE /* time.cpp */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXContainerItemProxy section */
@@ -49,6 +50,7 @@
 		CD62FCFF2291953700376440 /* game */ = {isa = PBXFileReference; lastKnownFileType = folder; name = game; path = include/game; sourceTree = "<group>"; };
 		CD62FD02229195FF00376440 /* files.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = files.cxx; sourceTree = "<group>"; };
 		CD62FD072291988F00376440 /* osx_env.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = osx_env.mm; sourceTree = "<group>"; };
+		CD7E876F2295FA1F00D877FE /* time.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = time.cpp; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -86,6 +88,7 @@
 				CD62FCFC2291951400376440 /* linux_env.cxx */,
 				CD62FD072291988F00376440 /* osx_env.mm */,
 				CD62FD02229195FF00376440 /* files.cxx */,
+				CD7E876F2295FA1F00D877FE /* time.cpp */,
 			);
 			path = src;
 			sourceTree = "<group>";
@@ -227,6 +230,7 @@
 			files = (
 				CD62FD082291988F00376440 /* osx_env.mm in Sources */,
 				CD62FD04229195FF00376440 /* files.cxx in Sources */,
+				CD7E87772295FA1F00D877FE /* time.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

engine/include/game/engine/time.hpp → util/include/game/util/time.hpp


+ 1 - 1
engine/src/time.cpp

@@ -5,7 +5,7 @@
 //  Created by Sam Jaffe on 9/3/16.
 //
 
-#include "game/engine/time.hpp"
+#include "game/util/time.hpp"
 
 namespace engine {
   using std::chrono::duration_cast;