Ver Fonte

Added bunnymark

Björn Ritzl há 2 anos atrás
pai
commit
c895e8adc6

+ 18 - 0
examples/_main/loader.go

@@ -1036,3 +1036,21 @@ embedded_components {
     w: 1.0
   }
 }
+embedded_components {
+  id: "sprite/bunnymark"
+  type: "collectionproxy"
+  data: "collection: \"/examples/sprite/bunnymark/bunnymark.collection\"\n"
+  "exclude: false\n"
+  ""
+  position {
+    x: 0.0
+    y: 0.0
+    z: 0.0
+  }
+  rotation {
+    x: 0.0
+    y: 0.0
+    z: 0.0
+    w: 1.0
+  }
+}

+ 1 - 1
examples/_main/menu.gui_script

@@ -112,7 +112,7 @@ function init(self)
 	self.index["render"] = { "camera" }
 	self.index["debug"] = { "physics", "profile" }
 	self.index["collection"] = { "proxy", "splash" }
-	self.index["sprite"] = { "size", "tint", "flip" }
+	self.index["sprite"] = { "size", "tint", "flip", "bunnymark" }
 	self.index["file"] = { "sys_save_load" }
 	self.index["tilemap"] = { "collisions", "get_set_tile" }
 	self.index["timer"] = { "repeating_timer", "trigger_timer", "cancel_timer" }

+ 20 - 0
examples/sprite/bunnymark/bunny.go

@@ -0,0 +1,20 @@
+embedded_components {
+  id: "sprite"
+  type: "sprite"
+  data: "tile_set: \"/examples/sprite/bunnymark/bunnymark.atlas\"\n"
+  "default_animation: \"rabbitv3\"\n"
+  "material: \"/builtins/materials/sprite.material\"\n"
+  "blend_mode: BLEND_MODE_ALPHA\n"
+  ""
+  position {
+    x: 0.0
+    y: 0.0
+    z: 0.0
+  }
+  rotation {
+    x: 0.0
+    y: 0.0
+    z: 0.0
+    w: 1.0
+  }
+}

+ 53 - 0
examples/sprite/bunnymark/bunnymark.atlas

@@ -0,0 +1,53 @@
+images {
+  image: "/examples/sprite/bunnymark/images/rabbitv3.png"
+  sprite_trim_mode: SPRITE_TRIM_MODE_OFF
+}
+images {
+  image: "/examples/sprite/bunnymark/images/rabbitv3_ash.png"
+  sprite_trim_mode: SPRITE_TRIM_MODE_OFF
+}
+images {
+  image: "/examples/sprite/bunnymark/images/rabbitv3_bb8.png"
+  sprite_trim_mode: SPRITE_TRIM_MODE_OFF
+}
+images {
+  image: "/examples/sprite/bunnymark/images/rabbitv3_neo.png"
+  sprite_trim_mode: SPRITE_TRIM_MODE_OFF
+}
+images {
+  image: "/examples/sprite/bunnymark/images/rabbitv3_tron.png"
+  sprite_trim_mode: SPRITE_TRIM_MODE_OFF
+}
+images {
+  image: "/examples/sprite/bunnymark/images/rabbitv3_batman.png"
+  sprite_trim_mode: SPRITE_TRIM_MODE_OFF
+}
+images {
+  image: "/examples/sprite/bunnymark/images/rabbitv3_sonic.png"
+  sprite_trim_mode: SPRITE_TRIM_MODE_OFF
+}
+images {
+  image: "/examples/sprite/bunnymark/images/rabbitv3_spidey.png"
+  sprite_trim_mode: SPRITE_TRIM_MODE_OFF
+}
+images {
+  image: "/examples/sprite/bunnymark/images/rabbitv3_superman.png"
+  sprite_trim_mode: SPRITE_TRIM_MODE_OFF
+}
+images {
+  image: "/examples/sprite/bunnymark/images/rabbitv3_wolverine.png"
+  sprite_trim_mode: SPRITE_TRIM_MODE_OFF
+}
+images {
+  image: "/examples/sprite/bunnymark/images/rabbitv3_frankenstein.png"
+  sprite_trim_mode: SPRITE_TRIM_MODE_OFF
+}
+images {
+  image: "/examples/sprite/bunnymark/images/rabbitv3_stormtrooper.png"
+  sprite_trim_mode: SPRITE_TRIM_MODE_OFF
+}
+margin: 0
+extrude_borders: 1
+inner_padding: 0
+max_page_width: 0
+max_page_height: 0

