Browse Source

Moved example.md

Björn Ritzl 7 tháng trước cách đây
mục cha
commit
412e4c5a2a
83 tập tin đã thay đổi với 2 bổ sung121 xóa
  1. 2 4
      README.md
  2. 0 0
      animation/basic_tween/example.md
  3. 0 0
      animation/chained_tween/example.md
  4. 0 0
      animation/cursor/example.md
  5. 0 0
      animation/easing/example.md
  6. 0 0
      animation/euler_rotation/example.md
  7. 0 0
      animation/flipbook/example.md
  8. 0 0
      animation/spine/example.md
  9. 0 0
      animation/spinner/example.md
  10. 0 0
      basics/message_passing/example.md
  11. 0 0
      basics/parent_child/example.md
  12. 0 0
      basics/z_order/example.md
  13. 0 0
      collection/proxy/example.md
  14. 0 0
      collection/splash/example.md
  15. 0 0
      collection/timestep/example.md
  16. 0 0
      debug/physics/example.md
  17. 0 0
      debug/profile/example.md
  18. 0 0
      factory/basic/example.md
  19. 0 0
      factory/bullets/example.md
  20. 0 0
      factory/dynamic/example.md
  21. 0 0
      file/sys_save_load/example.md
  22. 0 0
      gui/button/example.md
  23. 0 0
      gui/color/example.md
  24. 0 0
      gui/drag/example.md
  25. 0 0
      gui/get_set_font/example.md
  26. 0 0
      gui/get_set_material/example.md
  27. 0 0
      gui/get_set_texture/example.md
  28. 0 0
      gui/healthbar/example.md
  29. 0 0
      gui/layouts/example.md
  30. 0 0
      gui/load_texture/example.md
  31. 0 0
      gui/pointer_over/example.md
  32. 0 0
      gui/progress/example.md
  33. 0 0
      gui/slice9/example.md
  34. 0 0
      gui/stencil/example.md
  35. 0 0
      input/down_duration/example.md
  36. 0 0
      input/mouse_and_touch/example.md
  37. 0 0
      input/move/example.md
  38. 0 0
      input/text/example.md
  39. 0 0
      material/noise/example.md
  40. 0 0
      material/screenspace/example.md
  41. 0 0
      material/unlit/example.md
  42. 0 0
      material/uvgradient/example.md
  43. 0 0
      material/vertexcolor/example.md
  44. 0 0
      mesh/triangle/example.md
  45. 0 0
      model/cubemap/example.md
  46. 0 0
      movement/follow/example.md
  47. 0 0
      movement/look_at/example.md
  48. 0 0
      movement/look_rotation/example.md
  49. 0 0
      movement/move_forward/example.md
  50. 0 0
      movement/move_to/example.md
  51. 0 0
      movement/movement_speed/example.md
  52. 0 0
      movement/simple_move/example.md
  53. 0 49
      orbit_camera.script
  54. 0 0
      particles/confetti/example.md
  55. 0 0
      particles/fire_and_smoke/example.md
  56. 0 0
      particles/fireworks/example.md
  57. 0 0
      particles/modifiers/example.md
  58. 0 0
      particles/particlefx/example.md
  59. 0 0
      physics/dynamic/example.md
  60. 0 0
      physics/hinge_joint/example.md
  61. 0 0
      physics/kinematic/example.md
  62. 0 0
      physics/knockback/example.md
  63. 0 0
      physics/pendulum/example.md
  64. 0 0
      physics/raycast/example.md
  65. 0 0
      physics/trigger/example.md
  66. 0 0
      render/camera/example.md
  67. 0 0
      render/orbit_camera/example.md
  68. 0 0
      render/screen_to_world/example.md
  69. 0 0
      resource/create_atlas/example.md
  70. 0 0
      resource/modify_atlas/example.md
  71. 0 0
      sound/fade_in_out/example.md
  72. 0 0
      sound/music/example.md
  73. 0 0
      sound/panning/example.md
  74. 0 68
      split.py
  75. 0 0
      sprite/bunnymark/example.md
  76. 0 0
      sprite/flip/example.md
  77. 0 0
      sprite/size/example.md
  78. 0 0
      sprite/tint/example.md
  79. 0 0
      tilemap/collisions/example.md
  80. 0 0
      tilemap/get_set_tile/example.md
  81. 0 0
      timer/cancel_timer/example.md
  82. 0 0
      timer/repeating_timer/example.md
  83. 0 0
      timer/trigger_timer/example.md

