var startgame = function() { run("breakout.js"); Player.players[0].uncontrol(startcontroller); unregister_gui(startmenu); }; var exitgame = function() { quit(); }; var options = GUI.column({ items: [ GUI.text_fn("START", {action: startgame}), GUI.text_fn("EXIT", {action: exitgame}), GUI.image_fn({path:"ship1.png"}), ], hovered: { color: Color.blue, }, }); var idx = 0; var item = options.items[idx]; item.selected = true; function startmenu() { GUI.text_fn("SUPER BREAKOUT", {font_size:6, anchor: [0.5,0.5]}).draw(Window.dimensions.scale([0.5,0.9])); options.draw(Window.dimensions.scale([0.5,0.5]).add([-25,0])); GUI.image_fn({path:"arrow.png", anchor: [1,0.5]}).draw([item.bb.l, (item.bb.b + item.bb.t)/2].add([-3,1])); } register_gui(startmenu); var startcontroller = { input_s_pressed() { item.selected = false; idx = Math.clamp(idx+1, 0, options.items.length-1); item = options.items[idx]; item.selected = true; }, input_w_pressed() { item.selected = false; idx = Math.clamp(idx-1, 0, options.items.length-1); item = options.items[idx]; item.selected = true; }, input_enter_pressed() { item.action(); }, input_escape_pressed() { quit(); }, }; Player.players[0].control(startcontroller);