1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
mod = ...
require "ext"
mod.width = 640
mod.height = 480
win = am.window{
title: "Fools Rush In"
width: mod.width
height: mod.height
clear_color: vec4(85/255,180/255,255/255,255/255)
}
mod.root = am.group()
mod.pips = 5
char = require "char"
player = require "player"
import LocalPlayer from player
util = require "util"
world = require "world"
import World from world
main_menu = require "main_menu"
rng_seed = am.eval_js("Math.random()")
math.randomseed(rng_seed*1000)
mod.screenpos = util.Vec2!
mod.reload = () ->
--[[Groups for different layers]]
mod.screen = am.group!\tag("screen")^ am.translate(0,0)--Things that should draw on top of everything else, like a hud
mod.world_close = am.group!\tag("close")^ am.translate(0,0)--Things that should draw "close to the camera", fast-parallax background
mod.world = am.translate(0,0) ^ am.group({
am.group!\tag("world_front"), -- things in front of players
am.group!\tag("world_characters"), -- players
am.group!\tag("world_behind"), -- things behind players
})\tag("world")--Characters, the world, players, ect.
mod.world_far = am.group!\tag("far")^ am.translate(0,0) --Things that move slowly in the background
mod.background = am.group!\tag("bg")--The background does not move, draws behind everything.
mod.root = am.group{
mod.background,
mod.world_far,
mod.world,
mod.world_close,
mod.screen,
}
win.scene = mod.root
mod.action_queue = {
{main_menu.load, {}}
}
mod.root\action(coroutine.create(() ->
while true
if mod.server
mod.server\update!
coroutine.yield!
))
mod.root\action(coroutine.create(() ->
while true
start_time = am.current_time!
mod.world.x = -mod.screenpos.x
mod.world.y = -mod.screenpos.y
if #mod.action_queue > 0
action = table.remove(mod.action_queue)
f, args = action[1], action[2]
f(unpack(args))
if mod.world
mod.world\update!
end_time = am.current_time!
coroutine.yield!
))
mod.reload!
mod.win = win
mod
|