+ 2 - 4
README.md

@@ -6,8 +6,8 @@ This repository includes the Defold examples used in the examples section on htt
 Examples are grouped by category, for instance "physics", "sprite" or "collection". Each group of examples has a folder in /examples. Here's how to add a new example named "foobar" to the "sprite" category:
 
 * Create a folder named `foobar` in `examples/sprite`
-* Create `examples/sprite/foobar/foobar.collection` with your example
-* Create `examples/sprite/foobar/foobar.md` with example documentation. The file must start with:
+* Create `examples/sprite/foobar/game.project` and the files required for your example
+* Create `examples/sprite/foobar/example.md` with example documentation. The file must start with:
 
 ```
 ---
@@ -18,5 +18,3 @@ scripts: foobar.script
 ```
 
 * List any scripts your example uses in the `scripts` field of the file header
-* Add a new collection proxy in `examples/_main/loader.go`
-* Add a new entry in `examples/_main/menu.gui_script`

+ 0 - 0
animation/basic_tween/example/example.md → animation/basic_tween/example.md


+ 0 - 0
animation/chained_tween/example/example.md → animation/chained_tween/example.md


+ 0 - 0
animation/cursor/example/example.md → animation/cursor/example.md


+ 0 - 0
animation/easing/example/example.md → animation/easing/example.md


+ 0 - 0
animation/euler_rotation/example/example.md → animation/euler_rotation/example.md


+ 0 - 0
animation/flipbook/example/example.md → animation/flipbook/example.md


+ 0 - 0
animation/spine/example/example.md → animation/spine/example.md


+ 0 - 0
animation/spinner/example/example.md → animation/spinner/example.md


+ 0 - 0
basics/message_passing/example/example.md → basics/message_passing/example.md


+ 0 - 0
basics/parent_child/example/example.md → basics/parent_child/example.md


+ 0 - 0
basics/z_order/example/example.md → basics/z_order/example.md


+ 0 - 0
collection/proxy/example/example.md → collection/proxy/example.md


+ 0 - 0
collection/splash/example/example.md → collection/splash/example.md


+ 0 - 0
collection/timestep/example/example.md → collection/timestep/example.md


+ 0 - 0
debug/physics/example/example.md → debug/physics/example.md


+ 0 - 0
debug/profile/example/example.md → debug/profile/example.md


+ 0 - 0
factory/basic/example/example.md → factory/basic/example.md


+ 0 - 0
factory/bullets/example/example.md → factory/bullets/example.md


+ 0 - 0
factory/dynamic/example/example.md → factory/dynamic/example.md


+ 0 - 0
file/sys_save_load/example/example.md → file/sys_save_load/example.md


+ 0 - 0
gui/button/example/example.md → gui/button/example.md


+ 0 - 0
gui/color/example/example.md → gui/color/example.md


+ 0 - 0
gui/drag/example/example.md → gui/drag/example.md


+ 0 - 0
gui/get_set_font/example/example.md → gui/get_set_font/example.md


+ 0 - 0
gui/get_set_material/example/example.md → gui/get_set_material/example.md


+ 0 - 0
gui/get_set_texture/example/example.md → gui/get_set_texture/example.md


+ 0 - 0
gui/healthbar/example/example.md → gui/healthbar/example.md


+ 0 - 0
gui/layouts/example/example.md → gui/layouts/example.md


+ 0 - 0
gui/load_texture/example/example.md → gui/load_texture/example.md


+ 0 - 0
gui/pointer_over/example/example.md → gui/pointer_over/example.md


+ 0 - 0
gui/progress/example/example.md → gui/progress/example.md


+ 0 - 0
gui/slice9/example/example.md → gui/slice9/example.md


+ 0 - 0
gui/stencil/example/example.md → gui/stencil/example.md


+ 0 - 0
input/down_duration/example/example.md → input/down_duration/example.md


+ 0 - 0
input/mouse_and_touch/example/example.md → input/mouse_and_touch/example.md


+ 0 - 0
input/move/example/example.md → input/move/example.md


+ 0 - 0
input/text/example/example.md → input/text/example.md


