Legacy GM Lights Out Game in 2 lines of code

F

Forest

Guest
I made a lights out mini game that can be called in 2 lines. Enjoy :)

How to Use:
Create a script called "game_LightsOut" and paste the code at the bottom in it, to reset the game set "game_LightsOut_Start = true;"
This code needs to be set once before the game can be ran, or you'll get an error. When the user wins, the variable "game_LightsOut_win" will be set to true, if the game is reset this var will be set to false. Do not use any variables in your code that begin with "game_LightsOut_" as all of the variables this script uses begin with that.

EX:
-Create Event-
game_LightsOut_Start = true;
-Step-
game_LightsOut(50,100,false,9,9);
if(game_LightsOut_win){
draw_rectangle_colour(50,100,150,200,c_red,c_red,c_red,c_red,false);
if(keyboard_check_released(vk_enter)){
game_LightsOut_Start = true;
}
}
//This will start the game in the corner with a 9x9 grid, when the user wins it will draw a red box over the mini game screen and reset if the user pressed enter.

Code:
///game_LightsOut(x,y,cheat?,GridWidth,GridHeight,width,height);
if(game_LightsOut_Start){
for(game_LightsOut_i=0;game_LightsOut_i<10;game_LightsOut_i++){
for(game_LightsOut_j=0;game_LightsOut_j<10;game_LightsOut_j++){
game_LightsOut_G[game_LightsOut_i,game_LightsOut_j] = -1;
}
}
game_LightsOut_win = false;
game_LightsOut_Start = false;
}
//Start
game_LightsOut_win = true;
game_LightsOut_GW = 10;
game_LightsOut_GH = 10;
game_LightsOut_W = 10;
game_LightsOut_H = 10;
game_LightsOut_Cheat = false;
if(argument_count>2){
game_LightsOut_Cheat = argument[2];
if(argument_count>3){
game_LightsOut_GW = argument[3];
game_LightsOut_GH = argument[4];
game_LightsOut_W = 100/game_LightsOut_GW;
game_LightsOut_H = 100/game_LightsOut_GH;
if(argument_count>5){
game_LightsOut_W = argument[5]/game_LightsOut_GW;
game_LightsOut_H = argument[6]/game_LightsOut_GH;
}
}
}
for(game_LightsOut_i=0;game_LightsOut_i<game_LightsOut_GW;game_LightsOut_i++){
for(game_LightsOut_j=0;game_LightsOut_j<game_LightsOut_GH;game_LightsOut_j++){
if(mouse_x>argument[0]+game_LightsOut_i*game_LightsOut_W&&mouse_x<argument[0]+game_LightsOut_i*game_LightsOut_W+game_LightsOut_W&&mouse_y>argument[1]+game_LightsOut_j*game_LightsOut_H&&mouse_y<argument[1]+game_LightsOut_j*game_LightsOut_H+game_LightsOut_H){
if(mouse_check_button_released(mb_right)&&game_LightsOut_Cheat){
game_LightsOut_G[game_LightsOut_i,game_LightsOut_j] = -1*game_LightsOut_G[game_LightsOut_i,game_LightsOut_j];
}
if(mouse_check_button_released(mb_left)){
game_LightsOut_G[game_LightsOut_i,game_LightsOut_j] = -1*game_LightsOut_G[game_LightsOut_i,game_LightsOut_j];
if(game_LightsOut_j>0){
game_LightsOut_G[game_LightsOut_i,game_LightsOut_j-1] = -1*game_LightsOut_G[game_LightsOut_i,game_LightsOut_j-1];
}
if(game_LightsOut_j<game_LightsOut_GH-1){
game_LightsOut_G[game_LightsOut_i,game_LightsOut_j+1] = -1*game_LightsOut_G[game_LightsOut_i,game_LightsOut_j+1];
}
if(game_LightsOut_i>0){
game_LightsOut_G[game_LightsOut_i-1,game_LightsOut_j] = -1*game_LightsOut_G[game_LightsOut_i-1,game_LightsOut_j];
}
if(game_LightsOut_i<game_LightsOut_GW-1){
game_LightsOut_G[game_LightsOut_i+1,game_LightsOut_j] = -1*game_LightsOut_G[game_LightsOut_i+1,game_LightsOut_j];
}
}
}
if(game_LightsOut_G[game_LightsOut_i,game_LightsOut_j]==-1){
draw_rectangle_colour(argument[0]+game_LightsOut_i*game_LightsOut_W,argument[1]+game_LightsOut_j*game_LightsOut_H,argument[0]+game_LightsOut_i*game_LightsOut_W+game_LightsOut_W,argument[1]+game_LightsOut_j*game_LightsOut_H+game_LightsOut_H,c_white,c_white,c_white,c_white,false);
game_LightsOut_win = false;
}else{
draw_rectangle(argument[0]+game_LightsOut_i*game_LightsOut_W,argument[1]+game_LightsOut_j*game_LightsOut_H,argument[0]+game_LightsOut_i*game_LightsOut_W+game_LightsOut_W,argument[1]+game_LightsOut_j*game_LightsOut_H+game_LightsOut_H,false);
}
}
}
 
F

Forest

Guest
I'd be even more excited if I knew what 'lights out' was.
Lol, it's that game where when you click on one of the boxes it and all the ones around it change color, the goal of the game is to get all the boxes to black. if you set the "Cheat" argument to true you can use right click to only change one so you can test your game easier, just don't forget to change it to false before you publish your game
 
Top