Tinkering with Defold: public repo (just building - not sure what yet!)

I was once building publicly and it seemed to be popular. I axed that project, but I decided to build publicly again. I’m not sure what I’ll make yet and I don’t have as much time as I did before, but if and when I update the project, you’ll see the progression here:


The only thing I’ve done so far is create a simple 8-direction movement system for the player.

I’m tracking input like this:

function on_input(self, action_id, action)
	if action_id == hash("right") then
		self.input.x = 1
	elseif action_id == hash("left") then
		self.input.x = -1

	if action_id == hash("up") then
		self.input.y = 1
	elseif action_id == hash("down") then
		self.input.y = -1

I also added a dash mechanic to the input that has a cooldown attached. It looks like this:

if action_id == hash("spacebar") and action.released then
	if self.total_dashes > 0 then
		self.total_dashes = self.total_dashes - 1
		self.dashing = true
		msg.post("/guis", "show_dashes", { dashes = self.total_dashes } )
		print("out of dashes")

The update function takes the inputs and updates the player accordingly.

function update(self, dt)
	local pos = go.get_position()
	if vmath.length(self.input) > 1 then
		self.input = vmath.normalize(self.input)

	if self.dashing then
		go.animate(".", "position", go.PLAYBACK_ONCE_FORWARD, pos + self.input * 250, go.EASING_LINEAR, .2, 0, function()
			timer.delay(self.dash_cooldown, false, function()
				self.total_dashes = self.total_dashes + 1
				msg.post("/guis", "show_dashes", { dashes = self.total_dashes } )
		self.dashing = false

	pos = pos + self.input * self.speed * dt
	self.input = vmath.vector3()

And finally, there’s an indicator on the UI that shows how many dashes are available. I am using messages instead of a module because it was faster to set up that way. This is just a project for tinkering around and building fast!

Some ideas of things to do next:

  • Use a particle effect to add a trail when dashing
  • Generate items for the player to pickup (coins, xp, powerups?)
  • Add a camera and have it follow the player

A few small changes. Still not sure what I’ll build, but I figure it will have a pickup. So, I added a pickup.

Ended up adding more:

  • Sounds on pickup
  • Tile background (made by myself)
  • Camera that follows the player.
1 Like

Sitting here thinking about what to add next. It’s still in the very early stages, but I believe this is the best time to add a mechanic that’s:

  • Fun
  • Simple
  • Satisfying (even after doing it 100s of times)

Some examples of a mechanic that meets the above criteria include dragging to launch (Angry Birds) or swarms of enemies and getting insanely powerful (Vampire Survivors). I’m looking up popular hyper casual games for ideas.

Will dwell on this today and maybe over the next several days.

1 Like

Great to see your journey! Keep on going! :wink:

1 Like

A little update. I had an idea for a collapsing ground mechanic. The basic idea is the player has to continuously move from point a to b.

I set up this mechanic by using tilemap.get_tile() to track the player’s position and timer.delay() to animate the tile. Here’s how the code looks currently:

local TILESIZE = 64

local function get_player_tile(pos)
    return vmath.vector3(math.floor((pos.x + TILESIZE) / TILESIZE), math.floor((pos.y + TILESIZE) / TILESIZE), pos.z)

function update(self, dt)
	local pos = go.get_position()
	local ptile = get_player_tile(pos)
	local tile = tilemap.get_tile("/background#background", "ground", ptile.x, ptile.y)
	if tile == 1 then
		local ground = 1
		timer.delay(0.5, true, function(self, ground_gone, time_elapsed)
			tilemap.set_tile("/background#background", "ground", ptile.x, ptile.y, ground + 1)
			ground = ground + 1
			if ground == 5 then
	elseif tile == 4 or tile == 5 then
		msg.post(".", "release_input_focus")
		go.animate(".", "scale", go.PLAYBACK_ONCE_FORWARD, .01, go.EASING_LINEAR, .5)
		go.animate(".", "euler.z", go.PLAYBACK_LOOP_FORWARD, 360, go.EASING_LINEAR, .5)

Here’s how it looks.

A little scaling and swirling was added for a falling effect.


Some more possible ideas:

  • Have stable and unstable floors
  • Add dangerous objects and physics
  • Add keys/switches that the player must move to before the exit

With the last option, this could end up being a puzzle-like game where the player has to plan the best route to collect the objects and exit the room. The dash adds an interesting element to this.

Need to implement the most-basic version of this to see how it feels.

1 Like

This is my first update as of 6 days ago. I had some time this weekend and I made some minor changes — removing tile interaction when the player is dashing and new stable tiles. This was a fast update (~20 minutes). I hope to have more time in the future for programming, but I have to prioritize work and real life.

1 Like

I added acceleration to the player game object. Now it feels more like a ball rolling around the board. I was experimenting with the sounds to try and get a feel for the ball rolling, but I kept running into a problem where the sound would play nonstop instead of when pressing/releasing.

I’m sure I could figure out how to get it how I want, but I ran out of time today. I’ll likely use something like gated sounds. The goal with adding the sound is to get a feel for the game and use that feeling to help me decide what to add next.