+ 0 - 0
material/noise/example/example.md → material/noise/example.md


+ 0 - 0
material/screenspace/example/example.md → material/screenspace/example.md


+ 0 - 0
material/unlit/example/example.md → material/unlit/example.md


+ 0 - 0
material/uvgradient/example/example.md → material/uvgradient/example.md


+ 0 - 0
material/vertexcolor/example/example.md → material/vertexcolor/example.md


+ 0 - 0
mesh/triangle/example/example.md → mesh/triangle/example.md


+ 0 - 0
model/cubemap/example/example.md → model/cubemap/example.md


+ 0 - 0
movement/follow/example/example.md → movement/follow/example.md


+ 0 - 0
movement/look_at/example/example.md → movement/look_at/example.md


+ 0 - 0
movement/look_rotation/example/example.md → movement/look_rotation/example.md


+ 0 - 0
movement/move_forward/example/example.md → movement/move_forward/example.md


+ 0 - 0
movement/move_to/example/example.md → movement/move_to/example.md


+ 0 - 0
movement/movement_speed/example/example.md → movement/movement_speed/example.md


+ 0 - 0
movement/simple_move/example/example.md → movement/simple_move/example.md


+ 0 - 49
orbit_camera.script

@@ -1,49 +0,0 @@
--- The initial zoom level
-go.property("zoom", 3)
--- The speed of the zoom
-go.property("zoom_speed", 0.1)
--- The speed of the rotation
-go.property("rotation_speed", 0.5)
--- The offset of the camera from the origin
-go.property("offset", vmath.vector3(0, 0, 0))
-
-function init(self)
-	-- Acquire input focus to receive input events
-	msg.post(".", "acquire_input_focus")
-
-	-- Initialize start values
-	self.yaw = go.get(".", "euler.y")
-	self.pitch = go.get(".", "euler.x")
-	self.zoom_offset = 0
-	self.current_yaw = self.yaw
-	self.current_pitch = self.pitch
-	self.current_zoom = self.zoom_offset
-end
-
-function update(self, dt)
-	-- Animate camera rotation and zoom
-	self.current_yaw = vmath.lerp(0.15, self.current_yaw, self.yaw)
-	self.current_pitch = vmath.lerp(0.15, self.current_pitch, self.pitch)
-	self.current_zoom = vmath.lerp(0.15, self.current_zoom, self.zoom_offset)
-
-	-- Calculate rotation and position
-	local camera_yaw = vmath.quat_rotation_y(math.rad(self.current_yaw))
-	local camera_pitch = vmath.quat_rotation_x(math.rad(self.current_pitch))
-	local camera_rotation = camera_yaw * camera_pitch
-	local camera_position = self.offset + vmath.rotate(camera_rotation, vmath.vector3(0, 0, self.zoom + self.current_zoom))
-
-	-- Set camera position and rotation
-	go.set_position(camera_position)
-	go.set_rotation(camera_rotation)
-end
-
-function on_input(self, action_id, action)
-	if action_id == hash("touch") and not action.pressed then
-		self.yaw   = self.yaw   - action.dx * self.rotation_speed
-		self.pitch = self.pitch + action.dy * self.rotation_speed
-	elseif action_id == hash("wheel_up") then
-		self.zoom_offset = self.zoom_offset - self.zoom * self.zoom_speed
-	elseif action_id == hash("wheel_down") then
-		self.zoom_offset = self.zoom_offset + self.zoom * self.zoom_speed
-	end
-end

+ 0 - 0
particles/confetti/example/example.md → particles/confetti/example.md


+ 0 - 0
particles/fire_and_smoke/example/example.md → particles/fire_and_smoke/example.md


+ 0 - 0
particles/fireworks/example/example.md → particles/fireworks/example.md


+ 0 - 0
particles/modifiers/example/example.md → particles/modifiers/example.md


+ 0 - 0
particles/particlefx/example/example.md → particles/particlefx/example.md


+ 0 - 0
physics/dynamic/example/example.md → physics/dynamic/example.md


+ 0 - 0
physics/hinge_joint/example/example.md → physics/hinge_joint/example.md


+ 0 - 0
physics/kinematic/example/example.md → physics/kinematic/example.md


+ 0 - 0
physics/knockback/example/example.md → physics/knockback/example.md


