Browse Source

Actually parse the JSON into a burstshot.

Sam Jaffe 6 năm trước cách đây
mục cha
commit
cd3cfa6992
2 tập tin đã thay đổi với 21 bổ sung2 xóa
  1. 12 0
      danmaku.xcodeproj/project.pbxproj
  2. 9 2
      src/pattern/burstshot_pattern.cxx

+ 12 - 0
danmaku.xcodeproj/project.pbxproj

@@ -26,6 +26,7 @@
 		CD49F778229B0FCD00EB8926 /* actor.cxx in Sources */ = {isa = PBXBuildFile; fileRef = CD49F777229B0FCD00EB8926 /* actor.cxx */; };
 		CD49F783229B194C00EB8926 /* burstshot_pattern.cxx in Sources */ = {isa = PBXBuildFile; fileRef = CD49F782229B194C00EB8926 /* burstshot_pattern.cxx */; };
 		CD49F784229B25DE00EB8926 /* libmath.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CD7E883022960DBC00D877FE /* libmath.dylib */; };
+		CD49F786229B291D00EB8926 /* libjsoncpp.1.8.4.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CD49F785229B291D00EB8926 /* libjsoncpp.1.8.4.dylib */; };
 		CD7E87A52295FCED00D877FE /* danmakuUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = CD7E87A42295FCED00D877FE /* danmakuUITests.m */; };
 /* End PBXBuildFile section */
 
@@ -87,6 +88,7 @@
 		CD49F76C229B0A8000EB8926 /* bullet_pattern.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = bullet_pattern.cxx; sourceTree = "<group>"; };
 		CD49F777229B0FCD00EB8926 /* actor.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = actor.cxx; sourceTree = "<group>"; };
 		CD49F782229B194C00EB8926 /* burstshot_pattern.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = burstshot_pattern.cxx; sourceTree = "<group>"; };
+		CD49F785229B291D00EB8926 /* 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>"; };
 		CD7E87862295FCEA00D877FE /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
 		CD7E87872295FCEA00D877FE /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
 		CD7E878D2295FCEA00D877FE /* GameView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GameView.h; sourceTree = "<group>"; };
@@ -109,6 +111,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				CD49F786229B291D00EB8926 /* libjsoncpp.1.8.4.dylib in Frameworks */,
 				CD49F784229B25DE00EB8926 /* libmath.dylib in Frameworks */,
 				CD1C833F2298A9E000825C4E /* libengine.dylib in Frameworks */,
 				CD1C83402298A9E000825C4E /* libgameutils.dylib in Frameworks */,
@@ -211,6 +214,7 @@
 		CD7E87CE2295FFC500D877FE /* Frameworks */ = {
 			isa = PBXGroup;
 			children = (
+				CD49F785229B291D00EB8926 /* libjsoncpp.1.8.4.dylib */,
 			);
 			name = Frameworks;
 			sourceTree = "<group>";
@@ -450,6 +454,10 @@
 					"$(inherited)",
 					"@executable_path/../Frameworks",
 				);
+				LIBRARY_SEARCH_PATHS = (
+					"$(inherited)",
+					/opt/local/lib,
+				);
 				PRODUCT_BUNDLE_IDENTIFIER = leumasjaffe.danmaku;
 				PRODUCT_NAME = "$(TARGET_NAME)";
 			};
@@ -468,6 +476,10 @@
 					"$(inherited)",
 					"@executable_path/../Frameworks",
 				);
+				LIBRARY_SEARCH_PATHS = (
+					"$(inherited)",
+					/opt/local/lib,
+				);
 				PRODUCT_BUNDLE_IDENTIFIER = leumasjaffe.danmaku;
 				PRODUCT_NAME = "$(TARGET_NAME)";
 			};

+ 9 - 2
src/pattern/burstshot_pattern.cxx

@@ -6,6 +6,7 @@
 //  Copyright © 2019 Sam Jaffe. All rights reserved.
 //
 
+#include <json/json.h>
 #include <vector>
 
 #include "danmaku/bullet_pattern.hpp"
@@ -35,7 +36,10 @@ struct burstshot : public danmaku::bullet_pattern {
 std::vector<shot> shot_vector(std::size_t count, float facing, float covered,
                               float speed, bool clockwise) {
   if (covered == 360.f) { ++count; }
+  if (clockwise) { covered = -covered; }
+
   std::vector<shot> out(count);
+
   float start = facing + (.5f * covered);
   float end = start - covered;
   if (clockwise != (end < start)) { std::swap(start, end); }
@@ -55,8 +59,11 @@ burstshot::burstshot(danmaku::actor * actor, float shot_interval,
 
 std::shared_ptr<burstshot> burstshot::create(danmaku::actor * actor,
                                              Json::Value const & json) {
-  return std::make_shared<burstshot>(actor, 0.f,
-                                     shot_vector(0, 0.f, 0.f, 0.f, false));
+  return std::make_shared<burstshot>(
+      actor, json["timeBetweenBullets"].asFloat(),
+      shot_vector(json["bulletsPerWave"].asUInt(),
+                  json["centerAngle"].asFloat(), json["burstAngle"].asFloat(),
+                  json["bulletSpeed"].asFloat(), json["clockwise"].asBool()));
 }
 
 void burstshot::update(float delta) {}