main menu
This commit is contained in:
parent
93f944affe
commit
82a0e898db
24
breakout.js
24
breakout.js
|
@ -177,20 +177,20 @@ let gamepawn =
|
||||||
}
|
}
|
||||||
|
|
||||||
function gamegui() {
|
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_fn(`LIVES: ${lives}`),
|
||||||
GUI.text(`${score}`, [xpos,480],1);
|
GUI.text_fn("YARKANOID", {color: [5,120,240,255]}),
|
||||||
|
|
||||||
GUI.text("HIGH SCORE", [xpos,450],1, Color.red);
|
GUI.text_fn("ODPLOT GAMES"),
|
||||||
GUI.text(`${highscore}`, [xpos,430],1);
|
GUI.text_fn("[C] 2023"),
|
||||||
|
]
|
||||||
GUI.text(`LIVES: ${lives}`, [xpos, 400], 1, Color.white);
|
}).draw(Window.dimensions.scale([0.9,0.8]));
|
||||||
|
|
||||||
GUI.text("YARKANOID", [xpos,300], 1,[5,120,240]);
|
|
||||||
|
|
||||||
GUI.text("ODPLOT GAMES", [xpos,250],1);
|
|
||||||
GUI.text("[C] 2023", [xpos,230]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
register_gui(gamegui);
|
register_gui(gamegui);
|
||||||
|
|
61
startmenu.js
61
startmenu.js
|
@ -1,29 +1,58 @@
|
||||||
|
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() {
|
function startmenu() {
|
||||||
GUI.text_fn("SUPER BREAKOUT", {font_size:6, anchor: [0.5,0.5]}).draw(Window.dimensions.scale([0.5,0.9]));
|
GUI.text_fn("SUPER BREAKOUT", {font_size:6, anchor: [0.5,0.5]}).draw(Window.dimensions.scale([0.5,0.9]));
|
||||||
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"}),
|
|
||||||
],
|
|
||||||
anchor: [0.5,0],
|
|
||||||
font_size: 2,
|
|
||||||
});
|
|
||||||
|
|
||||||
options.draw(Window.dimensions.scale([0.5,0.5]));
|
options.draw(Window.dimensions.scale([0.5,0.5]).add([-25,0]));
|
||||||
|
|
||||||
GUI.image_fn({path:"arrow.png", anchor: [0,0]}).draw([options.items[0].bb.l, options.items[0].bb.t]);
|
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);
|
register_gui(startmenu);
|
||||||
|
|
||||||
var startcontroller = {
|
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() {
|
input_enter_pressed() {
|
||||||
run("breakout.js");
|
item.action();
|
||||||
Player.players[0].uncontrol(startcontroller);
|
|
||||||
unregister_gui(startmenu);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
input_escape_pressed() {
|
input_escape_pressed() {
|
||||||
|
|
Loading…
Reference in a new issue