├── .gitignore ├── 15-puzzle ├── README.md ├── assets │ ├── images │ │ └── monalisa.png │ └── monalisa.tilesource ├── game.project ├── input │ └── game.input_binding └── main │ ├── game.script │ ├── grid.tilemap │ └── main.collection ├── Day 1.pdf ├── Day 2.pdf ├── README.md ├── hands_on ├── assets │ ├── game.atlas │ ├── images │ │ ├── ball.png │ │ ├── bg.png │ │ ├── blocker.png │ │ ├── bucket.png │ │ ├── icon_120.png │ │ └── pin.png │ └── sounds │ │ ├── bounce1.wav │ │ ├── bounce2.wav │ │ ├── bounce3.wav │ │ ├── metal1.wav │ │ └── metal2.wav ├── game.project ├── input │ └── game.input_binding └── main │ ├── ball.go │ ├── ball.script │ ├── blocker.go │ ├── bucket.go │ ├── explosion.particlefx │ ├── game.script │ ├── images │ └── logo.png │ ├── main.collection │ ├── pin.go │ └── pin.script ├── material ├── assets │ ├── atlases │ │ ├── fire.atlas │ │ └── main.atlas │ ├── images │ │ ├── defold_logo_bigger.png │ │ ├── fire │ │ │ ├── scene00001.jpg │ │ │ ├── scene00005.jpg │ │ │ ├── scene00009.jpg │ │ │ ├── scene00013.jpg │ │ │ ├── scene00017.jpg │ │ │ ├── scene00021.jpg │ │ │ ├── scene00025.jpg │ │ │ ├── scene00029.jpg │ │ │ ├── scene00033.jpg │ │ │ ├── scene00037.jpg │ │ │ ├── scene00041.jpg │ │ │ ├── scene00045.jpg │ │ │ ├── scene00049.jpg │ │ │ ├── scene00053.jpg │ │ │ ├── scene00057.jpg │ │ │ ├── scene00061.jpg │ │ │ ├── scene00065.jpg │ │ │ ├── scene00069.jpg │ │ │ ├── scene00073.jpg │ │ │ ├── scene00077.jpg │ │ │ ├── scene00081.jpg │ │ │ ├── scene00085.jpg │ │ │ ├── scene00089.jpg │ │ │ ├── scene00093.jpg │ │ │ ├── scene00097.jpg │ │ │ ├── scene00101.jpg │ │ │ ├── scene00105.jpg │ │ │ ├── scene00109.jpg │ │ │ ├── scene00113.jpg │ │ │ ├── scene00117.jpg │ │ │ ├── scene00121.jpg │ │ │ ├── scene00125.jpg │ │ │ ├── scene00129.jpg │ │ │ ├── scene00133.jpg │ │ │ ├── scene00137.jpg │ │ │ ├── scene00141.jpg │ │ │ ├── scene00145.jpg │ │ │ ├── scene00149.jpg │ │ │ ├── scene00153.jpg │ │ │ ├── scene00157.jpg │ │ │ ├── scene00161.jpg │ │ │ ├── scene00165.jpg │ │ │ ├── scene00169.jpg │ │ │ ├── scene00173.jpg │ │ │ ├── scene00177.jpg │ │ │ ├── scene00181.jpg │ │ │ ├── scene00185.jpg │ │ │ ├── scene00189.jpg │ │ │ ├── scene00193.jpg │ │ │ ├── scene00197.jpg │ │ │ ├── scene00201.jpg │ │ │ ├── scene00205.jpg │ │ │ ├── scene00209.jpg │ │ │ ├── scene00213.jpg │ │ │ ├── scene00217.jpg │ │ │ ├── scene00221.jpg │ │ │ ├── scene00225.jpg │ │ │ ├── scene00229.jpg │ │ │ └── scene00233.jpg │ │ └── heatmap.png │ ├── materials │ │ ├── effect_animcoords.fp │ │ ├── effect_animcoords.material │ │ ├── effect_grayscale.fp │ │ ├── effect_grayscale.material │ │ ├── effect_heat.fp │ │ ├── effect_heat.material │ │ ├── effect_invert.fp │ │ ├── effect_invert.material │ │ ├── fsquad.fp │ │ ├── fsquad.material │ │ └── model.vp │ ├── meshes │ │ └── fsquad.dae │ └── models │ │ └── fsquad.model ├── fonts │ └── log.font ├── game.project ├── input │ └── game.input_binding ├── main │ ├── extra │ │ └── slider.gui │ ├── main.collection │ ├── main.gui │ └── main.gui_script └── render │ ├── custom.render │ └── custom.render_script ├── oceancommotion-linker ├── .gitignore ├── README.md ├── game.project ├── input │ └── game.input_binding └── main │ ├── board.script │ ├── fish.go │ ├── fish.script │ ├── hud.gui │ └── main.collection ├── pong ├── .gitignore ├── README.md ├── assets │ ├── font │ │ ├── pixelfont.material │ │ ├── smallest_pixel-7.font │ │ └── smallest_pixel-7.ttf │ └── images │ │ ├── ball.png │ │ └── paddle.png ├── game.project ├── input │ └── game.input_binding └── pong │ ├── ai.script │ ├── ball.go │ ├── ball.script │ ├── player.script │ ├── pong.atlas │ └── pong.collection ├── runner ├── .gitignore ├── README.md ├── assets │ ├── background.atlas │ ├── hero.atlas │ ├── images │ │ ├── background │ │ │ ├── bg.png │ │ │ ├── earthlike_planet.png │ │ │ ├── gas_planet.png │ │ │ ├── ice_planet.png │ │ │ └── ring_planet.png │ │ ├── hero │ │ │ ├── ArmL01.png │ │ │ ├── ArmL02.png │ │ │ ├── ArmL03.png │ │ │ ├── ArmR01.png │ │ │ ├── ArmR02.png │ │ │ ├── ArmR03.png │ │ │ ├── BodyA01.png │ │ │ ├── BodyA02.png │ │ │ ├── BodyB01.png │ │ │ ├── BodyB02.png │ │ │ ├── Eye01.png │ │ │ ├── Head01.png │ │ │ ├── Head02.png │ │ │ ├── Head02B.png │ │ │ ├── Head03.png │ │ │ ├── Head03B.png │ │ │ ├── LegB01.png │ │ │ ├── LegB02.png │ │ │ ├── LegB03.png │ │ │ ├── LegB04.png │ │ │ ├── LegL00.png │ │ │ ├── LegLA01.png │ │ │ ├── LegLA02.png │ │ │ ├── LegLA03.png │ │ │ ├── LegLA04.png │ │ │ ├── LegR00.png │ │ │ ├── LegRA01.png │ │ │ ├── LegRA02.png │ │ │ ├── LegRA03.png │ │ │ ├── LegRA04.png │ │ │ ├── ThighL.png │ │ │ ├── ThighR.png │ │ │ └── empty.png │ │ └── level │ │ │ ├── coin.png │ │ │ ├── ground01.png │ │ │ ├── ground02.png │ │ │ ├── heart.png │ │ │ ├── rock_planks.png │ │ │ └── spikes.png │ └── level.atlas ├── fonts │ ├── BoogalooOne-Regular.ttf │ └── text.font ├── game.project ├── hero │ ├── hero.go │ ├── hero.json │ ├── hero.script │ └── hero.spinescene ├── input │ └── game.input_binding ├── level │ ├── controller.script │ ├── ground.collection │ ├── ground.script │ ├── level.collection │ └── objects │ │ ├── planets.go │ │ ├── planets.script │ │ ├── planets_small.go │ │ ├── platform.go │ │ ├── platform.script │ │ └── platform_long.go └── particles │ ├── coin.particlefx │ └── death.particlefx ├── shooter_hot_reload ├── game.project ├── input │ └── game.input_binding ├── main │ ├── AvenirNextW1G-Demi.otf │ ├── bezier.lua │ ├── bg.script │ ├── cover.gui │ ├── cover.gui_script │ ├── enemy.go │ ├── enemy.script │ ├── enemycontroller.script │ ├── explosion.particlefx │ ├── images │ │ ├── defold-pattern.png │ │ ├── enemy01.png │ │ ├── explosion00.png │ │ ├── flash00.png │ │ ├── player.png │ │ ├── star1.png │ │ ├── star2.png │ │ └── star3.png │ ├── main.collection │ ├── player.go │ ├── player.script │ ├── quad.dae │ ├── shooter.font │ └── sprites.atlas └── render │ ├── grid.fp │ ├── grid.material │ ├── grid.script │ ├── grid.vp │ ├── shooter.render │ ├── shooter.render_script │ ├── stars.fp │ ├── stars.material │ ├── stars.script │ └── stars.vp ├── sidescroller ├── .gitignore ├── README.md ├── assets │ ├── background.atlas │ ├── enemies.atlas │ ├── fonts │ │ ├── BoogalooOne-Regular.ttf │ │ └── score.font │ ├── images │ │ ├── background │ │ │ ├── bg.png │ │ │ ├── earthlike_planet.png │ │ │ ├── gas_planet.png │ │ │ ├── ice_planet.png │ │ │ └── ring_planet.png │ │ ├── bonus_star │ │ │ ├── bonus_star_00.png │ │ │ ├── bonus_star_01.png │ │ │ ├── bonus_star_02.png │ │ │ ├── bonus_star_03.png │ │ │ ├── bonus_star_04.png │ │ │ ├── bonus_star_05.png │ │ │ ├── bonus_star_06.png │ │ │ ├── bonus_star_07.png │ │ │ ├── bonus_star_08.png │ │ │ ├── bonus_star_09.png │ │ │ ├── bonus_star_10.png │ │ │ ├── bonus_star_11.png │ │ │ ├── bonus_star_12.png │ │ │ ├── bonus_star_13.png │ │ │ ├── bonus_star_14.png │ │ │ ├── bonus_star_15.png │ │ │ ├── bonus_star_16.png │ │ │ ├── bonus_star_17.png │ │ │ ├── bonus_star_18.png │ │ │ ├── bonus_star_19.png │ │ │ ├── bonus_star_20.png │ │ │ ├── bonus_star_21.png │ │ │ ├── bonus_star_22.png │ │ │ └── bonus_star_23.png │ │ ├── enemies │ │ │ └── enemyBlack1.png │ │ ├── spaceship │ │ │ ├── spaceship_00.png │ │ │ ├── spaceship_01.png │ │ │ ├── spaceship_02.png │ │ │ ├── spaceship_03.png │ │ │ ├── spaceship_04.png │ │ │ ├── spaceship_05.png │ │ │ ├── spaceship_06.png │ │ │ ├── spaceship_07.png │ │ │ └── spaceship_08.png │ │ └── star │ │ │ ├── star_00.png │ │ │ ├── star_01.png │ │ │ ├── star_02.png │ │ │ ├── star_03.png │ │ │ ├── star_04.png │ │ │ ├── star_05.png │ │ │ ├── star_06.png │ │ │ ├── star_07.png │ │ │ ├── star_08.png │ │ │ ├── star_09.png │ │ │ ├── star_10.png │ │ │ ├── star_11.png │ │ │ ├── star_12.png │ │ │ ├── star_13.png │ │ │ ├── star_14.png │ │ │ ├── star_15.png │ │ │ ├── star_16.png │ │ │ ├── star_17.png │ │ │ ├── star_18.png │ │ │ ├── star_19.png │ │ │ ├── star_20.png │ │ │ ├── star_21.png │ │ │ ├── star_22.png │ │ │ └── star_23.png │ ├── spaceship.atlas │ └── stars.atlas ├── background │ ├── large_planets.go │ ├── large_planets.script │ ├── small_planets.go │ └── small_planets.script ├── game.project ├── input │ └── game.input_binding ├── main │ └── main.collection ├── spaceship │ ├── spaceship.go │ └── spaceship.script └── stars │ ├── factory.go │ ├── factory.script │ ├── star.go │ └── star.script ├── snake ├── README.md ├── assets │ ├── images │ │ └── snake.png │ └── tiles.tilesource ├── game.project ├── input │ └── game.input_binding └── main │ ├── grid.tilemap │ ├── main.collection │ └── snake.script ├── texture_profiles ├── assets │ ├── atlases │ │ ├── alternative.atlas │ │ └── main.atlas │ └── images │ │ ├── defold_logo_bigger.png │ │ └── subfolder │ │ └── alternative_logo.png ├── custom.texture_profiles ├── fonts │ └── log.font ├── game.project ├── input │ └── game.input_binding └── main │ └── main.collection └── threedee ├── assets ├── atlases │ └── main.atlas ├── images │ ├── chest_texture.png │ └── defold_logo_bigger.png ├── materials │ ├── model.fp │ ├── model.material │ └── model_world.material ├── meshes │ ├── chest_anim_open.dae │ ├── chest_anim_open_03.dae │ ├── chest_model.dae │ ├── cube.dae │ └── test.animationset └── models │ ├── chest.model │ └── cube.model ├── fonts └── log.font ├── game.project ├── input └── game.input_binding ├── main ├── camera.script └── main.collection └── render ├── custom.render └── custom.render_script /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | .externalToolBuilders 3 | .DS_Store 4 | .lock-wscript 5 | build 6 | *.pyc 7 | .project 8 | .cproject 9 | builtins 10 | .internal 11 | -------------------------------------------------------------------------------- /15-puzzle/README.md: -------------------------------------------------------------------------------- 1 | # 15 Puzzle 2 | This well-known puzzle became popular in America during the 1870s. The goal of the puzzle is to organize the tiles on the board by sliding them horizontally and vertically. The puzzle starts from a position where the tiles have been scrambled. 3 | 4 | ## Additional exercises 5 | * Make a 5⨉5 puzzle, then a 6⨉5 one. Make sure the solvability checks work generally. 6 | * Add sliding animations. Tiles cannot be moved separately from the tilemap so you will have to come up with a way of solving that. Perhaps a separate tilemap that only contains the sliding piece? 7 | 8 | ## Source 9 | https://www.defold.com/tutorials/15-puzzle/ 10 | -------------------------------------------------------------------------------- /15-puzzle/assets/images/monalisa.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/15-puzzle/assets/images/monalisa.png -------------------------------------------------------------------------------- /15-puzzle/assets/monalisa.tilesource: -------------------------------------------------------------------------------- 1 | image: "/assets/images/monalisa.png" 2 | tile_width: 128 3 | tile_height: 128 4 | tile_margin: 0 5 | tile_spacing: 0 6 | collision: "" 7 | material_tag: "tile" 8 | collision_groups: "default" 9 | animations { 10 | id: "anim" 11 | start_tile: 1 12 | end_tile: 1 13 | playback: PLAYBACK_ONCE_FORWARD 14 | fps: 30 15 | flip_horizontal: 0 16 | flip_vertical: 0 17 | } 18 | extrude_borders: 1 19 | inner_padding: 0 20 | -------------------------------------------------------------------------------- /15-puzzle/game.project: -------------------------------------------------------------------------------- 1 | [project] 2 | title = 15-Puzzle 3 | 4 | [bootstrap] 5 | main_collection = /main/main.collectionc 6 | 7 | [input] 8 | game_binding = /input/game.input_bindingc 9 | 10 | [display] 11 | width = 512 12 | height = 512 13 | 14 | [script] 15 | shared_state = 1 16 | 17 | [ios] 18 | app_icon_120x120 = /assets/appicons/icon_120.png 19 | app_icon_180x180 = /assets/appicons/icon_180.png 20 | app_icon_76x76 = /assets/appicons/icon_76.png 21 | app_icon_152x152 = /assets/appicons/icon_152.png 22 | app_icon_57x57 = /assets/appicons/icon_57.png 23 | app_icon_114x114 = /assets/appicons/icon_114.png 24 | app_icon_72x72 = /assets/appicons/icon_72.png 25 | app_icon_144x144 = /assets/appicons/icon_144.png 26 | launch_image_320x480 = /assets/loadingscreens/screen_320x480.png 27 | launch_image_640x960 = /assets/loadingscreens/screen_640x960.png 28 | launch_image_640x1136 = /assets/loadingscreens/screen_640x1136.png 29 | launch_image_750x1334 = /assets/loadingscreens/screen_750x1334.png 30 | launch_image_768x1024 = /assets/loadingscreens/screen_768x1024.png 31 | launch_image_1536x2048 = /assets/loadingscreens/screen_1536x2048.png 32 | launch_image_1024x768 = /assets/loadingscreens/screen_1024x768.png 33 | launch_image_1242x2208 = /assets/loadingscreens/screen_1242x2208.png 34 | launch_image_2208x1242 = /assets/loadingscreens/screen_2208x1242.png 35 | launch_image_2048x1536 = /assets/loadingscreens/screen_2048x1536.png 36 | bundle_identifier = com.example.todo 37 | app_icon_167x167 = /assets/appicons/icon_167.png 38 | 39 | [osx] 40 | bundle_identifier = com.example.todo 41 | 42 | [android] 43 | app_icon_36x36 = /assets/appicons/icon_36.png 44 | app_icon_48x48 = /assets/appicons/icon_48.png 45 | app_icon_72x72 = /assets/appicons/icon_72.png 46 | app_icon_96x96 = /assets/appicons/icon_96.png 47 | app_icon_144x144 = /assets/appicons/icon_144.png 48 | app_icon_192x192 = /assets/appicons/icon_192.png 49 | 50 | -------------------------------------------------------------------------------- /15-puzzle/input/game.input_binding: -------------------------------------------------------------------------------- 1 | mouse_trigger { 2 | input: MOUSE_BUTTON_1 3 | action: "press" 4 | } 5 | -------------------------------------------------------------------------------- /15-puzzle/main/game.script: -------------------------------------------------------------------------------- 1 | local function inversions(t) 2 | local inv = 0 3 | for i=1, #t do 4 | for j=i+1, #t do 5 | if t[i] > t[j] and t[j] ~= 0 then 6 | inv = inv + 1 7 | end 8 | end 9 | end 10 | return inv 11 | end 12 | 13 | local function find(t, tile) 14 | for i=1, #t do 15 | if t[i] == tile then 16 | local y = 5 - math.ceil(i/4) 17 | local x = i - (math.ceil(i/4) - 1) * 4 18 | return x,y 19 | end 20 | end 21 | end 22 | 23 | local function solvable(t) 24 | local x,y = find(t, 0) 25 | if y % 2 == 1 and inversions(t) % 2 == 0 then 26 | return true 27 | end 28 | if y % 2 == 0 and inversions(t) % 2 == 1 then 29 | return true 30 | end 31 | return false 32 | end 33 | 34 | local function scramble(t) 35 | for i=1, #t do 36 | local tmp = t[i] 37 | local r = math.random(#t) 38 | t[i] = t[r] 39 | t[r] = tmp 40 | end 41 | return t 42 | end 43 | 44 | local function swap(t, i, j) 45 | local tmp = t[i] 46 | t[i] = t[j] 47 | t[j] = tmp 48 | return t 49 | end 50 | 51 | local function draw(t) 52 | for i=1, #t do 53 | local y = 5 - math.ceil(i/4) 54 | local x = i - (math.ceil(i/4) - 1) * 4 55 | tilemap.set_tile("#tilemap","layer1",x,y,t[i]) 56 | end 57 | end 58 | 59 | function init(self) 60 | msg.post(".", "acquire_input_focus") 61 | math.randomseed(socket.gettime()) 62 | self.board = scramble({1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0}) 63 | while not solvable(self.board) do 64 | self.board = scramble(self.board) 65 | end 66 | draw(self.board) 67 | self.done = false 68 | msg.post("#done", "disable") 69 | end 70 | 71 | function on_input(self, action_id, action) 72 | if action_id == hash("press") and action.pressed and not self.done then 73 | local x = math.ceil(action.x / 128) 74 | local y = math.ceil(action.y / 128) 75 | local ex, ey = find(self.board, 0) 76 | if math.abs(x - ex) + math.abs(y - ey) == 1 then 77 | self.board = swap(self.board, (4-ey)*4+ex, (4-y)*4+x) 78 | draw(self.board) 79 | end 80 | ex, ey = find(self.board, 0) 81 | if inversions(self.board) == 0 and ex == 4 then 82 | self.done = true 83 | msg.post("#done", "enable") 84 | end 85 | end 86 | end 87 | 88 | function on_reload(self) 89 | self.done = false 90 | msg.post("#done", "disable") 91 | end -------------------------------------------------------------------------------- /15-puzzle/main/grid.tilemap: -------------------------------------------------------------------------------- 1 | tile_set: "/assets/monalisa.tilesource" 2 | layers { 3 | id: "layer1" 4 | z: 0.0 5 | is_visible: 1 6 | cell { 7 | x: 0 8 | y: 0 9 | tile: 3 10 | h_flip: 0 11 | v_flip: 0 12 | } 13 | cell { 14 | x: 3 15 | y: 0 16 | tile: 3 17 | h_flip: 0 18 | v_flip: 0 19 | } 20 | cell { 21 | x: 0 22 | y: 3 23 | tile: 3 24 | h_flip: 0 25 | v_flip: 0 26 | } 27 | cell { 28 | x: 3 29 | y: 3 30 | tile: 3 31 | h_flip: 0 32 | v_flip: 0 33 | } 34 | } 35 | material: "/builtins/materials/tile_map.material" 36 | blend_mode: BLEND_MODE_ALPHA 37 | -------------------------------------------------------------------------------- /15-puzzle/main/main.collection: -------------------------------------------------------------------------------- 1 | name: "default" 2 | scale_along_z: 0 3 | embedded_instances { 4 | id: "go" 5 | data: "components {\n" 6 | " id: \"tilemap\"\n" 7 | " component: \"/main/grid.tilemap\"\n" 8 | "}\n" 9 | "components {\n" 10 | " id: \"script\"\n" 11 | " component: \"/main/game.script\"\n" 12 | "}\n" 13 | "embedded_components {\n" 14 | " id: \"done\"\n" 15 | " type: \"label\"\n" 16 | " data: \"size {\\n" 17 | " x: 128.0\\n" 18 | " y: 32.0\\n" 19 | "}\\n" 20 | "font: \\\"/builtins/fonts/debug/always_on_top.font\\\"\\n" 21 | "material: \\\"/builtins/fonts/label.material\\\"\\n" 22 | "\"\n" 23 | " position {\n" 24 | " x: 256.0\n" 25 | " y: 256.0\n" 26 | " z: 1.0\n" 27 | " }\n" 28 | "}\n" 29 | "" 30 | } 31 | -------------------------------------------------------------------------------- /Day 1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/Day 1.pdf -------------------------------------------------------------------------------- /Day 2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/Day 2.pdf -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Defold training - intermediate 2 | Training material for intermediate users with previous programming experience 3 | 4 | 5 | ## Slides 6 | 7 | Slides were part of a presentation with participants and game projects were provided in a state were participants could modify the games to complete challenges while learning aspects of defold. 8 | 9 | * [Day 1](https://github.com/britzl/defold-training_intermediate/blob/master/Day%201.pdf) 10 | * [Day 2](https://github.com/britzl/defold-training_intermediate/blob/master/Day%202.pdf) 11 | 12 | note: The content was created some time ago and some information/links have been changed since then and may no longer be accurate. The projects have been updated to work with latest version of defold. 13 | -------------------------------------------------------------------------------- /hands_on/assets/game.atlas: -------------------------------------------------------------------------------- 1 | images { 2 | image: "/builtins/graphics/particle_blob.png" 3 | } 4 | images { 5 | image: "/assets/images/ball.png" 6 | } 7 | images { 8 | image: "/assets/images/bg.png" 9 | } 10 | images { 11 | image: "/assets/images/blocker.png" 12 | } 13 | images { 14 | image: "/assets/images/bucket.png" 15 | } 16 | images { 17 | image: "/assets/images/icon_120.png" 18 | } 19 | images { 20 | image: "/assets/images/pin.png" 21 | } 22 | images { 23 | image: "/main/images/logo.png" 24 | } 25 | margin: 0 26 | extrude_borders: 2 27 | inner_padding: 0 28 | -------------------------------------------------------------------------------- /hands_on/assets/images/ball.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/hands_on/assets/images/ball.png -------------------------------------------------------------------------------- /hands_on/assets/images/bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/hands_on/assets/images/bg.png -------------------------------------------------------------------------------- /hands_on/assets/images/blocker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/hands_on/assets/images/blocker.png -------------------------------------------------------------------------------- /hands_on/assets/images/bucket.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/hands_on/assets/images/bucket.png -------------------------------------------------------------------------------- /hands_on/assets/images/icon_120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/hands_on/assets/images/icon_120.png -------------------------------------------------------------------------------- /hands_on/assets/images/pin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/hands_on/assets/images/pin.png -------------------------------------------------------------------------------- /hands_on/assets/sounds/bounce1.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/hands_on/assets/sounds/bounce1.wav -------------------------------------------------------------------------------- /hands_on/assets/sounds/bounce2.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/hands_on/assets/sounds/bounce2.wav -------------------------------------------------------------------------------- /hands_on/assets/sounds/bounce3.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/hands_on/assets/sounds/bounce3.wav -------------------------------------------------------------------------------- /hands_on/assets/sounds/metal1.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/hands_on/assets/sounds/metal1.wav -------------------------------------------------------------------------------- /hands_on/assets/sounds/metal2.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/hands_on/assets/sounds/metal2.wav -------------------------------------------------------------------------------- /hands_on/game.project: -------------------------------------------------------------------------------- 1 | [project] 2 | title = HandsOn 3 | 4 | [bootstrap] 5 | main_collection = /main/main.collectionc 6 | 7 | [input] 8 | game_binding = /input/game.input_bindingc 9 | 10 | [display] 11 | width = 640 12 | height = 1136 13 | 14 | [script] 15 | shared_state = 1 16 | 17 | [ios] 18 | app_icon_120x120 = /assets/appicons/icon_120.png 19 | app_icon_180x180 = /assets/appicons/icon_180.png 20 | app_icon_76x76 = /assets/appicons/icon_76.png 21 | app_icon_152x152 = /assets/appicons/icon_152.png 22 | app_icon_57x57 = /assets/appicons/icon_57.png 23 | app_icon_114x114 = /assets/appicons/icon_114.png 24 | app_icon_72x72 = /assets/appicons/icon_72.png 25 | app_icon_144x144 = /assets/appicons/icon_144.png 26 | launch_image_320x480 = /assets/loadingscreens/screen_320x480.png 27 | launch_image_640x960 = /assets/loadingscreens/screen_640x960.png 28 | launch_image_640x1136 = /assets/loadingscreens/screen_640x1136.png 29 | launch_image_750x1334 = /assets/loadingscreens/screen_750x1334.png 30 | launch_image_768x1024 = /assets/loadingscreens/screen_768x1024.png 31 | launch_image_1536x2048 = /assets/loadingscreens/screen_1536x2048.png 32 | launch_image_1024x768 = /assets/loadingscreens/screen_1024x768.png 33 | launch_image_1242x2208 = /assets/loadingscreens/screen_1242x2208.png 34 | launch_image_2208x1242 = /assets/loadingscreens/screen_2208x1242.png 35 | launch_image_2048x1536 = /assets/loadingscreens/screen_2048x1536.png 36 | bundle_identifier = com.example.todo 37 | app_icon_167x167 = /assets/appicons/icon_167.png 38 | 39 | [osx] 40 | bundle_identifier = com.example.todo 41 | 42 | [android] 43 | app_icon_36x36 = /assets/appicons/icon_36.png 44 | app_icon_48x48 = /assets/appicons/icon_48.png 45 | app_icon_72x72 = /assets/appicons/icon_72.png 46 | app_icon_96x96 = /assets/appicons/icon_96.png 47 | app_icon_144x144 = /assets/appicons/icon_144.png 48 | app_icon_192x192 = /assets/appicons/icon_192.png 49 | 50 | [physics] 51 | scale = 0.2 52 | use_fixed_timestep = 1 53 | gravity_y = -200.0 54 | 55 | -------------------------------------------------------------------------------- /hands_on/input/game.input_binding: -------------------------------------------------------------------------------- 1 | mouse_trigger { 2 | input: MOUSE_BUTTON_LEFT 3 | action: "touch" 4 | } 5 | -------------------------------------------------------------------------------- /hands_on/main/ball.go: -------------------------------------------------------------------------------- 1 | components { 2 | id: "ball" 3 | component: "/main/ball.script" 4 | position { 5 | x: 0.0 6 | y: 0.0 7 | z: 0.0 8 | } 9 | rotation { 10 | x: 0.0 11 | y: 0.0 12 | z: 0.0 13 | w: 1.0 14 | } 15 | } 16 | embedded_components { 17 | id: "sprite" 18 | type: "sprite" 19 | data: "tile_set: \"/assets/game.atlas\"\n" 20 | "default_animation: \"ball\"\n" 21 | "material: \"/builtins/materials/sprite.material\"\n" 22 | "blend_mode: BLEND_MODE_ALPHA\n" 23 | "" 24 | position { 25 | x: 0.0 26 | y: 0.0 27 | z: 0.0 28 | } 29 | rotation { 30 | x: 0.0 31 | y: 0.0 32 | z: 0.0 33 | w: 1.0 34 | } 35 | } 36 | embedded_components { 37 | id: "collisionobject" 38 | type: "collisionobject" 39 | data: "collision_shape: \"\"\n" 40 | "type: COLLISION_OBJECT_TYPE_DYNAMIC\n" 41 | "mass: 1.0\n" 42 | "friction: 0.1\n" 43 | "restitution: 0.5\n" 44 | "group: \"ball\"\n" 45 | "mask: \"ball\"\n" 46 | "mask: \"pin\"\n" 47 | "mask: \"blocker\"\n" 48 | "mask: \"wall\"\n" 49 | "embedded_collision_shape {\n" 50 | " shapes {\n" 51 | " shape_type: TYPE_SPHERE\n" 52 | " position {\n" 53 | " x: 0.0\n" 54 | " y: 0.0\n" 55 | " z: 0.0\n" 56 | " }\n" 57 | " rotation {\n" 58 | " x: 0.0\n" 59 | " y: 0.0\n" 60 | " z: 0.0\n" 61 | " w: 1.0\n" 62 | " }\n" 63 | " index: 0\n" 64 | " count: 1\n" 65 | " }\n" 66 | " data: 35.0\n" 67 | "}\n" 68 | "linear_damping: 0.0\n" 69 | "angular_damping: 0.0\n" 70 | "locked_rotation: false\n" 71 | "" 72 | position { 73 | x: 0.0 74 | y: 0.0 75 | z: 0.0 76 | } 77 | rotation { 78 | x: 0.0 79 | y: 0.0 80 | z: 0.0 81 | w: 1.0 82 | } 83 | } 84 | embedded_components { 85 | id: "bounce" 86 | type: "sound" 87 | data: "sound: \"/assets/sounds/bounce1.wav\"\n" 88 | "looping: 0\n" 89 | "group: \"master\"\n" 90 | "gain: 1.0\n" 91 | "" 92 | position { 93 | x: 0.0 94 | y: 0.0 95 | z: 0.0 96 | } 97 | rotation { 98 | x: 0.0 99 | y: 0.0 100 | z: 0.0 101 | w: 1.0 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /hands_on/main/ball.script: -------------------------------------------------------------------------------- 1 | local score = 0 2 | 3 | 4 | function on_message(self, message_id, message, sender) 5 | if message_id == hash("collision_response") and message.group == hash("pin") then 6 | go.delete(message.other_id) 7 | score = score + 1 8 | print(score) 9 | label.set_text("score#label", tostring(score)) 10 | msg.post("#bounce", "play_sound") 11 | end 12 | end 13 | 14 | function on_input(self, action_id, action) 15 | -- Add input-handling code here 16 | -- Remove this function if not needed 17 | end 18 | 19 | function on_reload(self) 20 | -- Add reload-handling code here 21 | -- Remove this function if not needed 22 | end 23 | -------------------------------------------------------------------------------- /hands_on/main/blocker.go: -------------------------------------------------------------------------------- 1 | embedded_components { 2 | id: "sprite" 3 | type: "sprite" 4 | data: "tile_set: \"/assets/game.atlas\"\n" 5 | "default_animation: \"blocker\"\n" 6 | "material: \"/builtins/materials/sprite.material\"\n" 7 | "blend_mode: BLEND_MODE_ALPHA\n" 8 | "" 9 | position { 10 | x: 0.0 11 | y: 0.0 12 | z: 0.0 13 | } 14 | rotation { 15 | x: 0.0 16 | y: 0.0 17 | z: 0.0 18 | w: 1.0 19 | } 20 | } 21 | embedded_components { 22 | id: "collisionobject" 23 | type: "collisionobject" 24 | data: "collision_shape: \"\"\n" 25 | "type: COLLISION_OBJECT_TYPE_STATIC\n" 26 | "mass: 0.0\n" 27 | "friction: 0.1\n" 28 | "restitution: 0.5\n" 29 | "group: \"blocker\"\n" 30 | "mask: \"ball\"\n" 31 | "embedded_collision_shape {\n" 32 | " shapes {\n" 33 | " shape_type: TYPE_BOX\n" 34 | " position {\n" 35 | " x: 0.0\n" 36 | " y: 0.0\n" 37 | " z: 0.0\n" 38 | " }\n" 39 | " rotation {\n" 40 | " x: 0.0\n" 41 | " y: 0.0\n" 42 | " z: 0.0\n" 43 | " w: 1.0\n" 44 | " }\n" 45 | " index: 0\n" 46 | " count: 3\n" 47 | " }\n" 48 | " data: 55.0\n" 49 | " data: 17.5\n" 50 | " data: 10.0\n" 51 | "}\n" 52 | "linear_damping: 0.0\n" 53 | "angular_damping: 0.0\n" 54 | "locked_rotation: false\n" 55 | "" 56 | position { 57 | x: 0.0 58 | y: 0.0 59 | z: 0.0 60 | } 61 | rotation { 62 | x: 0.0 63 | y: 0.0 64 | z: 0.0 65 | w: 1.0 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /hands_on/main/bucket.go: -------------------------------------------------------------------------------- 1 | embedded_components { 2 | id: "sprite" 3 | type: "sprite" 4 | data: "default_animation: \"bucket\"\n" 5 | "material: \"/builtins/materials/sprite.material\"\n" 6 | "textures {\n" 7 | " sampler: \"texture_sampler\"\n" 8 | " texture: \"/assets/game.atlas\"\n" 9 | "}\n" 10 | "" 11 | } 12 | -------------------------------------------------------------------------------- /hands_on/main/explosion.particlefx: -------------------------------------------------------------------------------- 1 | emitters { 2 | id: "emitter" 3 | mode: PLAY_MODE_ONCE 4 | duration: 1.0 5 | space: EMISSION_SPACE_WORLD 6 | position { 7 | x: 0.0 8 | y: 0.0 9 | z: 0.0 10 | } 11 | rotation { 12 | x: 0.0 13 | y: 0.0 14 | z: 0.0 15 | w: 1.0 16 | } 17 | tile_source: "/builtins/graphics/particle_blob.tilesource" 18 | animation: "anim" 19 | material: "/builtins/materials/particlefx.material" 20 | blend_mode: BLEND_MODE_ADD 21 | particle_orientation: PARTICLE_ORIENTATION_DEFAULT 22 | inherit_velocity: 0.0 23 | max_particle_count: 128 24 | type: EMITTER_TYPE_CIRCLE 25 | start_delay: 0.0 26 | properties { 27 | key: EMITTER_KEY_SPAWN_RATE 28 | points { 29 | x: 0.0 30 | y: 50.0 31 | t_x: 1.0 32 | t_y: 0.0 33 | } 34 | spread: 0.0 35 | } 36 | properties { 37 | key: EMITTER_KEY_SIZE_X 38 | points { 39 | x: 0.0 40 | y: 8.0 41 | t_x: 1.0 42 | t_y: 0.0 43 | } 44 | spread: 0.0 45 | } 46 | properties { 47 | key: EMITTER_KEY_SIZE_Y 48 | points { 49 | x: 0.0 50 | y: 12.0 51 | t_x: 1.0 52 | t_y: 0.0 53 | } 54 | spread: 0.0 55 | } 56 | properties { 57 | key: EMITTER_KEY_SIZE_Z 58 | points { 59 | x: 0.0 60 | y: 0.0 61 | t_x: 1.0 62 | t_y: 0.0 63 | } 64 | spread: 0.0 65 | } 66 | properties { 67 | key: EMITTER_KEY_PARTICLE_LIFE_TIME 68 | points { 69 | x: 0.0 70 | y: 2.5 71 | t_x: 1.0 72 | t_y: 0.0 73 | } 74 | spread: 0.0 75 | } 76 | properties { 77 | key: EMITTER_KEY_PARTICLE_SPEED 78 | points { 79 | x: 0.0 80 | y: 100.0 81 | t_x: 1.0 82 | t_y: 0.0 83 | } 84 | spread: 0.0 85 | } 86 | properties { 87 | key: EMITTER_KEY_PARTICLE_SIZE 88 | points { 89 | x: 0.0 90 | y: 20.0 91 | t_x: 1.0 92 | t_y: 0.0 93 | } 94 | spread: 0.0 95 | } 96 | properties { 97 | key: EMITTER_KEY_PARTICLE_RED 98 | points { 99 | x: 0.0 100 | y: 1.0 101 | t_x: 1.0 102 | t_y: 0.0 103 | } 104 | spread: 0.0 105 | } 106 | properties { 107 | key: EMITTER_KEY_PARTICLE_GREEN 108 | points { 109 | x: 0.0 110 | y: 1.0 111 | t_x: 1.0 112 | t_y: 0.0 113 | } 114 | spread: 0.0 115 | } 116 | properties { 117 | key: EMITTER_KEY_PARTICLE_BLUE 118 | points { 119 | x: 0.0 120 | y: 1.0 121 | t_x: 1.0 122 | t_y: 0.0 123 | } 124 | spread: 0.0 125 | } 126 | properties { 127 | key: EMITTER_KEY_PARTICLE_ALPHA 128 | points { 129 | x: 0.0 130 | y: 1.0 131 | t_x: 1.0 132 | t_y: 0.0 133 | } 134 | spread: 0.0 135 | } 136 | properties { 137 | key: EMITTER_KEY_PARTICLE_ROTATION 138 | points { 139 | x: 0.0 140 | y: 0.0 141 | t_x: 1.0 142 | t_y: 0.0 143 | } 144 | spread: 0.0 145 | } 146 | particle_properties { 147 | key: PARTICLE_KEY_SCALE 148 | points { 149 | x: 0.0 150 | y: 1.0 151 | t_x: 1.0 152 | t_y: 0.0 153 | } 154 | } 155 | particle_properties { 156 | key: PARTICLE_KEY_RED 157 | points { 158 | x: 0.0 159 | y: 1.0 160 | t_x: 1.0 161 | t_y: 0.0 162 | } 163 | } 164 | particle_properties { 165 | key: PARTICLE_KEY_GREEN 166 | points { 167 | x: 0.0 168 | y: 1.0 169 | t_x: 1.0 170 | t_y: 0.0 171 | } 172 | } 173 | particle_properties { 174 | key: PARTICLE_KEY_BLUE 175 | points { 176 | x: 0.0 177 | y: 1.0 178 | t_x: 1.0 179 | t_y: 0.0 180 | } 181 | } 182 | particle_properties { 183 | key: PARTICLE_KEY_ALPHA 184 | points { 185 | x: 0.0 186 | y: 0.0 187 | t_x: 0.07194582 188 | t_y: 0.99740857 189 | } 190 | points { 191 | x: 0.11320755 192 | y: 0.99277455 193 | t_x: 0.99418455 194 | t_y: 0.10768964 195 | } 196 | points { 197 | x: 0.7112546 198 | y: 0.555656 199 | t_x: 0.5694311 200 | t_y: -0.82203907 201 | } 202 | points { 203 | x: 1.0 204 | y: 0.0072254334 205 | t_x: 0.4737472 206 | t_y: -0.8806609 207 | } 208 | } 209 | particle_properties { 210 | key: PARTICLE_KEY_ROTATION 211 | points { 212 | x: 0.0 213 | y: 0.0 214 | t_x: 1.0 215 | t_y: 0.0 216 | } 217 | } 218 | size_mode: SIZE_MODE_MANUAL 219 | start_delay_spread: 0.0 220 | duration_spread: 0.0 221 | } 222 | -------------------------------------------------------------------------------- /hands_on/main/game.script: -------------------------------------------------------------------------------- 1 | local balls_left = 10 2 | 3 | local function update_balls() 4 | label.set_text("balls#label", tostring(balls_left)) 5 | end 6 | 7 | 8 | function init(self) 9 | msg.post(".", "acquire_input_focus") 10 | update_balls() 11 | end 12 | 13 | function on_input(self, action_id, action) 14 | if action_id == hash("touch") and action.released then 15 | if balls_left > 0 then 16 | balls_left = balls_left - 1 17 | update_balls() 18 | factory.create("game#ballfactory", vmath.vector3(action.x, action.y, 1)) 19 | end 20 | end 21 | end 22 | 23 | function on_reload(self) 24 | -- Add reload-handling code here 25 | -- Remove this function if not needed 26 | end 27 | -------------------------------------------------------------------------------- /hands_on/main/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/hands_on/main/images/logo.png -------------------------------------------------------------------------------- /hands_on/main/pin.go: -------------------------------------------------------------------------------- 1 | components { 2 | id: "explosion" 3 | component: "/main/explosion.particlefx" 4 | position { 5 | x: 0.0 6 | y: 0.0 7 | z: 0.0 8 | } 9 | rotation { 10 | x: 0.0 11 | y: 0.0 12 | z: 0.0 13 | w: 1.0 14 | } 15 | } 16 | components { 17 | id: "pin" 18 | component: "/main/pin.script" 19 | position { 20 | x: 0.0 21 | y: 0.0 22 | z: 0.0 23 | } 24 | rotation { 25 | x: 0.0 26 | y: 0.0 27 | z: 0.0 28 | w: 1.0 29 | } 30 | } 31 | embedded_components { 32 | id: "sprite" 33 | type: "sprite" 34 | data: "tile_set: \"/assets/game.atlas\"\n" 35 | "default_animation: \"pin\"\n" 36 | "material: \"/builtins/materials/sprite.material\"\n" 37 | "blend_mode: BLEND_MODE_ALPHA\n" 38 | "" 39 | position { 40 | x: 0.0 41 | y: 0.0 42 | z: 0.0 43 | } 44 | rotation { 45 | x: 0.0 46 | y: 0.0 47 | z: 0.0 48 | w: 1.0 49 | } 50 | } 51 | embedded_components { 52 | id: "collisionobject" 53 | type: "collisionobject" 54 | data: "collision_shape: \"\"\n" 55 | "type: COLLISION_OBJECT_TYPE_STATIC\n" 56 | "mass: 0.0\n" 57 | "friction: 0.1\n" 58 | "restitution: 0.5\n" 59 | "group: \"pin\"\n" 60 | "mask: \"ball\"\n" 61 | "embedded_collision_shape {\n" 62 | " shapes {\n" 63 | " shape_type: TYPE_SPHERE\n" 64 | " position {\n" 65 | " x: 0.0\n" 66 | " y: 0.0\n" 67 | " z: 0.0\n" 68 | " }\n" 69 | " rotation {\n" 70 | " x: 0.0\n" 71 | " y: 0.0\n" 72 | " z: 0.0\n" 73 | " w: 1.0\n" 74 | " }\n" 75 | " index: 0\n" 76 | " count: 1\n" 77 | " }\n" 78 | " data: 22.5\n" 79 | "}\n" 80 | "linear_damping: 0.0\n" 81 | "angular_damping: 0.0\n" 82 | "locked_rotation: false\n" 83 | "" 84 | position { 85 | x: 0.0 86 | y: 0.0 87 | z: 0.0 88 | } 89 | rotation { 90 | x: 0.0 91 | y: 0.0 92 | z: 0.0 93 | w: 1.0 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /hands_on/main/pin.script: -------------------------------------------------------------------------------- 1 | function final(self) 2 | particlefx.play("#explosion") 3 | 4 | end 5 | -------------------------------------------------------------------------------- /material/assets/atlases/main.atlas: -------------------------------------------------------------------------------- 1 | images { 2 | image: "/assets/images/defold_logo_bigger.png" 3 | } 4 | margin: 0 5 | extrude_borders: 0 6 | inner_padding: 2 7 | -------------------------------------------------------------------------------- /material/assets/images/defold_logo_bigger.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/defold_logo_bigger.png -------------------------------------------------------------------------------- /material/assets/images/fire/scene00001.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00001.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00005.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00005.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00009.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00009.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00013.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00013.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00017.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00017.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00021.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00021.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00025.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00025.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00029.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00029.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00033.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00033.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00037.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00037.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00041.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00041.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00045.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00045.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00049.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00049.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00053.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00053.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00057.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00057.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00061.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00061.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00065.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00065.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00069.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00069.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00073.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00073.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00077.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00077.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00081.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00081.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00085.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00085.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00089.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00089.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00093.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00093.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00097.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00097.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00101.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00101.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00105.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00105.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00109.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00109.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00113.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00113.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00117.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00117.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00121.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00121.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00125.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00125.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00129.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00129.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00133.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00133.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00137.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00137.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00141.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00141.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00145.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00145.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00149.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00149.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00153.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00153.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00157.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00157.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00161.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00161.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00165.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00165.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00169.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00169.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00173.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00173.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00177.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00177.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00181.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00181.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00185.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00185.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00189.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00189.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00193.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00193.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00197.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00197.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00201.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00201.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00205.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00205.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00209.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00209.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00213.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00213.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00217.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00217.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00221.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00221.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00225.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00225.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00229.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00229.jpg -------------------------------------------------------------------------------- /material/assets/images/fire/scene00233.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/fire/scene00233.jpg -------------------------------------------------------------------------------- /material/assets/images/heatmap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/material/assets/images/heatmap.png -------------------------------------------------------------------------------- /material/assets/materials/effect_animcoords.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec4 var_position; 2 | varying mediump vec3 var_normal; 3 | varying mediump vec2 var_texcoord0; 4 | varying mediump vec4 var_light; 5 | 6 | uniform lowp sampler2D tex0; 7 | uniform highp vec4 anim; 8 | uniform highp vec4 prop; 9 | 10 | void main() 11 | { 12 | // Exctract properties and animation data 13 | float divider = prop.x; 14 | float dt = anim.x; 15 | float a = anim.y; 16 | 17 | 18 | vec2 uv0 = var_texcoord0.xy; 19 | if (var_texcoord0.x > divider) { 20 | // Perform invert effect 21 | uv0.y += sin((uv0.x + a) * 10.0)*0.02; 22 | } 23 | vec4 color = texture2D(tex0, uv0.xy); 24 | 25 | gl_FragColor = vec4(color.rgb,1.0); 26 | } 27 | 28 | -------------------------------------------------------------------------------- /material/assets/materials/effect_animcoords.material: -------------------------------------------------------------------------------- 1 | name: "fsquad" 2 | tags: "fsquad" 3 | vertex_program: "/assets/materials/model.vp" 4 | fragment_program: "/assets/materials/effect_animcoords.fp" 5 | vertex_constants { 6 | name: "mtx_view" 7 | type: CONSTANT_TYPE_VIEW 8 | value { 9 | x: 0.0 10 | y: 0.0 11 | z: 0.0 12 | w: 0.0 13 | } 14 | } 15 | vertex_constants { 16 | name: "mtx_proj" 17 | type: CONSTANT_TYPE_PROJECTION 18 | value { 19 | x: 0.0 20 | y: 0.0 21 | z: 0.0 22 | w: 0.0 23 | } 24 | } 25 | vertex_constants { 26 | name: "mtx_normal" 27 | type: CONSTANT_TYPE_NORMAL 28 | value { 29 | x: 0.0 30 | y: 0.0 31 | z: 0.0 32 | w: 0.0 33 | } 34 | } 35 | vertex_constants { 36 | name: "light" 37 | type: CONSTANT_TYPE_USER 38 | value { 39 | x: 1.0 40 | y: 1.0 41 | z: 1.0 42 | w: 1.0 43 | } 44 | } 45 | fragment_constants { 46 | name: "anim" 47 | type: CONSTANT_TYPE_USER 48 | value { 49 | x: 0.0 50 | y: 0.0 51 | z: 0.0 52 | w: 0.0 53 | } 54 | } 55 | fragment_constants { 56 | name: "prop" 57 | type: CONSTANT_TYPE_USER 58 | value { 59 | x: 0.0 60 | y: 0.0 61 | z: 0.0 62 | w: 0.0 63 | } 64 | } 65 | samplers { 66 | name: "tex0" 67 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 68 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 69 | filter_min: FILTER_MODE_MIN_LINEAR 70 | filter_mag: FILTER_MODE_MAG_LINEAR 71 | } 72 | -------------------------------------------------------------------------------- /material/assets/materials/effect_grayscale.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec4 var_position; 2 | varying mediump vec3 var_normal; 3 | varying mediump vec2 var_texcoord0; 4 | varying mediump vec4 var_light; 5 | 6 | uniform lowp sampler2D tex0; 7 | uniform highp vec4 anim; 8 | uniform highp vec4 prop; 9 | 10 | void main() 11 | { 12 | // Exctract properties and animation data 13 | float divider = prop.x; 14 | float dt = anim.x; 15 | float a = anim.y; 16 | 17 | vec4 color = texture2D(tex0, var_texcoord0.xy); 18 | 19 | if (var_texcoord0.x > divider) { 20 | // Perform grayscale effect 21 | float gray = (color.r + color.g + color.b) / 3.0; 22 | color.rgb = vec3(gray); 23 | } 24 | 25 | gl_FragColor = vec4(color.rgb,1.0); 26 | } 27 | 28 | -------------------------------------------------------------------------------- /material/assets/materials/effect_grayscale.material: -------------------------------------------------------------------------------- 1 | name: "fsquad" 2 | tags: "fsquad" 3 | vertex_program: "/assets/materials/model.vp" 4 | fragment_program: "/assets/materials/effect_grayscale.fp" 5 | vertex_constants { 6 | name: "mtx_view" 7 | type: CONSTANT_TYPE_VIEW 8 | value { 9 | x: 0.0 10 | y: 0.0 11 | z: 0.0 12 | w: 0.0 13 | } 14 | } 15 | vertex_constants { 16 | name: "mtx_proj" 17 | type: CONSTANT_TYPE_PROJECTION 18 | value { 19 | x: 0.0 20 | y: 0.0 21 | z: 0.0 22 | w: 0.0 23 | } 24 | } 25 | vertex_constants { 26 | name: "mtx_normal" 27 | type: CONSTANT_TYPE_NORMAL 28 | value { 29 | x: 0.0 30 | y: 0.0 31 | z: 0.0 32 | w: 0.0 33 | } 34 | } 35 | vertex_constants { 36 | name: "light" 37 | type: CONSTANT_TYPE_USER 38 | value { 39 | x: 1.0 40 | y: 1.0 41 | z: 1.0 42 | w: 1.0 43 | } 44 | } 45 | fragment_constants { 46 | name: "anim" 47 | type: CONSTANT_TYPE_USER 48 | value { 49 | x: 0.0 50 | y: 0.0 51 | z: 0.0 52 | w: 0.0 53 | } 54 | } 55 | fragment_constants { 56 | name: "prop" 57 | type: CONSTANT_TYPE_USER 58 | value { 59 | x: 0.0 60 | y: 0.0 61 | z: 0.0 62 | w: 0.0 63 | } 64 | } 65 | samplers { 66 | name: "tex0" 67 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 68 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 69 | filter_min: FILTER_MODE_MIN_LINEAR 70 | filter_mag: FILTER_MODE_MAG_LINEAR 71 | } 72 | -------------------------------------------------------------------------------- /material/assets/materials/effect_heat.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec4 var_position; 2 | varying mediump vec3 var_normal; 3 | varying mediump vec2 var_texcoord0; 4 | varying mediump vec4 var_light; 5 | 6 | uniform lowp sampler2D tex0; 7 | uniform lowp sampler2D tex1; 8 | uniform highp vec4 anim; 9 | uniform highp vec4 prop; 10 | 11 | void main() 12 | { 13 | // Exctract properties and animation data 14 | float divider = prop.x; 15 | float dt = anim.x; 16 | float a = anim.y; 17 | 18 | 19 | vec2 uv0 = var_texcoord0.xy; 20 | if (var_texcoord0.x > divider) { 21 | // Perform heat effect 22 | vec2 uv1 = var_texcoord0.xy; 23 | vec4 norm_map = texture2D(tex1, uv1.xy + vec2(sin(-uv0.y*4.0+a*1.5)*0.04, -a*0.1)); 24 | uv0.xy += (norm_map.xy*2.0 - 1.0)*0.03*(1.0 - uv0.y); 25 | } 26 | vec4 color = texture2D(tex0, uv0.xy); 27 | 28 | gl_FragColor = vec4(color.rgb,1.0); 29 | } 30 | 31 | -------------------------------------------------------------------------------- /material/assets/materials/effect_heat.material: -------------------------------------------------------------------------------- 1 | name: "fsquad" 2 | tags: "fsquad" 3 | vertex_program: "/assets/materials/model.vp" 4 | fragment_program: "/assets/materials/effect_heat.fp" 5 | vertex_constants { 6 | name: "mtx_view" 7 | type: CONSTANT_TYPE_VIEW 8 | value { 9 | x: 0.0 10 | y: 0.0 11 | z: 0.0 12 | w: 0.0 13 | } 14 | } 15 | vertex_constants { 16 | name: "mtx_proj" 17 | type: CONSTANT_TYPE_PROJECTION 18 | value { 19 | x: 0.0 20 | y: 0.0 21 | z: 0.0 22 | w: 0.0 23 | } 24 | } 25 | vertex_constants { 26 | name: "mtx_normal" 27 | type: CONSTANT_TYPE_NORMAL 28 | value { 29 | x: 0.0 30 | y: 0.0 31 | z: 0.0 32 | w: 0.0 33 | } 34 | } 35 | vertex_constants { 36 | name: "light" 37 | type: CONSTANT_TYPE_USER 38 | value { 39 | x: 1.0 40 | y: 1.0 41 | z: 1.0 42 | w: 1.0 43 | } 44 | } 45 | fragment_constants { 46 | name: "anim" 47 | type: CONSTANT_TYPE_USER 48 | value { 49 | x: 0.0 50 | y: 0.0 51 | z: 0.0 52 | w: 0.0 53 | } 54 | } 55 | fragment_constants { 56 | name: "prop" 57 | type: CONSTANT_TYPE_USER 58 | value { 59 | x: 0.0 60 | y: 0.0 61 | z: 0.0 62 | w: 0.0 63 | } 64 | } 65 | samplers { 66 | name: "tex0" 67 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 68 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 69 | filter_min: FILTER_MODE_MIN_LINEAR 70 | filter_mag: FILTER_MODE_MAG_LINEAR 71 | } 72 | samplers { 73 | name: "tex1" 74 | wrap_u: WRAP_MODE_REPEAT 75 | wrap_v: WRAP_MODE_REPEAT 76 | filter_min: FILTER_MODE_MIN_LINEAR 77 | filter_mag: FILTER_MODE_MAG_LINEAR 78 | } 79 | -------------------------------------------------------------------------------- /material/assets/materials/effect_invert.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec4 var_position; 2 | varying mediump vec3 var_normal; 3 | varying mediump vec2 var_texcoord0; 4 | varying mediump vec4 var_light; 5 | 6 | uniform lowp sampler2D tex0; 7 | uniform highp vec4 anim; 8 | uniform highp vec4 prop; 9 | 10 | void main() 11 | { 12 | // Exctract properties and animation data 13 | float divider = prop.x; 14 | float dt = anim.x; 15 | float a = anim.y; 16 | 17 | vec4 color = texture2D(tex0, var_texcoord0.xy); 18 | 19 | if (var_texcoord0.x > divider) { 20 | // Perform invert effect 21 | color.r = 1.0 - color.r; 22 | color.g = 1.0 - color.g; 23 | color.b = 1.0 - color.b; 24 | } 25 | 26 | gl_FragColor = vec4(color.rgb,1.0); 27 | } 28 | 29 | -------------------------------------------------------------------------------- /material/assets/materials/effect_invert.material: -------------------------------------------------------------------------------- 1 | name: "fsquad" 2 | tags: "fsquad" 3 | vertex_program: "/assets/materials/model.vp" 4 | fragment_program: "/assets/materials/effect_invert.fp" 5 | vertex_constants { 6 | name: "mtx_view" 7 | type: CONSTANT_TYPE_VIEW 8 | value { 9 | x: 0.0 10 | y: 0.0 11 | z: 0.0 12 | w: 0.0 13 | } 14 | } 15 | vertex_constants { 16 | name: "mtx_proj" 17 | type: CONSTANT_TYPE_PROJECTION 18 | value { 19 | x: 0.0 20 | y: 0.0 21 | z: 0.0 22 | w: 0.0 23 | } 24 | } 25 | vertex_constants { 26 | name: "mtx_normal" 27 | type: CONSTANT_TYPE_NORMAL 28 | value { 29 | x: 0.0 30 | y: 0.0 31 | z: 0.0 32 | w: 0.0 33 | } 34 | } 35 | vertex_constants { 36 | name: "light" 37 | type: CONSTANT_TYPE_USER 38 | value { 39 | x: 1.0 40 | y: 1.0 41 | z: 1.0 42 | w: 1.0 43 | } 44 | } 45 | fragment_constants { 46 | name: "anim" 47 | type: CONSTANT_TYPE_USER 48 | value { 49 | x: 0.0 50 | y: 0.0 51 | z: 0.0 52 | w: 0.0 53 | } 54 | } 55 | fragment_constants { 56 | name: "prop" 57 | type: CONSTANT_TYPE_USER 58 | value { 59 | x: 0.0 60 | y: 0.0 61 | z: 0.0 62 | w: 0.0 63 | } 64 | } 65 | samplers { 66 | name: "tex0" 67 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 68 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 69 | filter_min: FILTER_MODE_MIN_LINEAR 70 | filter_mag: FILTER_MODE_MAG_LINEAR 71 | } 72 | -------------------------------------------------------------------------------- /material/assets/materials/fsquad.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec4 var_position; 2 | varying mediump vec3 var_normal; 3 | varying mediump vec2 var_texcoord0; 4 | varying mediump vec4 var_light; 5 | 6 | uniform lowp sampler2D tex0; 7 | uniform highp vec4 anim; 8 | uniform highp vec4 prop; 9 | 10 | void main() 11 | { 12 | // Exctract properties and animation data 13 | float divider = prop.x; 14 | float dt = anim.x; 15 | float a = anim.y; 16 | 17 | if (var_texcoord0.x > divider) { 18 | // Perform post process effects 19 | vec2 coords = var_texcoord0.xy; 20 | //coords.y += sin(coords.x*a*100.0)*0.02; 21 | vec4 color = texture2D(tex0, coords.xy); 22 | color.rgb = color.rrr; 23 | gl_FragColor = vec4(color.rgb,1.0); 24 | } else { 25 | // No post process, just output input texture 26 | vec4 color = texture2D(tex0, var_texcoord0.xy); 27 | gl_FragColor = vec4(color.rgb,1.0); 28 | } 29 | 30 | 31 | } 32 | 33 | -------------------------------------------------------------------------------- /material/assets/materials/fsquad.material: -------------------------------------------------------------------------------- 1 | name: "fsquad" 2 | tags: "fsquad" 3 | vertex_program: "/assets/materials/model.vp" 4 | fragment_program: "/assets/materials/fsquad.fp" 5 | vertex_constants { 6 | name: "mtx_view" 7 | type: CONSTANT_TYPE_VIEW 8 | value { 9 | x: 0.0 10 | y: 0.0 11 | z: 0.0 12 | w: 0.0 13 | } 14 | } 15 | vertex_constants { 16 | name: "mtx_proj" 17 | type: CONSTANT_TYPE_PROJECTION 18 | value { 19 | x: 0.0 20 | y: 0.0 21 | z: 0.0 22 | w: 0.0 23 | } 24 | } 25 | vertex_constants { 26 | name: "mtx_normal" 27 | type: CONSTANT_TYPE_NORMAL 28 | value { 29 | x: 0.0 30 | y: 0.0 31 | z: 0.0 32 | w: 0.0 33 | } 34 | } 35 | vertex_constants { 36 | name: "light" 37 | type: CONSTANT_TYPE_USER 38 | value { 39 | x: 1.0 40 | y: 1.0 41 | z: 1.0 42 | w: 1.0 43 | } 44 | } 45 | fragment_constants { 46 | name: "anim" 47 | type: CONSTANT_TYPE_USER 48 | value { 49 | x: 0.0 50 | y: 0.0 51 | z: 0.0 52 | w: 0.0 53 | } 54 | } 55 | fragment_constants { 56 | name: "prop" 57 | type: CONSTANT_TYPE_USER 58 | value { 59 | x: 0.0 60 | y: 0.0 61 | z: 0.0 62 | w: 0.0 63 | } 64 | } 65 | samplers { 66 | name: "tex0" 67 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 68 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 69 | filter_min: FILTER_MODE_MIN_LINEAR 70 | filter_mag: FILTER_MODE_MAG_LINEAR 71 | } 72 | samplers { 73 | name: "tex1" 74 | wrap_u: WRAP_MODE_REPEAT 75 | wrap_v: WRAP_MODE_REPEAT 76 | filter_min: FILTER_MODE_MIN_LINEAR 77 | filter_mag: FILTER_MODE_MAG_LINEAR 78 | } 79 | -------------------------------------------------------------------------------- /material/assets/materials/model.vp: -------------------------------------------------------------------------------- 1 | 2 | // positions are in world space 3 | attribute mediump vec4 position; 4 | attribute mediump vec2 texcoord0; 5 | attribute mediump vec3 normal; 6 | 7 | uniform mediump mat4 mtx_view; 8 | uniform mediump mat4 mtx_proj; 9 | uniform mediump mat4 mtx_normal; 10 | uniform mediump vec4 light; 11 | 12 | varying mediump vec4 var_position; 13 | varying mediump vec3 var_normal; 14 | varying mediump vec2 var_texcoord0; 15 | varying mediump vec4 var_light; 16 | 17 | void main() 18 | { 19 | vec4 p = mtx_view * vec4(position.xyz, 1.0); 20 | var_light = mtx_view * vec4(light.xyz, 1.0); 21 | var_position = p; 22 | var_texcoord0 = texcoord0; 23 | var_normal = normalize((mtx_normal * vec4(normal, 0.0)).xyz); 24 | gl_Position = mtx_proj * p; 25 | } 26 | 27 | -------------------------------------------------------------------------------- /material/assets/models/fsquad.model: -------------------------------------------------------------------------------- 1 | mesh: "/assets/meshes/fsquad.dae" 2 | material: "/assets/materials/fsquad.material" 3 | textures: "/assets/images/defold_logo_bigger.png" 4 | textures: "/assets/images/heatmap.png" 5 | skeleton: "" 6 | animations: "" 7 | default_animation: "" 8 | name: "unnamed" 9 | -------------------------------------------------------------------------------- /material/fonts/log.font: -------------------------------------------------------------------------------- 1 | font: "/builtins/fonts/vera_mo_bd.ttf" 2 | material: "/builtins/fonts/font.material" 3 | size: 16 4 | outline_alpha: 1.0 5 | outline_width: 2.0 6 | -------------------------------------------------------------------------------- /material/game.project: -------------------------------------------------------------------------------- 1 | [project] 2 | title = MaterialsExample 3 | write_log = 0 4 | dependencies = https://github.com/andsve/dirtylarry/archive/master.zip 5 | 6 | [bootstrap] 7 | main_collection = /main/main.collectionc 8 | render = /render/custom.renderc 9 | 10 | [input] 11 | game_binding = /input/game.input_bindingc 12 | 13 | [display] 14 | width = 1280 15 | height = 720 16 | high_dpi = 1 17 | 18 | [physics] 19 | scale = 0.02 20 | 21 | [script] 22 | shared_state = 1 23 | 24 | [ios] 25 | bundle_identifier = se.svenandersson.Clean 26 | 27 | [android] 28 | package = se.svenandersson.Clean 29 | iap_provider = GooglePlay 30 | input_method = HiddenInputField 31 | manifest = 32 | 33 | [osx] 34 | bundle_identifier = se.svenandersson.Clean 35 | 36 | [tracking] 37 | app_id = 38 | 39 | -------------------------------------------------------------------------------- /material/input/game.input_binding: -------------------------------------------------------------------------------- 1 | key_trigger { 2 | input: KEY_UP 3 | action: "up" 4 | } 5 | key_trigger { 6 | input: KEY_DOWN 7 | action: "down" 8 | } 9 | key_trigger { 10 | input: KEY_BACKSPACE 11 | action: "backspace" 12 | } 13 | mouse_trigger { 14 | input: MOUSE_BUTTON_1 15 | action: "touch" 16 | } 17 | text_trigger { 18 | input: TEXT 19 | action: "text" 20 | } 21 | text_trigger { 22 | input: MARKED_TEXT 23 | action: "marked_text" 24 | } 25 | -------------------------------------------------------------------------------- /material/main/extra/slider.gui: -------------------------------------------------------------------------------- 1 | script: "" 2 | textures { 3 | name: "dirtylarry" 4 | texture: "/dirtylarry/dirtylarry.atlas" 5 | } 6 | background_color { 7 | x: 0.0 8 | y: 0.0 9 | z: 0.0 10 | w: 0.0 11 | } 12 | nodes { 13 | position { 14 | x: 0.0 15 | y: 0.0 16 | z: 0.0 17 | w: 1.0 18 | } 19 | rotation { 20 | x: 0.0 21 | y: 0.0 22 | z: 0.0 23 | w: 1.0 24 | } 25 | scale { 26 | x: 1.0 27 | y: 1.0 28 | z: 1.0 29 | w: 1.0 30 | } 31 | size { 32 | x: 300.0 33 | y: 33.0 34 | z: 0.0 35 | w: 1.0 36 | } 37 | color { 38 | x: 1.0 39 | y: 1.0 40 | z: 1.0 41 | w: 1.0 42 | } 43 | type: TYPE_BOX 44 | blend_mode: BLEND_MODE_ALPHA 45 | texture: "dirtylarry/checkbox_pressed" 46 | id: "larryslider" 47 | xanchor: XANCHOR_NONE 48 | yanchor: YANCHOR_NONE 49 | pivot: PIVOT_W 50 | adjust_mode: ADJUST_MODE_FIT 51 | layer: "" 52 | inherit_alpha: true 53 | slice9 { 54 | x: 16.0 55 | y: 16.0 56 | z: 16.0 57 | w: 16.0 58 | } 59 | clipping_mode: CLIPPING_MODE_NONE 60 | clipping_visible: true 61 | clipping_inverted: false 62 | alpha: 1.0 63 | template_node_child: false 64 | size_mode: SIZE_MODE_MANUAL 65 | } 66 | nodes { 67 | position { 68 | x: 0.0 69 | y: 0.0 70 | z: 0.0 71 | w: 1.0 72 | } 73 | rotation { 74 | x: 0.0 75 | y: 0.0 76 | z: 0.0 77 | w: 1.0 78 | } 79 | scale { 80 | x: 0.75 81 | y: 0.75 82 | z: 1.0 83 | w: 1.0 84 | } 85 | size { 86 | x: 64.0 87 | y: 68.0 88 | z: 0.0 89 | w: 1.0 90 | } 91 | color { 92 | x: 1.0 93 | y: 1.0 94 | z: 1.0 95 | w: 1.0 96 | } 97 | type: TYPE_BOX 98 | blend_mode: BLEND_MODE_ALPHA 99 | texture: "dirtylarry/radio_normal" 100 | id: "larryknob" 101 | xanchor: XANCHOR_NONE 102 | yanchor: YANCHOR_NONE 103 | pivot: PIVOT_CENTER 104 | adjust_mode: ADJUST_MODE_FIT 105 | parent: "larryslider" 106 | layer: "" 107 | inherit_alpha: true 108 | slice9 { 109 | x: 0.0 110 | y: 0.0 111 | z: 0.0 112 | w: 0.0 113 | } 114 | clipping_mode: CLIPPING_MODE_NONE 115 | clipping_visible: true 116 | clipping_inverted: false 117 | alpha: 1.0 118 | template_node_child: false 119 | size_mode: SIZE_MODE_AUTO 120 | } 121 | material: "/builtins/materials/gui.material" 122 | adjust_reference: ADJUST_REFERENCE_PARENT 123 | max_nodes: 512 124 | -------------------------------------------------------------------------------- /material/main/main.collection: -------------------------------------------------------------------------------- 1 | name: "parallax" 2 | scale_along_z: 0 3 | embedded_instances { 4 | id: "postprocess" 5 | data: "components {\n" 6 | " id: \"fsquad\"\n" 7 | " component: \"/assets/models/fsquad.model\"\n" 8 | " position {\n" 9 | " x: 0.0\n" 10 | " y: 0.0\n" 11 | " z: 0.0\n" 12 | " }\n" 13 | " rotation {\n" 14 | " x: 0.0\n" 15 | " y: 0.0\n" 16 | " z: 0.0\n" 17 | " w: 1.0\n" 18 | " }\n" 19 | "}\n" 20 | "" 21 | position { 22 | x: 0.0 23 | y: 0.0 24 | z: 0.0 25 | } 26 | rotation { 27 | x: 0.0 28 | y: 0.0 29 | z: 0.0 30 | w: 1.0 31 | } 32 | scale3 { 33 | x: 1.0 34 | y: 1.0 35 | z: 1.0 36 | } 37 | } 38 | embedded_instances { 39 | id: "go" 40 | data: "components {\n" 41 | " id: \"main\"\n" 42 | " component: \"/main/main.gui\"\n" 43 | " position {\n" 44 | " x: 0.0\n" 45 | " y: 0.0\n" 46 | " z: 0.0\n" 47 | " }\n" 48 | " rotation {\n" 49 | " x: 0.0\n" 50 | " y: 0.0\n" 51 | " z: 0.0\n" 52 | " w: 1.0\n" 53 | " }\n" 54 | "}\n" 55 | "embedded_components {\n" 56 | " id: \"sprite\"\n" 57 | " type: \"sprite\"\n" 58 | " data: \"tile_set: \\\"/assets/atlases/main.atlas\\\"\\n" 59 | "default_animation: \\\"defold_logo_bigger\\\"\\n" 60 | "material: \\\"/builtins/materials/sprite.material\\\"\\n" 61 | "blend_mode: BLEND_MODE_ALPHA\\n" 62 | "\"\n" 63 | " position {\n" 64 | " x: 0.0\n" 65 | " y: 0.0\n" 66 | " z: 0.0\n" 67 | " }\n" 68 | " rotation {\n" 69 | " x: 0.0\n" 70 | " y: 0.0\n" 71 | " z: 0.0\n" 72 | " w: 1.0\n" 73 | " }\n" 74 | "}\n" 75 | "embedded_components {\n" 76 | " id: \"sprite1\"\n" 77 | " type: \"sprite\"\n" 78 | " data: \"tile_set: \\\"/assets/atlases/fire.atlas\\\"\\n" 79 | "default_animation: \\\"fire\\\"\\n" 80 | "material: \\\"/builtins/materials/sprite.material\\\"\\n" 81 | "blend_mode: BLEND_MODE_ADD\\n" 82 | "\"\n" 83 | " position {\n" 84 | " x: 0.0\n" 85 | " y: 0.0\n" 86 | " z: 0.0\n" 87 | " }\n" 88 | " rotation {\n" 89 | " x: 0.0\n" 90 | " y: 0.0\n" 91 | " z: 0.0\n" 92 | " w: 1.0\n" 93 | " }\n" 94 | "}\n" 95 | "" 96 | position { 97 | x: 0.0 98 | y: 0.0 99 | z: 0.0 100 | } 101 | rotation { 102 | x: 0.0 103 | y: 0.0 104 | z: 0.0 105 | w: 1.0 106 | } 107 | scale3 { 108 | x: 1.0 109 | y: 1.0 110 | z: 1.0 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /material/main/main.gui_script: -------------------------------------------------------------------------------- 1 | local dirtylarry = require("dirtylarry/dirtylarry") 2 | 3 | ------------------------------------------------------------ 4 | -- monkey patch dirtylarry with slider functionality 5 | local function hit_test(self, node, action_id, action) 6 | if not dirtylarry.is_enabled(self, node) then 7 | return false 8 | end 9 | 10 | local hit = gui.pick_node( node, action.x, action.y ) 11 | local touch = action_id == dirtylarry.action_id_touch 12 | return touch and hit 13 | end 14 | dirtylarry.slider = function(self, node, action_id, action, value) 15 | local node_bg = gui.get_node(node .. "/larryslider") 16 | local node_knob = gui.get_node(node .. "/larryknob") 17 | local s = gui.get_size(node_bg) 18 | 19 | local hit = hit_test(self, node_bg, action_id, action) 20 | if hit then 21 | if not action.released then 22 | local p = gui.get_screen_position(node_bg) 23 | local mp = vmath.vector3(action.screen_x, action.screen_y, 0) 24 | 25 | local px = p.x - s.x / 2 26 | local mpx = mp.x 27 | 28 | local rel_pos = math.min(1.0, math.max(0.0, (mpx - px) / s.x)) 29 | value = rel_pos 30 | end 31 | end 32 | 33 | gui.set_position(node_knob, vmath.vector3(s.x * value, 0, 0)) 34 | return value 35 | end 36 | ------------------------------------------------------------ 37 | 38 | function init(self) 39 | msg.post(".","acquire_input_focus") 40 | self.pp_enabled = true 41 | self.pp_divider = 0.5 42 | self.pp_material = "grayscale" 43 | end 44 | 45 | function update(self, dt) 46 | msg.post("@render:", "render_options", { 47 | pp_enabled = self.pp_enabled, 48 | pp_divider = self.pp_divider, 49 | pp_material = self.pp_material 50 | }) 51 | end 52 | 53 | function on_input(self, action_id, action) 54 | self.pp_enabled = dirtylarry:checkbox("pp_enabled", action_id, action, self.pp_enabled) 55 | self.pp_divider = dirtylarry:slider("pp_divider", action_id, action, self.pp_divider) 56 | self.pp_material = dirtylarry:radio("effect_grayscale", action_id, action, "grayscale", self.pp_material) 57 | self.pp_material = dirtylarry:radio("effect_invert", action_id, action, "invert", self.pp_material) 58 | self.pp_material = dirtylarry:radio("effect_animcoords", action_id, action, "animcoords", self.pp_material) 59 | self.pp_material = dirtylarry:radio("effect_heat", action_id, action, "heat", self.pp_material) 60 | end 61 | -------------------------------------------------------------------------------- /material/render/custom.render: -------------------------------------------------------------------------------- 1 | script: "/render/custom.render_script" 2 | materials { 3 | name: "grayscale" 4 | material: "/assets/materials/effect_grayscale.material" 5 | } 6 | materials { 7 | name: "invert" 8 | material: "/assets/materials/effect_invert.material" 9 | } 10 | materials { 11 | name: "animcoords" 12 | material: "/assets/materials/effect_animcoords.material" 13 | } 14 | materials { 15 | name: "heat" 16 | material: "/assets/materials/effect_heat.material" 17 | } 18 | -------------------------------------------------------------------------------- /oceancommotion-linker/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | .externalToolBuilders 3 | .DS_Store 4 | .lock-wscript 5 | build 6 | *.pyc 7 | .project 8 | .cproject 9 | builtins 10 | .internal 11 | -------------------------------------------------------------------------------- /oceancommotion-linker/README.md: -------------------------------------------------------------------------------- 1 | # Ocean Commotion Linker 2 | A variant of the original [Ocean Commotion match-3 sample game](https://github.com/defold/defold-examples/tree/master/ocean-commotion) but with a linker mechanic instead. 3 | 4 | ## Additional exercises 5 | * Add score and score counter 6 | * Create more special fish 7 | -------------------------------------------------------------------------------- /oceancommotion-linker/game.project: -------------------------------------------------------------------------------- 1 | [project] 2 | title = Ocean Commotion Linker 3 | version = 0.1 4 | dependencies = https://github.com/defold/defold-examples/releases/download/0.2.0/ocean-commotion.zip 5 | 6 | [bootstrap] 7 | main_collection = /main/main.collectionc 8 | 9 | [input] 10 | game_binding = /input/game.input_bindingc 11 | 12 | [display] 13 | width = 1024 14 | height = 1024 15 | high_dpi = 1 16 | 17 | [physics] 18 | scale = 0.02 19 | 20 | [script] 21 | shared_state = 1 22 | 23 | [particle_fx] 24 | max_count = 256 25 | max_particle_count = 4096 26 | 27 | [sprite] 28 | max_count = 256 29 | 30 | [library] 31 | include_dirs = 32 | -------------------------------------------------------------------------------- /oceancommotion-linker/input/game.input_binding: -------------------------------------------------------------------------------- 1 | mouse_trigger { 2 | input: MOUSE_BUTTON_1 3 | action: "touch" 4 | } 5 | -------------------------------------------------------------------------------- /oceancommotion-linker/main/fish.go: -------------------------------------------------------------------------------- 1 | components { 2 | id: "explosion" 3 | component: "/def-ocean-commotion/explode.particlefx" 4 | position { 5 | x: 0.0 6 | y: 0.0 7 | z: 0.0 8 | } 9 | rotation { 10 | x: 0.0 11 | y: 0.0 12 | z: 0.0 13 | w: 1.0 14 | } 15 | } 16 | components { 17 | id: "script" 18 | component: "/main/fish.script" 19 | position { 20 | x: 0.0 21 | y: 0.0 22 | z: 0.0 23 | } 24 | rotation { 25 | x: 0.0 26 | y: 0.0 27 | z: 0.0 28 | w: 1.0 29 | } 30 | } 31 | embedded_components { 32 | id: "sprite" 33 | type: "sprite" 34 | data: "tile_set: \"/def-ocean-commotion/sprites.atlas\"\n" 35 | "default_animation: \"fish-blue\"\n" 36 | "material: \"/builtins/materials/sprite.material\"\n" 37 | "blend_mode: BLEND_MODE_ALPHA\n" 38 | "" 39 | position { 40 | x: 0.0 41 | y: 0.0 42 | z: 0.0 43 | } 44 | rotation { 45 | x: 0.0 46 | y: 0.0 47 | z: 0.0 48 | w: 1.0 49 | } 50 | } 51 | embedded_components { 52 | id: "sprite-eyes" 53 | type: "sprite" 54 | data: "tile_set: \"/def-ocean-commotion/sprites.atlas\"\n" 55 | "default_animation: \"eyes-blue\"\n" 56 | "material: \"/builtins/materials/sprite.material\"\n" 57 | "blend_mode: BLEND_MODE_ALPHA\n" 58 | "" 59 | position { 60 | x: 0.0 61 | y: 0.0 62 | z: 0.1 63 | } 64 | rotation { 65 | x: 0.0 66 | y: 0.0 67 | z: 0.0 68 | w: 1.0 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /oceancommotion-linker/main/hud.gui: -------------------------------------------------------------------------------- 1 | script: "" 2 | fonts { 3 | name: "text" 4 | font: "/def-ocean-commotion/font/text.font" 5 | } 6 | background_color { 7 | x: 0.0 8 | y: 0.0 9 | z: 0.0 10 | w: 1.0 11 | } 12 | nodes { 13 | position { 14 | x: 512.0 15 | y: 984.0 16 | z: 0.0 17 | w: 1.0 18 | } 19 | rotation { 20 | x: 0.0 21 | y: 0.0 22 | z: 0.0 23 | w: 1.0 24 | } 25 | scale { 26 | x: 0.5 27 | y: 0.5 28 | z: 1.0 29 | w: 1.0 30 | } 31 | size { 32 | x: 200.0 33 | y: 100.0 34 | z: 0.0 35 | w: 1.0 36 | } 37 | color { 38 | x: 1.0 39 | y: 1.0 40 | z: 1.0 41 | w: 1.0 42 | } 43 | type: TYPE_TEXT 44 | blend_mode: BLEND_MODE_ALPHA 45 | text: "Ocean Commotion" 46 | font: "text" 47 | id: "title" 48 | xanchor: XANCHOR_NONE 49 | yanchor: YANCHOR_NONE 50 | pivot: PIVOT_CENTER 51 | outline { 52 | x: 1.0 53 | y: 1.0 54 | z: 1.0 55 | w: 1.0 56 | } 57 | shadow { 58 | x: 1.0 59 | y: 1.0 60 | z: 1.0 61 | w: 1.0 62 | } 63 | adjust_mode: ADJUST_MODE_FIT 64 | line_break: false 65 | layer: "" 66 | inherit_alpha: true 67 | clipping_mode: CLIPPING_MODE_NONE 68 | clipping_visible: true 69 | clipping_inverted: false 70 | alpha: 1.0 71 | outline_alpha: 1.0 72 | shadow_alpha: 1.0 73 | template_node_child: false 74 | text_leading: 1.0 75 | text_tracking: 0.0 76 | size_mode: SIZE_MODE_AUTO 77 | } 78 | material: "/builtins/materials/gui.material" 79 | adjust_reference: ADJUST_REFERENCE_PARENT 80 | max_nodes: 512 81 | -------------------------------------------------------------------------------- /oceancommotion-linker/main/main.collection: -------------------------------------------------------------------------------- 1 | name: "main" 2 | scale_along_z: 0 3 | embedded_instances { 4 | id: "board" 5 | data: "components {\n" 6 | " id: \"script\"\n" 7 | " component: \"/main/board.script\"\n" 8 | " position {\n" 9 | " x: 0.0\n" 10 | " y: 0.0\n" 11 | " z: 0.0\n" 12 | " }\n" 13 | " rotation {\n" 14 | " x: 0.0\n" 15 | " y: 0.0\n" 16 | " z: 0.0\n" 17 | " w: 1.0\n" 18 | " }\n" 19 | "}\n" 20 | "embedded_components {\n" 21 | " id: \"fish_factory\"\n" 22 | " type: \"factory\"\n" 23 | " data: \"prototype: \\\"/main/fish.go\\\"\\n" 24 | "\"\n" 25 | " position {\n" 26 | " x: 0.0\n" 27 | " y: 0.0\n" 28 | " z: 0.0\n" 29 | " }\n" 30 | " rotation {\n" 31 | " x: 0.0\n" 32 | " y: 0.0\n" 33 | " z: 0.0\n" 34 | " w: 1.0\n" 35 | " }\n" 36 | "}\n" 37 | "" 38 | position { 39 | x: 0.0 40 | y: 0.0 41 | z: 0.0 42 | } 43 | rotation { 44 | x: 0.0 45 | y: 0.0 46 | z: 0.0 47 | w: 1.0 48 | } 49 | scale3 { 50 | x: 1.0 51 | y: 1.0 52 | z: 1.0 53 | } 54 | } 55 | embedded_instances { 56 | id: "hud" 57 | data: "components {\n" 58 | " id: \"hud\"\n" 59 | " component: \"/main/hud.gui\"\n" 60 | " position {\n" 61 | " x: 0.0\n" 62 | " y: 0.0\n" 63 | " z: 0.0\n" 64 | " }\n" 65 | " rotation {\n" 66 | " x: 0.0\n" 67 | " y: 0.0\n" 68 | " z: 0.0\n" 69 | " w: 1.0\n" 70 | " }\n" 71 | "}\n" 72 | "" 73 | position { 74 | x: 0.0 75 | y: 0.0 76 | z: 0.0 77 | } 78 | rotation { 79 | x: 0.0 80 | y: 0.0 81 | z: 0.0 82 | w: 1.0 83 | } 84 | scale3 { 85 | x: 1.0 86 | y: 1.0 87 | z: 1.0 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /pong/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | .externalToolBuilders 3 | .DS_Store 4 | .lock-wscript 5 | build 6 | *.pyc 7 | .project 8 | .cproject 9 | builtins 10 | .internal 11 | -------------------------------------------------------------------------------- /pong/README.md: -------------------------------------------------------------------------------- 1 | # Pong 2 | Implementation of the classic game Pong. 3 | 4 | ## Additional exercises 5 | * Add score counter. 6 | * Change from AI opponent to human opponent. 7 | * Add multiple balls. 8 | -------------------------------------------------------------------------------- /pong/assets/font/pixelfont.material: -------------------------------------------------------------------------------- 1 | name: "font" 2 | tags: "gui" 3 | vertex_program: "/builtins/fonts/font.vp" 4 | fragment_program: "/builtins/fonts/font.fp" 5 | vertex_constants { 6 | name: "view_proj" 7 | type: CONSTANT_TYPE_VIEWPROJ 8 | } 9 | vertex_constants { 10 | name: "world" 11 | type: CONSTANT_TYPE_WORLD 12 | } 13 | samplers { 14 | name: "texture" 15 | wrap_u: WRAP_MODE_REPEAT 16 | wrap_v: WRAP_MODE_REPEAT 17 | filter_min: FILTER_MODE_MIN_NEAREST 18 | filter_mag: FILTER_MODE_MAG_NEAREST 19 | } 20 | -------------------------------------------------------------------------------- /pong/assets/font/smallest_pixel-7.font: -------------------------------------------------------------------------------- 1 | font: "/assets/font/smallest_pixel-7.ttf" 2 | material: "/assets/font/pixelfont.material" 3 | size: 59 4 | antialias: 0 5 | -------------------------------------------------------------------------------- /pong/assets/font/smallest_pixel-7.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/pong/assets/font/smallest_pixel-7.ttf -------------------------------------------------------------------------------- /pong/assets/images/ball.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/pong/assets/images/ball.png -------------------------------------------------------------------------------- /pong/assets/images/paddle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/pong/assets/images/paddle.png -------------------------------------------------------------------------------- /pong/game.project: -------------------------------------------------------------------------------- 1 | [project] 2 | title = Pong 3 | version = 1.0 4 | dependencies = 5 | 6 | [bootstrap] 7 | main_collection = /pong/pong.collectionc 8 | 9 | [input] 10 | game_binding = /input/game.input_bindingc 11 | repeat_delay = 0.0 12 | repeat_interval = 0.0 13 | 14 | [display] 15 | width = 1136 16 | height = 640 17 | 18 | [physics] 19 | scale = 0.02 20 | 21 | [script] 22 | shared_state = 1 23 | 24 | [library] 25 | include_dirs = defcon 26 | 27 | [android] 28 | package = com.britzl.defcon 29 | 30 | [ios] 31 | bundle_identifier = com.britzl.defcon 32 | 33 | [osx] 34 | bundle_identifier = com.britzl.defcon 35 | 36 | -------------------------------------------------------------------------------- /pong/input/game.input_binding: -------------------------------------------------------------------------------- 1 | key_trigger { 2 | input: KEY_UP 3 | action: "up" 4 | } 5 | key_trigger { 6 | input: KEY_DOWN 7 | action: "down" 8 | } 9 | key_trigger { 10 | input: KEY_W 11 | action: "up" 12 | } 13 | key_trigger { 14 | input: KEY_S 15 | action: "down" 16 | } 17 | mouse_trigger { 18 | input: MOUSE_BUTTON_1 19 | action: "fire" 20 | } 21 | -------------------------------------------------------------------------------- /pong/pong/ai.script: -------------------------------------------------------------------------------- 1 | go.property("speed", 300) 2 | 3 | function init(self) 4 | self.direction = 0 5 | end 6 | 7 | function update(self, dt) 8 | local ball_pos = go.get_position("ball") 9 | local ball_direction = go.get("ball#script", "direction") 10 | local my_pos = go.get_position() 11 | 12 | -- only move the ai paddle when the ball is travelling towards the paddle 13 | if (ball_pos.x < my_pos.x and ball_direction.x > 0) then 14 | local vertical_distance_to_ball = (my_pos.y - ball_pos.y) 15 | -- update direction of movement when the vertical distance to the ball 16 | -- is above a threshold 17 | -- reduce this value to make the AI react faster 18 | if math.abs(vertical_distance_to_ball) > 64 then 19 | if vertical_distance_to_ball < 0 then 20 | self.direction = 1 21 | else 22 | self.direction = -1 23 | end 24 | end 25 | else 26 | self.direction = 0 27 | end 28 | 29 | -- move the paddle based on ai input 30 | local pos = go.get_position() 31 | pos.y = pos.y + self.direction * self.speed * dt 32 | go.set_position(pos) 33 | end 34 | 35 | function on_message(self, message_id, message, sender) 36 | -- stop the paddle from going through the walls 37 | if message_id == hash("contact_point_response") and message.group == hash("wall") then 38 | go.set_position(go.get_position() + message.normal * message.distance) 39 | end 40 | end 41 | 42 | function on_reload(self) 43 | -- Add reload-handling code here 44 | -- Remove this function if not needed 45 | end 46 | -------------------------------------------------------------------------------- /pong/pong/ball.go: -------------------------------------------------------------------------------- 1 | components { 2 | id: "script" 3 | component: "/pong/ball.script" 4 | position { 5 | x: 0.0 6 | y: 0.0 7 | z: 0.0 8 | } 9 | rotation { 10 | x: 0.0 11 | y: 0.0 12 | z: 0.0 13 | w: 1.0 14 | } 15 | } 16 | embedded_components { 17 | id: "sprite" 18 | type: "sprite" 19 | data: "tile_set: \"/pong/pong.atlas\"\n" 20 | "default_animation: \"ball\"\n" 21 | "material: \"/builtins/materials/sprite.material\"\n" 22 | "blend_mode: BLEND_MODE_ALPHA\n" 23 | "" 24 | position { 25 | x: 0.0 26 | y: 0.0 27 | z: 0.0 28 | } 29 | rotation { 30 | x: 0.0 31 | y: 0.0 32 | z: 0.0 33 | w: 1.0 34 | } 35 | } 36 | embedded_components { 37 | id: "collisionobject" 38 | type: "collisionobject" 39 | data: "collision_shape: \"\"\n" 40 | "type: COLLISION_OBJECT_TYPE_KINEMATIC\n" 41 | "mass: 0.0\n" 42 | "friction: 0.1\n" 43 | "restitution: 0.5\n" 44 | "group: \"ball\"\n" 45 | "mask: \"paddle\"\n" 46 | "mask: \"wall\"\n" 47 | "mask: \"ball\"\n" 48 | "mask: \"goalp1\"\n" 49 | "mask: \"goalp2\"\n" 50 | "embedded_collision_shape {\n" 51 | " shapes {\n" 52 | " shape_type: TYPE_BOX\n" 53 | " position {\n" 54 | " x: 0.0\n" 55 | " y: 0.0\n" 56 | " z: 0.0\n" 57 | " }\n" 58 | " rotation {\n" 59 | " x: 0.0\n" 60 | " y: 0.0\n" 61 | " z: 0.0\n" 62 | " w: 1.0\n" 63 | " }\n" 64 | " index: 0\n" 65 | " count: 3\n" 66 | " }\n" 67 | " data: 16.0\n" 68 | " data: 16.0\n" 69 | " data: 10.0\n" 70 | "}\n" 71 | "linear_damping: 0.0\n" 72 | "angular_damping: 0.0\n" 73 | "locked_rotation: false\n" 74 | "" 75 | position { 76 | x: 0.0 77 | y: 0.0 78 | z: 0.0 79 | } 80 | rotation { 81 | x: 0.0 82 | y: 0.0 83 | z: 0.0 84 | w: 1.0 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /pong/pong/ball.script: -------------------------------------------------------------------------------- 1 | go.property("direction", vmath.vector3()) 2 | go.property("speed", 500) 3 | 4 | function init(self) 5 | math.randomseed(os.time()) 6 | 7 | -- store the original position of the ball so we can reset it 8 | self.original_position = go.get_position() 9 | 10 | -- set an initial random direction of travel 11 | self.direction = vmath.normalize(vmath.vector3(math.random(3, 7) * (math.random(0, 1) > 0.5 and -1 or 1), math.random(-1, 1), 0)) 12 | end 13 | 14 | function update(self, dt) 15 | -- move the ball in it's current direction 16 | -- with the specified speed (pixels/second) 17 | -- apply delta time for correct movement regardless 18 | -- of framerate 19 | local pos = go.get_position() 20 | pos = pos + self.direction * self.speed * dt 21 | go.set_position(pos) 22 | end 23 | 24 | function on_message(self, message_id, message, sender) 25 | if message_id == hash("contact_point_response") then 26 | -- bounce on something above/below ball? 27 | if message.normal.y ~= 0 then 28 | self.direction.y = -self.direction.y 29 | end 30 | 31 | -- bounce on something to the left/right of ball? 32 | if message.normal.x ~= 0 then 33 | self.direction.x = -self.direction.x 34 | end 35 | 36 | -- resolve collision by moving ball "out of" whatever it collided with 37 | go.set_position(go.get_position() + message.normal * message.distance) 38 | 39 | -- collided with player 1 goal - reset position and increase score 40 | if message.group == hash("goalp1") then 41 | go.set_position(self.original_position) 42 | -- collided with player 2 goal - reset position and increase score 43 | elseif message.group == hash("goalp2") then 44 | go.set_position(self.original_position) 45 | -- collided with a padde - add random adjustment to vertical direction 46 | elseif message.group == hash("paddle") then 47 | local dist = go.get_position(message.other_id) - go.get_position() 48 | self.direction.y = self.direction.y - dist.y / 150 49 | self.direction = vmath.normalize(self.direction) 50 | end 51 | end 52 | end 53 | -------------------------------------------------------------------------------- /pong/pong/player.script: -------------------------------------------------------------------------------- 1 | go.property("speed", 300) 2 | 3 | function init(self) 4 | msg.post(".", "acquire_input_focus") 5 | 6 | self.direction = 0 7 | end 8 | 9 | function update(self, dt) 10 | -- move paddle according to player input 11 | local pos = go.get_position() 12 | pos.y = pos.y + self.direction * self.speed * dt 13 | go.set_position(pos) 14 | 15 | -- reset movement direction 16 | self.direction = 0 17 | end 18 | 19 | function on_message(self, message_id, message, sender) 20 | -- stop the paddle from going through the walls 21 | if message_id == hash("contact_point_response") and message.group == hash("wall") then 22 | go.set_position(go.get_position() + message.normal * message.distance) 23 | end 24 | end 25 | 26 | function on_input(self, action_id, action) 27 | if action_id == hash("up") then 28 | self.direction = 1 29 | elseif action_id == hash("down") then 30 | self.direction = -1 31 | end 32 | end 33 | 34 | function on_reload(self) 35 | -- Add reload-handling code here 36 | -- Remove this function if not needed 37 | end 38 | -------------------------------------------------------------------------------- /pong/pong/pong.atlas: -------------------------------------------------------------------------------- 1 | images { 2 | image: "/assets/images/ball.png" 3 | } 4 | images { 5 | image: "/assets/images/paddle.png" 6 | } 7 | margin: 0 8 | extrude_borders: 2 9 | inner_padding: 0 10 | -------------------------------------------------------------------------------- /runner/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | .externalToolBuilders 3 | .DS_Store 4 | .lock-wscript 5 | build 6 | *.pyc 7 | .project 8 | .cproject 9 | builtins 10 | .internal 11 | -------------------------------------------------------------------------------- /runner/README.md: -------------------------------------------------------------------------------- 1 | # Runner 2 | Infinite runner game with an animated character, physics collision and pickups. 3 | 4 | ## Additional exercises 5 | * Add coin pickups to platforms and award score. 6 | * Add lives and a game over text when out of lives. 7 | 8 | ## Source 9 | https://www.defold.com/tutorials/runner/ 10 | -------------------------------------------------------------------------------- /runner/assets/background.atlas: -------------------------------------------------------------------------------- 1 | images { 2 | image: "/assets/images/background/bg.png" 3 | } 4 | images { 5 | image: "/assets/images/background/earthlike_planet.png" 6 | } 7 | images { 8 | image: "/assets/images/background/gas_planet.png" 9 | } 10 | images { 11 | image: "/assets/images/background/ice_planet.png" 12 | } 13 | images { 14 | image: "/assets/images/background/ring_planet.png" 15 | } 16 | margin: 0 17 | extrude_borders: 2 18 | inner_padding: 0 19 | -------------------------------------------------------------------------------- /runner/assets/hero.atlas: -------------------------------------------------------------------------------- 1 | images { 2 | image: "/assets/images/hero/ArmL01.png" 3 | } 4 | images { 5 | image: "/assets/images/hero/ArmL02.png" 6 | } 7 | images { 8 | image: "/assets/images/hero/ArmL03.png" 9 | } 10 | images { 11 | image: "/assets/images/hero/ArmR01.png" 12 | } 13 | images { 14 | image: "/assets/images/hero/ArmR02.png" 15 | } 16 | images { 17 | image: "/assets/images/hero/ArmR03.png" 18 | } 19 | images { 20 | image: "/assets/images/hero/BodyA01.png" 21 | } 22 | images { 23 | image: "/assets/images/hero/BodyA02.png" 24 | } 25 | images { 26 | image: "/assets/images/hero/BodyB01.png" 27 | } 28 | images { 29 | image: "/assets/images/hero/BodyB02.png" 30 | } 31 | images { 32 | image: "/assets/images/hero/empty.png" 33 | } 34 | images { 35 | image: "/assets/images/hero/Eye01.png" 36 | } 37 | images { 38 | image: "/assets/images/hero/Head01.png" 39 | } 40 | images { 41 | image: "/assets/images/hero/Head02.png" 42 | } 43 | images { 44 | image: "/assets/images/hero/Head02B.png" 45 | } 46 | images { 47 | image: "/assets/images/hero/Head03.png" 48 | } 49 | images { 50 | image: "/assets/images/hero/Head03B.png" 51 | } 52 | images { 53 | image: "/assets/images/hero/LegB01.png" 54 | } 55 | images { 56 | image: "/assets/images/hero/LegB02.png" 57 | } 58 | images { 59 | image: "/assets/images/hero/LegB03.png" 60 | } 61 | images { 62 | image: "/assets/images/hero/LegB04.png" 63 | } 64 | images { 65 | image: "/assets/images/hero/LegL00.png" 66 | } 67 | images { 68 | image: "/assets/images/hero/LegLA01.png" 69 | } 70 | images { 71 | image: "/assets/images/hero/LegLA02.png" 72 | } 73 | images { 74 | image: "/assets/images/hero/LegLA03.png" 75 | } 76 | images { 77 | image: "/assets/images/hero/LegLA04.png" 78 | } 79 | images { 80 | image: "/assets/images/hero/LegR00.png" 81 | } 82 | images { 83 | image: "/assets/images/hero/LegRA01.png" 84 | } 85 | images { 86 | image: "/assets/images/hero/LegRA02.png" 87 | } 88 | images { 89 | image: "/assets/images/hero/LegRA03.png" 90 | } 91 | images { 92 | image: "/assets/images/hero/LegRA04.png" 93 | } 94 | images { 95 | image: "/assets/images/hero/ThighL.png" 96 | } 97 | images { 98 | image: "/assets/images/hero/ThighR.png" 99 | } 100 | margin: 0 101 | extrude_borders: 0 102 | inner_padding: 0 103 | -------------------------------------------------------------------------------- /runner/assets/images/background/bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/runner/assets/images/background/bg.png -------------------------------------------------------------------------------- /runner/assets/images/background/earthlike_planet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/runner/assets/images/background/earthlike_planet.png -------------------------------------------------------------------------------- /runner/assets/images/background/gas_planet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/runner/assets/images/background/gas_planet.png -------------------------------------------------------------------------------- /runner/assets/images/background/ice_planet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/runner/assets/images/background/ice_planet.png -------------------------------------------------------------------------------- /runner/assets/images/background/ring_planet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/runner/assets/images/background/ring_planet.png -------------------------------------------------------------------------------- /runner/assets/images/hero/ArmL01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/runner/assets/images/hero/ArmL01.png -------------------------------------------------------------------------------- /runner/assets/images/hero/ArmL02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/runner/assets/images/hero/ArmL02.png -------------------------------------------------------------------------------- /runner/assets/images/hero/ArmL03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/runner/assets/images/hero/ArmL03.png -------------------------------------------------------------------------------- /runner/assets/images/hero/ArmR01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/runner/assets/images/hero/ArmR01.png -------------------------------------------------------------------------------- /runner/assets/images/hero/ArmR02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/runner/assets/images/hero/ArmR02.png -------------------------------------------------------------------------------- /runner/assets/images/hero/ArmR03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/runner/assets/images/hero/ArmR03.png -------------------------------------------------------------------------------- /runner/assets/images/hero/BodyA01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/runner/assets/images/hero/BodyA01.png -------------------------------------------------------------------------------- /runner/assets/images/hero/BodyA02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/runner/assets/images/hero/BodyA02.png -------------------------------------------------------------------------------- /runner/assets/images/hero/BodyB01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/runner/assets/images/hero/BodyB01.png -------------------------------------------------------------------------------- /runner/assets/images/hero/BodyB02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/runner/assets/images/hero/BodyB02.png -------------------------------------------------------------------------------- /runner/assets/images/hero/Eye01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/runner/assets/images/hero/Eye01.png -------------------------------------------------------------------------------- /runner/assets/images/hero/Head01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/runner/assets/images/hero/Head01.png -------------------------------------------------------------------------------- /runner/assets/images/hero/Head02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/runner/assets/images/hero/Head02.png -------------------------------------------------------------------------------- /runner/assets/images/hero/Head02B.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/runner/assets/images/hero/Head02B.png -------------------------------------------------------------------------------- /runner/assets/images/hero/Head03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/runner/assets/images/hero/Head03.png -------------------------------------------------------------------------------- /runner/assets/images/hero/Head03B.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/runner/assets/images/hero/Head03B.png -------------------------------------------------------------------------------- /runner/assets/images/hero/LegB01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/runner/assets/images/hero/LegB01.png -------------------------------------------------------------------------------- /runner/assets/images/hero/LegB02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/runner/assets/images/hero/LegB02.png -------------------------------------------------------------------------------- /runner/assets/images/hero/LegB03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/runner/assets/images/hero/LegB03.png -------------------------------------------------------------------------------- /runner/assets/images/hero/LegB04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/runner/assets/images/hero/LegB04.png -------------------------------------------------------------------------------- /runner/assets/images/hero/LegL00.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/runner/assets/images/hero/LegL00.png -------------------------------------------------------------------------------- /runner/assets/images/hero/LegLA01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/runner/assets/images/hero/LegLA01.png -------------------------------------------------------------------------------- /runner/assets/images/hero/LegLA02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/runner/assets/images/hero/LegLA02.png -------------------------------------------------------------------------------- /runner/assets/images/hero/LegLA03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/runner/assets/images/hero/LegLA03.png -------------------------------------------------------------------------------- /runner/assets/images/hero/LegLA04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/runner/assets/images/hero/LegLA04.png -------------------------------------------------------------------------------- /runner/assets/images/hero/LegR00.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/runner/assets/images/hero/LegR00.png -------------------------------------------------------------------------------- /runner/assets/images/hero/LegRA01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/runner/assets/images/hero/LegRA01.png -------------------------------------------------------------------------------- /runner/assets/images/hero/LegRA02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/runner/assets/images/hero/LegRA02.png -------------------------------------------------------------------------------- /runner/assets/images/hero/LegRA03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/runner/assets/images/hero/LegRA03.png -------------------------------------------------------------------------------- /runner/assets/images/hero/LegRA04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/runner/assets/images/hero/LegRA04.png -------------------------------------------------------------------------------- /runner/assets/images/hero/ThighL.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/runner/assets/images/hero/ThighL.png -------------------------------------------------------------------------------- /runner/assets/images/hero/ThighR.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/runner/assets/images/hero/ThighR.png -------------------------------------------------------------------------------- /runner/assets/images/hero/empty.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/runner/assets/images/hero/empty.png -------------------------------------------------------------------------------- /runner/assets/images/level/coin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/runner/assets/images/level/coin.png -------------------------------------------------------------------------------- /runner/assets/images/level/ground01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/runner/assets/images/level/ground01.png -------------------------------------------------------------------------------- /runner/assets/images/level/ground02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/runner/assets/images/level/ground02.png -------------------------------------------------------------------------------- /runner/assets/images/level/heart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/runner/assets/images/level/heart.png -------------------------------------------------------------------------------- /runner/assets/images/level/rock_planks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/runner/assets/images/level/rock_planks.png -------------------------------------------------------------------------------- /runner/assets/images/level/spikes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/runner/assets/images/level/spikes.png -------------------------------------------------------------------------------- /runner/assets/level.atlas: -------------------------------------------------------------------------------- 1 | images { 2 | image: "/assets/images/level/ground01.png" 3 | } 4 | images { 5 | image: "/assets/images/level/ground02.png" 6 | } 7 | images { 8 | image: "/assets/images/level/rock_planks.png" 9 | } 10 | images { 11 | image: "/assets/images/level/spikes.png" 12 | } 13 | images { 14 | image: "/assets/images/level/coin.png" 15 | } 16 | images { 17 | image: "/assets/images/level/heart.png" 18 | } 19 | animations { 20 | id: "wall_right" 21 | playback: PLAYBACK_ONCE_FORWARD 22 | fps: 30 23 | flip_horizontal: 0 24 | flip_vertical: 0 25 | } 26 | animations { 27 | id: "wall_left" 28 | playback: PLAYBACK_ONCE_FORWARD 29 | fps: 30 30 | flip_horizontal: 1 31 | flip_vertical: 0 32 | } 33 | margin: 0 34 | extrude_borders: 4 35 | inner_padding: 0 36 | -------------------------------------------------------------------------------- /runner/fonts/BoogalooOne-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/runner/fonts/BoogalooOne-Regular.ttf -------------------------------------------------------------------------------- /runner/fonts/text.font: -------------------------------------------------------------------------------- 1 | font: "/fonts/BoogalooOne-Regular.ttf" 2 | material: "/builtins/fonts/font-df.material" 3 | size: 40 4 | outline_alpha: 1.0 5 | outline_width: 2.0 6 | output_format: TYPE_DISTANCE_FIELD 7 | -------------------------------------------------------------------------------- /runner/game.project: -------------------------------------------------------------------------------- 1 | [project] 2 | title = platformer 3 | 4 | [bootstrap] 5 | main_collection = /level/level.collectionc 6 | 7 | [input] 8 | game_binding = /input/game.input_bindingc 9 | 10 | [display] 11 | width = 1280 12 | height = 720 13 | 14 | [physics] 15 | scale = 0.02 16 | debug = 0 17 | 18 | [graphics] 19 | default_texture_min_filter = linear 20 | default_texture_mag_filter = linear 21 | 22 | [script] 23 | shared_state = 1 24 | 25 | [particle_fx] 26 | max_count = 1024 27 | max_particle_count = 2048 28 | 29 | -------------------------------------------------------------------------------- /runner/hero/hero.go: -------------------------------------------------------------------------------- 1 | components { 2 | id: "deathfx" 3 | component: "/particles/death.particlefx" 4 | position { 5 | x: 0.0 6 | y: 0.0 7 | z: 0.1 8 | } 9 | rotation { 10 | x: 0.0 11 | y: 0.0 12 | z: 0.0 13 | w: 1.0 14 | } 15 | } 16 | components { 17 | id: "script" 18 | component: "/hero/hero.script" 19 | position { 20 | x: 0.0 21 | y: 0.0 22 | z: 0.0 23 | } 24 | rotation { 25 | x: 0.0 26 | y: 0.0 27 | z: 0.0 28 | w: 1.0 29 | } 30 | } 31 | embedded_components { 32 | id: "collisionobject" 33 | type: "collisionobject" 34 | data: "collision_shape: \"\"\n" 35 | "type: COLLISION_OBJECT_TYPE_KINEMATIC\n" 36 | "mass: 0.0\n" 37 | "friction: 0.1\n" 38 | "restitution: 0.5\n" 39 | "group: \"hero\"\n" 40 | "mask: \"geometry\"\n" 41 | "mask: \"danger\"\n" 42 | "mask: \"pickup\"\n" 43 | "embedded_collision_shape {\n" 44 | " shapes {\n" 45 | " shape_type: TYPE_BOX\n" 46 | " position {\n" 47 | " x: -3.229794\n" 48 | " y: -7.944098\n" 49 | " z: 0.0\n" 50 | " }\n" 51 | " rotation {\n" 52 | " x: 0.0\n" 53 | " y: 0.0\n" 54 | " z: 0.0\n" 55 | " w: 1.0\n" 56 | " }\n" 57 | " index: 0\n" 58 | " count: 3\n" 59 | " }\n" 60 | " data: 19.835552\n" 61 | " data: 26.133411\n" 62 | " data: 10.0\n" 63 | "}\n" 64 | "linear_damping: 0.0\n" 65 | "angular_damping: 0.0\n" 66 | "locked_rotation: false\n" 67 | "" 68 | position { 69 | x: 0.0 70 | y: 0.0 71 | z: 0.0 72 | } 73 | rotation { 74 | x: 0.0 75 | y: 0.0 76 | z: 0.0 77 | w: 1.0 78 | } 79 | } 80 | embedded_components { 81 | id: "spinemodel" 82 | type: "spinemodel" 83 | data: "spine_scene: \"/hero/hero.spinescene\"\n" 84 | "default_animation: \"run_right\"\n" 85 | "skin: \"\"\n" 86 | "blend_mode: BLEND_MODE_ALPHA\n" 87 | "material: \"/builtins/materials/spine.material\"\n" 88 | "" 89 | position { 90 | x: -6.628304 91 | y: -29.32896 92 | z: 0.0 93 | } 94 | rotation { 95 | x: 0.0 96 | y: 0.0 97 | z: 0.0 98 | w: 1.0 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /runner/hero/hero.spinescene: -------------------------------------------------------------------------------- 1 | spine_json: "/hero/hero.json" 2 | atlas: "/assets/hero.atlas" 3 | sample_rate: 30.0 4 | -------------------------------------------------------------------------------- /runner/input/game.input_binding: -------------------------------------------------------------------------------- 1 | key_trigger { 2 | input: KEY_LEFT 3 | action: "left" 4 | } 5 | key_trigger { 6 | input: KEY_RIGHT 7 | action: "right" 8 | } 9 | key_trigger { 10 | input: KEY_SPACE 11 | action: "jump" 12 | } 13 | key_trigger { 14 | input: KEY_ENTER 15 | action: "enter" 16 | } 17 | mouse_trigger { 18 | input: MOUSE_BUTTON_1 19 | action: "left_button" 20 | } 21 | touch_trigger { 22 | input: TOUCH_MULTI 23 | action: "touch" 24 | } 25 | -------------------------------------------------------------------------------- /runner/level/controller.script: -------------------------------------------------------------------------------- 1 | go.property("speed", 6) 2 | 3 | local grid = 460 4 | local platform_heights = { 100, 200, 350 } 5 | local coins = 3 6 | 7 | function init(self) 8 | msg.post("ground/controller#script", "set_speed", { speed = self.speed }) 9 | self.gridw = 0 10 | self.spawns = {} 11 | 12 | self.score = 0 13 | end 14 | 15 | function update(self, dt) 16 | self.gridw = self.gridw + self.speed 17 | 18 | if self.gridw >= grid then 19 | self.gridw = 0 20 | 21 | -- Maybe spawn a platform at random height 22 | if math.random() > 0.2 then 23 | local h = platform_heights[math.random(#platform_heights)] 24 | local f = "#platform_factory" 25 | if math.random() > 0.5 then 26 | f = "#platform_long_factory" 27 | end 28 | 29 | local p = factory.create(f, vmath.vector3(1600, h, 0), nil, {}, 0.6) 30 | msg.post(p, "set_speed", { speed = self.speed }) 31 | table.insert(self.spawns, p) 32 | end 33 | end 34 | end 35 | 36 | function on_message(self, message_id, message, sender) 37 | if message_id == hash("reset") then 38 | msg.post("hero#script", "reset") 39 | -- Delete all platforms 40 | for i,p in ipairs(self.spawns) do 41 | go.delete(p) 42 | end 43 | self.spawns = {} 44 | elseif message_id == hash("delete_spawn") then 45 | for i,p in ipairs(self.spawns) do 46 | if p == message.id then 47 | table.remove(self.spawns, i) 48 | go.delete(p) 49 | end 50 | end 51 | end 52 | end 53 | -------------------------------------------------------------------------------- /runner/level/ground.script: -------------------------------------------------------------------------------- 1 | -- ids of our seven pieces of ground that we move to create the illusion 2 | -- of an infinite scroller 3 | local pieces = { "ground0", "ground1", "ground2", "ground3", "ground4", "ground5", "ground6" } 4 | 5 | function init(self) 6 | self.speed = 9 7 | end 8 | 9 | function update(self, dt) 10 | for i, p in ipairs(pieces) do 11 | local pos = go.get_position(p) 12 | if pos.x <= -228 then 13 | pos.x = 1368 + (pos.x + 228) 14 | end 15 | pos.x = pos.x - self.speed 16 | go.set_position(pos, p) 17 | end 18 | end 19 | 20 | function on_message(self, message_id, message, sender) 21 | if message_id == hash("set_speed") then 22 | self.speed = message.speed 23 | end 24 | end -------------------------------------------------------------------------------- /runner/level/objects/planets.go: -------------------------------------------------------------------------------- 1 | components { 2 | id: "script" 3 | component: "/level/objects/planets.script" 4 | position { 5 | x: 0.0 6 | y: 0.0 7 | z: 0.0 8 | } 9 | rotation { 10 | x: 0.0 11 | y: 0.0 12 | z: 0.0 13 | w: 1.0 14 | } 15 | } 16 | embedded_components { 17 | id: "sprite" 18 | type: "sprite" 19 | data: "tile_set: \"/assets/background.atlas\"\n" 20 | "default_animation: \"earthlike_planet\"\n" 21 | "material: \"/builtins/materials/sprite.material\"\n" 22 | "blend_mode: BLEND_MODE_ALPHA\n" 23 | "" 24 | position { 25 | x: 132.7056 26 | y: 129.61942 27 | z: 0.0 28 | } 29 | rotation { 30 | x: 0.0 31 | y: 0.0 32 | z: 0.0 33 | w: 1.0 34 | } 35 | } 36 | embedded_components { 37 | id: "sprite1" 38 | type: "sprite" 39 | data: "tile_set: \"/assets/background.atlas\"\n" 40 | "default_animation: \"gas_planet\"\n" 41 | "material: \"/builtins/materials/sprite.material\"\n" 42 | "blend_mode: BLEND_MODE_ALPHA\n" 43 | "" 44 | position { 45 | x: 638.4472 46 | y: 607.02057 47 | z: 0.0 48 | } 49 | rotation { 50 | x: 0.0 51 | y: 0.0 52 | z: 0.0 53 | w: 1.0 54 | } 55 | } 56 | embedded_components { 57 | id: "sprite3" 58 | type: "sprite" 59 | data: "tile_set: \"/assets/background.atlas\"\n" 60 | "default_animation: \"ring_planet\"\n" 61 | "material: \"/builtins/materials/sprite.material\"\n" 62 | "blend_mode: BLEND_MODE_ALPHA\n" 63 | "" 64 | position { 65 | x: 1145.589 66 | y: 249.55098 67 | z: 0.0 68 | } 69 | rotation { 70 | x: 0.0 71 | y: 0.0 72 | z: 0.0 73 | w: 1.0 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /runner/level/objects/planets.script: -------------------------------------------------------------------------------- 1 | go.property("speed", -30) 2 | 3 | function update(self, dt) 4 | local p = go.get_position() 5 | -- apply the speed 6 | p.x = p.x + self.speed * dt 7 | -- reset to far right when they reach the far left to create infinite scrolling 8 | if p.x <= -1280 then 9 | p.x = 1280 10 | end 11 | go.set_position(p) 12 | end 13 | -------------------------------------------------------------------------------- /runner/level/objects/planets_small.go: -------------------------------------------------------------------------------- 1 | components { 2 | id: "script" 3 | component: "/level/objects/planets.script" 4 | position { 5 | x: 0.0 6 | y: 0.0 7 | z: 0.0 8 | } 9 | rotation { 10 | x: 0.0 11 | y: 0.0 12 | z: 0.0 13 | w: 1.0 14 | } 15 | } 16 | embedded_components { 17 | id: "sprite" 18 | type: "sprite" 19 | data: "tile_set: \"/assets/background.atlas\"\n" 20 | "default_animation: \"ring_planet\"\n" 21 | "material: \"/builtins/materials/sprite.material\"\n" 22 | "blend_mode: BLEND_MODE_ALPHA\n" 23 | "" 24 | position { 25 | x: 440.72092 26 | y: 905.91815 27 | z: 0.0 28 | } 29 | rotation { 30 | x: 0.0 31 | y: 0.0 32 | z: 0.0 33 | w: 1.0 34 | } 35 | } 36 | embedded_components { 37 | id: "sprite1" 38 | type: "sprite" 39 | data: "tile_set: \"/assets/background.atlas\"\n" 40 | "default_animation: \"earthlike_planet\"\n" 41 | "material: \"/builtins/materials/sprite.material\"\n" 42 | "blend_mode: BLEND_MODE_ALPHA\n" 43 | "" 44 | position { 45 | x: 843.7908 46 | y: 64.72669 47 | z: 0.0 48 | } 49 | rotation { 50 | x: 0.0 51 | y: 0.0 52 | z: 0.0 53 | w: 1.0 54 | } 55 | } 56 | embedded_components { 57 | id: "sprite3" 58 | type: "sprite" 59 | data: "tile_set: \"/assets/background.atlas\"\n" 60 | "default_animation: \"ice_planet\"\n" 61 | "material: \"/builtins/materials/sprite.material\"\n" 62 | "blend_mode: BLEND_MODE_ALPHA\n" 63 | "" 64 | position { 65 | x: 1531.2341 66 | y: 612.65845 67 | z: 0.0 68 | } 69 | rotation { 70 | x: 0.0 71 | y: 0.0 72 | z: 0.0 73 | w: 1.0 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /runner/level/objects/platform.script: -------------------------------------------------------------------------------- 1 | function init(self) 2 | self.speed = 9 -- Default speed 3 | self.coins = {} 4 | end 5 | 6 | function final(self) 7 | for i,p in ipairs(self.coins) do 8 | go.delete(p) 9 | end 10 | end 11 | 12 | function update(self, dt) 13 | -- delete platform when outside screen 14 | local pos = go.get_position(p) 15 | if pos.x < -500 then 16 | msg.post("controller#script", "delete_spawn", { id = go.get_id() }) 17 | end 18 | pos.x = pos.x - self.speed 19 | go.set_position(pos, p) 20 | end 21 | 22 | function on_message(self, message_id, message, sender) 23 | if message_id == hash("set_speed") then 24 | self.speed = message.speed 25 | end 26 | end -------------------------------------------------------------------------------- /shooter_hot_reload/game.project: -------------------------------------------------------------------------------- 1 | [project] 2 | title = Shooter demo 3 | version = 0.1 4 | 5 | [bootstrap] 6 | main_collection = /main/main.collectionc 7 | render = /render/shooter.renderc 8 | 9 | [input] 10 | game_binding = /input/game.input_bindingc 11 | 12 | [display] 13 | width = 400 14 | height = 850 15 | 16 | [physics] 17 | scale = 0.02 18 | debug = 0 19 | 20 | [script] 21 | shared_state = 1 22 | 23 | [sprite] 24 | subpixels = 1 25 | 26 | -------------------------------------------------------------------------------- /shooter_hot_reload/input/game.input_binding: -------------------------------------------------------------------------------- 1 | key_trigger { 2 | input: KEY_LEFT 3 | action: "left" 4 | } 5 | key_trigger { 6 | input: KEY_RIGHT 7 | action: "right" 8 | } 9 | key_trigger { 10 | input: KEY_UP 11 | action: "up" 12 | } 13 | key_trigger { 14 | input: KEY_DOWN 15 | action: "down" 16 | } 17 | key_trigger { 18 | input: KEY_SPACE 19 | action: "fire" 20 | } 21 | key_trigger { 22 | input: KEY_P 23 | action: "plus" 24 | } 25 | key_trigger { 26 | input: KEY_M 27 | action: "minus" 28 | } 29 | -------------------------------------------------------------------------------- /shooter_hot_reload/main/AvenirNextW1G-Demi.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/shooter_hot_reload/main/AvenirNextW1G-Demi.otf -------------------------------------------------------------------------------- /shooter_hot_reload/main/bezier.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | -- 3 | -- Cubic bezier curve 4 | -- M(t) = (1-t)³A + 3t(1-t)²B + 3t²(1-t)C + t³D 5 | -- 6 | M.point = function(t, A, B, C, D) 7 | local u = 1 - t 8 | local tt = t*t 9 | local uu = u*u 10 | local uuu = uu * u 11 | local ttt = tt * t 12 | 13 | local p = uuu * A -- first term 14 | p = p + 3 * t * uu * B -- second term 15 | p = p + 3 * tt * u * C -- third term 16 | p = p + ttt * D -- fourth term 17 | return p 18 | end 19 | 20 | -- Precompute the three vector terms of the derivative 21 | -- dM/dt = t²(-3A + 9B - 9C + 3D) + t(6A - 12B + 6C) + (-3A + 3B) 22 | 23 | -- v1 = -3A + 9B - 9C + 3D 24 | -- 25 | M.v1 = function(A, B, C, D) 26 | return -3*A + 9*B - 9*C + 3*D 27 | end 28 | 29 | -- v2 = 6A - 12B + 6C 30 | M.v2 = function(A, B, C) 31 | return 6*A - 12*B + 6*C 32 | end 33 | 34 | -- v3 = -3A + 3B 35 | M.v3 = function(A, B) 36 | return -3*A + 3*B 37 | end 38 | 39 | -- 40 | -- Tangent vector 41 | -- 42 | -- dM/dt = t²(-3A + 9B - 9C + 3D) + t(6A - 12B + 6C) + (-3A + 3B) 43 | -- = t²v1 + tv2 + v3 precomputed derivative terms 44 | -- 45 | M.tangent = function(t, v1, v2, v3) 46 | return t * t * v1 + t * v2 + v3 47 | end 48 | 49 | -- 50 | -- Advance a (small) step along curve 51 | -- t = t + L / length(t * t * v1 + t * v2 + v3); 52 | -- 53 | M.step = function(t, l, v1, v2, v3) 54 | return t + l / vmath.length(M.tangent(t, v1, v2, v3)) 55 | end 56 | 57 | -- 58 | -- Advance a large step along curve iteratively 59 | -- 60 | M.long_step = function(t, l, v1, v2, v3) 61 | for i = 0,200 do 62 | t = t + (l / 200) / vmath.length(M.tangent(t, v1, v2, v3)) 63 | end 64 | return t 65 | end 66 | 67 | return M 68 | -------------------------------------------------------------------------------- /shooter_hot_reload/main/bg.script: -------------------------------------------------------------------------------- 1 | function update(self, dt) 2 | local p = go.get_position() 3 | p.y = p.y - 1 4 | go.set_position(p) 5 | end 6 | -------------------------------------------------------------------------------- /shooter_hot_reload/main/cover.gui: -------------------------------------------------------------------------------- 1 | script: "/main/cover.gui_script" 2 | fonts { 3 | name: "shooter" 4 | font: "/main/shooter.font" 5 | } 6 | textures { 7 | name: "sprites" 8 | texture: "/main/sprites.atlas" 9 | } 10 | background_color { 11 | x: 0.0 12 | y: 0.0 13 | z: 0.0 14 | w: 1.0 15 | } 16 | nodes { 17 | position { 18 | x: 200.0 19 | y: 450.0 20 | z: 0.0 21 | w: 1.0 22 | } 23 | rotation { 24 | x: 0.0 25 | y: 0.0 26 | z: 0.0 27 | w: 1.0 28 | } 29 | scale { 30 | x: 1.0 31 | y: 1.0 32 | z: 1.0 33 | w: 1.0 34 | } 35 | size { 36 | x: 400.0 37 | y: 900.0 38 | z: 0.0 39 | w: 1.0 40 | } 41 | color { 42 | x: 1.0 43 | y: 1.0 44 | z: 1.0 45 | w: 1.0 46 | } 47 | type: TYPE_BOX 48 | blend_mode: BLEND_MODE_ALPHA 49 | texture: "sprites/defold-pattern" 50 | id: "cover" 51 | xanchor: XANCHOR_NONE 52 | yanchor: YANCHOR_NONE 53 | pivot: PIVOT_CENTER 54 | adjust_mode: ADJUST_MODE_FIT 55 | layer: "" 56 | inherit_alpha: true 57 | slice9 { 58 | x: 0.0 59 | y: 0.0 60 | z: 0.0 61 | w: 0.0 62 | } 63 | clipping_mode: CLIPPING_MODE_NONE 64 | clipping_visible: true 65 | clipping_inverted: false 66 | alpha: 1.0 67 | template_node_child: false 68 | size_mode: SIZE_MODE_AUTO 69 | } 70 | nodes { 71 | position { 72 | x: 200.0 73 | y: 450.0 74 | z: 0.0 75 | w: 1.0 76 | } 77 | rotation { 78 | x: 0.0 79 | y: 0.0 80 | z: 0.0 81 | w: 1.0 82 | } 83 | scale { 84 | x: 1.0 85 | y: 1.0 86 | z: 1.0 87 | w: 1.0 88 | } 89 | size { 90 | x: 200.0 91 | y: 100.0 92 | z: 0.0 93 | w: 1.0 94 | } 95 | color { 96 | x: 1.0 97 | y: 1.0 98 | z: 1.0 99 | w: 1.0 100 | } 101 | type: TYPE_TEXT 102 | blend_mode: BLEND_MODE_ALPHA 103 | text: "Defold Demo" 104 | font: "shooter" 105 | id: "title" 106 | xanchor: XANCHOR_NONE 107 | yanchor: YANCHOR_NONE 108 | pivot: PIVOT_CENTER 109 | outline { 110 | x: 1.0 111 | y: 1.0 112 | z: 1.0 113 | w: 1.0 114 | } 115 | shadow { 116 | x: 1.0 117 | y: 1.0 118 | z: 1.0 119 | w: 1.0 120 | } 121 | adjust_mode: ADJUST_MODE_FIT 122 | line_break: false 123 | layer: "" 124 | inherit_alpha: true 125 | alpha: 1.0 126 | outline_alpha: 1.0 127 | shadow_alpha: 1.0 128 | template_node_child: false 129 | text_leading: 1.0 130 | text_tracking: 0.0 131 | } 132 | nodes { 133 | position { 134 | x: 192.0 135 | y: 384.0 136 | z: 0.0 137 | w: 1.0 138 | } 139 | rotation { 140 | x: 0.0 141 | y: 0.0 142 | z: 0.0 143 | w: 1.0 144 | } 145 | scale { 146 | x: 0.5 147 | y: 0.5 148 | z: 1.0 149 | w: 1.0 150 | } 151 | size { 152 | x: 200.0 153 | y: 100.0 154 | z: 0.0 155 | w: 1.0 156 | } 157 | color { 158 | x: 1.0 159 | y: 1.0 160 | z: 1.0 161 | w: 1.0 162 | } 163 | type: TYPE_TEXT 164 | blend_mode: BLEND_MODE_ALPHA 165 | text: "press [space] to start" 166 | font: "shooter" 167 | id: "start" 168 | xanchor: XANCHOR_NONE 169 | yanchor: YANCHOR_NONE 170 | pivot: PIVOT_CENTER 171 | outline { 172 | x: 1.0 173 | y: 1.0 174 | z: 1.0 175 | w: 1.0 176 | } 177 | shadow { 178 | x: 1.0 179 | y: 1.0 180 | z: 1.0 181 | w: 1.0 182 | } 183 | adjust_mode: ADJUST_MODE_FIT 184 | line_break: false 185 | layer: "" 186 | inherit_alpha: true 187 | alpha: 1.0 188 | outline_alpha: 1.0 189 | shadow_alpha: 1.0 190 | template_node_child: false 191 | text_leading: 1.0 192 | text_tracking: 0.0 193 | } 194 | material: "/builtins/materials/gui.material" 195 | adjust_reference: ADJUST_REFERENCE_PARENT 196 | max_nodes: 512 197 | -------------------------------------------------------------------------------- /shooter_hot_reload/main/cover.gui_script: -------------------------------------------------------------------------------- 1 | function init(self) 2 | msg.post("#", "acquire_input_focus") 3 | 4 | local node = gui.get_node("start") 5 | gui.animate(node, "color.w", 0.1, gui.EASING_INOUTEXPO, 0.4, 0.0, nil, gui.PLAYBACK_LOOP_PINGPONG) 6 | end 7 | 8 | function update(self, dt) 9 | -- Add update code here 10 | -- Remove this function if not needed 11 | end 12 | 13 | function on_message(self, message_id, message, sender) 14 | -- Add message-handling code here 15 | -- Remove this function if not needed 16 | end 17 | 18 | function on_input(self, action_id, action) 19 | if action_id == hash("fire") and action.pressed then 20 | gui.delete_node(gui.get_node("title")) 21 | gui.delete_node(gui.get_node("start")) 22 | gui.delete_node(gui.get_node("cover")) 23 | msg.post("#", "release_input_focus") 24 | msg.post("/enemycontroller#script", "start") 25 | end 26 | end 27 | 28 | function on_reload(self) 29 | local node = gui.get_node("start") 30 | gui.cancel_animation(node, "color.w") 31 | gui.set_color(node, vmath.vector4(1, 1, 1, 1)) 32 | gui.animate(node, "color.w", 0.1, gui.EASING_INOUTEXPO, 0.4, 0.0, nil, gui.PLAYBACK_LOOP_PINGPONG) 33 | end 34 | -------------------------------------------------------------------------------- /shooter_hot_reload/main/enemy.go: -------------------------------------------------------------------------------- 1 | components { 2 | id: "script" 3 | component: "/main/enemy.script" 4 | position { 5 | x: 0.0 6 | y: 0.0 7 | z: 0.0 8 | } 9 | rotation { 10 | x: 0.0 11 | y: 0.0 12 | z: 0.0 13 | w: 1.0 14 | } 15 | } 16 | embedded_components { 17 | id: "collisionobject" 18 | type: "collisionobject" 19 | data: "collision_shape: \"\"\n" 20 | "type: COLLISION_OBJECT_TYPE_KINEMATIC\n" 21 | "mass: 0.0\n" 22 | "friction: 0.1\n" 23 | "restitution: 0.5\n" 24 | "group: \"enemy\"\n" 25 | "mask: \"ship\"\n" 26 | "embedded_collision_shape {\n" 27 | " shapes {\n" 28 | " shape_type: TYPE_SPHERE\n" 29 | " position {\n" 30 | " x: 0.0\n" 31 | " y: -0.48503938\n" 32 | " z: 0.0\n" 33 | " }\n" 34 | " rotation {\n" 35 | " x: 0.0\n" 36 | " y: 0.0\n" 37 | " z: 0.0\n" 38 | " w: 1.0\n" 39 | " }\n" 40 | " index: 0\n" 41 | " count: 1\n" 42 | " }\n" 43 | " data: 20.0\n" 44 | "}\n" 45 | "linear_damping: 0.0\n" 46 | "angular_damping: 0.0\n" 47 | "locked_rotation: false\n" 48 | "" 49 | position { 50 | x: 0.0 51 | y: 0.0 52 | z: 0.0 53 | } 54 | rotation { 55 | x: 0.0 56 | y: 0.0 57 | z: 0.0 58 | w: 1.0 59 | } 60 | } 61 | embedded_components { 62 | id: "sprite" 63 | type: "sprite" 64 | data: "tile_set: \"/main/sprites.atlas\"\n" 65 | "default_animation: \"enemy01\"\n" 66 | "material: \"/builtins/materials/sprite.material\"\n" 67 | "blend_mode: BLEND_MODE_ALPHA\n" 68 | "" 69 | position { 70 | x: 0.0 71 | y: 0.0 72 | z: 0.0 73 | } 74 | rotation { 75 | x: 0.0 76 | y: 0.0 77 | z: 0.0 78 | w: 1.0 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /shooter_hot_reload/main/enemy.script: -------------------------------------------------------------------------------- 1 | function init(self) 2 | end 3 | 4 | function on_message(self, message_id, message, sender) 5 | -- Add message-handling code here 6 | -- Remove this function if not needed 7 | end 8 | 9 | function on_reload(self) 10 | end 11 | -------------------------------------------------------------------------------- /shooter_hot_reload/main/images/defold-pattern.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/shooter_hot_reload/main/images/defold-pattern.png -------------------------------------------------------------------------------- /shooter_hot_reload/main/images/enemy01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/shooter_hot_reload/main/images/enemy01.png -------------------------------------------------------------------------------- /shooter_hot_reload/main/images/explosion00.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/shooter_hot_reload/main/images/explosion00.png -------------------------------------------------------------------------------- /shooter_hot_reload/main/images/flash00.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/shooter_hot_reload/main/images/flash00.png -------------------------------------------------------------------------------- /shooter_hot_reload/main/images/player.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/shooter_hot_reload/main/images/player.png -------------------------------------------------------------------------------- /shooter_hot_reload/main/images/star1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/shooter_hot_reload/main/images/star1.png -------------------------------------------------------------------------------- /shooter_hot_reload/main/images/star2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/shooter_hot_reload/main/images/star2.png -------------------------------------------------------------------------------- /shooter_hot_reload/main/images/star3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/shooter_hot_reload/main/images/star3.png -------------------------------------------------------------------------------- /shooter_hot_reload/main/main.collection: -------------------------------------------------------------------------------- 1 | name: "main" 2 | instances { 3 | id: "player" 4 | prototype: "/main/player.go" 5 | position { 6 | x: 200.0 7 | y: 170.0 8 | } 9 | } 10 | scale_along_z: 0 11 | embedded_instances { 12 | id: "enemycontroller" 13 | data: "components {\n" 14 | " id: \"script\"\n" 15 | " component: \"/main/enemycontroller.script\"\n" 16 | "}\n" 17 | "embedded_components {\n" 18 | " id: \"enemyfactory\"\n" 19 | " type: \"factory\"\n" 20 | " data: \"prototype: \\\"/main/enemy.go\\\"\\n" 21 | "\"\n" 22 | "}\n" 23 | "" 24 | position { 25 | x: 200.0 26 | y: 450.0 27 | z: -0.5 28 | } 29 | } 30 | embedded_instances { 31 | id: "grid" 32 | data: "components {\n" 33 | " id: \"script\"\n" 34 | " component: \"/render/grid.script\"\n" 35 | "}\n" 36 | "embedded_components {\n" 37 | " id: \"model\"\n" 38 | " type: \"model\"\n" 39 | " data: \"mesh: \\\"/main/quad.dae\\\"\\n" 40 | "materials {\\n" 41 | " name: \\\"default\\\"\\n" 42 | " material: \\\"/render/grid.material\\\"\\n" 43 | "}\\n" 44 | "\"\n" 45 | "}\n" 46 | "" 47 | position { 48 | x: 200.0 49 | y: 450.0 50 | z: -0.9 51 | } 52 | scale3 { 53 | x: 500.0 54 | y: 500.0 55 | } 56 | } 57 | embedded_instances { 58 | id: "stars" 59 | data: "components {\n" 60 | " id: \"script\"\n" 61 | " component: \"/render/stars.script\"\n" 62 | "}\n" 63 | "embedded_components {\n" 64 | " id: \"model\"\n" 65 | " type: \"model\"\n" 66 | " data: \"mesh: \\\"/main/quad.dae\\\"\\n" 67 | "materials {\\n" 68 | " name: \\\"default\\\"\\n" 69 | " material: \\\"/render/stars.material\\\"\\n" 70 | "}\\n" 71 | "\"\n" 72 | "}\n" 73 | "" 74 | position { 75 | x: 200.0 76 | y: 450.0 77 | z: -0.89 78 | } 79 | scale3 { 80 | x: 450.0 81 | y: 450.0 82 | } 83 | } 84 | embedded_instances { 85 | id: "ui" 86 | data: "components {\n" 87 | " id: \"gui\"\n" 88 | " component: \"/main/cover.gui\"\n" 89 | "}\n" 90 | "" 91 | position { 92 | x: 422.85706 93 | y: 450.0 94 | z: -0.5 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /shooter_hot_reload/main/player.go: -------------------------------------------------------------------------------- 1 | components { 2 | id: "explode" 3 | component: "/main/explosion.particlefx" 4 | position { 5 | x: 0.0 6 | y: 0.0 7 | z: 0.0 8 | } 9 | rotation { 10 | x: 0.0 11 | y: 0.0 12 | z: 0.0 13 | w: 1.0 14 | } 15 | } 16 | components { 17 | id: "script" 18 | component: "/main/player.script" 19 | position { 20 | x: 0.0 21 | y: 0.0 22 | z: 0.0 23 | } 24 | rotation { 25 | x: 0.0 26 | y: 0.0 27 | z: 0.0 28 | w: 1.0 29 | } 30 | } 31 | embedded_components { 32 | id: "collisionobject" 33 | type: "collisionobject" 34 | data: "collision_shape: \"\"\n" 35 | "type: COLLISION_OBJECT_TYPE_KINEMATIC\n" 36 | "mass: 0.0\n" 37 | "friction: 0.1\n" 38 | "restitution: 0.5\n" 39 | "group: \"ship\"\n" 40 | "mask: \"enemy\"\n" 41 | "embedded_collision_shape {\n" 42 | " shapes {\n" 43 | " shape_type: TYPE_SPHERE\n" 44 | " position {\n" 45 | " x: 0.0\n" 46 | " y: -4.0188975\n" 47 | " z: 0.0\n" 48 | " }\n" 49 | " rotation {\n" 50 | " x: 0.0\n" 51 | " y: 0.0\n" 52 | " z: 0.0\n" 53 | " w: 1.0\n" 54 | " }\n" 55 | " index: 0\n" 56 | " count: 1\n" 57 | " }\n" 58 | " data: 20.0\n" 59 | "}\n" 60 | "linear_damping: 0.0\n" 61 | "angular_damping: 0.0\n" 62 | "locked_rotation: false\n" 63 | "" 64 | position { 65 | x: 0.0 66 | y: 0.0 67 | z: 0.0 68 | } 69 | rotation { 70 | x: 0.0 71 | y: 0.0 72 | z: 0.0 73 | w: 1.0 74 | } 75 | } 76 | embedded_components { 77 | id: "sprite" 78 | type: "sprite" 79 | data: "tile_set: \"/main/sprites.atlas\"\n" 80 | "default_animation: \"player\"\n" 81 | "material: \"/builtins/materials/sprite.material\"\n" 82 | "blend_mode: BLEND_MODE_ALPHA\n" 83 | "" 84 | position { 85 | x: 0.0 86 | y: 0.0 87 | z: 0.0 88 | } 89 | rotation { 90 | x: 0.0 91 | y: 0.0 92 | z: 0.0 93 | w: 1.0 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /shooter_hot_reload/main/player.script: -------------------------------------------------------------------------------- 1 | function init(self) 2 | msg.post(".", "acquire_input_focus") 3 | 4 | self.velocity = vmath.vector3() 5 | self.input_vec = vmath.vector3() 6 | end 7 | 8 | function final(self) 9 | -- Add finalization code here 10 | -- Remove this function if not needed 11 | end 12 | 13 | function update(self, dt) 14 | self.velocity = self.velocity + self.input_vec * 1000 * dt 15 | local pos = go.get_position() 16 | pos = pos + self.velocity * dt 17 | go.set_position(pos) 18 | self.velocity = vmath.lerp(0.05, self.velocity, vmath.vector3()) 19 | 20 | self.input_vec.x = 0 21 | self.input_vec.y = 0 22 | end 23 | 24 | function on_message(self, message_id, message, sender) 25 | if message_id == hash("collision_response") then 26 | -- die! 27 | particlefx.play("#explode") 28 | go.delete() 29 | end 30 | end 31 | 32 | function on_input(self, action_id, action) 33 | if action_id == hash("left") then 34 | self.input_vec.x = -1 35 | end 36 | 37 | if action_id == hash("right") then 38 | self.input_vec.x = 1 39 | end 40 | 41 | if action_id == hash("up") then 42 | self.input_vec.y = 1 43 | end 44 | 45 | if action_id == hash("down") then 46 | self.input_vec.y = -1 47 | end 48 | end 49 | 50 | function on_reload(self) 51 | end 52 | -------------------------------------------------------------------------------- /shooter_hot_reload/main/shooter.font: -------------------------------------------------------------------------------- 1 | font: "/main/AvenirNextW1G-Demi.otf" 2 | material: "/builtins/fonts/font.material" 3 | size: 48 4 | -------------------------------------------------------------------------------- /shooter_hot_reload/main/sprites.atlas: -------------------------------------------------------------------------------- 1 | images { 2 | image: "/main/images/explosion00.png" 3 | } 4 | images { 5 | image: "/main/images/flash00.png" 6 | } 7 | images { 8 | image: "/main/images/player.png" 9 | } 10 | images { 11 | image: "/main/images/defold-pattern.png" 12 | } 13 | images { 14 | image: "/main/images/enemy01.png" 15 | } 16 | animations { 17 | id: "star" 18 | images { 19 | image: "/main/images/star1.png" 20 | } 21 | images { 22 | image: "/main/images/star2.png" 23 | } 24 | images { 25 | image: "/main/images/star3.png" 26 | } 27 | playback: PLAYBACK_LOOP_PINGPONG 28 | fps: 10 29 | flip_horizontal: 0 30 | flip_vertical: 0 31 | } 32 | margin: 0 33 | extrude_borders: 2 34 | inner_padding: 0 35 | -------------------------------------------------------------------------------- /shooter_hot_reload/render/grid.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec2 var_texcoord0; 2 | 3 | uniform lowp vec4 time; 4 | 5 | vec3 sampleVoronoi(vec2 uv, float size) 6 | { 7 | float nbPoints = size * size; 8 | float m = floor(uv.x * size); 9 | float n = floor(uv.y * size); 10 | 11 | vec3 voronoiPoint = vec3(0.0); 12 | float dist2Max = 3.0; 13 | const float _2PI = 6.28318530718; 14 | 15 | for(int i = -1; i < 2; i++) { 16 | for(int j = -1; j < 2; j++) { 17 | vec2 coords = vec2(m + float(i), n + float(j)); 18 | float phase = _2PI * (size * coords.x + coords.y) / nbPoints; 19 | vec2 delta = 0.7 * vec2(sin(time.x + phase), cos(time.x + phase)); 20 | vec2 point = (coords + vec2(0.5) + delta) / size; 21 | vec2 dir = uv - point; 22 | float dist2 = dot(dir, dir); 23 | 24 | float t = 0.5 * (1.0 + sign(dist2Max - dist2)); 25 | vec3 tmp = vec3(point, dist2); 26 | dist2Max = mix(dist2Max, dist2, t); 27 | voronoiPoint = mix(voronoiPoint, tmp, t); 28 | } 29 | } 30 | return voronoiPoint; 31 | } 32 | 33 | void main() 34 | { 35 | float size = 6.0; 36 | vec3 voronoi = sampleVoronoi(var_texcoord0, size); 37 | float t = exp(-1.0 * size * voronoi.x) * voronoi.y; 38 | gl_FragColor = vec4(voronoi.x / 2.0, 0.2, voronoi.z * t * 100.0, t * 10.0); 39 | } 40 | -------------------------------------------------------------------------------- /shooter_hot_reload/render/grid.material: -------------------------------------------------------------------------------- 1 | name: "grid" 2 | tags: "grid" 3 | vertex_program: "/render/grid.vp" 4 | fragment_program: "/render/grid.fp" 5 | vertex_constants { 6 | name: "view_proj" 7 | type: CONSTANT_TYPE_VIEWPROJ 8 | value { 9 | } 10 | } 11 | fragment_constants { 12 | name: "time" 13 | type: CONSTANT_TYPE_USER 14 | value { 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /shooter_hot_reload/render/grid.script: -------------------------------------------------------------------------------- 1 | function init(self) 2 | self.t = 0 3 | go.animate(".", "euler.z", go.PLAYBACK_LOOP_FORWARD, 360, go.EASING_LINEAR, 10) 4 | end 5 | 6 | function update(self, dt) 7 | self.t = self.t + dt 8 | sprite.set_constant("#model", "time", vmath.vector4(self.t, 0, 0, 0)) 9 | end 10 | -------------------------------------------------------------------------------- /shooter_hot_reload/render/grid.vp: -------------------------------------------------------------------------------- 1 | uniform mediump mat4 view_proj; 2 | 3 | attribute mediump vec4 position; 4 | attribute mediump vec2 texcoord0; 5 | 6 | varying mediump vec2 var_texcoord0; 7 | 8 | void main() 9 | { 10 | gl_Position = view_proj * vec4(position.xyz, 1.0); 11 | var_texcoord0 = texcoord0; 12 | } 13 | -------------------------------------------------------------------------------- /shooter_hot_reload/render/shooter.render: -------------------------------------------------------------------------------- 1 | script: "/render/shooter.render_script" 2 | -------------------------------------------------------------------------------- /shooter_hot_reload/render/shooter.render_script: -------------------------------------------------------------------------------- 1 | function init(self) 2 | self.tile_pred = render.predicate({"tile"}) 3 | self.gui_pred = render.predicate({"gui"}) 4 | self.text_pred = render.predicate({"text"}) 5 | self.particle_pred = render.predicate({"particle"}) 6 | self.grid_pred = render.predicate({"grid"}) 7 | self.stars_pred = render.predicate({"stars"}) 8 | 9 | self.clear_color = vmath.vector4(0, 0, 0, 0) 10 | self.clear_color.x = sys.get_config("render.clear_color_red", 0) 11 | self.clear_color.y = sys.get_config("render.clear_color_green", 0) 12 | self.clear_color.z = sys.get_config("render.clear_color_blue", 0) 13 | self.clear_color.w = sys.get_config("render.clear_color_alpha", 0) 14 | 15 | self.view = vmath.matrix4() 16 | end 17 | 18 | function update(self) 19 | render.set_depth_mask(true) 20 | render.clear({[render.BUFFER_COLOR_BIT] = self.clear_color, [render.BUFFER_DEPTH_BIT] = 1, [render.BUFFER_STENCIL_BIT] = 0}) 21 | 22 | render.set_viewport(0, 0, render.get_window_width(), render.get_window_height()) 23 | render.set_view(self.view) 24 | 25 | render.set_depth_mask(false) 26 | render.disable_state(render.STATE_DEPTH_TEST) 27 | render.disable_state(render.STATE_STENCIL_TEST) 28 | render.enable_state(render.STATE_BLEND) 29 | render.set_blend_func(render.BLEND_SRC_ALPHA, render.BLEND_ONE_MINUS_SRC_ALPHA) 30 | render.disable_state(render.STATE_CULL_FACE) 31 | 32 | render.set_projection(vmath.matrix4_orthographic(0, render.get_width(), 0, render.get_height(), -1, 1)) 33 | 34 | render.draw(self.stars_pred) 35 | render.draw(self.grid_pred) 36 | render.draw(self.tile_pred) 37 | render.draw(self.particle_pred) 38 | 39 | render.draw_debug3d() 40 | 41 | render.set_view(vmath.matrix4()) 42 | render.set_projection(vmath.matrix4_orthographic(0, render.get_window_width(), 0, render.get_window_height(), -1, 1)) 43 | 44 | render.enable_state(render.STATE_STENCIL_TEST) 45 | render.draw(self.gui_pred) 46 | render.draw(self.text_pred) 47 | render.disable_state(render.STATE_STENCIL_TEST) 48 | 49 | render.set_depth_mask(false) 50 | end 51 | 52 | function on_message(self, message_id, message) 53 | if message_id == hash("clear_color") then 54 | self.clear_color = message.color 55 | elseif message_id == hash("set_view_projection") then 56 | self.view = message.view 57 | end 58 | end 59 | -------------------------------------------------------------------------------- /shooter_hot_reload/render/stars.fp: -------------------------------------------------------------------------------- 1 | #define iterations 17 2 | #define formuparam 0.53 3 | 4 | #define volsteps 2 5 | #define stepsize 0.15 6 | 7 | #define zoom 0.800 8 | #define tile 0.850 9 | #define speed 0.040 10 | 11 | #define brightness 0.0015 12 | #define darkmatter 0.300 13 | #define distfading 0.730 14 | #define saturation 0.750 15 | 16 | varying mediump vec2 var_texcoord0; 17 | uniform lowp vec4 time; 18 | 19 | void main() 20 | { 21 | //get coords and direction 22 | vec2 res = vec2(1.0, 0.44); 23 | vec2 uv = var_texcoord0.xy / res.xy - 0.5; 24 | uv.y *= res.y / res.x; 25 | vec3 dir = vec3(uv * zoom, 1.0); 26 | float time = time.x * speed + 0.25; 27 | 28 | vec3 from = vec3(1.0, 0.5, 0.5); 29 | from += vec3(1.0 * sin(time * 50.0) / 200.0, time, -2.0); 30 | 31 | //volumetric rendering 32 | float s = 0.1, fade = 1.0; 33 | vec3 v = vec3(0.0); 34 | for(int r = 0; r < volsteps; r++) { 35 | vec3 p = from + s * dir * 0.5; 36 | // tiling fold 37 | p = abs(vec3(tile) - mod(p, vec3(tile * 2.0))); 38 | float pa, a = pa = 0.0; 39 | for (int i=0; i < iterations; i++) { 40 | // the magic formula 41 | p = abs(p) / dot(p, p) - formuparam; 42 | // absolute sum of average change 43 | a += abs(length(p) - pa); 44 | pa = length(p); 45 | } 46 | //dark matter 47 | float dm = max(0.0, darkmatter - a * a * 0.001); 48 | a *= a * a; 49 | // dark matter, don't render near 50 | if(r > 6) fade *= 1.0 - dm; 51 | v += fade; 52 | // coloring based on distance 53 | v += vec3(s, s * s, s * s * s * s) * a * brightness * fade; 54 | fade *= distfading; 55 | s += stepsize; 56 | } 57 | //color adjust 58 | v = mix(vec3(length(v)), v, saturation); 59 | gl_FragColor = vec4(v * 0.01, 1.0); 60 | } -------------------------------------------------------------------------------- /shooter_hot_reload/render/stars.material: -------------------------------------------------------------------------------- 1 | name: "stars" 2 | tags: "stars" 3 | vertex_program: "/render/stars.vp" 4 | fragment_program: "/render/stars.fp" 5 | vertex_constants { 6 | name: "view_proj" 7 | type: CONSTANT_TYPE_VIEWPROJ 8 | value { 9 | } 10 | } 11 | fragment_constants { 12 | name: "time" 13 | type: CONSTANT_TYPE_USER 14 | value { 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /shooter_hot_reload/render/stars.script: -------------------------------------------------------------------------------- 1 | function init(self) 2 | self.t = 0.0 3 | end 4 | 5 | function update(self, dt) 6 | self.t = self.t + dt 7 | sprite.set_constant("#model", "time", vmath.vector4(self.t, 0, 0, 0)) 8 | end 9 | 10 | function on_reload(self) 11 | -- self.t = 11.04 12 | end -------------------------------------------------------------------------------- /shooter_hot_reload/render/stars.vp: -------------------------------------------------------------------------------- 1 | uniform mediump mat4 view_proj; 2 | 3 | attribute mediump vec4 position; 4 | attribute mediump vec2 texcoord0; 5 | 6 | varying mediump vec2 var_texcoord0; 7 | 8 | void main() 9 | { 10 | gl_Position = view_proj * vec4(position.xyz, 1.0); 11 | var_texcoord0 = texcoord0; 12 | } 13 | -------------------------------------------------------------------------------- /sidescroller/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | .externalToolBuilders 3 | .DS_Store 4 | .lock-wscript 5 | build 6 | *.pyc 7 | .project 8 | .cproject 9 | builtins 10 | .internal 11 | -------------------------------------------------------------------------------- /sidescroller/README.md: -------------------------------------------------------------------------------- 1 | # Sidescroller 2 | The game is extremely simple. The player controls a space ship and is supposed to collect stars that appear on the screen. The ship is controlled with the up and down arrow keys on the keyboard. 3 | 4 | ## Additional exercises 5 | * Award points for picking up stars. Perhaps show score using a label? 6 | * Add special stars that award more points. 7 | * Add enemies that need to be avoided. 8 | 9 | ## Source 10 | https://www.defold.com/tutorials/side-scroller/ 11 | -------------------------------------------------------------------------------- /sidescroller/assets/background.atlas: -------------------------------------------------------------------------------- 1 | images { 2 | image: "/assets/images/background/bg.png" 3 | } 4 | images { 5 | image: "/assets/images/background/earthlike_planet.png" 6 | } 7 | images { 8 | image: "/assets/images/background/gas_planet.png" 9 | } 10 | images { 11 | image: "/assets/images/background/ice_planet.png" 12 | } 13 | images { 14 | image: "/assets/images/background/ring_planet.png" 15 | } 16 | margin: 0 17 | extrude_borders: 1 18 | inner_padding: 0 19 | -------------------------------------------------------------------------------- /sidescroller/assets/enemies.atlas: -------------------------------------------------------------------------------- 1 | images { 2 | image: "/assets/images/enemies/enemyBlack1.png" 3 | } 4 | margin: 0 5 | extrude_borders: 0 6 | inner_padding: 0 7 | -------------------------------------------------------------------------------- /sidescroller/assets/fonts/BoogalooOne-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/fonts/BoogalooOne-Regular.ttf -------------------------------------------------------------------------------- /sidescroller/assets/fonts/score.font: -------------------------------------------------------------------------------- 1 | font: "/assets/fonts/BoogalooOne-Regular.ttf" 2 | material: "/builtins/fonts/font.material" 3 | size: 40 4 | antialias: 1 5 | alpha: 1.0 6 | outline_alpha: 1.0 7 | outline_width: 2.0 8 | shadow_alpha: 0.0 9 | shadow_blur: 0 10 | shadow_x: 0.0 11 | shadow_y: 0.0 12 | extra_characters: "" 13 | output_format: TYPE_BITMAP 14 | all_chars: false 15 | cache_width: 0 16 | cache_height: 0 17 | -------------------------------------------------------------------------------- /sidescroller/assets/images/background/bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/background/bg.png -------------------------------------------------------------------------------- /sidescroller/assets/images/background/earthlike_planet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/background/earthlike_planet.png -------------------------------------------------------------------------------- /sidescroller/assets/images/background/gas_planet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/background/gas_planet.png -------------------------------------------------------------------------------- /sidescroller/assets/images/background/ice_planet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/background/ice_planet.png -------------------------------------------------------------------------------- /sidescroller/assets/images/background/ring_planet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/background/ring_planet.png -------------------------------------------------------------------------------- /sidescroller/assets/images/bonus_star/bonus_star_00.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/bonus_star/bonus_star_00.png -------------------------------------------------------------------------------- /sidescroller/assets/images/bonus_star/bonus_star_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/bonus_star/bonus_star_01.png -------------------------------------------------------------------------------- /sidescroller/assets/images/bonus_star/bonus_star_02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/bonus_star/bonus_star_02.png -------------------------------------------------------------------------------- /sidescroller/assets/images/bonus_star/bonus_star_03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/bonus_star/bonus_star_03.png -------------------------------------------------------------------------------- /sidescroller/assets/images/bonus_star/bonus_star_04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/bonus_star/bonus_star_04.png -------------------------------------------------------------------------------- /sidescroller/assets/images/bonus_star/bonus_star_05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/bonus_star/bonus_star_05.png -------------------------------------------------------------------------------- /sidescroller/assets/images/bonus_star/bonus_star_06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/bonus_star/bonus_star_06.png -------------------------------------------------------------------------------- /sidescroller/assets/images/bonus_star/bonus_star_07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/bonus_star/bonus_star_07.png -------------------------------------------------------------------------------- /sidescroller/assets/images/bonus_star/bonus_star_08.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/bonus_star/bonus_star_08.png -------------------------------------------------------------------------------- /sidescroller/assets/images/bonus_star/bonus_star_09.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/bonus_star/bonus_star_09.png -------------------------------------------------------------------------------- /sidescroller/assets/images/bonus_star/bonus_star_10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/bonus_star/bonus_star_10.png -------------------------------------------------------------------------------- /sidescroller/assets/images/bonus_star/bonus_star_11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/bonus_star/bonus_star_11.png -------------------------------------------------------------------------------- /sidescroller/assets/images/bonus_star/bonus_star_12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/bonus_star/bonus_star_12.png -------------------------------------------------------------------------------- /sidescroller/assets/images/bonus_star/bonus_star_13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/bonus_star/bonus_star_13.png -------------------------------------------------------------------------------- /sidescroller/assets/images/bonus_star/bonus_star_14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/bonus_star/bonus_star_14.png -------------------------------------------------------------------------------- /sidescroller/assets/images/bonus_star/bonus_star_15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/bonus_star/bonus_star_15.png -------------------------------------------------------------------------------- /sidescroller/assets/images/bonus_star/bonus_star_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/bonus_star/bonus_star_16.png -------------------------------------------------------------------------------- /sidescroller/assets/images/bonus_star/bonus_star_17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/bonus_star/bonus_star_17.png -------------------------------------------------------------------------------- /sidescroller/assets/images/bonus_star/bonus_star_18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/bonus_star/bonus_star_18.png -------------------------------------------------------------------------------- /sidescroller/assets/images/bonus_star/bonus_star_19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/bonus_star/bonus_star_19.png -------------------------------------------------------------------------------- /sidescroller/assets/images/bonus_star/bonus_star_20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/bonus_star/bonus_star_20.png -------------------------------------------------------------------------------- /sidescroller/assets/images/bonus_star/bonus_star_21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/bonus_star/bonus_star_21.png -------------------------------------------------------------------------------- /sidescroller/assets/images/bonus_star/bonus_star_22.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/bonus_star/bonus_star_22.png -------------------------------------------------------------------------------- /sidescroller/assets/images/bonus_star/bonus_star_23.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/bonus_star/bonus_star_23.png -------------------------------------------------------------------------------- /sidescroller/assets/images/enemies/enemyBlack1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/enemies/enemyBlack1.png -------------------------------------------------------------------------------- /sidescroller/assets/images/spaceship/spaceship_00.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/spaceship/spaceship_00.png -------------------------------------------------------------------------------- /sidescroller/assets/images/spaceship/spaceship_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/spaceship/spaceship_01.png -------------------------------------------------------------------------------- /sidescroller/assets/images/spaceship/spaceship_02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/spaceship/spaceship_02.png -------------------------------------------------------------------------------- /sidescroller/assets/images/spaceship/spaceship_03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/spaceship/spaceship_03.png -------------------------------------------------------------------------------- /sidescroller/assets/images/spaceship/spaceship_04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/spaceship/spaceship_04.png -------------------------------------------------------------------------------- /sidescroller/assets/images/spaceship/spaceship_05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/spaceship/spaceship_05.png -------------------------------------------------------------------------------- /sidescroller/assets/images/spaceship/spaceship_06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/spaceship/spaceship_06.png -------------------------------------------------------------------------------- /sidescroller/assets/images/spaceship/spaceship_07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/spaceship/spaceship_07.png -------------------------------------------------------------------------------- /sidescroller/assets/images/spaceship/spaceship_08.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/spaceship/spaceship_08.png -------------------------------------------------------------------------------- /sidescroller/assets/images/star/star_00.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/star/star_00.png -------------------------------------------------------------------------------- /sidescroller/assets/images/star/star_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/star/star_01.png -------------------------------------------------------------------------------- /sidescroller/assets/images/star/star_02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/star/star_02.png -------------------------------------------------------------------------------- /sidescroller/assets/images/star/star_03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/star/star_03.png -------------------------------------------------------------------------------- /sidescroller/assets/images/star/star_04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/star/star_04.png -------------------------------------------------------------------------------- /sidescroller/assets/images/star/star_05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/star/star_05.png -------------------------------------------------------------------------------- /sidescroller/assets/images/star/star_06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/star/star_06.png -------------------------------------------------------------------------------- /sidescroller/assets/images/star/star_07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/star/star_07.png -------------------------------------------------------------------------------- /sidescroller/assets/images/star/star_08.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/star/star_08.png -------------------------------------------------------------------------------- /sidescroller/assets/images/star/star_09.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/star/star_09.png -------------------------------------------------------------------------------- /sidescroller/assets/images/star/star_10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/star/star_10.png -------------------------------------------------------------------------------- /sidescroller/assets/images/star/star_11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/star/star_11.png -------------------------------------------------------------------------------- /sidescroller/assets/images/star/star_12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/star/star_12.png -------------------------------------------------------------------------------- /sidescroller/assets/images/star/star_13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/star/star_13.png -------------------------------------------------------------------------------- /sidescroller/assets/images/star/star_14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/star/star_14.png -------------------------------------------------------------------------------- /sidescroller/assets/images/star/star_15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/star/star_15.png -------------------------------------------------------------------------------- /sidescroller/assets/images/star/star_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/star/star_16.png -------------------------------------------------------------------------------- /sidescroller/assets/images/star/star_17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/star/star_17.png -------------------------------------------------------------------------------- /sidescroller/assets/images/star/star_18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/star/star_18.png -------------------------------------------------------------------------------- /sidescroller/assets/images/star/star_19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/star/star_19.png -------------------------------------------------------------------------------- /sidescroller/assets/images/star/star_20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/star/star_20.png -------------------------------------------------------------------------------- /sidescroller/assets/images/star/star_21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/star/star_21.png -------------------------------------------------------------------------------- /sidescroller/assets/images/star/star_22.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/star/star_22.png -------------------------------------------------------------------------------- /sidescroller/assets/images/star/star_23.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/sidescroller/assets/images/star/star_23.png -------------------------------------------------------------------------------- /sidescroller/assets/spaceship.atlas: -------------------------------------------------------------------------------- 1 | animations { 2 | id: "spin" 3 | images { 4 | image: "/assets/images/spaceship/spaceship_00.png" 5 | } 6 | images { 7 | image: "/assets/images/spaceship/spaceship_01.png" 8 | } 9 | images { 10 | image: "/assets/images/spaceship/spaceship_02.png" 11 | } 12 | images { 13 | image: "/assets/images/spaceship/spaceship_03.png" 14 | } 15 | images { 16 | image: "/assets/images/spaceship/spaceship_04.png" 17 | } 18 | images { 19 | image: "/assets/images/spaceship/spaceship_05.png" 20 | } 21 | images { 22 | image: "/assets/images/spaceship/spaceship_06.png" 23 | } 24 | images { 25 | image: "/assets/images/spaceship/spaceship_07.png" 26 | } 27 | images { 28 | image: "/assets/images/spaceship/spaceship_08.png" 29 | } 30 | playback: PLAYBACK_LOOP_FORWARD 31 | fps: 30 32 | flip_horizontal: 0 33 | flip_vertical: 0 34 | } 35 | margin: 0 36 | extrude_borders: 0 37 | inner_padding: 0 38 | -------------------------------------------------------------------------------- /sidescroller/assets/stars.atlas: -------------------------------------------------------------------------------- 1 | animations { 2 | id: "star" 3 | images { 4 | image: "/assets/images/star/star_00.png" 5 | } 6 | images { 7 | image: "/assets/images/star/star_01.png" 8 | } 9 | images { 10 | image: "/assets/images/star/star_02.png" 11 | } 12 | images { 13 | image: "/assets/images/star/star_03.png" 14 | } 15 | images { 16 | image: "/assets/images/star/star_04.png" 17 | } 18 | images { 19 | image: "/assets/images/star/star_05.png" 20 | } 21 | images { 22 | image: "/assets/images/star/star_06.png" 23 | } 24 | images { 25 | image: "/assets/images/star/star_07.png" 26 | } 27 | images { 28 | image: "/assets/images/star/star_08.png" 29 | } 30 | images { 31 | image: "/assets/images/star/star_09.png" 32 | } 33 | images { 34 | image: "/assets/images/star/star_10.png" 35 | } 36 | images { 37 | image: "/assets/images/star/star_11.png" 38 | } 39 | images { 40 | image: "/assets/images/star/star_12.png" 41 | } 42 | images { 43 | image: "/assets/images/star/star_13.png" 44 | } 45 | images { 46 | image: "/assets/images/star/star_14.png" 47 | } 48 | images { 49 | image: "/assets/images/star/star_15.png" 50 | } 51 | images { 52 | image: "/assets/images/star/star_16.png" 53 | } 54 | images { 55 | image: "/assets/images/star/star_17.png" 56 | } 57 | images { 58 | image: "/assets/images/star/star_18.png" 59 | } 60 | images { 61 | image: "/assets/images/star/star_19.png" 62 | } 63 | images { 64 | image: "/assets/images/star/star_20.png" 65 | } 66 | images { 67 | image: "/assets/images/star/star_21.png" 68 | } 69 | images { 70 | image: "/assets/images/star/star_22.png" 71 | } 72 | images { 73 | image: "/assets/images/star/star_23.png" 74 | } 75 | playback: PLAYBACK_LOOP_FORWARD 76 | fps: 30 77 | flip_horizontal: 0 78 | flip_vertical: 0 79 | } 80 | animations { 81 | id: "bonus_star" 82 | images { 83 | image: "/assets/images/bonus_star/bonus_star_00.png" 84 | } 85 | images { 86 | image: "/assets/images/bonus_star/bonus_star_01.png" 87 | } 88 | images { 89 | image: "/assets/images/bonus_star/bonus_star_02.png" 90 | } 91 | images { 92 | image: "/assets/images/bonus_star/bonus_star_03.png" 93 | } 94 | images { 95 | image: "/assets/images/bonus_star/bonus_star_04.png" 96 | } 97 | images { 98 | image: "/assets/images/bonus_star/bonus_star_05.png" 99 | } 100 | images { 101 | image: "/assets/images/bonus_star/bonus_star_06.png" 102 | } 103 | images { 104 | image: "/assets/images/bonus_star/bonus_star_07.png" 105 | } 106 | images { 107 | image: "/assets/images/bonus_star/bonus_star_08.png" 108 | } 109 | images { 110 | image: "/assets/images/bonus_star/bonus_star_09.png" 111 | } 112 | images { 113 | image: "/assets/images/bonus_star/bonus_star_10.png" 114 | } 115 | images { 116 | image: "/assets/images/bonus_star/bonus_star_11.png" 117 | } 118 | images { 119 | image: "/assets/images/bonus_star/bonus_star_12.png" 120 | } 121 | images { 122 | image: "/assets/images/bonus_star/bonus_star_13.png" 123 | } 124 | images { 125 | image: "/assets/images/bonus_star/bonus_star_14.png" 126 | } 127 | images { 128 | image: "/assets/images/bonus_star/bonus_star_15.png" 129 | } 130 | images { 131 | image: "/assets/images/bonus_star/bonus_star_16.png" 132 | } 133 | images { 134 | image: "/assets/images/bonus_star/bonus_star_17.png" 135 | } 136 | images { 137 | image: "/assets/images/bonus_star/bonus_star_18.png" 138 | } 139 | images { 140 | image: "/assets/images/bonus_star/bonus_star_19.png" 141 | } 142 | images { 143 | image: "/assets/images/bonus_star/bonus_star_20.png" 144 | } 145 | images { 146 | image: "/assets/images/bonus_star/bonus_star_21.png" 147 | } 148 | images { 149 | image: "/assets/images/bonus_star/bonus_star_22.png" 150 | } 151 | images { 152 | image: "/assets/images/bonus_star/bonus_star_23.png" 153 | } 154 | playback: PLAYBACK_LOOP_FORWARD 155 | fps: 30 156 | flip_horizontal: 0 157 | flip_vertical: 0 158 | } 159 | margin: 0 160 | extrude_borders: 0 161 | inner_padding: 0 162 | -------------------------------------------------------------------------------- /sidescroller/background/large_planets.go: -------------------------------------------------------------------------------- 1 | components { 2 | id: "script" 3 | component: "/background/large_planets.script" 4 | position { 5 | x: 0.0 6 | y: 0.0 7 | z: 0.0 8 | } 9 | rotation { 10 | x: 0.0 11 | y: 0.0 12 | z: 0.0 13 | w: 1.0 14 | } 15 | } 16 | embedded_components { 17 | id: "sprite" 18 | type: "sprite" 19 | data: "tile_set: \"/assets/background.atlas\"\n" 20 | "default_animation: \"earthlike_planet\"\n" 21 | "material: \"/builtins/materials/sprite.material\"\n" 22 | "blend_mode: BLEND_MODE_ALPHA\n" 23 | "" 24 | position { 25 | x: 367.68527 26 | y: 271.58572 27 | z: 0.0 28 | } 29 | rotation { 30 | x: 0.0 31 | y: 0.0 32 | z: 0.0 33 | w: 1.0 34 | } 35 | } 36 | embedded_components { 37 | id: "sprite1" 38 | type: "sprite" 39 | data: "tile_set: \"/assets/background.atlas\"\n" 40 | "default_animation: \"gas_planet\"\n" 41 | "material: \"/builtins/materials/sprite.material\"\n" 42 | "blend_mode: BLEND_MODE_ALPHA\n" 43 | "" 44 | position { 45 | x: 1090.5211 46 | y: 655.98395 47 | z: 0.0 48 | } 49 | rotation { 50 | x: 0.0 51 | y: 0.0 52 | z: 0.0 53 | w: 1.0 54 | } 55 | } 56 | embedded_components { 57 | id: "sprite2" 58 | type: "sprite" 59 | data: "tile_set: \"/assets/background.atlas\"\n" 60 | "default_animation: \"ice_planet\"\n" 61 | "material: \"/builtins/materials/sprite.material\"\n" 62 | "blend_mode: BLEND_MODE_ALPHA\n" 63 | "" 64 | position { 65 | x: 1203.3336 66 | y: 125.34725 67 | z: 0.0 68 | } 69 | rotation { 70 | x: 0.0 71 | y: 0.0 72 | z: 0.0 73 | w: 1.0 74 | } 75 | } 76 | embedded_components { 77 | id: "sprite3" 78 | type: "sprite" 79 | data: "tile_set: \"/assets/background.atlas\"\n" 80 | "default_animation: \"ring_planet\"\n" 81 | "material: \"/builtins/materials/sprite.material\"\n" 82 | "blend_mode: BLEND_MODE_ALPHA\n" 83 | "" 84 | position { 85 | x: 2047.3385 86 | y: 614.20154 87 | z: 0.0 88 | } 89 | rotation { 90 | x: 0.0 91 | y: 0.0 92 | z: 0.0 93 | w: 1.0 94 | } 95 | } 96 | embedded_components { 97 | id: "sprite4" 98 | type: "sprite" 99 | data: "tile_set: \"/assets/background.atlas\"\n" 100 | "default_animation: \"earthlike_planet\"\n" 101 | "material: \"/builtins/materials/sprite.material\"\n" 102 | "blend_mode: BLEND_MODE_ALPHA\n" 103 | "" 104 | position { 105 | x: 2444.2715 106 | y: 116.99077 107 | z: 0.0 108 | } 109 | rotation { 110 | x: 0.0 111 | y: 0.0 112 | z: 0.0 113 | w: 1.0 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /sidescroller/background/large_planets.script: -------------------------------------------------------------------------------- 1 | local speed = -60 2 | 3 | function update(self, dt) 4 | local p = go.get_position() 5 | -- apply the speed 6 | p.x = p.x + speed * dt 7 | -- reset clouds to far right when they reach the far left to create infinite scrolling 8 | if p.x <= -1280 * 2 then 9 | p.x = 1280 * 2 10 | end 11 | go.set_position(p) 12 | end 13 | -------------------------------------------------------------------------------- /sidescroller/background/small_planets.go: -------------------------------------------------------------------------------- 1 | components { 2 | id: "script" 3 | component: "/background/small_planets.script" 4 | position { 5 | x: 0.0 6 | y: 0.0 7 | z: 0.0 8 | } 9 | rotation { 10 | x: 0.0 11 | y: 0.0 12 | z: 0.0 13 | w: 1.0 14 | } 15 | } 16 | embedded_components { 17 | id: "sprite2" 18 | type: "sprite" 19 | data: "tile_set: \"/assets/background.atlas\"\n" 20 | "default_animation: \"earthlike_planet\"\n" 21 | "material: \"/builtins/materials/sprite.material\"\n" 22 | "blend_mode: BLEND_MODE_ALPHA\n" 23 | "" 24 | position { 25 | x: 1675.8176 26 | y: 1219.3085 27 | z: 0.0 28 | } 29 | rotation { 30 | x: 0.0 31 | y: 0.0 32 | z: 0.0 33 | w: 1.0 34 | } 35 | } 36 | embedded_components { 37 | id: "sprite3" 38 | type: "sprite" 39 | data: "tile_set: \"/assets/background.atlas\"\n" 40 | "default_animation: \"ice_planet\"\n" 41 | "material: \"/builtins/materials/sprite.material\"\n" 42 | "blend_mode: BLEND_MODE_ALPHA\n" 43 | "" 44 | position { 45 | x: 653.92444 46 | y: 1265.6538 47 | z: 0.0 48 | } 49 | rotation { 50 | x: 0.0 51 | y: 0.0 52 | z: 0.0 53 | w: 1.0 54 | } 55 | } 56 | embedded_components { 57 | id: "sprite4" 58 | type: "sprite" 59 | data: "tile_set: \"/assets/background.atlas\"\n" 60 | "default_animation: \"ring_planet\"\n" 61 | "material: \"/builtins/materials/sprite.material\"\n" 62 | "blend_mode: BLEND_MODE_ALPHA\n" 63 | "" 64 | position { 65 | x: 249.6802 66 | y: 307.51465 67 | z: 0.0 68 | } 69 | rotation { 70 | x: 0.0 71 | y: 0.0 72 | z: 0.0 73 | w: 1.0 74 | } 75 | } 76 | embedded_components { 77 | id: "sprite5" 78 | type: "sprite" 79 | data: "tile_set: \"/assets/background.atlas\"\n" 80 | "default_animation: \"gas_planet\"\n" 81 | "material: \"/builtins/materials/sprite.material\"\n" 82 | "blend_mode: BLEND_MODE_ALPHA\n" 83 | "" 84 | position { 85 | x: 2486.6028 86 | y: 640.6514 87 | z: 0.0 88 | } 89 | rotation { 90 | x: 0.0 91 | y: 0.0 92 | z: 0.0 93 | w: 1.0 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /sidescroller/background/small_planets.script: -------------------------------------------------------------------------------- 1 | local speed = -30 2 | 3 | function update(self, dt) 4 | local p = go.get_position() 5 | -- apply the speed 6 | p.x = p.x + speed * dt 7 | -- reset clouds to far right when they reach the far left to create infinite scrolling 8 | if p.x <= -1280 then 9 | p.x = 1280 10 | end 11 | go.set_position(p) 12 | end 13 | -------------------------------------------------------------------------------- /sidescroller/game.project: -------------------------------------------------------------------------------- 1 | [project] 2 | title = Side-scroller 3 | 4 | [bootstrap] 5 | main_collection = /main/main.collectionc 6 | 7 | [input] 8 | game_binding = /input/game.input_bindingc 9 | 10 | [display] 11 | width = 1280 12 | height = 720 13 | variable_dt = 1 14 | 15 | [physics] 16 | scale = 0.02 17 | 18 | [script] 19 | shared_state = 1 20 | 21 | -------------------------------------------------------------------------------- /sidescroller/input/game.input_binding: -------------------------------------------------------------------------------- 1 | key_trigger { 2 | input: KEY_UP 3 | action: "up" 4 | } 5 | key_trigger { 6 | input: KEY_DOWN 7 | action: "down" 8 | } 9 | gamepad_trigger { 10 | input: GAMEPAD_LPAD_UP 11 | action: "up" 12 | } 13 | gamepad_trigger { 14 | input: GAMEPAD_RPAD_DOWN 15 | action: "down" 16 | } 17 | -------------------------------------------------------------------------------- /sidescroller/main/main.collection: -------------------------------------------------------------------------------- 1 | name: "parallax" 2 | instances { 3 | id: "factory" 4 | prototype: "/stars/factory.go" 5 | position { 6 | x: 1312.0 7 | y: 360.0 8 | z: 0.5 9 | } 10 | } 11 | instances { 12 | id: "spaceship" 13 | prototype: "/spaceship/spaceship.go" 14 | position { 15 | x: 209.66061 16 | y: 400.0 17 | z: 0.5 18 | } 19 | } 20 | instances { 21 | id: "large_planets1" 22 | prototype: "/background/large_planets.go" 23 | } 24 | instances { 25 | id: "large_planets2" 26 | prototype: "/background/large_planets.go" 27 | position { 28 | x: 2844.91 29 | } 30 | } 31 | instances { 32 | id: "small_planets1" 33 | prototype: "/background/small_planets.go" 34 | scale3 { 35 | x: 0.3 36 | y: 0.3 37 | } 38 | } 39 | instances { 40 | id: "small_planets2" 41 | prototype: "/background/small_planets.go" 42 | position { 43 | x: 1418.621 44 | } 45 | scale3 { 46 | x: 0.3 47 | y: 0.3 48 | } 49 | } 50 | scale_along_z: 0 51 | embedded_instances { 52 | id: "background" 53 | data: "embedded_components {\n" 54 | " id: \"sprite\"\n" 55 | " type: \"sprite\"\n" 56 | " data: \"default_animation: \\\"bg\\\"\\n" 57 | "material: \\\"/builtins/materials/sprite.material\\\"\\n" 58 | "textures {\\n" 59 | " sampler: \\\"texture_sampler\\\"\\n" 60 | " texture: \\\"/assets/background.atlas\\\"\\n" 61 | "}\\n" 62 | "\"\n" 63 | "}\n" 64 | "" 65 | position { 66 | x: 640.0 67 | y: 360.0 68 | z: -0.9 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /sidescroller/spaceship/spaceship.go: -------------------------------------------------------------------------------- 1 | components { 2 | id: "script" 3 | component: "/spaceship/spaceship.script" 4 | position { 5 | x: 0.0 6 | y: 0.0 7 | z: 0.0 8 | } 9 | rotation { 10 | x: 0.0 11 | y: 0.0 12 | z: 0.0 13 | w: 1.0 14 | } 15 | } 16 | embedded_components { 17 | id: "collisionobject" 18 | type: "collisionobject" 19 | data: "collision_shape: \"\"\n" 20 | "type: COLLISION_OBJECT_TYPE_KINEMATIC\n" 21 | "mass: 0.0\n" 22 | "friction: 0.1\n" 23 | "restitution: 0.5\n" 24 | "group: \"spaceship\"\n" 25 | "mask: \"star\"\n" 26 | "embedded_collision_shape {\n" 27 | " shapes {\n" 28 | " shape_type: TYPE_SPHERE\n" 29 | " position {\n" 30 | " x: 0.0\n" 31 | " y: -6.287068\n" 32 | " z: 0.0\n" 33 | " }\n" 34 | " rotation {\n" 35 | " x: 0.0\n" 36 | " y: 0.0\n" 37 | " z: 0.0\n" 38 | " w: 1.0\n" 39 | " }\n" 40 | " index: 0\n" 41 | " count: 1\n" 42 | " }\n" 43 | " data: 28.0\n" 44 | "}\n" 45 | "linear_damping: 0.0\n" 46 | "angular_damping: 0.0\n" 47 | "locked_rotation: false\n" 48 | "" 49 | position { 50 | x: 0.0 51 | y: 0.0 52 | z: 0.0 53 | } 54 | rotation { 55 | x: 0.0 56 | y: 0.0 57 | z: 0.0 58 | w: 1.0 59 | } 60 | } 61 | embedded_components { 62 | id: "sprite" 63 | type: "sprite" 64 | data: "tile_set: \"/assets/spaceship.atlas\"\n" 65 | "default_animation: \"spin\"\n" 66 | "material: \"/builtins/materials/sprite.material\"\n" 67 | "blend_mode: BLEND_MODE_ALPHA\n" 68 | "" 69 | position { 70 | x: 0.0 71 | y: 0.0 72 | z: 0.0 73 | } 74 | rotation { 75 | x: 0.0 76 | y: 0.0 77 | z: 0.0 78 | w: 1.0 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /sidescroller/spaceship/spaceship.script: -------------------------------------------------------------------------------- 1 | local max_speed = 160 2 | local min_y = 60 3 | local max_y = 600 4 | 5 | function init(self) 6 | -- Let the script receive input from the player 7 | msg.post(".", "acquire_input_focus") 8 | -- the current speed of the space ship 9 | self.speed = 0 10 | 11 | -- Animate the ship so it's swaying back and forth 12 | go.set(".", "euler.z", -5) 13 | go.animate(".", "euler.z", go.PLAYBACK_LOOP_PINGPONG, 5, go.EASING_INOUTSINE, 2) 14 | end 15 | 16 | function update(self, dt) 17 | -- get current position 18 | local p = go.get_position() 19 | -- apply speed 20 | p.y = p.y + self.speed * dt 21 | -- limit vertical position so we don't move outside screen bounds 22 | if p.y < min_y then 23 | p.y = min_y 24 | elseif p.y > max_y then 25 | p.y = max_y 26 | end 27 | -- update position 28 | go.set_position(p) 29 | -- reset speed 30 | self.speed = 0 31 | end 32 | 33 | function on_input(self, action_id, action) 34 | -- set speed up/down 35 | if action_id == hash("up") then 36 | self.speed = max_speed 37 | elseif action_id == hash("down") then 38 | self.speed = -max_speed 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /sidescroller/stars/factory.go: -------------------------------------------------------------------------------- 1 | components { 2 | id: "script" 3 | component: "/stars/factory.script" 4 | position { 5 | x: 0.0 6 | y: 0.0 7 | z: 0.0 8 | } 9 | rotation { 10 | x: 0.0 11 | y: 0.0 12 | z: 0.0 13 | w: 1.0 14 | } 15 | } 16 | embedded_components { 17 | id: "star_factory" 18 | type: "factory" 19 | data: "prototype: \"/stars/star.go\"\n" 20 | position { 21 | x: 0.0 22 | y: 0.0 23 | z: 0.0 24 | } 25 | rotation { 26 | x: 0.0 27 | y: 0.0 28 | z: 0.0 29 | w: 1.0 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /sidescroller/stars/factory.script: -------------------------------------------------------------------------------- 1 | local frequency = 0.5 2 | local min_y = 60 3 | local max_y = 600 4 | 5 | function init(self) 6 | self.timer = 1/frequency 7 | math.randomseed(os.time()) 8 | end 9 | 10 | function update(self, dt) 11 | self.timer = self.timer - dt 12 | if self.timer <= 0 then 13 | self.timer = 1/frequency 14 | local p = go.get_position() 15 | p.y = math.random(min_y, max_y) 16 | factory.create("#star_factory", p) 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /sidescroller/stars/star.go: -------------------------------------------------------------------------------- 1 | components { 2 | id: "script" 3 | component: "/stars/star.script" 4 | position { 5 | x: 0.0 6 | y: 0.0 7 | z: 0.0 8 | } 9 | rotation { 10 | x: 0.0 11 | y: 0.0 12 | z: 0.0 13 | w: 1.0 14 | } 15 | } 16 | embedded_components { 17 | id: "collisionobject" 18 | type: "collisionobject" 19 | data: "collision_shape: \"\"\n" 20 | "type: COLLISION_OBJECT_TYPE_KINEMATIC\n" 21 | "mass: 0.0\n" 22 | "friction: 0.1\n" 23 | "restitution: 0.5\n" 24 | "group: \"star\"\n" 25 | "mask: \"spaceship\"\n" 26 | "embedded_collision_shape {\n" 27 | " shapes {\n" 28 | " shape_type: TYPE_SPHERE\n" 29 | " position {\n" 30 | " x: 0.0\n" 31 | " y: -3.5058432\n" 32 | " z: 0.0\n" 33 | " }\n" 34 | " rotation {\n" 35 | " x: 0.0\n" 36 | " y: 0.0\n" 37 | " z: 0.0\n" 38 | " w: 1.0\n" 39 | " }\n" 40 | " index: 0\n" 41 | " count: 1\n" 42 | " }\n" 43 | " data: 20.742905\n" 44 | "}\n" 45 | "linear_damping: 0.0\n" 46 | "angular_damping: 0.0\n" 47 | "locked_rotation: false\n" 48 | "" 49 | position { 50 | x: 0.0 51 | y: 0.0 52 | z: 0.0 53 | } 54 | rotation { 55 | x: 0.0 56 | y: 0.0 57 | z: 0.0 58 | w: 1.0 59 | } 60 | } 61 | embedded_components { 62 | id: "sprite" 63 | type: "sprite" 64 | data: "tile_set: \"/assets/stars.atlas\"\n" 65 | "default_animation: \"star\"\n" 66 | "material: \"/builtins/materials/sprite.material\"\n" 67 | "blend_mode: BLEND_MODE_ALPHA\n" 68 | "" 69 | position { 70 | x: 0.0 71 | y: 0.0 72 | z: 0.5 73 | } 74 | rotation { 75 | x: 0.0 76 | y: 0.0 77 | z: 0.0 78 | w: 1.0 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /sidescroller/stars/star.script: -------------------------------------------------------------------------------- 1 | local score = 1 2 | local speed = -240 3 | 4 | function update(self, dt) 5 | local p = go.get_position() 6 | p.x = p.x + speed * dt 7 | if p.x < -32 then 8 | go.delete() 9 | end 10 | go.set_position(p) 11 | end 12 | 13 | function on_message(self, message_id, message, sender) 14 | if message_id == hash("collision_response") then 15 | go.delete() 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /snake/README.md: -------------------------------------------------------------------------------- 1 | # Snake 2 | Snake is one of the most common classic games you can attempt to recreate. There are a lot of variations on this game, this one features a snake that eats “food” and that only grows when it eats. This snake also crawls on a playfield that contains obstacles. 3 | 4 | ## Additional exercises 5 | * Add scoring and a score counter. Perhaps using a label? 6 | * The function put_food() does not take into account the position of the snake, nor where obstacles are. Fix that. 7 | * If the game is over, show a “game over” message, then allow the player to try again. 8 | * Extra points: add a player 2 snake. 9 | 10 | ## Source 11 | https://www.defold.com/tutorials/snake/ 12 | -------------------------------------------------------------------------------- /snake/assets/images/snake.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/snake/assets/images/snake.png -------------------------------------------------------------------------------- /snake/assets/tiles.tilesource: -------------------------------------------------------------------------------- 1 | image: "/assets/images/snake.png" 2 | tile_width: 16 3 | tile_height: 16 4 | tile_margin: 0 5 | tile_spacing: 0 6 | collision: "" 7 | material_tag: "tile" 8 | collision_groups: "default" 9 | animations { 10 | id: "anim" 11 | start_tile: 1 12 | end_tile: 1 13 | playback: PLAYBACK_ONCE_FORWARD 14 | fps: 30 15 | flip_horizontal: 0 16 | flip_vertical: 0 17 | } 18 | extrude_borders: 1 19 | inner_padding: 0 20 | -------------------------------------------------------------------------------- /snake/game.project: -------------------------------------------------------------------------------- 1 | [project] 2 | title = Snake 3 | 4 | [bootstrap] 5 | main_collection = /main/main.collectionc 6 | 7 | [input] 8 | game_binding = /input/game.input_bindingc 9 | 10 | [display] 11 | width = 800 12 | height = 800 13 | 14 | [script] 15 | shared_state = 1 16 | 17 | [ios] 18 | app_icon_120x120 = /assets/appicons/icon_120.png 19 | app_icon_180x180 = /assets/appicons/icon_180.png 20 | app_icon_76x76 = /assets/appicons/icon_76.png 21 | app_icon_152x152 = /assets/appicons/icon_152.png 22 | app_icon_57x57 = /assets/appicons/icon_57.png 23 | app_icon_114x114 = /assets/appicons/icon_114.png 24 | app_icon_72x72 = /assets/appicons/icon_72.png 25 | app_icon_144x144 = /assets/appicons/icon_144.png 26 | launch_image_320x480 = /assets/loadingscreens/screen_320x480.png 27 | launch_image_640x960 = /assets/loadingscreens/screen_640x960.png 28 | launch_image_640x1136 = /assets/loadingscreens/screen_640x1136.png 29 | launch_image_750x1334 = /assets/loadingscreens/screen_750x1334.png 30 | launch_image_768x1024 = /assets/loadingscreens/screen_768x1024.png 31 | launch_image_1536x2048 = /assets/loadingscreens/screen_1536x2048.png 32 | launch_image_1024x768 = /assets/loadingscreens/screen_1024x768.png 33 | launch_image_1242x2208 = /assets/loadingscreens/screen_1242x2208.png 34 | launch_image_2208x1242 = /assets/loadingscreens/screen_2208x1242.png 35 | launch_image_2048x1536 = /assets/loadingscreens/screen_2048x1536.png 36 | bundle_identifier = com.example.todo 37 | app_icon_167x167 = /assets/appicons/icon_167.png 38 | 39 | [osx] 40 | bundle_identifier = com.example.todo 41 | 42 | [android] 43 | app_icon_36x36 = /assets/appicons/icon_36.png 44 | app_icon_48x48 = /assets/appicons/icon_48.png 45 | app_icon_72x72 = /assets/appicons/icon_72.png 46 | app_icon_96x96 = /assets/appicons/icon_96.png 47 | app_icon_144x144 = /assets/appicons/icon_144.png 48 | app_icon_192x192 = /assets/appicons/icon_192.png 49 | 50 | -------------------------------------------------------------------------------- /snake/input/game.input_binding: -------------------------------------------------------------------------------- 1 | key_trigger { 2 | input: KEY_LEFT 3 | action: "left" 4 | } 5 | key_trigger { 6 | input: KEY_RIGHT 7 | action: "right" 8 | } 9 | key_trigger { 10 | input: KEY_DOWN 11 | action: "down" 12 | } 13 | key_trigger { 14 | input: KEY_UP 15 | action: "up" 16 | } 17 | mouse_trigger { 18 | input: MOUSE_BUTTON_1 19 | action: "touch" 20 | } 21 | -------------------------------------------------------------------------------- /snake/main/main.collection: -------------------------------------------------------------------------------- 1 | name: "default" 2 | scale_along_z: 0 3 | embedded_instances { 4 | id: "go" 5 | data: "components {\n" 6 | " id: \"grid\"\n" 7 | " component: \"/main/grid.tilemap\"\n" 8 | " position {\n" 9 | " x: 0.0\n" 10 | " y: 0.0\n" 11 | " z: 0.0\n" 12 | " }\n" 13 | " rotation {\n" 14 | " x: 0.0\n" 15 | " y: 0.0\n" 16 | " z: 0.0\n" 17 | " w: 1.0\n" 18 | " }\n" 19 | "}\n" 20 | "components {\n" 21 | " id: \"snake\"\n" 22 | " component: \"/main/snake.script\"\n" 23 | " position {\n" 24 | " x: 0.0\n" 25 | " y: 0.0\n" 26 | " z: 0.0\n" 27 | " }\n" 28 | " rotation {\n" 29 | " x: 0.0\n" 30 | " y: 0.0\n" 31 | " z: 0.0\n" 32 | " w: 1.0\n" 33 | " }\n" 34 | "}\n" 35 | "" 36 | position { 37 | x: 0.0 38 | y: 0.0 39 | z: 0.0 40 | } 41 | rotation { 42 | x: 0.0 43 | y: 0.0 44 | z: 0.0 45 | w: 1.0 46 | } 47 | scale3 { 48 | x: 1.0 49 | y: 1.0 50 | z: 1.0 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /snake/main/snake.script: -------------------------------------------------------------------------------- 1 | local function put_food(self) 2 | self.food = {x = math.random(2, 47), y = math.random(2, 47)} 3 | tilemap.set_tile("#grid", "layer1", self.food.x, self.food.y, 3) 4 | end 5 | 6 | function init(self) 7 | msg.post(".", "acquire_input_focus") 8 | 9 | -- the current list of segments for the snake 10 | self.segments = { 11 | {x = 7, y = 24}, 12 | {x = 8, y = 24}, 13 | {x = 9, y = 24}, 14 | {x = 10, y = 24} } 15 | 16 | -- current direction of travel 17 | self.dir = {x = 1, y = 0} 18 | 19 | -- list of direction commands issued by the player to move 20 | self.dirqueue = {} 21 | self.speed = 7.0 22 | self.alive = true 23 | 24 | self.t = 0 25 | 26 | math.randomseed(os.time()) 27 | put_food(self) 28 | end 29 | 30 | function update(self, dt) 31 | self.t = self.t + dt 32 | -- time to move the snake? 33 | if self.t >= 1.0 / self.speed and self.alive then 34 | -- get the next command from the player (if any) 35 | if #self.dirqueue > 0 then 36 | local newdir = table.remove(self.dirqueue, 1) 37 | -- is the command in the opposite direction of travel? 38 | -- if so ignore it, otherwise use it as the new direction of travel 39 | local opposite = newdir.x == -self.dir.x or newdir.y == -self.dir.y 40 | if not opposite then 41 | self.dir = newdir 42 | end 43 | end 44 | 45 | -- get the current head position 46 | local head = self.segments[#self.segments] 47 | -- create new head in the direction of movement 48 | local newhead = {x = head.x + self.dir.x, y = head.y + self.dir.y} 49 | table.insert(self.segments, newhead) 50 | 51 | -- get what we're moving into on the level 52 | local tile = tilemap.get_tile("#grid", "layer1", newhead.x, newhead.y) 53 | -- colliding with obstacle or self (2 = wall, 4 = snake) 54 | if tile == 2 or tile == 4 then 55 | self.alive = false 56 | -- food? 57 | elseif tile == 3 then 58 | self.speed = self.speed + 1 59 | put_food(self) 60 | -- nothing? get tail and remove it 61 | else 62 | local tail = table.remove(self.segments, 1) 63 | tilemap.set_tile("#grid", "layer1", tail.x, tail.y, 1) 64 | end 65 | 66 | -- update the remaining segments of the snake 67 | for i, s in ipairs(self.segments) do 68 | tilemap.set_tile("#grid", "layer1", s.x, s.y, 2) 69 | end 70 | 71 | self.t = 0 72 | end 73 | end 74 | 75 | function on_input(self, action_id, action) 76 | if action_id == hash("up") and action.pressed then 77 | table.insert(self.dirqueue, {x = 0, y = 1}) 78 | elseif action_id == hash("down") and action.pressed then 79 | table.insert(self.dirqueue, {x = 0, y = -1}) 80 | elseif action_id == hash("left") and action.pressed then 81 | table.insert(self.dirqueue, {x = -1, y = 0}) 82 | elseif action_id == hash("right") and action.pressed then 83 | table.insert(self.dirqueue, {x = 1, y = 0}) 84 | end 85 | end -------------------------------------------------------------------------------- /texture_profiles/assets/atlases/alternative.atlas: -------------------------------------------------------------------------------- 1 | images { 2 | image: "/assets/images/subfolder/alternative_logo.png" 3 | } 4 | margin: 0 5 | extrude_borders: 0 6 | inner_padding: 2 7 | -------------------------------------------------------------------------------- /texture_profiles/assets/atlases/main.atlas: -------------------------------------------------------------------------------- 1 | images { 2 | image: "/assets/images/defold_logo_bigger.png" 3 | } 4 | margin: 0 5 | extrude_borders: 0 6 | inner_padding: 2 7 | -------------------------------------------------------------------------------- /texture_profiles/assets/images/defold_logo_bigger.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/texture_profiles/assets/images/defold_logo_bigger.png -------------------------------------------------------------------------------- /texture_profiles/assets/images/subfolder/alternative_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/texture_profiles/assets/images/subfolder/alternative_logo.png -------------------------------------------------------------------------------- /texture_profiles/custom.texture_profiles: -------------------------------------------------------------------------------- 1 | path_settings { 2 | path: "/assets/atlases/alternative*" 3 | profile: "LowRes" 4 | } 5 | path_settings { 6 | path: "**" 7 | profile: "Default" 8 | } 9 | profiles { 10 | name: "Default" 11 | platforms { 12 | os: OS_ID_GENERIC 13 | formats { 14 | format: TEXTURE_FORMAT_RGBA 15 | compression_level: BEST 16 | } 17 | mipmaps: true 18 | max_texture_size: 0 19 | } 20 | } 21 | profiles { 22 | name: "LowRes" 23 | platforms { 24 | os: OS_ID_WINDOWS 25 | formats { 26 | format: TEXTURE_FORMAT_RGBA 27 | compression_level: BEST 28 | } 29 | mipmaps: false 30 | max_texture_size: 128 31 | } 32 | platforms { 33 | os: OS_ID_GENERIC 34 | formats { 35 | format: TEXTURE_FORMAT_RGBA 36 | compression_level: BEST 37 | } 38 | mipmaps: false 39 | max_texture_size: 0 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /texture_profiles/fonts/log.font: -------------------------------------------------------------------------------- 1 | font: "/builtins/fonts/vera_mo_bd.ttf" 2 | material: "/builtins/fonts/font.material" 3 | size: 16 4 | outline_alpha: 1.0 5 | outline_width: 2.0 6 | -------------------------------------------------------------------------------- /texture_profiles/game.project: -------------------------------------------------------------------------------- 1 | [project] 2 | title = TextureProfilesExample 3 | write_log = 0 4 | dependencies = 5 | 6 | [bootstrap] 7 | main_collection = /main/main.collectionc 8 | 9 | [input] 10 | game_binding = /input/game.input_bindingc 11 | 12 | [display] 13 | width = 1280 14 | height = 720 15 | high_dpi = 1 16 | 17 | [physics] 18 | scale = 0.02 19 | 20 | [script] 21 | shared_state = 1 22 | 23 | [ios] 24 | bundle_identifier = se.svenandersson.Clean 25 | 26 | [android] 27 | package = se.svenandersson.Clean 28 | iap_provider = GooglePlay 29 | input_method = HiddenInputField 30 | manifest = 31 | 32 | [osx] 33 | bundle_identifier = se.svenandersson.Clean 34 | 35 | [tracking] 36 | app_id = 37 | 38 | [graphics] 39 | texture_profiles = /custom.texture_profiles 40 | 41 | -------------------------------------------------------------------------------- /texture_profiles/input/game.input_binding: -------------------------------------------------------------------------------- 1 | key_trigger { 2 | input: KEY_UP 3 | action: "up" 4 | } 5 | key_trigger { 6 | input: KEY_DOWN 7 | action: "down" 8 | } 9 | key_trigger { 10 | input: KEY_BACKSPACE 11 | action: "backspace" 12 | } 13 | mouse_trigger { 14 | input: MOUSE_BUTTON_1 15 | action: "touch" 16 | } 17 | text_trigger { 18 | input: TEXT 19 | action: "text" 20 | } 21 | text_trigger { 22 | input: MARKED_TEXT 23 | action: "marked_text" 24 | } 25 | -------------------------------------------------------------------------------- /texture_profiles/main/main.collection: -------------------------------------------------------------------------------- 1 | name: "parallax" 2 | scale_along_z: 0 3 | embedded_instances { 4 | id: "go" 5 | data: "embedded_components {\n" 6 | " id: \"sprite\"\n" 7 | " type: \"sprite\"\n" 8 | " data: \"tile_set: \\\"/assets/atlases/main.atlas\\\"\\n" 9 | "default_animation: \\\"defold_logo_bigger\\\"\\n" 10 | "material: \\\"/builtins/materials/sprite.material\\\"\\n" 11 | "blend_mode: BLEND_MODE_ALPHA\\n" 12 | "\"\n" 13 | " position {\n" 14 | " x: 0.0\n" 15 | " y: 0.0\n" 16 | " z: 0.0\n" 17 | " }\n" 18 | " rotation {\n" 19 | " x: 0.0\n" 20 | " y: 0.0\n" 21 | " z: 0.0\n" 22 | " w: 1.0\n" 23 | " }\n" 24 | "}\n" 25 | "embedded_components {\n" 26 | " id: \"sprite1\"\n" 27 | " type: \"sprite\"\n" 28 | " data: \"tile_set: \\\"/assets/atlases/alternative.atlas\\\"\\n" 29 | "default_animation: \\\"alternative_logo\\\"\\n" 30 | "material: \\\"/builtins/materials/sprite.material\\\"\\n" 31 | "blend_mode: BLEND_MODE_ALPHA\\n" 32 | "\"\n" 33 | " position {\n" 34 | " x: 668.85\n" 35 | " y: 0.0\n" 36 | " z: 0.0\n" 37 | " }\n" 38 | " rotation {\n" 39 | " x: 0.0\n" 40 | " y: 0.0\n" 41 | " z: 0.0\n" 42 | " w: 1.0\n" 43 | " }\n" 44 | "}\n" 45 | "" 46 | position { 47 | x: 310.632 48 | y: 303.503 49 | z: 0.0 50 | } 51 | rotation { 52 | x: 0.0 53 | y: 0.0 54 | z: 0.0 55 | w: 1.0 56 | } 57 | scale3 { 58 | x: 1.0 59 | y: 1.0 60 | z: 1.0 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /threedee/assets/atlases/main.atlas: -------------------------------------------------------------------------------- 1 | images { 2 | image: "/assets/images/defold_logo_bigger.png" 3 | } 4 | margin: 0 5 | extrude_borders: 0 6 | inner_padding: 2 7 | -------------------------------------------------------------------------------- /threedee/assets/images/chest_texture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/threedee/assets/images/chest_texture.png -------------------------------------------------------------------------------- /threedee/assets/images/defold_logo_bigger.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/britzl/defold-training_intermediate/a8b5f34fe7e617176e132413f94975fce5203d76/threedee/assets/images/defold_logo_bigger.png -------------------------------------------------------------------------------- /threedee/assets/materials/model.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec4 var_position; 2 | varying mediump vec3 var_normal; 3 | varying mediump vec2 var_texcoord0; 4 | varying mediump vec4 var_light; 5 | 6 | uniform lowp sampler2D tex0; 7 | uniform lowp vec4 tint; 8 | uniform lowp vec4 light; 9 | 10 | void main() 11 | { 12 | // Pre-multiply alpha since all runtime textures already are 13 | vec4 tint_pm = vec4(tint.xyz * tint.w, tint.w); 14 | vec4 color = texture2D(tex0, var_texcoord0.xy) * tint_pm; 15 | 16 | gl_FragColor = vec4(color.rgb,1.0); 17 | } 18 | 19 | -------------------------------------------------------------------------------- /threedee/assets/materials/model.material: -------------------------------------------------------------------------------- 1 | name: "model" 2 | tags: "model" 3 | vertex_program: "/builtins/materials/model.vp" 4 | fragment_program: "/assets/materials/model.fp" 5 | vertex_constants { 6 | name: "mtx_view" 7 | type: CONSTANT_TYPE_VIEW 8 | value { 9 | x: 0.0 10 | y: 0.0 11 | z: 0.0 12 | w: 0.0 13 | } 14 | } 15 | vertex_constants { 16 | name: "mtx_proj" 17 | type: CONSTANT_TYPE_PROJECTION 18 | value { 19 | x: 0.0 20 | y: 0.0 21 | z: 0.0 22 | w: 0.0 23 | } 24 | } 25 | vertex_constants { 26 | name: "mtx_normal" 27 | type: CONSTANT_TYPE_NORMAL 28 | value { 29 | x: 0.0 30 | y: 0.0 31 | z: 0.0 32 | w: 0.0 33 | } 34 | } 35 | fragment_constants { 36 | name: "tint" 37 | type: CONSTANT_TYPE_USER 38 | value { 39 | x: 1.0 40 | y: 1.0 41 | z: 1.0 42 | w: 1.0 43 | } 44 | } 45 | samplers { 46 | name: "tex0" 47 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 48 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 49 | filter_min: FILTER_MODE_MIN_LINEAR 50 | filter_mag: FILTER_MODE_MAG_LINEAR 51 | } 52 | -------------------------------------------------------------------------------- /threedee/assets/materials/model_world.material: -------------------------------------------------------------------------------- 1 | name: "model" 2 | tags: "model" 3 | vertex_program: "/builtins/materials/model.vp" 4 | fragment_program: "/builtins/materials/model.fp" 5 | vertex_constants { 6 | name: "mtx_worldview" 7 | type: CONSTANT_TYPE_WORLDVIEW 8 | } 9 | vertex_constants { 10 | name: "mtx_view" 11 | type: CONSTANT_TYPE_VIEW 12 | } 13 | vertex_constants { 14 | name: "mtx_proj" 15 | type: CONSTANT_TYPE_PROJECTION 16 | } 17 | vertex_constants { 18 | name: "mtx_normal" 19 | type: CONSTANT_TYPE_NORMAL 20 | } 21 | vertex_constants { 22 | name: "light" 23 | type: CONSTANT_TYPE_USER 24 | value { 25 | x: 1.0 26 | y: 1.0 27 | z: 1.0 28 | w: 1.0 29 | } 30 | } 31 | fragment_constants { 32 | name: "tint" 33 | type: CONSTANT_TYPE_USER 34 | value { 35 | x: 1.0 36 | y: 1.0 37 | z: 1.0 38 | w: 1.0 39 | } 40 | } 41 | samplers { 42 | name: "tex0" 43 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 44 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 45 | filter_min: FILTER_MODE_MIN_LINEAR 46 | filter_mag: FILTER_MODE_MAG_LINEAR 47 | } 48 | -------------------------------------------------------------------------------- /threedee/assets/meshes/cube.dae: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Blender User 6 | Blender 2.78.0 commit date:2017-02-24, commit time:14:33, hash:e92f235 7 | 8 | 2017-07-28T16:50:10 9 | 2017-07-28T16:50:10 10 | 11 | Z_UP 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -1 -1 -1 -1 -1 1 -1 1 -1 -1 1 1 1 -1 -1 1 -1 1 1 1 -1 1 1 1 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -1 0 0 0 1 0 1 0 0 0 -1 0 0 0 -1 0 0 1 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 3 3 3 3 3 3 3 3 3 3 3 3 55 |

