Writing a book on Defold

Off-topic but I’d like to comment anyway. Rotation using quaternions is almost a de-facto standard in game engines. Defold also provides support for euler angles, but you should try to get to terms with quaternions.

There’s a go.set_rotation():

-- rotate 45 degrees around the z-axis
go.set_rotation(vmath.quat_rotation_z(math.rad(45))

There’s also go.set(".", "euler.z") and go.animate(".", "rotation.z", ...)

Not quite. It relies on hashed strings. There’s a difference (performance mainly). If you’re worried about typos and refactoring you can store all hashed message ids in a Lua module. Change in a single place instead of all over. And until we’re adding static code analysis to our internal editor you can use Atom with a Lua linter to get a warning if you’re mistyping a message id reference when you have them stored in a module.

1 Like

Okay first of all - that was a fast reply. I’m officialy impressed.

With rotate() I mean: rotate x degree / rad from your current rotation. So rotate() is not the same as set_rotation() (which I’m aware of). For the very simple act of rotating a thing from its current rotation the following code is needed:

go.set_rotation(go.get_rotation() * vmath.quat_rotation_z(x_rad))

Which seems ridiculous to me. What I’d like to see is:

go.rotate(x_rad)

Done. That’s the way it’s handled in the Godot game engine.

I couldn’t get rotation using the euler propertie to work for rotations > 90 degree. The game object seemed to get stuck at this value.

Regarding the messaging system - it’s fine for most things, but why isn’t there a method acquire_input_focus()? From a user perspective it just seems so much easier.

But I’ll keep using the engine for the next week or so and see if I can get used to it because I really want this relationship to work out :grinning:

Yes, that’s more cumbersome for sure. I’m not going to deny that. Even though it might be a candidate for an engine provided function there really is nothing stopping you from adding these kind of utility functions in a Lua module.

I agree. I don’t know why really. I usually use this Lua module when I need to deal with user input in Defold:

https://github.com/britzl/ludobits/blob/master/ludobits/m/input.lua

I’ve been on contract work most of this year but have less obligations now. Editor 2 seems close to release so it’s a good time to put the time in. Glad @britzl could help you!

4 Likes

what happened to this?

1 Like

Gitbook changed their site to a new version with entirely different features, I’m moving the old text over and also updating it as I go, adding screenshots of new editor, redoing some examples. It is tedious and time consuming and I don’t have a ton of free time right now for how much time it needs so progress is slow.

There’s a lot which has not been seen before like https://www.bookofdefold.com/dive-into-defold/avoider/ but it will all get published eventually…

5 Likes

I see,

I’m slacking off with my self learning of Defold , I think your book could be really good for someone who does not want to be distracted by the Internet(such as me unfortunately).

I’m looking forward for this , thanks for the reply

2 Likes

Yes! Books are great. I spend so much time helping students who would prefer a book, but have been obliged to do online courses.

(Although I think it’s actually an online book)

2 Likes

@Pkeod I saw some cool shader effects in this thread like the blur or the sine wave distortion shaders. However, I cannot manage to find the sections about those concepts inside your book. I can’t find projects in the github repo of the book either. Could you give me link to those so I could take a look at your code ?

There are some blur examples here https://github.com/subsoap/deffx/tree/master/deffx/materials/rendertarget

Here is another blur shader made by someone else https://www.defold.com/community/projects/125545/

There are more materials here

FXAA Render Target example + FXAA

Keep in mind with all things material if things don’t work right check the builtin materials for breaking changes that are possible when using other stuff a few years old.

I still have work and plans left for the book and stuff beyond it but I’m focusing on gamedev right now. Will probably focus on this again after the next game is done later this year!

4 Likes