Creating a Tower Defense Game in Pico8: Part 5 - Placing Totems

In the previous tutorial, we made our player move around the screen. Next on our list is the ability to place totems (our towers) - a core gameplay element in a tower defense game! Unlike the player, totems don’t exist at the start of the game. Also, there can be many totems on the screen at the same time! So for this to work, we’ll need to introduce two new concepts: ...

February 22, 2024 · 4 min · Mike Cartmell

Creating a Tower Defense Game in Pico8: Part 4 - Player Movement

What Next? So far, we’ve introduced some basic coding and game design concepts and written some helper functions that will live up to their name soon enough. Let’s take a step back and think about what kind of game we’re making, as this will help guide us over the next few parts of this tutorial. Tower Defense Player controls Typically, the player in tower defense games acts as a godlike presence, building and upgrading towers from nowhere as the player issues actions using their mouse or a touchscreen. However, this is a Pico-8 game, and Pico-8 games usually mimic an oldschool console with two-button control schemes using either a gamepad or joystick or the keyboard. While we could implement a cursor controlled by a gamepad, I don’t think it’d be very fun here. So, unlike traditional tower defense games, I’ve decided to use an actual player character to control and build the towers. This can be seen in games like Factorio, which features base-building with a player character instead of the traditional god-game approach, and also has tower defense gameplay among many many other things! ...

February 6, 2024 · 10 min · Mike Cartmell

Creating a Tower Defense Game in Pico8: Part 3 - Setting Foundations

Helper Functions There are some techniques, like _debug mentioned in part 2, that I use in almost all my games. In this post we’ll implement some of them right at the beginning, because it’ll save us time later! In Pico-8’s code editor you’ll notice a number at the bottom-right which increases as you write code. This is the token count, and it’s very important to keep an eye on this because Pico-8 programs can only have 8192 tokens! This might seem restrictive but it’s actually useful when just starting out to have constraints like this, because it encourages you to keep your game short which means you’ll have more chance of finishing it. It also encourages good coding practises which will be useful even when writing non-game programs later on. ...

February 6, 2024 · 8 min · Mike Cartmell

Creating a Tower Defense Game in Pico8: Part 2 - Special Functions

Special Functions In part 1, we wrote some commands called function calls to tell Pico-8 to draw text and shapes on the screen. But we can write our own functions too. And there are 3 special functions that, if you include them in your code, will be called by Pico-8 itself while your program is running! This forms what’s known in game programming as a game loop. Games must run code constantly to calculate game logic, move characters around on the screen, respond to the user pressing controller buttons and so on. And then it must display what’s happening on the screen many times per second (the rate of this is called frames per second or FPS). This means there is a constant ’loop’ that consists of: updating the game’s state, drawing it to the screen, and repeating. ...

February 6, 2024 · 6 min · Mike Cartmell

Creating a Tower Defense Game in Pico8: Part 1 - Hello World

Hello! This post is the first in a new series where I’m going to make a tower defense game in Pico-8 and explain exactly how to do it, from scratch. If you’re looking to learn how to code, or you know how to code and are interested in learning how to make games, this is for you! I think making games is an excellent way to learn how to code, for several reasons. You get instant feedback on the code you write, through actually playing your game! There’s a lot of freedom in that there’s usually no right or wrong way to do things - what’s more important is whether something is fun or not, and that’s for you to decide. And finally, there’s many different aspects of game development to explore, from coding game mechanics to visual effects and pixel art, level design, sound effects and music and more. If you get stuck on one problem, there’s always different things to try and work on while you recharge. ...

February 5, 2024 · 4 min · Mike Cartmell