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