+ 0 - 0
physics/pendulum/example/example.md → physics/pendulum/example.md


+ 0 - 0
physics/raycast/example/example.md → physics/raycast/example.md


+ 0 - 0
physics/trigger/example/example.md → physics/trigger/example.md


+ 0 - 0
render/camera/example/example.md → render/camera/example.md


+ 0 - 0
render/orbit_camera/example/example.md → render/orbit_camera/example.md


+ 0 - 0
render/screen_to_world/example/example.md → render/screen_to_world/example.md


+ 0 - 0
resource/create_atlas/example/example.md → resource/create_atlas/example.md


+ 0 - 0
resource/modify_atlas/example/example.md → resource/modify_atlas/example.md


+ 0 - 0
sound/fade_in_out/example/example.md → sound/fade_in_out/example.md


+ 0 - 0
sound/music/example/example.md → sound/music/example.md


+ 0 - 0
sound/panning/example/example.md → sound/panning/example.md


+ 0 - 68
split.py

@@ -1,68 +0,0 @@
-#!/usr/bin/env python
-
-import os
-import shutil
-import re
-
-
-def replace_in_file(filename, old, new, flags=None):
-    with open(filename) as f:
-        if flags is None:
-            content = re.sub(old, new, f.read())
-        else:
-            content = re.sub(old, new, f.read(), flags=flags)
-
-    with open(filename, "w") as f:
-        f.write(content)
-
-
-
-output_dir = "foo"
-os.makedirs(output_dir, exist_ok=True)
-
-
-
-
-examples_dir = "examples"
-
-categories = os.listdir(examples_dir)
-
-for category in categories:
-	category_path = os.path.join(examples_dir, category)
-	if os.path.isfile(category_path):
-		continue
-	if category == "_main":
-		continue
-	print("category", category)
-	for example in os.listdir(category_path):
-		print("  example", example)
-
-		example_out_dir = os.path.join(output_dir, category + "_" + example)
-		os.makedirs(example_out_dir, exist_ok=True)
-
-		shutil.copytree("assets", os.path.join(example_out_dir, "assets"), dirs_exist_ok=True)
-		shutil.copytree("input", os.path.join(example_out_dir, "input"), dirs_exist_ok=True)
-		shutil.copyfile("game.project", os.path.join(example_out_dir, "game.project"))
-		shutil.copyfile("all.texture_profiles", os.path.join(example_out_dir, "all.texture_profiles"))
-		shutil.copyfile(".gitignore", os.path.join(example_out_dir, ".gitignore"))
-
-		example_src = os.path.join(examples_dir, category, example)
-		example_dst = os.path.join(example_out_dir, "example")
-		shutil.copytree(example_src, example_dst, dirs_exist_ok=True)
-
-		replace_in_file(os.path.join(example_out_dir, "game.project"), r"/examples/main.collectionc", r"/example/" + example + ".collectionc")
-
-		for file in os.listdir(example_dst):
-			file_path = os.path.join(example_dst, file)
-			name, ext = os.path.splitext(file)
-			if os.path.isdir(file_path):
-				continue
-			if ext in [".png", ".wav", ".ogg", ".jpg"]:
-				continue
-			# /examples/animation/basic_tween/
-			src = r"/examples/" + category + "/" + example + "/"
-			tgt = r"/example/"
-			replace_in_file(file_path, src, tgt)
-
-			if ext == ".md":
-				replace_in_file(file_path, r"title", r"tags: " + category + "\ntitle")

+ 0 - 0
sprite/bunnymark/example/example.md → sprite/bunnymark/example.md


+ 0 - 0
sprite/flip/example/example.md → sprite/flip/example.md


+ 0 - 0
sprite/size/example/example.md → sprite/size/example.md


+ 0 - 0
sprite/tint/example/example.md → sprite/tint/example.md


+ 0 - 0
tilemap/collisions/example/example.md → tilemap/collisions/example.md


+ 0 - 0
tilemap/get_set_tile/example/example.md → tilemap/get_set_tile/example.md


+ 0 - 0
timer/cancel_timer/example/example.md → timer/cancel_timer/example.md


+ 0 - 0
timer/repeating_timer/example/example.md → timer/repeating_timer/example.md


+ 0 - 0
timer/trigger_timer/example/example.md → timer/trigger_timer/example.md