Skip to content
muffintrap ^ FCCCF edited this page Jun 30, 2022 · 9 revisions

Introduction

A tutorial for learning the very beginner basics of game programming. The language used is Lua (https://en.wikipedia.org/wiki/Lua_(programming_language)) and the method is the TIC-80 fantasy console (https://tic80.com/). Lua is a very simple and forgiving programming language and TIC-80 is a sort of all-in-one program for creating small games. It contains the editors for code, sprites, sound and music creation. It also provides many useful functions for game development.

Learn all programming things, such as variables, functions, parameters, control structures and data types. Lessons and examples are arranged in a logical order that will give you more knowledge and tools as you progress. Several simple games are also part of the tutorial.

The tutorial is broken down to levels. Each level contains multiple topics. Along with these topics there are game projects in which you get to utilize everything you have learned so far.

Level 1

This level covers the fundamental concepts needed to write a small interactive program and teaches how to make custom functions and different uses of variables. You will also learn how to handle input from keyboard and mouse and to make a simple game react to that input.

Covered topics: Variables: numbers, booleans. Calling functions, function parameters. If and else. Clearing the screen and drawing, simple input and cursor position detection.

Level 2

This level adds tools to handle arbitrary number of values using arrays and for-loops. This facilitates more complex games with multiple players and random elements.

Covered topics: for-loops, creating and accessing arrays and arrays of arrays. Grids and grid input handling.

Level 3

This level adds the magic of things moving by themselves. The movement is enabled by measuring time and performing simple physics calculations. This enables you to make games where things happen in real time and timing matters.

Covered topics: measuring time, calculating a new position from velocity and acceleration, introduction to vector math.

Level 4

This level teaches more about vector mathematics and 2D rotation. This in turn enables more complex collision detection and camera movement.

Covered topics: level generation, trajectories, complex collision to environment, particle effects.

Level 5

This level is all about AI. From simply going towards player to making decisions based on player actions.

Covered topics: pathfinding, making predictions and decisions, distance calculation, creating an AI manager.

Level 6

In this level we are starting to grow out of the limitations of TIC-80. To make even more complex games it is necessary to be able to reuse code more efficiently and to separate it to multiple files.

Covered topics: emulating the TIC-80 in Löve 2D, how to make a multi-file project, reading files, automated testing.

TIC-80 quick quide

  • Download from the official site: https://tic80.com/create
  • Extract to a nice folder like Documents/TIC80
  • Launch the program
  • Type '''NEW''' to create a new default cart
  • Press '''ESC''' to change between editor and command line. Press '''F1-F4''' to change between editor tabs
  • Run the cart with '''Ctrl + R''' and stop with '''ESC'''
  • Save by typing '''SAVE cart-name''' where cart-name is the name you want
  • See all saved carts by typing '''SURF'''
  • The TIC-80 stores the carts/files in C:\Users'''You'''\AppData\Roaming\com.nesbox.tic\TIC-80 aka, %appdata%\com.nesbox.tic\TIC-80

How to use this tutorial

The lessons are collected in the Wiki. Each lesson consists of an explanation, some example code and one or more exercises.

  • Read the description
  • Read the example and try to understand what happens on each line
  • Open TIC-80 and type in the example yourself, testing after every change. This way you build a mental connection between code and the result on the screen. Do not copy and paste!
  • Try to modify or extend the example yourself.
  • Try to break the example intentionally, see what error message you get.
  • Read the exercise
  • Write or draw a plan on paper or type it. Break down the task into smaller parts that are in a logic succession.
  • Start writing the solution bit by bit, testing after changes using trace() and exit()
  • Have fun! Experiment!

Lessons

  1. Level 1
  2. Level 1 games
  3. Level 2
  4. Level 2 games
  5. Level 3
  6. Level 3 games
Clone this wiki locally