New Defold course: Make a Fully-Fledged 2D Action RPG in Defold

Hi all! we’ve published a new Defold course at Zenva: Make a Fully-Fledged 2D Action RPG in Defold.

This new course builds on the previous Defold courses in the series (all of which have just been updated).

9 Likes

Cool! Thank you for creating great learning materials for the Defold community! I noticed that you also have a Block Breaker tutorial:

This is also new right?

3 Likes

The course is not bad overall and is perfect for beginners. However, the approach using world coordinates used in the course will not work when the window size is changed. Everything will break.

2 Likes

@Pablo_Farias this might be worth looking into!

Thanks @Alexander_Bulatov for this feedback, I’ll speak with Daniel and we’ll test the game when the screen is resized and modify the course if needed. As a non-Defold developer, I’m not sure why taking screen coordinates and transforming them to world coordinates is not the recommended approach (as it sounds intuitive as how it’s done in other engines I’ve used), could you elaborate on what we did wrong or what was the correct way of implementing it?

@britzl that is correct we just released that second course (I didn’t know it’d be out so soon hence not included in the PR, but will add it to a new one)

3 Likes

I didn’t look into it very deeply, so I can’t say off the top of my head how to solve this problem, but here’s an example: if you get the size from the render script using:

render.get_window_width()

render.get_window_height()

the character shoots correctly, but sometimes glitches, which is most likely related to camera interpolation, and the GUI nodes are not bound correctly. Perhaps it is possible to do this without render.script.

And you also need to check the player’s input, otherwise there will be an error.
Like this:
if action.x then
self.mouse_pos.x = action.x
self.mouse_pos.y = action.y
end

@Pablo_Farias send me an email with the course materials and I’ll take a look and provide some recommendations!

2 Likes

I’m new to Defold and I was trying this course out and I’ve run into this problem. When I add the

self.mouse_pos.x = action.screen_x
self.mouse_pos.y = action.screen_y

under on_input, I get this error:
ERROR:SCRIPT: game/player/player.script:59: bad argument #3 to ‘__newindex’ (number expected, got nil)
stack traceback:
[C]:- 1: in function __newindex
game/player/player.script:59: in function <game/player/player.script:57>

The rest works fine when I comment that line out. I don’t know what I’m doing wrong, and any help would be appreciated. It’s an otherwise very good course, very well explained and beginner friendly.
I’m using Defold 1.10.2 on Linux Mint, if that helps.

Huh, I just tried this on a previous beta version of Defold, 1.10.0 and the code works just fine!

The action was cleaned up in 1.10.1. You should check if action.screen_x and action.screen_y are available.

I was using action.screen_x and action.screen_y when I got the error. Using action.x and action.y also threw the exact same error message.

You should verify that the action_id is the one you want, as it dictates what members are available in the action table.

1 Like

as I wrote above, you need to check before setting the mouse position.

1 Like

For some reason, most game engines have game and world coordinate systems at war.

I’m reworking now my stuff (because I learned new stuff on variables), but if that can be of use, look at how I had to code the relation between the two :slight_smile:
https://github.com/Vampiloup/syzygie/blob/main/Normal/Scripts/camera.script
and
https://github.com/Vampiloup/syzygie/blob/main/Normal/Scripts/curseur.script

The game is a Space conquest game.

  • The “galaxy” can be bigger or smaller than the screen.
  • I have can move the “galaxie” with mouse middle button + moving mouse.
  • I can zoom the “galaxy” with middle button rolls
  • There is “borders” the moving of cursors has to respect.
  • Objects (“stars”) on the “galaxy” can be clicked by the mouse. Meaning I had to add a sprite to the cursor, and the two don’t use the same coordinate system.
  • When I click on an object, a GUI panel open with stats of the clicked object.

Now look at what I had to do.

Worst thing : In Godot, it wasn’t even possible. Making game and world move without losing coordinates is hard enough, but when you add zoom, it’s just pain.

2 Likes

Thanks everyone for the feedback!

@britzl we’ve edited the video and the code with self.mouse_x_pos = action.screen_x so that is sorted.

I can see we might need to add a check for the action to be available, it is my understanding the code works in 1.10.1, but I’ll double check with Daniel. We’ll make further changes if needed in order to be fully compliant with the best practices of Defold.

@britzl we’ll look into this action check issue, and then email you the code, much appreciated!!

1 Like

Ok we’ve updated both courses source code for 1.10.2 with checks for action presence.

We still have to update the videos but that should be done in a few hours.

@britzl I’ve emailed you the updated code of both courses. We should have done that earlier and will make sure to do it next time around before recording :sweat_smile:

These two course will remain in 1.10.2 for a few months, so it’s important people use the exact version specified in the course requirements (which we are also yet to finish updating)…

Thanks everyone for the feedback and patience!!

3 Likes

updated version, run from editor, fullcsreen:

html5 version:

Oh no.. I’ve sent the feedback to the author, he might not be able to review it until tomorrow

In our tests this doesn’t happen unless you drag a running exported game into another monitor. Is that how you came across that issue?

No, I just went full screen and moved the character.

1 Like