Skip to content
Josh Goebel edited this page Oct 7, 2021 · 13 revisions

Hello World

Below are reference copies of the Hello World starter cartridge that can be easily generated from the TIC-80 Console using the new command:

  • new lua
  • new fennel
  • new js
  • new wren
  • etc

Lua

-- title:  game title
-- author: game developer
-- desc:   short description
-- 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

Wren

// title:  game title
// author: game developer
// desc:   short description
// script: wren

class Game is TIC{

	construct new(){
		_t=0
		_x=96
		_y=24
	}

	TIC(){
		if(TIC.btn(0)){
			_y=_y-1
		}
		if(TIC.btn(1)){
			_y=_y+1
		}
		if(TIC.btn(2)){
			_x=_x-1
		}
		if(TIC.btn(3)){
			_x=_x+1
		}

		TIC.cls(13)
		TIC.spr(1+((_t%60)/30|0)*2,_x,_y,14,3,0,0,2,2)
		TIC.print("HELLO WORLD!",84,84)

		_t=_t+1
	}
}

Fennel

;; title: game title
;; author: game developer
;; desc: short description
;; script: fennel

(var t 0)
(var x 96)
(var y 24)

(global TIC
  (fn tic []
    (when (btn 0) (set y (- y 1)))
    (when (btn 1) (set y (+ y 1)))
    (when (btn 2) (set x (- x 1)))
    (when (btn 3) (set x (+ x 1)))
    (cls 0)
    (spr (+ 1 (* (// (% t 60) 30) 2))
         x y 14 3 0 0 2 2)
    (print "HELLO WORLD!" 84 84)
    (set t (+ t 1))))

JavaScript

// title:  game title
// author: game developer
// desc:   short description
// script: js

var t=0
var x=96
var y=24

function TIC()
{
	if(btn(0))y--
	if(btn(1))y++
	if(btn(2))x--
	if(btn(3))x++

	cls(13)
	spr(1+((t%60)/30|0)*2,x,y,14,3,0,0,2,2)
	print("HELLO WORLD!",84,84)
	t++
}
Clone this wiki locally