singe/assets/Forge/tutorials/06-gun.game
2026-09-14 22:32:53 -05:00

115 lines
2.4 KiB
Text

-- Written by Forge/AuthorCompile.singe. Edit by hand or in the editor; either is fine.
return {
types = {
gun = {
behaviours = {
{ ammo = 6, kind = "gun", player = 1, reload = "offscreen" }
},
look = { kind = "none" },
vars = { ammo = 6 }
},
hand = {
behaviours = {
{ kind = "hitbox", track = "hand" }
},
look = { kind = "none" },
vars = {}
},
readout = {
look = { b = 245, g = 235, kind = "text", r = 235, text = "score 0" }
},
target = {
behaviours = {
{ kind = "hitbox", track = "target" },
{ kind = "health", max = 1 }
},
look = { kind = "none" },
vars = { health = 1 }
}
},
layers = {
{ file = "Forge/kit/clip.mkv", kind = "disc" },
{ kind = "overlay" }
},
rooms = {
{
entities = {
{ id = "readout", type = "readout", x = 12, y = 12 },
{ id = "gun", type = "gun", x = 30, y = 450 },
{ id = "target", type = "target", x = 450, y = 210 },
{ id = "hand", type = "hand", x = 600, y = 210 }
},
name = "start",
tracks = {
{
boxes = {
{ at = 150, h = 90, w = 90, x = 405, y = 165 },
{ at = 210, h = 90, w = 90, x = 405, y = 165 }
},
key = "frame",
name = "target"
},
{
boxes = {
{ at = 220, h = 105, w = 240, x = 480, y = 157 },
{ at = 260, h = 105, w = 240, x = 480, y = 157 }
},
key = "frame",
name = "hand"
}
}
}
},
rules = {
{
act = {
{ "setText", entity = "readout", text = "\"score \" .. score .. \" ammo \" .. gun.ammo .. \" misses \" .. misses" }
},
note = "The readout, every frame",
on = "frame"
},
{
act = {
{ "addScore", amount = 100 },
{ "damage", amount = 1, entity = "self" },
{ "playSound", file = "Forge/kit/hit.wav" }
},
type = "target",
note = "The target is hit",
on = "hit",
when = {}
},
{
act = {
{ "addScore", amount = -200 },
{ "flash", b = 40, g = 40, r = 255, seconds = 0.3 }
},
type = "hand",
note = "The hand is hit",
on = "hit",
when = {}
},
{
act = {
{ "addVar", amount = 1, name = "misses" },
{ "playSound", file = "Forge/kit/shot.wav" }
},
note = "A shot at nothing",
on = "miss",
when = {
{ "test", expr = "not event.offscreen" }
}
},
{
act = {
{ "say", seconds = 1, text = "\"DRAW!\"" }
},
frame = 150,
note = "Draw!",
on = "frameReached",
when = {}
}
},
title = "Draw",
vars = { misses = 0, score = 0 }
}