Author Topic: Shutdown (a clone of Lights Out Deluxe)  (Read 5153 times)

0 Members and 2 Guests are viewing this topic.

Offline JWinslow23

  • Coder Of Tomorrow
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 556
  • Rating: +43/-6
  • I make quality calculator games...when I have time
    • View Profile
Shutdown (a clone of Lights Out Deluxe)
« on: November 11, 2013, 12:35:52 pm »
This is a less-than-a-kilobyte clone of Lights Out.
CONTROLS
First, you will go to the main menu. Press up and down to go between menu options, and Enter to select. Press left and right to switch between modes.
In-game, press the arrow keys to move along the Lights Out grid, and Enter to turn that and all adjacent lights off. You keep going until the lights are all turned off, or you can press CLEAR at any time to quit. Either way, you will be sent back to the main menu.
MODES
The first mode is Normal mode, where all the lights are turned on.
The second mode is Random mode, where it selects a random configuration of lights.
The third mode is custom. It brings you to a screen with the grid you can customize. The controls are the same as in-game, except no special rules for switching lights apply. CLEAR goes to the game with the pattern.
CODE
Code: [Select]
Lbl S
ClrHome
"----
Ans+Ans+Ans+Ans
Disp "    SHUTDOWN",Ans," PLAY",Ans," MODE:",Ans," EXIT
3→X
1→Y
Repeat K=105
Output(5,8,sub("NORMALRANDOMCUSTOM",6Y-5,6
Output(X,1,">
getKey→K
If Ans
Then
Output(X,1,"
X+2(Ans=34 and X≠7)-2(Ans=25 and X≠3→X
Y+(K=26)-(K=24
Ans-3(Ans=4)+3not(Ans→Y
End
End
36→dim(L₁
If X=7
Goto E
If Y=3
Then
ClrHome
DelVar A1→B
Disp "
For X,1,6
Disp " OOOOOO
End
Fill(0,L₁
Repeat K=45 and sum(L₁
Output(A+2,B+1,"
rand(8
Output(A+2,B+1,sub("O*",1+L₁(6A+B),1
getKey→K
A+(Ans=34 and A≠5)-(Ans=25 and A→A
B+(K=26 and B≠6)-(K=24 and B≠1→B
6A+Ans
If K=105
not(L₁(Ans→L₁(Ans
End
End
If Y=2
Then
Repeat sum(Ans
int(2rand(36→L₁
End
End
If Y=1
Fill(1,L₁
ClrHome
"         
Output(1,10,"! SHUT "+Ans+"! DOWN "+Ans+"+------"+Ans+"!MODE: "+Ans+"!      "+Ans+"+------"+Ans+"LIGHT:"+Ans+"!
Output(5,11,sub("NORMALRANDOMCUSTOM",6Y-5,6
For(X,0,5
For(Y,1,6
Output(2+X,1+Y,sub("O*",1+L₁(6X+Y),1
End
End
DelVar X1→Y
Repeat K=45 or not(sum(L₁
Output(8,12,"
Output(8,11,sum(L₁
Output(X+2,Y+1,"
rand(8
Output(X+2,Y+1,sub"O*",1+L₁(6X+Y),1
getKey→K
X-(Ans=25 and X)+(Ans=34 and X≠5→X
Y-(K=24 and Y≠1)+(K=26 and Y≠6→Y
If K=105
Then
For(A,1,5
6X+Y
{(Ans-6)not(not(X)),(Ans-1)(Y≠1),Ans,(Ans+1)(Y≠6),(Ans+6)(X≠5
Ans(A
If Ans
not(L₁(Ans→L₁(Ans
End
For(A,X-not(not(X)),X+(X≠5
For(B,Y-(Y≠1),Y+(Y≠6
Output(A+2,B+1,sub("O*",1+L₁(6A+B),1
End
End
End
End
If K=45
Goto S
Output(8,11,0
Pause "YOU WIN!
Goto S
Lbl E
DelVar L₁DelVar ADelVar BDelVar KDelVar XDelVar YClrHome
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
Click here for the only set of games you'll ever need
= ?

Offline Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
Re: Shutdown (a clone of Lights Out Deluxe)
« Reply #1 on: November 11, 2013, 12:42:09 pm »
* Streetwalker sees a label in BASIC and faints
* Streetwalker runs
Anyway sounds cool. ;)
« Last Edit: November 11, 2013, 12:42:23 pm by Streetwalker »

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: Shutdown (a clone of Lights Out Deluxe)
« Reply #2 on: November 11, 2013, 12:43:56 pm »
You should try working without labels, that'll make your program better, you can like put a long while loop around it with
Code: [Select]
While K=45

[...]

End
Seeing that you have K=45 as a condition to start again.
Just an idea, though ;)

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline harold

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 226
  • Rating: +41/-3
    • View Profile
Re: Shutdown (a clone of Lights Out Deluxe)
« Reply #3 on: November 11, 2013, 12:45:02 pm »
How do you ensure that the random instances are solvable?
Blog about bitmath: bitmath.blogspot.nl
Check the haroldbot thread for the supported commands and syntax.
You can use haroldbot from this website.

Offline JWinslow23

  • Coder Of Tomorrow
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 556
  • Rating: +43/-6
  • I make quality calculator games...when I have time
    • View Profile
Re: Shutdown (a clone of Lights Out Deluxe)
« Reply #4 on: November 11, 2013, 12:46:30 pm »
You can like put a long while loop around it with
Code: [Select]
While K=45

[...]

End
Seeing that you have K=45 as a condition to start again.
Just an idea, though ;)

I don't see how that would work. I know that labels are discouraged in BASIC, but sometimes they are the optimal solution. This may be one of those times.
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
Click here for the only set of games you'll ever need
= ?

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: Shutdown (a clone of Lights Out Deluxe)
« Reply #5 on: November 11, 2013, 12:51:56 pm »
I build my basic progs usually somehow like this:

Variables as following: for a menu, A the position, C the Keypress
Code: [Select]
Repeat A=3 and C=21  //A=3 is then the bottom-most menu item, exit
<draw menu>
Repeat C=21
<menu routine
End
If A=0
Then
<stuff for first menu point>
0->A //put cursor at the top again and prevent exiting
End
If A=1
Then
<stuff for second menu point>
0->A //put cursor at the top again and prevent exiting
End
If A=2
Then
<stuff for third menu point>
0->A //put cursor at the top again and prevent exiting
End

End

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline JWinslow23

  • Coder Of Tomorrow
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 556
  • Rating: +43/-6
  • I make quality calculator games...when I have time
    • View Profile
Re: Shutdown (a clone of Lights Out Deluxe)
« Reply #6 on: November 11, 2013, 12:55:31 pm »
I build my basic progs usually somehow like this:
(blah blah blah code)

Now I see how it works! We just need to optimally substitute it into the program somehow. You can see how the program works, right?
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
Click here for the only set of games you'll ever need
= ?

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Shutdown (a clone of Lights Out Deluxe)
« Reply #7 on: November 11, 2013, 12:56:18 pm »
I like labels in BASIC because they can often be an excellent solution and often the best solution ;)

Anyways, to answer harold, there are no unsolvable starting conditions. (Think of it like a scrambled Rubiks cube, or a scrambled knot in a string whose ends are tied together). When I made one, I wasn't sure if there were unsolvable solutions, so I just simulated n steps and presented the board.

EDIT: Oops, it seems there are some unsolvable boards for some sizes.

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: Shutdown (a clone of Lights Out Deluxe)
« Reply #8 on: November 11, 2013, 12:59:36 pm »
I build my basic progs usually somehow like this:
(blah blah blah code)

Now I see how it works! We just need to optimally substitute it into the program somehow. You can see how the program works, right?
I didn't really look at your code yet but I like that you use Ans a lot :D
I like labels in BASIC because they can often be an excellent solution and often the best solution ;)
[...]
When's that ??? They also have that memory bug

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline JWinslow23

  • Coder Of Tomorrow
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 556
  • Rating: +43/-6
  • I make quality calculator games...when I have time
    • View Profile
Re: Shutdown (a clone of Lights Out Deluxe)
« Reply #9 on: November 11, 2013, 01:00:23 pm »
I like labels in BASIC because they can often be an excellent solution and often the best solution ;)

I agree with Xeda. I used labels because I thought it was the best solution.

Anyways, to answer harold, there are no unsolvable starting conditions. (Think of it like a scrambled Rubiks cube, or a scrambled knot in a string whose ends are tied together). When I made one, I wasn't sure if there were unsolvable solutions, so I just simulated n steps and presented the board.

That must have been slow, Xeda.
Harold, I did my research first, and at least for 6 by 6 grids, there are no unsolvable starting conditions. So, int(2rand(36 was sufficient.

So, was the game good?
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
Click here for the only set of games you'll ever need
= ?

Offline JWinslow23

  • Coder Of Tomorrow
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 556
  • Rating: +43/-6
  • I make quality calculator games...when I have time
    • View Profile
Re: Shutdown (a clone of Lights Out Deluxe)
« Reply #10 on: November 11, 2013, 01:02:28 pm »
When's that ??? They also have that memory bug

Note, he said OFTEN, not ALWAYS. That memory bug only happens if you escape out of a loop with a Lbl, and I always try to prevent that.
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
Click here for the only set of games you'll ever need
= ?

Offline Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
Re: Shutdown (a clone of Lights Out Deluxe)
« Reply #11 on: November 11, 2013, 01:03:32 pm »
Hmm, try to avoid double posting please. You have an edit and a delete button at the top of your post.

Offline JWinslow23

  • Coder Of Tomorrow
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 556
  • Rating: +43/-6
  • I make quality calculator games...when I have time
    • View Profile
Re: Shutdown (a clone of Lights Out Deluxe)
« Reply #12 on: November 11, 2013, 01:04:15 pm »
Hmm, try to avoid double posting please. You have an edit and a delete button at the top of your post.
Sorry. I failed to notice the EDIT button.

EDIT: Maybe because it was labelled MODIFY.
« Last Edit: November 11, 2013, 01:04:34 pm by JWinslow23 »
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
Click here for the only set of games you'll ever need
= ?

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Shutdown (a clone of Lights Out Deluxe)
« Reply #13 on: November 11, 2013, 01:15:16 pm »
I like labels in BASIC because they can often be an excellent solution and often the best solution ;)
[...]
When's that ??? They also have that memory bug
That memory 'bug' isn't a bug, actually, it is just misuse of Goto and Lbl inside While, Repeat, and For loops.

Examples are when you use the Menu() command, the options need to jump to labels, then if you want to jump back to the menu, you either need to use a non-optimal Repeat loop, or the more optimal Goto. For example:
Code: [Select]
Lbl 0
Menu("HEADER","ITEM 1",01,"ITEM 2",10,"EXIT",1
Lbl 01
Pause "HI!
Goto 0
Lbl 10
Pause "HAHAHAHAHA
Goto 0
Lbl 1

In reality, While loops and Repeat loops use memory (so large nestings of these can consume lots of RAM) whereas Lbl and Goto use no memory. In RPGs, using labels is usually the best option, and for games where you want to use subroutines without using subprograms, you can take advantage of mixing labels and while loops. I made heavy use of this in an RPG a while ago.

To be more technical, the OS needs to push information onto an operator stack whenever it executes a loop. When it reaches an End, it uses that information and it doesn't remove it until the loop is finished. If you had 9 nested while loops, then , it pushes the data for each loop onto this stack, and when it reaches an End, the information is popped off in reverse order. If you use a Goto to jump out of a loop, the data never gets popped off the stack unless you place an unused end somewhere (but then only one item is popped off).

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: Shutdown (a clone of Lights Out Deluxe)
« Reply #14 on: November 11, 2013, 01:24:17 pm »
Oh, now the memory error makes sence to me O.O But isn't it the same then for multi-line if conditions?
Anyways, I prefer using loops.....

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!