Need Help with Timer Not Acting Properly

Now the score accumulates in the way I want, except you can go back and forth indefinitely which is something I will fix by deleting the areas that give you the score as soon as you get the score, and it will also fix that you get 2 points rather than 1 because it gives you a point for both the bird and rabbit seperately which is not intended.

Okay, now that is fixed too, now all I have to do is add the extra score and life points, and fix some last couple of glitches before I add the polish to the sound effects, music and animations, then it should be a good to go game.

1 Like

I fixed a glitch about the slow down effect playing forever if you die while slowed down, by setting the variable responsible for controlling it to “false” and stopping the countdown timer for the effect early, but one last glitch before I add the powerups is - how do I prevent the rabbit from going and staying up slightly when you are at the very top?

I would assume it would be to have the rabbit constantly/forever be in a position relative to the player and not just only start in a fixed position and let the engine take care of the rest, like I am doing now.

If they are suppose to always be in the same position, it’s probably best the rabbit is just a Sprite2D child of the bird, no code or area2d

Okay, another awesome idea, and I think it will flip properly as well with the bird but haven’t tried it out. It doesn’t hurt however, then I can work on the very last powerups and polishing details.

It works, but even with the position clamp in place from the Dodge the Creeps tutorial on the player script, the player can go off the screen to the bottom but not the top.

Do you know why this is?

And also even after I delete the word and re-type it, after I added the score powerup the snail powerup is no longer registered correctly as a global class, as the latest download at the first post will show when you try it out in the Godot editor version I specified.

Okay, I just re-typed it again, originally I didn’t delete the “class_name” part but after I did do that and re-typed every last detail, it is correctly treated like a class.

However, I still need help understanding why you can go off screen to the bottom but not the top, even though I used the clamp function from the official Dodge the Creeps! tutorial.

Is the position of the Sprite2D for the bird lower than the Area2D’s position? This clamp is only checking the Player’s scripted Area2D position. You might a more complex clamp, some amount of the player will be able to go off screen, you would hope not the whole Sprite2D though.

Oh, that makes sense, it’s not checking the entire screen width

It’s not checking the entire sprite height

Unfortunately it is lower, but it also has to be because it would look awkward/incorrect if it’s exactly at the position, so do you know the correct code to make the more complex clamp that accounts for both things?

You’d have to know the height of the player. If the position works as a minimum that makes things simpiler. Check if the position.y is less than the screen start (0) or else make the position.y zero. Then check if the position.y + sprite_height is greater than the screen height or else make the position.y equal to screen_height - sprite_height

Okay, after I do that then I clamp the position.

Is that correct?

that is clamping the position

Oh, the code already clamps the position in a more complex way than the pre-made clamp script.

That’s your point?

1 Like

How do I define the screen_height first, is it the same way as screen_size with a Vector2 at the top, or some other variable type/way?

1 Like

screen size sounds like the right variable, it might have the width and the height packed into one, just need to get the height out of it

Oh, the same way I access the $AnimatedSprite2D.height? Makes sense.

No, it doesn’t work by just typing “screen_size.height” - what should I do differently?