I found “velocity = velocity.bounce(collision.get_normal())” in the documentation for how to make objects bounce, but I don’t quite get how it works. Is there a more detailed write up on it for beginners?
Link
I made this in about an hour after having watched a few tutorials on gamedev tv, I think I did okay with it given the time constraint and the fact I only used the documentation. Is there anything I can improve? I don’t want to start my Godot journey with bad habits
One really helpful thing that you can do is to export variables to avoid situations where you have “magic numbers” in your code. A “magic number” is essentially a number that is hard-coded into your script with no easy way to alter it other than by going in and altering the script. If you keep up with your gamedev.tv course, they’ll probably talk about those a bit.
So for example, in your code you have the following line to set the speed of the player’s paddle:
const speed = 400
but, you can actually make this value changeable in the editor itself by doing this:
pennyloafers thank you, that clears things up a bit for me. As for the classes, I figured I’d need to use them at some point . Would I just move the entire _physics_process function to a class and grab all the balls in the scene and keep track of them like that? Maybe a ball_manager script?
mark-wiemer I did not, but I’m going to look into it - thanks!
TK_W Oh yeah, that makes sense. I should have @export’d the speed, I just kinda threw it together to see if it’d work but I guess even in a project like this it’s good practice to get into, thank you!