LidiaYoshino / godot-brackey-platformer

Game started from Brackey's tutorial on making a platformer
3 stars 1 forks source link

infinite berries #19

Closed LidiaYoshino closed 2 months ago

LidiaYoshino commented 2 months ago

Everytime I die, there is a new berry, so I'm basically immortal

LidiaYoshino commented 2 months ago

This is not as simple as I thought at first. Due to how the game resets after each death I will need to add a way to remember which berry was picked and which wasn't and only reset it when there is a Game Over.

It'd be good if it was inside the Fruit code and the screen manager or the Game Manager, so that I don't have to repeat similar code at every level that I create.

Maybe I could create a dictionary that has one entry for each level and that entry stores an array of ids for the berries that were picked? And then the levels have a code that consults that list and only loads the berries that have not been picked.

Need to think a bit more about this structure

LidiaYoshino commented 2 months ago

The fruit has access to the GameManager, since it is a singleton. That means on its ready function I could check if it was picked and render it or not. Would that be efficient in terms of performance? There won't be all that many fruits, so I think it will be okay, but that's something to be checked too.

Let's get it functioning and then we iterate and improve on it.

LidiaYoshino commented 2 months ago

I could use the groups feature from Godot. Put all the fruits that were picked in a group and everytime the level resets, it removes all the berries in that group

LidiaYoshino commented 2 months ago

I could use the groups feature from Godot. Put all the fruits that were picked in a group and everytime the level resets, it removes all the berries in that group

that won't work actually, because if I'm adding a node to a group via code, it won't be part of it when it resets, I think. Needs to test it to understand it better

LidiaYoshino commented 2 months ago

yeah, doesn't work like that, because when it resets it turns into a new instance, so the reference is lost. Gonna stay with the GameManager strategy for now