Skip to content
Vadim Grigoruk edited this page Nov 22, 2026 · 14 revisions

The Hello World cartridge is the demo cart created by the new command. With several runtimes in the build, new needs the language name: new lua, new python, new wren, and so on. The NEW submenu of the TIC-80 menu lists the same languages.

Code

Lua

-- title:   game title
-- author:  game developer, email, etc.
-- desc:    short description
-- site:    website link
-- license: MIT License (change this to your license of choice)
-- version: 0.1
-- script:  lua

t=0
x=96
y=24

function TIC()

	if btn(0) then y=y-1 end
	if btn(1) then y=y+1 end
	if btn(2) then x=x-1 end
	if btn(3) then x=x+1 end

	cls(13)
	spr(1+t%60//30*2,x,y,14,3,0,0,2,2)
	print("HELLO WORLD!",84,84)
	t=t+1
end

Sprite Animation Explanation

The first argument of the spr function corresponds to the sprites indices. The formula 1+t%60//30*2 switches from one sprite to the other to animate the character.

Let's explain it:
The two sprites have indices 1 and 3 so we need something that switches from 1 to 3 regularly.

In lua % is the modulo operator, it returns the remainder of the division.

> eval trace(154 % 60)
34

Because 154 is 2×60+34.
So mechanically t%60 increases with t from 0 to 59 and then restart at 0 when t is a multiple of 60.

// is the floor division, it divides the number, then truncates it.

> eval trace(34//30)
1

So t%60//30 will be 0 when t%60<30 and 1 else.
Therefore 1+t%60//30*2 switches between 1 and 3.

Edit Hello World Template

The default cart template can be modified using the config default command. That can be used to use a custom palette for all your projects. Do not forget to save.

Home
Tips for newcomers

Built-in Editors

Code | Sprites | Maps | SFX | Music

Console

All commands

save | export | load | import | menu | config | surf | shelf | demo | eval 

Platform

RAM | VRAM | Display | Palette | Bits per Pixel (BPP) | .tic Format | Supported Languages

Other

Tutorials | Code Snippets | Libraries | External Tools | FFT


API

All API functions

Callbacks

TIC | BOOT | MENU | BDR

  • SCN (deprecated)
  • OVR (deprecated)

Input

btn | btnp | btnr | key | keyp | keyr | mouse

Drawing

circ | circb | clip | cls | elli | ellib | font | line | map | paint | pix | print | rect | rectb | rrect | rrectb | spr | tri | trib | ttri | fill patterns

Sound

music | sfx | FFT | VQT

Memory

memcpy | memset | mget | mset | peek | poke | pmem | sync | vbank

System

exit | reset | time | tstamp | trace

Clone this wiki locally