var startgame = function() { run("breakout.js"); Player.players[0].uncontrol(startcontroller); Register.gui.unregister(startmenu); }; var exitgame = function() { Game.quit(); }; var colorshifter = { color: Color.green, font_size: 1, }; var colorshiftend = { color: Color.blue, font_size: 1.5 }; var options = GUI.column({ items: [ GUI.text_fn("START", {action: startgame}), GUI.text_fn("EXIT", {action: exitgame}), ], }); Tween.embed(options, 'hovered', [colorshifter, colorshiftend], {time: 0.35, loop: "yoyo", whole: false, ease: Ease.sine.out}); var rainbowchain = [ [255,0,0,255], [255,255,0,255], [0,255,0,255], [0,255,255,255], [0,0,255,255], [255,0,255,255], ]; var idx = 0; var item = options.items[idx]; item.selected = true; var menuopts = { superpos: [0,0], color: [], }; var stt = Tween.embed(menuopts, 'superpos', [Window.dimensions.scale([0.4,0.9]), Window.dimensions.scale([0.6,0.9])], { time: 1, loop: "circle", whole: false, ease: Ease.cubic.inout }); Tween.embed(menuopts, 'color', rainbowchain, {time: 1, loop: "circle", whole: false}); var background_gui = GUI.image_fn({path:"hexagon_pattern_gray.png", color: Color.red, width: Window.width, height: Window.height, image_repeat: true}); Tween.embed(background_gui, 'image_repeat_offset', [[0,0], [1,1]], {time: 1, loop: "repeat"}); Tween.embed(background_gui, 'color', [Color.red, Color.blue], {time: 3, loop: "circle"}); function startmenu() { background_gui.draw([0,0]); stt.update_vals([Window.dimensions.scale([0.4,0.9]), Window.dimensions.scale([0.6,0.9])]); GUI.text_fn("SUPER BREAKOUT", {font_size:6, anchor: [0.5,0.5], color: menuopts.color}).draw(menuopts.superpos); options.draw(Window.dimensions.scale([0.5,0.5])); GUI.image_fn({path:"coin.png", anchor: [1,0.5]}).draw([item.bb.l, (item.bb.b + item.bb.t)/2].add([-3,1])); } Register.gui.register(startmenu); var startcontroller = {}; startcontroller.inputs = {}; startcontroller.inputs.s = function() { item.selected = false; idx = Math.clamp(idx+1, 0, options.items.length-1); item = options.items[idx]; item.selected = true; }; startcontroller.inputs.w = function() { item.selected = false; idx = Math.clamp(idx-1, 0, options.items.length-1); item = options.items[idx]; item.selected = true; }; startcontroller.inputs.enter = function() { Log.warn("TEST"); item.action(); }; Player.players[0].control(startcontroller); Game.play();