Let’s talk about programming. I’m not good at it in any way, shape or form. Maybe rotten is a bit too harsh, so we’ll just say I’m bad at it. Okay. Why? Maybe I’m too old and learning things is incredibly fun but it’s becoming increasingly difficult to retain complex information. After being stuck in tutorial hell copying what others did and retaining nothing but engine workflow, I came across a video telling me to stop making games and start making systems. It’s something that’s been told forever in forums, on breaking down each problem into tiny bits that can be their own thing in itself then eventually assemble those bits into a game and this made sense to me. So I begin making a “bit” and I’m suddenly fish-eyed staring at the screen or go to watch a different video about design or sketching or trail-cam. I have no problem at all with using the engine and finding what I need inside it for the most part but when it comes to creating the logic behind making it work, I draw a blank. No, the logic is fine, it’s the knowing how to translate that into something the computer can understand that I struggle with. “Read the documentation” Okay, so here’s a function and here’s the things it affects. Good. Now, how do I string this together? Where do these parts go? What exactly IS an argument and how do I know when I’ll need to use something that needs an argument? I also believe in manifest destiny so let’s stop talking about how bad I am at coding and start talking about solutions to this.
Yes. You are my rubber duck now and we’re going to talk through this.
I want to make the player object rotate based on its forward speed, which in turn happens after the input (movement) but doesn’t stop or slow down (for now). So Godot uses the term radians as units of rotation, I think. Where does it go? I guess process function as it is part of the player controller. Okay. Now, how is it written? If forward motion is a non zero amount, have rotation == speed + direction? No f** clue. “cHeCk ThE dOcS!” For What? I want the player to rotate. Okay, searching “Sprite rotation.”
TAU / 2, or 180 degrees in rotations. TAU = 6.28318530717959. The circle constant, the circumference of the unit circle in radians. This is equiv…
Nope.
Turning around It's time to make our node move and rotate. To do so, we're going to add two member variables
Bingo, in “Creating your first script” of course. How easy was that? I can rotate it automatically and indefinitely using PI. rotation += angular_speed * delta; where angular_speed = PI. Good. Now attach it to only when the player moves. . . AND crickets.
“Just start writing something.”
if player_input = direction.x:
sprite.rotation += angular_speed * delta
elif player_input = direction.x(except the opposite direction):
sprite.rotation -= angular_speed * delta
else:
do_a_jig()
Is it really that easy? How do I fix the syntax? Read the error message carefully, you say?
Oh gods, that means I need to open it and try this out. What are you doing to me…
if direction:
velocity.x = direction * SPEED
ball_sprite.rotation += rotate * rotate_speed * delta
This rotates it in one direction while pushing forward but doesn’t keep rotating as it moves. It’s nested inside the player controller code after defining direction as Input.get_axis(“left”, “right”) Maybe doing it long-hand would help define which direction it should spin? Now we’re going backwards in terms of function over efficiency. I guess I shouldn’t worry about that yet. Well that only took 15 minutes and it’s still not solved. Now I’m beginning to see how the burnout happened; BUT, coming up with that using my own brain and the docs feels really good.
I guess the point is to enjoy the moment and don’t get bogged down with the Big Picture, even though every part of me needs to see a finalised Big Picture in order for it to make sense.
Take a breath and enjoy being. I’m glad we talked this out, ciao.
Did you like this post? Tell us
Leave a comment
Log in with your itch.io account to leave a comment.