main menu

This commit is contained in:
John Alanbrook 2023-06-05 15:31:57 +00:00
parent 93f944affe
commit 82a0e898db
2 changed files with 58 additions and 29 deletions

View file

@ -177,20 +177,20 @@ let gamepawn =
}
function gamegui() {
var xpos = 1000;
GUI.column({
items: [
GUI.text_fn("SCORE", {color: Color.red}),
GUI.text_fn(`${score}`),
GUI.text_fn("HIGH SCORE", {color: Color.red}),
GUI.text_fn(`${highscore}`),
GUI.text("SCORE", [xpos,500],1,Color.red);
GUI.text(`${score}`, [xpos,480],1);
GUI.text_fn(`LIVES: ${lives}`),
GUI.text_fn("YARKANOID", {color: [5,120,240,255]}),
GUI.text("HIGH SCORE", [xpos,450],1, Color.red);
GUI.text(`${highscore}`, [xpos,430],1);
GUI.text(`LIVES: ${lives}`, [xpos, 400], 1, Color.white);
GUI.text("YARKANOID", [xpos,300], 1,[5,120,240]);
GUI.text("ODPLOT GAMES", [xpos,250],1);
GUI.text("[C] 2023", [xpos,230]);
GUI.text_fn("ODPLOT GAMES"),
GUI.text_fn("[C] 2023"),
]
}).draw(Window.dimensions.scale([0.9,0.8]));
}
register_gui(gamegui);

View file

@ -1,29 +1,58 @@
function startmenu() {
GUI.text_fn("SUPER BREAKOUT", {font_size:6, anchor: [0.5,0.5]}).draw(Window.dimensions.scale([0.5,0.9]));
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("Press ENTER start"),
GUI.text_fn("Press ESCAPE to exit"),
GUI.text_fn("Press H for help"),
GUI.image_fn({path:"bigball.png"}),
GUI.image_fn({path:"arrow.png"}),
GUI.text_fn("START", {action: startgame}),
GUI.text_fn("EXIT", {action: exitgame}),
GUI.image_fn({path:"ship1.png"}),
],
anchor: [0.5,0],
font_size: 2,
hovered: {
color: Color.blue,
},
});
options.draw(Window.dimensions.scale([0.5,0.5]));
var idx = 0;
var item = options.items[idx];
item.selected = true;
GUI.image_fn({path:"arrow.png", anchor: [0,0]}).draw([options.items[0].bb.l, options.items[0].bb.t]);
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() {
run("breakout.js");
Player.players[0].uncontrol(startcontroller);
unregister_gui(startmenu);
item.action();
},
input_escape_pressed() {