Asteroids prototype

Just want to fill in on the topics above:

Hashes are used instead of string because strings are really bad when it comes to comparison and lookup (this is a general thing for all languages. Avoid strings as much as possible). It’s all about performance really. If you want to improve performance even more it’s a good practise to store hashes in a local variable and use the variable in the comparison condition instead.

I guess the reason why “tint” is not in the sprite API would probably be because it is a part of the shader. As you can create your own shaders and use/name the properties differently it isn’t really a constant thing and shouldn’t be a part of that API.

2 Likes

@andreas.strangequest Thank you. Now I understand the reason behind hashes. They still are a mystery though. I don’t really get what they actually are.
For the tint property, I understood what you wrote but then it leads to other questions. How a shader property is accessible from a sprite component? And wouldn’t it be useful to add an API section for that default shader for everyone to better use it? Basically, a sprite doesn’t have an alpha value. Wouldn’t it be simpler to give it that kind of property? I mean, ok Defold is highly customizable for the experts but not everyone is a master of shaders or rendering. No wonder there is not that many people using Defold. It scares the hell out of beginners. Standard configuration files is a step toward helping beginners learning Defold in a safe environment but there should have full documentation of properties they can access.

My advice is that you don’t worry about the hash thing. It’s really not important to know how the code works (… but it is useful to learn about the engine, platform, etc).

@flashjaysan
Sprites do have transparency. try go.set("#sprite", “tint.w”, 0) to make a sprite transparent. And by the way, this is actually included as one of the examples in the documentation. Look here: sprite section of defold manual .

The fact is that game development is complicated. There is a lot to learn. But what you mentioned (standard configuration files + full documentation) is exactly what defold has. Check the manual I have linked above to see what you can do with sprites (…really. you’re going to need to get use to reading the documentation. sprite transparency is the second example on that page).

I have made a couple of games with defold without ever worrying about shaders or what a hash is. Although i would admit that creating exciting graphics is a weakness of mine. But what I mean is that all that stuff can come later.

3 Likes

@88.josh i don’t know where to start…

  • Maybe you’re a professional programmer but I am not. I’m creating games for fun. I’m no expert.
  • I’d really like to not worry about hash things but they are all over the place in Defold. I never know when I can use a simple string and where I absolutely must use a hash. So, no, it’s impossible to skip hashes learning.
  • When I’m looking for specific information, I first look toward the documentation so, “really, I’m already used to take a look at it.” However, I expect to find a list of functions and properties at the top of a specific entry (which is exactly how Defold documentation is laid out). Also, I skim through documentation to find information. I don’t read entries in full when I look for a specific information. Don’t tell me that you have ever read the full documentation of anything you use and that you remember everything. Of course reading in details documentation is much better than skiming through it but when you search specific information, you have to make some assumptions to be effective. I thought: “Maybe, the alpha value property is located in the Sprite API.” Looking at the methods and properties didnn’t help in that case. Finally you imply that I should read examples over descriptions and explanations? This is not logical at all. I want to understand my craft. Not find premade scripts to use instead of understanding the inner workings. So, no, that tint property should be more visible than being in an example entry lost in the descriptions.

I’m not angry at you or anything but I don’t agree with those points.
However, you’re right about the complexity of game development. I’m often frustrated and it may alter my ability to look in depth to documentation entries. Doing it all alone is not simple and the forum is a major help in addition to the documentation.
Also, thank you for the link to the example. At least, I’ll better remember where it’s located from now on.

Learning a game engine in the context of a game jam may be a good thing for experienced programmer but I think it was beyond my level and was in fact a bad decision. I think my current level is at knowing how to use constructs of a language but I’m not able to pass the next step: knowing how to use a library to construct full things. That’s another skill all together and I’ve been stucked at it from 15 years.

I’m an amateur programmer, just like you, but with 2 years experience now. For reference, I made do not open this suitcase and bikiniverse (both without ever understanding what a hash is!!).

Whilst I have been working with defold for longer than you, I am pretty sure our level of knowledge is similar (If you play bikiniverse, you will see how simple it is. dnots is more complicated, but not from a coding point of view).

here’s a quick lesson on hashes:

´true´ and ´false´ are booleans
1 is a number
hash('start') is a hash
"start" is a string (and it’s different from a hash)
{ "yes", true, 1 } is a table with three entries: a string, a boolean, and a number.

For reasons that are a little complicated, computers prefer hashes to strings. But there’s a lot of other stuff to learn before that difference actually matters. The main thing is this:

  1. hash('start') is not the same as "start"
  2. the defold engine uses hashes for messaging and input, for that reason, so must you.
1 Like

The third entry in the Sprite API documentation page which I already linked to tells you how to set a sprite constant in about 150 words, and gives you an example of tinting a sprite red. And when I say an example, i mean three lines of code, not a “premade script” as you said.

it would be really useful if the same entry mentioned how to make a sprite transparent, because I think that’s much more common than wanting to make a sprite red. But learning to use the API documentation (not just the manual!) is going to become a really important skill as you go on.

edit: I agree that the manual (not just the API doc) should mention tint and briefly give an example of how to make a sprite transparent/not transparent using go.set("#sprite", “tint.w”, 0) as that is something pretty important in many very basic games.

1 Like

You’re absolutely right in all that last message. I’m also guilty in not putting enough effort to decypher the API documentation. This strengthen my point about making a game when we don’t know enough of a game engine.

OK. I got collection proxies swap working. I got asteroids spawning. I got score. And I got many bugs ! :smiley:
My project is a mess and I feel like browsing in a wasteland of files. However, the game starts to feel funny if not fun. I’d really have liked to have someone to help me organise my project.

1 Like

Yes, project organisation can be a pain in the ass on your first project. But congratulations for finishing your first game! It’s looking good.

1 Like

@88.josh Thank you very much. And thank you again for your help and advices.

I’m still not finished but it’s somewhat close to a playable game.

(by the way, this is in fact my second game made with Defold. The first being a clone to the side scroller tutorial: gold rush)