1 0 0 2 0 1 0 0 2 3 1 3 6 1 4 2 1 5 7 2 6 4 2 7 6 2 8 5 3 9 0 3 10 4 3 11 6 4 12 0 4 13 2 4 14 3 5 15 5 5 16 7 5 17 1 0 18 3 0 19 2 0 20 3 1 21 7 1 22 6 1 23 7 2 24 5 2 25 4 2 26 5 3 27 1 3 28 0 3 29 6 4 30 4 4 31 0 4 32 3 5 33 1 5 34 5 5 35

56 |
57 |
58 |
59 |
60 | 61 | 62 | 63 | 64 | 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 |
-------------------------------------------------------------------------------- /threedee/assets/meshes/test.animationset: -------------------------------------------------------------------------------- 1 | animations { 2 | animation: "/assets/meshes/chest_anim_open.dae" 3 | } 4 | animations { 5 | animation: "/assets/meshes/chest_model.dae" 6 | } 7 | animations { 8 | animation: "/assets/meshes/chest_anim_open_03.dae" 9 | } 10 | -------------------------------------------------------------------------------- /threedee/assets/models/chest.model: -------------------------------------------------------------------------------- 1 | mesh: "/assets/meshes/chest_model.dae" 2 | skeleton: "/assets/meshes/chest_anim_open_03.dae" 3 | animations: "/assets/meshes/test.animationset" 4 | default_animation: "chest_anim_open_03" 5 | name: "unnamed" 6 | materials { 7 | name: "default" 8 | material: "/assets/materials/model_world.material" 9 | textures { 10 | sampler: "tex0" 11 | texture: "/assets/images/chest_texture.png" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /threedee/assets/models/cube.model: -------------------------------------------------------------------------------- 1 | mesh: "/assets/meshes/cube.dae" 2 | name: "unnamed" 3 | materials { 4 | name: "default" 5 | material: "/assets/materials/model_world.material" 6 | textures { 7 | sampler: "tex0" 8 | texture: "/assets/images/defold_logo_bigger.png" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /threedee/fonts/log.font: -------------------------------------------------------------------------------- 1 | font: "/builtins/fonts/vera_mo_bd.ttf" 2 | material: "/builtins/fonts/font.material" 3 | size: 16 4 | outline_alpha: 1.0 5 | outline_width: 2.0 6 | -------------------------------------------------------------------------------- /threedee/game.project: -------------------------------------------------------------------------------- 1 | [project] 2 | title = ThreeDeeExample 3 | write_log = 0 4 | 5 | [bootstrap] 6 | main_collection = /main/main.collectionc 7 | render = /render/custom.renderc 8 | 9 | [input] 10 | game_binding = /input/game.input_bindingc 11 | 12 | [display] 13 | width = 1280 14 | height = 720 15 | high_dpi = 1 16 | 17 | [physics] 18 | scale = 0.02 19 | 20 | [script] 21 | shared_state = 1 22 | 23 | [ios] 24 | bundle_identifier = se.svenandersson.Clean 25 | 26 | [android] 27 | package = se.svenandersson.Clean 28 | iap_provider = GooglePlay 29 | input_method = HiddenInputField 30 | manifest = 31 | 32 | [osx] 33 | bundle_identifier = se.svenandersson.Clean 34 | 35 | [tracking] 36 | app_id = 37 | 38 | -------------------------------------------------------------------------------- /threedee/input/game.input_binding: -------------------------------------------------------------------------------- 1 | key_trigger { 2 | input: KEY_UP 3 | action: "up" 4 | } 5 | key_trigger { 6 | input: KEY_DOWN 7 | action: "down" 8 | } 9 | key_trigger { 10 | input: KEY_BACKSPACE 11 | action: "backspace" 12 | } 13 | mouse_trigger { 14 | input: MOUSE_BUTTON_1 15 | action: "touch" 16 | } 17 | text_trigger { 18 | input: TEXT 19 | action: "text" 20 | } 21 | text_trigger { 22 | input: MARKED_TEXT 23 | action: "marked_text" 24 | } 25 | -------------------------------------------------------------------------------- /threedee/main/camera.script: -------------------------------------------------------------------------------- 1 | function init(self) 2 | self.a = 0.0 3 | self.b = 0.0 4 | self.a_amp = 0.01 5 | self.b_amp = -0.01 6 | send_camera_state(self) 7 | 8 | msg.post(".", "acquire_input_focus") 9 | end 10 | 11 | function send_camera_state(self) 12 | msg.post("@render:", "camera_state", { a = self.a, b = self.b }) 13 | end 14 | 15 | function update(self, dt) 16 | send_camera_state(self) 17 | end 18 | 19 | function on_input(self, action_id, action) 20 | if action_id == hash("touch") then 21 | self.a = self.a + action.dx * self.a_amp 22 | self.b = self.b + action.dy * self.b_amp 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /threedee/main/main.collection: -------------------------------------------------------------------------------- 1 | name: "parallax" 2 | scale_along_z: 0 3 | embedded_instances { 4 | id: "go" 5 | data: "components {\n" 6 | " id: \"cube\"\n" 7 | " component: \"/assets/models/cube.model\"\n" 8 | "}\n" 9 | "components {\n" 10 | " id: \"camera\"\n" 11 | " component: \"/main/camera.script\"\n" 12 | "}\n" 13 | "" 14 | position { 15 | y: -1.0 16 | } 17 | } 18 | embedded_instances { 19 | id: "chest" 20 | data: "components {\n" 21 | " id: \"chest\"\n" 22 | " component: \"/assets/models/chest.model\"\n" 23 | "}\n" 24 | "" 25 | } 26 | -------------------------------------------------------------------------------- /threedee/render/custom.render: -------------------------------------------------------------------------------- 1 | script: "/render/custom.render_script" 2 | -------------------------------------------------------------------------------- /threedee/render/custom.render_script: -------------------------------------------------------------------------------- 1 | function init(self) 2 | self.tile_pred = render.predicate({"tile"}) 3 | self.gui_pred = render.predicate({"gui"}) 4 | self.text_pred = render.predicate({"text"}) 5 | self.particle_pred = render.predicate({"particle"}) 6 | self.model_pred = render.predicate({"model"}) 7 | 8 | self.clear_color = vmath.vector4(0.3, 0.3, 0.3, 0) 9 | 10 | self.camera_a = 0.0 11 | self.camera_b = 0.0 12 | self.camera_dist = 10.0 13 | 14 | self.view = vmath.matrix4() 15 | end 16 | 17 | function update(self) 18 | render.set_depth_mask(true) 19 | render.set_stencil_mask(0xff) 20 | render.clear({[render.BUFFER_COLOR_BIT] = self.clear_color, [render.BUFFER_DEPTH_BIT] = 1, [render.BUFFER_STENCIL_BIT] = 0}) 21 | 22 | render.set_viewport(0, 0, render.get_window_width(), render.get_window_height()) 23 | render.set_view(self.view) 24 | 25 | render.set_depth_mask(false) 26 | render.disable_state(render.STATE_DEPTH_TEST) 27 | render.disable_state(render.STATE_STENCIL_TEST) 28 | render.enable_state(render.STATE_BLEND) 29 | render.set_blend_func(render.BLEND_SRC_ALPHA, render.BLEND_ONE_MINUS_SRC_ALPHA) 30 | render.disable_state(render.STATE_CULL_FACE) 31 | 32 | render.set_projection(vmath.matrix4_orthographic(0, render.get_width(), 0, render.get_height(), -1, 1)) 33 | 34 | render.draw(self.tile_pred) 35 | render.draw(self.particle_pred) 36 | render.draw_debug3d() 37 | 38 | ---------------------------------------- 39 | -- Render 3D models 40 | -- calc camera rotation etc 41 | --local offset = math.sin(self.camera_b) * self.camera_dist 42 | --render.set_view(vmath.matrix4_look_at(vmath.vector3(math.cos(self.camera_a)*offset,offset,math.sin(self.camera_a)*offset), vmath.vector3(0,0,0), vmath.vector3(0,1,0))) 43 | local offset = math.cos(self.camera_b) 44 | render.set_view(vmath.matrix4_look_at(vmath.vector3(math.cos(self.camera_a)*self.camera_dist*offset, math.sin(self.camera_b)*self.camera_dist, math.sin(self.camera_a)*self.camera_dist*offset), vmath.vector3(0, 0, 0), vmath.vector3(0, 1, 0))) 45 | render.set_projection(vmath.matrix4_perspective(45 * (math.pi / 180), render.get_window_width() / render.get_window_height(), 0.1, 100.0)) 46 | 47 | render.set_depth_mask(true) 48 | render.enable_state(render.STATE_DEPTH_TEST) 49 | render.draw(self.model_pred) 50 | render.disable_state(render.STATE_DEPTH_TEST) 51 | ---------------------------------------- 52 | 53 | render.set_view(vmath.matrix4()) 54 | render.set_projection(vmath.matrix4_orthographic(0, render.get_window_width(), 0, render.get_window_height(), -1, 1)) 55 | 56 | render.enable_state(render.STATE_STENCIL_TEST) 57 | render.draw(self.gui_pred) 58 | render.draw(self.text_pred) 59 | render.disable_state(render.STATE_STENCIL_TEST) 60 | 61 | render.set_depth_mask(false) 62 | render.draw_debug3d() 63 | end 64 | 65 | function on_message(self, message_id, message) 66 | if message_id == hash("clear_color") then 67 | self.clear_color = message.color 68 | elseif message_id == hash("set_view_projection") then 69 | self.view = message.view 70 | elseif message_id == hash("camera_state") then 71 | self.camera_a = message.a 72 | self.camera_b = message.b 73 | end 74 | end 75 | --------------------------------------------------------------------------------