My first game with Defold : Gold Rush

#1

Here is my first personal game with Defold:
Gold Rush

It is based upon the side scroller tutorial. I tried to redo everything myself with free assets. It’s a little rough and many things need to be polished. The difficulty is quite challenging.
I still haven’t looked at a way to reload the game when game over occurs nor have I put any message or title screen. This will be the next challenge for me.

Should I put the game on the assets portal or should I wait for a more polished version to publish it there?

14 Likes

#2

Nicely done!
I think there’s an issue when dying, it plays the death sound/fx twice?

The asset portal contains games at various polished stages, so feel free to add your own if you want!

5 Likes

#3

Yes, you’re right. I noticed it too and I have to look for the bug.^^
Thanks for playing. :slight_smile:

0 Likes

#4

Seems like I needed to disable the collision shape to prevent the sound to play twice.

0 Likes

#5

Nice! Love the graphics! Have you considered applying a fixed zoom for lovely chunky retro pixels?

4 Likes

#6

Haha, wow, I thought there was something wrong with my browser. So tiny!

Reloading is pretty simple. If you put your game stuff into a collection other than “main”, then hook it up to your main collection with a Collection Proxy, then you can unload and reload it whenever you want. The simplest way is to just let people press “R” (or something) to reload. (so you don’t have to make a menu or whatnot.)

1 Like

#7

@britzl: Yes, I will do that soon. Original size is 160*144 so, how much zoom should I use? The graphics are from Grafxkid. I liked his style so I based the game upon some of his graphics.

@ross.grams: Yes I thought that Collection Proxies would do the trick but I need to study a little more to add a title screen too. I’m currently working on that.

0 Likes

#8

Maybe 3 or 4 times?

1 Like

#9

To enable resizing, I tried this but it didn’t worked:

msg.post("@render:", "use_fixed_fit_projection", { near = -1, far = 1, zoom = 3 })

By using fixed_fit_projection, I wanted to prevent stretching. and since it could show beyond border of the screen (where I spawn objects), I decided to add a black tilemap as a frame mask to the screen.

mask_screenshot

It seems that zoom is not a valid data for fixed_fit_projection.

0 Likes

#10

Correct. Fixed fit projection will maintain aspect ratio and scale the game to fit the window.

What you want is the Fixed projection where you can specify your own zoom. The window will maintain aspect ratio and always keep the content zoomed to the level you specify.

4 Likes

#11

Cool :sunglasses: Really enjoyed playing it!!!

1 Like

#12

I think that after dying you can still hit the next bomb or whats that, thats why it plays twice

1 Like

#13

Exactly! I disabled the collision shape and it no longer hits twice. I stille have some tweaks to do so I won’t update the released game until I’m done. Do you think it’s a bad move?

1 Like

#14

Not at all, I don’t see the sound a big issue

1 Like

#15

I updated the game with some new things. Clouds, title and exploding bombs. Very simple stuff but I think it helps to better enjoy the game. I still haven’t found how to restart the game. I tried unloading the collection proxy when pressing escape but my code doesn’t work.

2 Likes

#16

Restarting the game is simple. All you need is just another collection. I generally like to call it controller.

Change the name of the collection to controller too. Then go to game.project and set the default collection as the controller

In the controller collection, add a game object called proxies, and add a collection proxy called main. Assign the main collection to its target.
Next, create a script called controller.
In the init function, ask the collection proxy to load the proxies#main collection proxy, which we created above. This will load the main collection on start up.
Then, in the on_message function, say that

if message_id == hash("reload_scene") then --never put reload here , it will cause an error.
load()  --call a function load 
end 

Then finally in the load function, unload the currently loaded main collection…(pause)…and then load it again, as we did in the init function.
And then, when you want to reload the scene, just say.

msg.post("controller:/controller#controller", "reload_scene") 

This will reload your scene.
You can see the code for loading and unloading scenes from the manual.

Ask if you get stuck somewhere. I could have sent done code too , but I am away from my computer atm. :frowning:

Hope it helps. :slight_smile:

3 Likes

#17

Thanks.
Actually, I already did something like that. I have a main collection with a game object called loader holding the different collections (actually, scenes or screens) proxies.
I then use this script based upon documentation about proxies:

function init(self)
	self.current_screen = "title"
	msg.post("#" .. self.current_screen .. "_proxy", "load")
end

function on_message(self, message_id, message, sender)
	if message_id == hash("proxy_loaded") then
		-- New world is loaded. Init and enable it.
		msg.post(sender, "init")
		msg.post(sender, "enable")
	end
	if message_id == hash("switch_to_game") then
		msg.post("#" .. self.current_screen .. "_proxy", "disable")
		msg.post("#" .. self.current_screen .. "_proxy", "final")
		msg.post("#" .. self.current_screen .. "_proxy", "unload")
		self.current_screen = "game"
		msg.post("#" .. self.current_screen .. "_proxy", "load")
	end
end

As you can see, there are (for now) two proxies. One called “title_proxy” that loads at startup of the game and one called “game_proxy” that loads when the message “switch_to_game” is received. This is sent from the “title” collection when the player pushes an input.

I tried this on “on_input” function but it didn’t worked:

function on_input(self, action_id, action)
	if action_id == hash("escape") then
		msg.post("#" .. self.current_screen .. "_proxy", "disable")
		msg.post("#" .. self.current_screen .. "_proxy", "final")
		msg.post("#" .. self.current_screen .. "_proxy", "unload")
		self.current_screen = "game"
		msg.post("#" .. self.current_screen .. "_proxy", "load")
	end
end

The problem comes from the fact that the key press sends a message each frame. It seems to hinder the loading of the collection.

0 Likes

#18

Add action.pressed or action.released in the in input function.

1 Like