breakout/startmenu.js

105 lines
2.4 KiB
JavaScript
Raw Normal View History

2023-06-05 10:31:57 -05:00
var startgame = function()
{
2023-06-06 08:07:18 -05:00
run("breakout.js");
Player.players[0].uncontrol(startcontroller);
unregister_gui(startmenu);
2023-06-05 10:31:57 -05:00
};
var exitgame = function()
{
quit();
};
2023-06-05 14:48:46 -05:00
var colorshifter = {
color: Color.green,
2023-06-05 17:19:35 -05:00
font_size: 1,
2023-06-05 14:48:46 -05:00
};
2023-06-05 17:19:35 -05:00
var colorshiftend = {
color: Color.blue,
font_size: 1.5
};
2023-06-05 10:31:57 -05:00
var options = GUI.column({
items: [
2023-06-05 17:19:35 -05:00
GUI.text_fn("START", {action: startgame}),
2023-06-05 10:31:57 -05:00
GUI.text_fn("EXIT", {action: exitgame}),
],
2023-06-05 17:19:35 -05:00
hovered: {},
2023-06-05 10:31:57 -05:00
});
2023-06-05 17:19:35 -05:00
2023-06-06 15:49:47 -05:00
Tween.embed(options, 'hovered', [colorshifter, colorshiftend], {time: 0.35, loop: "yoyo", whole: false, ease: Ease.sine.out});
2023-06-06 08:07:18 -05:00
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],
];
2023-06-05 10:31:57 -05:00
var idx = 0;
var item = options.items[idx];
item.selected = true;
2023-06-06 08:07:18 -05:00
var menuopts = {
superpos: [0,0],
2023-06-06 15:49:47 -05:00
color: [],
2023-06-06 08:07:18 -05:00
};
2023-06-06 15:49:47 -05:00
var stt = Tween.embed(menuopts, 'superpos', [Window.dimensions.scale([0.4,0.9]), Window.dimensions.scale([0.6,0.9])], {
2023-06-06 08:07:18 -05:00
time: 1,
loop: "circle",
whole: false,
ease: Ease.cubic.inout
});
2023-06-06 15:49:47 -05:00
Tween.embed(menuopts, 'color', rainbowchain, {time: 1, loop: "circle", whole: false});
2023-06-07 08:40:13 -05:00
var background_gui = GUI.image_fn({path:"hexagon_pattern_gray.png", color: Color.red, width: Window.width, height: Window.height, image_repeat: true});
2023-06-06 15:49:47 -05:00
Tween.embed(background_gui, 'image_repeat_offset', [[0,0], [1,1]], {time: 1, loop: "repeat"});
2023-06-07 08:40:13 -05:00
Tween.embed(background_gui, 'color', [Color.red, Color.blue], {time: 3, loop: "circle"});
2023-06-06 15:49:47 -05:00
2023-05-29 10:47:47 -05:00
function startmenu() {
2023-06-06 15:49:47 -05:00
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);
2023-06-01 15:58:48 -05:00
2023-06-06 15:49:47 -05:00
options.draw(Window.dimensions.scale([0.5,0.5]));
2023-05-30 15:41:13 -05:00
2023-06-06 15:49:47 -05:00
// GUI.image_fn({path:"arrow.png", anchor: [1,0.5]}).draw([item.bb.l, (item.bb.b + item.bb.t)/2].add([-3,1]));
2023-05-29 10:47:47 -05:00
}
register_gui(startmenu);
var startcontroller = {
2023-06-05 10:31:57 -05:00
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];
2023-06-05 17:19:35 -05:00
item.selected = true;
2023-06-05 10:31:57 -05:00
},
2023-05-29 10:47:47 -05:00
input_enter_pressed() {
2023-06-05 10:31:57 -05:00
item.action();
2023-05-29 10:47:47 -05:00
},
input_escape_pressed() {
quit();
},
};
Player.players[0].control(startcontroller);
2023-06-08 17:27:51 -05:00
run("file1.js");
run("file2.js");
Log.warn(x);