You CAN make a game in 30 minutes!



Video

IMPORTANT: This is the main event, the write-up is there as a last resort.

Write-Up

IMPORTANT: This is just a slightly edited version of what I said in the video, I highly recommend you watch the video, it will do a much better job of explaining.

So you wanna make a game, but it’s too hard. Wrong! And you need expensive software. Also Wrong! And good hardware. Definitely Wrong!

Today, you’re gonna make a game in a FREE game engine called Godot that you can get anywhere in the world AND it can run on just about any computer!

Download it here: https://godotengine.org/

So, once you’ve downloaded that, you can open it up and make your first game by clicking Create, calling it whatever you want, storing wherever you want, and setting the renderer to Compatibility. This makes sure that when you’re done, you can build this game for any platform, Windows, Mac, Linux, Mobile or even the web!

Then, click Create and Edit and it will open up your brand new project.

We’re going to make a 3D game, so go ahead and select Create 3D scene and then we’ll download some free 3D models to get started with.

Farm Assets: https://automataworkshop.itch.io/lowpoly-farm

We’re going to be making a simple 3D game, but I’d like the ground to have some character, so I’ll open up a drawing software like sketch.io, make the background green, and then draw some brown spots of dirt and an X we could use later on. We can download this and drag-and-drop it right into Godot.

Inside of Godot, we can create a Sprite3D and set the sprite to that texture, and duplicate it a few times to make there be a bit more ground.

Now, this looks great (ok it looks terrible), but the bigger problem is that the player will just fall through it. We need to tell the computer that there is ground here, so I’ll create a static body, which is an object that can interact with other objects physically and then create a collision shape 3D under that. Now that collision shape, which I’ll line up with the ground, will keep the player from falling through.

I’ll box the player in by creating a group of 5 fences and then putting another static body with a collision shape 3D under it around them, positioning the box so it will feel like the fences are what’s stopping the player from moving.

I’ll also add a barn and some trees to make the scene more interesting.

Remember, every object that you want the player to not be able to walk through has to have a static or rigid body AND a collider underneath that. So if I put the barn inside the fence, it must have a collision. But if I put the trees outside the fence, they don't need a collision setup because the player will never interact with them.

But if we were to play the game right now, everything would be kind of dark, and that’s because we need a light, so let’s add a directional light, which basically simulates the sun, and rotate it to point somewhat down, as that’s what the sun tends to do.

Now that we have some environment, let’s make a player to walk around.

The player will be a CharacterBody3D, which is like a staticbody but we can use code to move it around super easily! Inside of it we need a collider to shape how the player will interact with these other objects, and I’m going to use a cylinder collider, because it allows the player to slide up and over small bumps or ramps.

Inside of the characterbody, I’m also going to add a camera, which is how the player will see the world. If we click preview, we can see exactly what the player will see, and we can move this around to be roughly at the players head level.

Now we want the player to be able to look around, so we’ll need to take the players mouse movement and turn that into camera movement in our code. So we’ll create a script by scrolling to the bottom of our camera and selecting Script>New Script. I’ll call this camera_movement.gd and save it to a new Scripts folder.

Inside the script we need to add two variables and a function: var rot_x = 0, this is a variable that will store the x rotation of the player. var rot_y = 0, this is a variable that will store the y rotation of the player. And last but not least, func _input(event): colon This is declaring a function called _input, so every time godot gets input from the keyboard or mouse, it will call this function, and it will give us a variable called event, which contains all of the information about what the input actually is.

We want to check if event is InputEventMouseMotion, so if the input was a mouse movement, and if it was, we’ll say

rot_x = event.relative.x * 0.003

Now this means that however the mouse moved side to side, we’ll set rot_x to be that. And a couple of lines down lets say

get_parent().transform.basis = Basis()

so we’ll reset the rotation of the player, which is this objects parent, (remember it’s over it in the inspector)

get_parent().rotate_object_local(Vector3(0, 1, 0), rot_x)

so basically we’re rotating the player object to be the whatever the stored rotation is.

Now the player can rotate side to side like this, and if we want to add up and down rotation, we’ll do the same thing but with the y axis, and instead of rotating the player, we’ll just rotate the camera, because we want to look up without the player tilting up and falling over.

