Tag Archives: gamedev

pongodot day 4: paddles

SJR paddlin - Pong? That's a paddlin'
memes anyone?

That’s right, today it’s time to add paddles to pong. finally time to make this somewhat like a game with a player controlled element.

First step is input. Godot uses an input map through the player settings, allowing multiple inputs to translate to specific actions. For this I added three, padde_up, paddle_down, and an action I called launch, which will be used to launch the ball after a point is scored. This last one will not be used today, since the scoring mechanism is tomorrow’s task.

all the ui ones are there by default, and I didn’t bother removing them.

The input actions we’ll be able to use in code to move the paddle. Speaking of which, it was also time to make the paddles.

The paddles have a similar node structure to the ball, they are KinematicBody2D nodes, with a sprite and a collision shape attached. Putting them both in the scene with no scripting attached made the ball simply bounce off them, which is exactly what we wanted.

Looks a bit more like pong now, eh?

First up, the player paddle. The script here was relatively simple, getting the input is the only thing new about this script compared to what we wrote for the ball, and unlike the ball we are using move_and_slide instead of move_and_collide, since I don’t want the paddle to stop moving when you hit the ball.

Next, we’ll do the COM paddle. Later on I want to play around with an algorithm that will be fun to play against, but for now I’m going to make it super dumb.

The plan is to have the COM paddle simply follow the y coordinate of the ball, however, it’s going to have a slightly lower speed than the ball, so it lags behind a bit, hopefully allowing the player to score sometimes. When we get to the scoring stuff tomorrow I might change this up, but for today’s task it’s all about keeping it simple and stupid.


So here, we use get_node() to get a reference to our Ball object, and just simply move the paddle up and down to follow the ball. We can adjust the speed to make the paddle more likely to miss, but for now this works great.

That almost looks like a game!

In this gif I am controlling the left paddle with the up and down arrows! As you can see, nothing happens when I miss and the ball goes behind me, but that is tomorrows task. See you then!


learning godot with #pongodot

So, I’ve been taking a break from game dev, which, to be honest, has been nice and somewhat refreshing. Most of that time the last six months or so have been spent working on my webcomic, which has been really cool, and I’m excited for the future of A Star Below.

The last time I really did anything major in game development was last year, for Ludum Dare 48. Along with some good friends of mine, we made a game in 72 hours… and then futzed around with it for a few weeks polishing it further. That game was Crashdown, which you can play now if you like!

Since then, haven’t done much in games. The aforementioned comic has occupied a lot of my free time and creative energy, but right now, with the comic on hiatus and my role on the script pretty far ahead it seems like a good time to jump back into game dev! And just in time for Ludum Dare 50!

For a variety of reasons I won’t get into right now, I am wanting to try out something other than Unity for this one. I have tinkered with Godot in the past, and while there were things I liked about it I did sort of bounce off it at the time. However, I thought this would be a good time to take another crack at it.

So, Ludum Dare 50 starts on April 1st, so I have a month to play around and learn Godot. So, that’s my plan, I’m going to spend the month of march learning Godot by making a Pong clone. I have named this endeavor: Pongodot.

My goal is to do 1 thing each day. I figure at that pace by day 5 I will have a basic working pong game, and then I will spend the next 26 days futzing around adding a bunch more features and bells and whistles as I see fit.

Day 1

So, for day 1, let’s talk about basic scenes in Godot!

For this project I am keeping things simple, and building my scene in 2d. I’ve got godot installed, added a new scene with it’s root node.

oooh, aaah

My background so far in game dev has been almost exclusively in Unity and C#. I (very briefly) played around in Unreal 3 one semester in college, and I tried out a Python library for games, though that second one wasn’t really an engine. Point is, my basis for comparison is entirely from Unity, and I will be using it to understand.

Two things setting up this scene that struck me. First, is that the scene itself is the root node. Godot structures everything as nodes in a tree, and if you think about the Unity scene as a hidden root node, this is really not a big paradigm shift, easy enough.

The second is that I don’t need to add a camera. In Unity, even when working within its 2D tools you need a camera, otherwise how do you show anything? Here it seems the camera is implicit, and the scene even draws out for you the view of it so you can set up your scene with that in mind.

There are 2D camera objects, but from what I can tell those are used for when you need the camera to MOVE and you don’t want to move the whole scene. For pong our perspective doesn’t need to change, so we can ignore that.

Next I just need to draw in the walls. For this I created a few simple png images in gimp, and imported them into godot. There was some fenagling, that I’m sure I could have handled better, and some weirdness getting everything sized, but oh well. With some effort we have a pong field.

I know, it’s impressive.

And that will conclude today’s foray into Godot. Just familiarizing myself a bit with the editor and scene layout, but hopefully I’ll be able to make more progress tomorrow when I actually add a ball and start learning a bit of scripting.

So far my thoughts: being used to Unity this is going to take some getting used to. The Unity editor has a lot more QoL improvements over where Godot is at right now, but I’m sure with more experience in the engine I’ll get more adept at it. Just this little bit of basic setup likely took me longer than it should have, but honestly that also might be PEBKAC, so ¯\_(ツ)_/¯