+ 106 - 0
examples/sprite/bunnymark/bunnymark.collection

@@ -0,0 +1,106 @@
+name: "bunnymark"
+scale_along_z: 0
+embedded_instances {
+  id: "go"
+  data: "components {\n"
+  "  id: \"bunnymark\"\n"
+  "  component: \"/examples/sprite/bunnymark/bunnymark.script\"\n"
+  "  position {\n"
+  "    x: 0.0\n"
+  "    y: 0.0\n"
+  "    z: 0.0\n"
+  "  }\n"
+  "  rotation {\n"
+  "    x: 0.0\n"
+  "    y: 0.0\n"
+  "    z: 0.0\n"
+  "    w: 1.0\n"
+  "  }\n"
+  "  property_decls {\n"
+  "  }\n"
+  "}\n"
+  "embedded_components {\n"
+  "  id: \"factory\"\n"
+  "  type: \"factory\"\n"
+  "  data: \"prototype: \\\"/examples/sprite/bunnymark/bunny.go\\\"\\n"
+  "load_dynamically: false\\n"
+  "dynamic_prototype: false\\n"
+  "\"\n"
+  "  position {\n"
+  "    x: 0.0\n"
+  "    y: 0.0\n"
+  "    z: 0.0\n"
+  "  }\n"
+  "  rotation {\n"
+  "    x: 0.0\n"
+  "    y: 0.0\n"
+  "    z: 0.0\n"
+  "    w: 1.0\n"
+  "  }\n"
+  "}\n"
+  "embedded_components {\n"
+  "  id: \"label\"\n"
+  "  type: \"label\"\n"
+  "  data: \"size {\\n"
+  "  x: 128.0\\n"
+  "  y: 32.0\\n"
+  "  z: 0.0\\n"
+  "  w: 0.0\\n"
+  "}\\n"
+  "color {\\n"
+  "  x: 0.0\\n"
+  "  y: 0.0\\n"
+  "  z: 0.0\\n"
+  "  w: 1.0\\n"
+  "}\\n"
+  "outline {\\n"
+  "  x: 0.0\\n"
+  "  y: 0.0\\n"
+  "  z: 0.0\\n"
+  "  w: 1.0\\n"
+  "}\\n"
+  "shadow {\\n"
+  "  x: 0.0\\n"
+  "  y: 0.0\\n"
+  "  z: 0.0\\n"
+  "  w: 1.0\\n"
+  "}\\n"
+  "leading: 1.0\\n"
+  "tracking: 0.0\\n"
+  "pivot: PIVOT_S\\n"
+  "blend_mode: BLEND_MODE_ALPHA\\n"
+  "line_break: false\\n"
+  "text: \\\"Label\\\"\\n"
+  "font: \\\"/builtins/fonts/system_font.font\\\"\\n"
+  "material: \\\"/builtins/fonts/label.material\\\"\\n"
+  "\"\n"
+  "  position {\n"
+  "    x: 0.0\n"
+  "    y: 0.0\n"
+  "    z: 0.0\n"
+  "  }\n"
+  "  rotation {\n"
+  "    x: 0.0\n"
+  "    y: 0.0\n"
+  "    z: 0.0\n"
+  "    w: 1.0\n"
+  "  }\n"
+  "}\n"
+  ""
+  position {
+    x: 360.0
+    y: 5.0
+    z: 0.0
+  }
+  rotation {
+    x: 0.0
+    y: 0.0
+    z: 0.0
+    w: 1.0
+  }
+  scale3 {
+    x: 1.0
+    y: 1.0
+    z: 1.0
+  }
+}

+ 7 - 0
examples/sprite/bunnymark/bunnymark.md