Now the player can look all around, but they’re still stuck in one place,

So let’s go to the player, scroll down, and add a new script, which we’ll save as player_movement.gd

The first thing we need to do is read the WASD keys to find out how the player wants to move, and we can set this up in Project>Project Settings>Input Map. In the Add New Action box we’ll type left and then click add, and then we can add whatever keys we want to move our player left, so I’ll add the A key by pressing it and hitting OK and the left arrow key as well.

Once we’ve added all four of those,

we can go into our player script and use those values to move the player, so let’s create another built-in function called _physics_process, which the game will run over and over again, so every time the game runs it we can read the user input and move the player.

First we’ll get the direction the player would like to move by saying var move_dir = Input.get_vector("left", "right", "forward", "backward"), so using all of those keybinds we just set up.

Then we need to figure out what direction the player would like to move, which is whatever direction the player is facing, so

var direction = (transform * Vector3(move_dir.x, 0, move_dir.y)).normalized() 

we’ll create a variable called direction and we’ll set it equal to the transform of this object, which is it’s position and rotation * a new vector 3 where we use the left and right keybinds to move left and right, that’s move_dir.x and the up and down keybinds to move forward and backwards, that’s move_dir.y. We’ll also normalize this so the player always has the same speed.

The last thing to do is check if that direction variable actually has anything in it, so if it does, if direction:

then velocity.x, so how the player is moving on the left and right becomes direction.x and velocity.z = direction.z to make the player move forward and backward based on direction.z

Now otherwise, else, if direction is empty, we’ll say velocity.x = move_toward(velocity.x, 0, 1), so if the player isn’t pressing anything, let’s decrease the x-speed to 0 smoothly

And we’ll do the same thing for the z speed

if direction:
    velocity.x = direction.x
    velocity.z = direction.z
else:
    velocity.x = move_toward(velocity.x, 0, 1)
    velocity.z = move_toward(velocity.z, 0, 1)  

Now, currently the player is very slow, so let’s add a variable that we can edit in the inspector to control the speed.

So at the top of the script we’ll say 

@export var speed: float = 1

@export says show this in the inspector, var speed says make a variable called speed and : float says we’d like this variable to be a floating point number, so a number with a decimal in it

And inside of the if direction check, we’ll multiply direction.x and direction.z times SPEED

And in the else statement we’ll replace the 1s with SPEED, so how fast the player is going determines how long it takes for them to slow back down to 0, which makes sense. Now in the inspector we can see a speed variable, and if we set that to 5, we’re much faster!

if direction:
    velocity.x = direction.x * SPEED
    velocity.z = direction.z * SPEED
else:
    velocity.x = move_toward(velocity.x, 0, SPEED)
    velocity.z = move_toward(velocity.z, 0, SPEED)

So, now that we have a basic game, with a player moving around in the environment we created, let’s build our game so other people can play it!

And the most accessible way to do that is to put it on the web, so let’s go to Project>Export and then we can click Add and select Web. Now it might ask you to download this web template if you don’t have it, so do that and then you can hit Export All, select a folder, and export.

Now we have it on our local machine, but we want to share it with the entire internet, so let’s go to itch.io, a website created just for that. You may need to create an account, but after you do you can go to your profile and then click dashboard and then Create New Project.

Go ahead and put in a title, change the Kind of Project to HTML, and click Upload Files to upload your file. Now itch.io likes the files to be named a little differently, so go to wherever you exported the project and rename the .html file to index.html. Then take the whole folder and right click>compress to zipfile. Then you can upload this zip file to itch.io. You can then set whether you'd like your game to run in itch.io's little window or go fullscreen. You'll also want to check the box to use SharedArrayBuffer (experimental) because otherwise your game won't run.

Now your game is ready to publish, so scroll down to the bottom and click Save and View page.

Now click view, hit run game, and enjoy your first game!

You can also go back and change the visibility to public and save again so anyone you send the link to can play the game.

Also, if you want to take this from being just a simple walk around experience to having actual game logic, check out my next tutorial, which I’ll probably put right here (once it's done):

Leave a comment

Log in with itch.io to leave a comment.