“Mike Dangers” HTML5 engine now is also available for King’s Defold engine

Read all posts about "" game
You surely know King, one of the leading companies when we talk about casual gaming. You may not know King owns a 2D cross platform game engine called Defold, it was used to create games like King’s Blossom Blast Saga and TouchArcade game of the week Hero Slide – you can find a tutorial series at this link – and it’s free to use. It may seem out of the ordinary, that a commercial game company releases its core technology for free, they think the more people who use Defold, the better the engine will be. By releasing Defold to the community, everyone can help making Defold better, by creating tutorials, by finding bugs, improving the documentation, and much more. I have to say, I agree with them. While at the moment I am leaving to you the task to explore Defold engine and its Lua language, I want to show you Björn Ritzl‘s port of Mike Dangers game using Defold, playable at this link. The source code is also intuitive and should help you to start with Defold engine:
go.property(“gravity”, vmath.vector3(0, -4500, 0)) go.property(“ground_speed”, 450) go.property(“jump_speed”, 900) — distance between the platforms local PLATFORM_SPACING = 250 function init(self) msg.post(“.”, “acquire_input_focus”) self.velocity = vmath.vector3(self.ground_speed, 0, 0) — the platforms each consist of a ground and ladder game object — they are defined in game.collection — the game object ids are sequentially named ground1, ladder1, …, ground6, ladder6 — the list will be kept ordered so that the first element will represent the platform — at the bottom of the screen while the last element represents the platform at — the top of the screen self.platforms = { 1, 2, 3, 4, 5, 6 } for i,id in ipairs(self.platforms) do go.set_position(vmath.vector3(400, PLATFORM_SPACING * i, 0), “ground” .. id) end end function update(self, dt) msg.post(“@render:/”, “clear_color”, { color = vmath.vector4(0xaa / 0xff, 0xeea / 0xff, 1.0, 1.0) }) — ignore any movement logic while the player is climbing a ladder if self.climbing then return end — add gravity to the hero velocity self.velocity = self.velocity + self.gravity * dt — move the player — if the player has moved outside the left or right edge of the — the screen the horizontal component of the velocity is reversed — also flip the hero sprite local pos = go.get_position() pos = pos + self.velocity * dt if pos.x > 800 then pos.x = 800 self.velocity.x = -self.velocity.x sprite.set_hflip(“#sprite”, true) elseif pos.x < 0 then pos.x = 0 self.velocity.x = -self.velocity.x sprite.set_hflip("#sprite", false) end go.set_position(pos) -- reset volatile state self.can_jump = false end function on_message(self, message_id, message, sender) if message_id == hash("contact_point_response") then if message.group == hash("ground") and not self.climbing then -- resolve the collision by moving the hero out of the collision object -- also reset the vertical component of the velocity go.set_position(go.get_position() + message.normal * message.distance) self.velocity.y = 0 self.can_jump = true elseif message.group == hash("ladder") and not self.climbing then self.velocity.y = 0 self.climbing = true for i,id in ipairs(self.platforms) do -- fade out the bottom most ground and ladder if i == 1 then go.animate("ground" .. id .. "#sprite", "tint.w", go.PLAYBACK_ONCE_FORWARD, 0, go.EASING_OUTCUBIC, 0.3) go.animate("ladder" .. id .. "#sprite", "tint.w", go.PLAYBACK_ONCE_FORWARD, 0, go.EASING_OUTCUBIC, 0.3) end -- animate the platform downwards -- if the platform was animated outside of the view it will -- be moved to the top go.animate("ground" .. id, "position.y", go.PLAYBACK_ONCE_FORWARD, go.get_position("ground" .. id).y - PLATFORM_SPACING, go.EASING_LINEAR, 0.3, 0, function() self.climbing = false -- if this was the first (ie bottom-most platform) we need to -- move it to the top of the platforms -- we also move it to the end of the list of platforms to -- keep the order intact -- and finally we also reset the alpha value (we faded it) if i == 1 then go.set("ground" .. id .. "#sprite", "tint.w", 1.0) go.set("ladder" .. id .. "#sprite", "tint.w", 1.0) table.insert(self.platforms, table.remove(self.platforms, i)) local pos = go.get_position("ground" .. id) pos.y = pos.y + #self.platforms * PLATFORM_SPACING go.set_position(pos, "ground" .. id) end end) end end end end function on_input(self, action_id, action) if action_id == hash("touch") or action_id == hash("jump") then if action.pressed and self.can_jump then self.velocity.y = self.jump_speed end end end
The full source code is also available at this link. I suggest to have a look at Björn’s GitHub page as it’s full of interesting examples. I will also try to publish some tutorials about Defold.

Get the most popular Phaser 3 book

Through 202 pages, 32 source code examples and an Android Studio project you will learn how to build cross platform HTML5 games and create a complete game along the way.

Get the book

215 GAME PROTOTYPES EXPLAINED WITH SOURCE CODE
// 1+2=3
// 100 rounds
// 10000000
// 2 Cars
// 2048
// A Blocky Christmas
// A Jumping Block
// A Life of Logic
// Angry Birds
// Angry Birds Space
// Artillery
// Astro-PANIC!
// Avoider
// Back to Square One
// Ball Game
// Ball vs Ball
// Ball: Revamped
// Balloon Invasion
// BallPusher
// Ballz
// Bar Balance
// Bejeweled
// Biggification
// Block it
// Blockage
// Bloons
// Boids
// Bombuzal
// Boom Dots
// Bouncing Ball
// Bouncing Ball 2
// Bouncy Light
// BoxHead
// Breakout
// Bricks
// Bubble Chaos
// Bubbles 2
// Card Game
// Castle Ramble
// Chronotron
// Circle Chain
// Circle Path
// Circle Race
// Circular endless runner
// Cirplosion
// CLOCKS - The Game
// Color Hit
// Color Jump
// ColorFill
// Columns
// Concentration
// Crossy Road
// Crush the Castle
// Cube Jump
// CubesOut
// Dash N Blast
// Dashy Panda
// Deflection
// Diamond Digger Saga
// Don't touch the spikes
// Dots
// Down The Mountain
// Drag and Match
// Draw Game
// Drop Wizard
// DROP'd
// Dudeski
// Dungeon Raid
// Educational Game
// Elasticity
// Endless Runner
// Erase Box
// Eskiv
// Farm Heroes Saga
// Filler
// Flappy Bird
// Fling
// Flipping Legend
// Floaty Light
// Fuse Ballz
// GearTaker
// Gem Sweeper
// Globe
// Goat Rider
// Gold Miner
// Grindstone
// GuessNext
// Helicopter
// Hero Emblems
// Hero Slide
// Hexagonal Tiles
// HookPod
// Hop Hop Hop Underwater
// Horizontal Endless Runner
// Hundreds
// Hungry Hero
// Hurry it's Christmas
// InkTd
// Iromeku
// Jet Set Willy
// Jigsaw Game
// Knife Hit
// Knightfall
// Legends of Runeterra
// Lep's World
// Line Rider
// Lumines
// Magick
// MagOrMin
// Mass Attack
// Math Game
// Maze
// Meeblings
// Memdot
// Metro Siberia Underground
// Mike Dangers
// Mikey Hooks
// Nano War
// Nodes
// o:anquan
// One Button Game
// One Tap RPG
// Ononmin
// Pacco
// Perfect Square!
// Perfectionism
// Phyballs
// Pixel Purge
// PixelField
// Planet Revenge
// Plants Vs Zombies
// Platform
// Platform game
// Plus+Plus
// Pocket Snap
// Poker
// Pool
// Pop the Lock
// Pop to Save
// Poux
// Pudi
// Pumpkin Story
// Puppet Bird
// Pyramids of Ra
// qomp
// Quick Switch
// Racing
// Radical
// Rebuild Chile
// Renju
// Rise Above
// Risky Road
// Roguelike
// Roly Poly
// Run Around
// Rush Hour
// SameGame
// SamePhysics
// Save the Totem
// Security
// Serious Scramblers
// Shrink it
// Sling
// Slingy
// Snowflakes
// Sokoban
// Space Checkers
// Space is Key
// Spellfall
// Spinny Gun
// Splitter
// Spring Ninja
// Sproing
// Stabilize!
// Stack
// Stairs
// Stick Hero
// String Avoider
// Stringy
// Sudoku
// Super Mario Bros
// Surfingers
// Survival Horror
// Talesworth Adventure
// Tetris
// The Impossible Line
// The Moops - Combos of Joy
// The Next Arrow
// Threes
// Tic Tac Toe
// Timberman
// Tiny Wings
// Tipsy Tower
// Toony
// Totem Destroyer
// Tower Defense
// Trick Shot
// Tunnelball
// Turn
// Turnellio
// TwinSpin
// vvvvvv
// Warp Shift
// Way of an Idea
// Whack a Creep
// Wheel of Fortune
// Where's my Water
// Wish Upon a Star
// Word Game
// Wordle
// Worms
// Yanga
// Yeah Bunny
// Zhed
// zNumbers