@@ -0,0 +1,7 @@
+---
+title: Bunnymark
+brief: This is a performance test for sprites
+scripts: bunnymark.script
+---
+
+The example spawns game objects and animates them using go.animate(). An alternative bunnymark test with more options can be found [here](https://github.com/britzl/defold-bunnymark).

+ 58 - 0
examples/sprite/bunnymark/bunnymark.script

@@ -0,0 +1,58 @@
+local BUNNY_IMAGES = {
+	hash("rabbitv3_batman"),
+	hash("rabbitv3_bb8"),
+	hash("rabbitv3"),
+	hash("rabbitv3_ash"),
+	hash("rabbitv3_frankenstein"),
+	hash("rabbitv3_neo"),
+	hash("rabbitv3_sonic"),
+	hash("rabbitv3_spidey"),
+	hash("rabbitv3_stormtrooper"),
+	hash("rabbitv3_superman"),
+	hash("rabbitv3_tron"),
+	hash("rabbitv3_wolverine"),
+}
+
+local DISPLAY_WIDTH = sys.get_config_int("display.width")
+local DISPLAY_HEIGHT = sys.get_config_int("display.height")
+
+local SPAWN_COUNT = 1000
+
+local function spawn(self, amount)
+	for i=1,amount do
+		local bunny = factory.create("#factory")
+		if bunny then
+			local img = BUNNY_IMAGES[math.random(1, #BUNNY_IMAGES)]
+			sprite.play_flipbook(msg.url(nil, bunny, "sprite"), img)
+			go.set_position(vmath.vector3(math.random(DISPLAY_WIDTH), DISPLAY_HEIGHT, 0), bunny)
+			go.animate(bunny, "position.y", go.PLAYBACK_LOOP_PINGPONG, 40, go.EASING_INQUAD, 2, math.random())
+			self.bunnies = self.bunnies + 1
+		else
+			print("Unable to create more bunnies")
+			break
+		end
+	end
+end
+
+function init(self)
+	msg.post(".", "acquire_input_focus")
+	self.frames = {}
+	self.bunnies = 0
+	spawn(self, SPAWN_COUNT)
+end
+
+function update(self, dt)
+	self.frames[#self.frames + 1] = socket.gettime()
+	local fps = 0
+	if #self.frames == 61 then
+		table.remove(self.frames, 1)
+		fps = 1 / ((self.frames[#self.frames] - self.frames[1]) / (#self.frames - 1))
+	end
+	label.set_text("#label", ("Bunnies: %d FPS: %.2f. Click to add more"):format(self.bunnies, fps))	
+end
+
+function on_input(self, action_id, action)
+	if action_id == hash("touch") and action.released and action.y < 1030 then
+		spawn(self, SPAWN_COUNT)
+	end
+end

BIN
examples/sprite/bunnymark/images/rabbitv3.png


BIN
examples/sprite/bunnymark/images/rabbitv3_ash.png


BIN
examples/sprite/bunnymark/images/rabbitv3_batman.png


BIN
examples/sprite/bunnymark/images/rabbitv3_bb8.png


BIN
examples/sprite/bunnymark/images/rabbitv3_frankenstein.png


BIN
examples/sprite/bunnymark/images/rabbitv3_neo.png


BIN
examples/sprite/bunnymark/images/rabbitv3_sonic.png


BIN
examples/sprite/bunnymark/images/rabbitv3_spidey.png


BIN
examples/sprite/bunnymark/images/rabbitv3_stormtrooper.png


BIN
examples/sprite/bunnymark/images/rabbitv3_superman.png


BIN
examples/sprite/bunnymark/images/rabbitv3_tron.png


BIN
examples/sprite/bunnymark/images/rabbitv3_wolverine.png


+ 5 - 1
game.project

@@ -1,7 +1,7 @@
 [project]
 title = Defold-examples
 version = 0.1
-dependencies#0 = https://github.com/defold/extension-spine/archive/refs/tags/2.10.3.zip
+dependencies#0 = https://github.com/defold/extension-spine/archive/refs/tags/2.10.6.zip
 
 [bootstrap]
 main_collection = /examples/main.collectionc
@@ -33,6 +33,7 @@ subpixels = 1
 
 [sprite]
 subpixels = 1
+max_count = 32765
 
 [windows]
 iap_provider = 
@@ -54,3 +55,6 @@ scale_mode = no_scale
 [graphics]
 texture_profiles = /all.texture_profiles
 
+[collection]
+max_instances = 32765
+