Discussion forum about PANORAMIC language
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Discussion forum about PANORAMIC language

Mac, Windows & Android application development with PANORAMIC language
 
HomeHome  SearchSearch  Latest imagesLatest images  RegisterRegister  Log in  
Latest topics
» What happened with the panoramic language ?
by Wed Jan 03, 2024 4:09 pm

» Hello world.
by Wed May 09, 2018 11:53 pm

» Biomorphes de PICKOVER
by Sun Jun 18, 2017 2:33 am

» In less than 10 lines of code
by Fri Jun 16, 2017 5:03 am

» Effect Dopler
by Fri Jun 16, 2017 3:29 am

» SuperEllipse
by Wed Jun 14, 2017 4:01 am

» Plants
by Wed Jun 14, 2017 3:38 am

» Mira's attractor
by Wed Jun 14, 2017 3:30 am

» Triangle of Sierpinski
by Wed Jun 14, 2017 3:22 am

» Esthétique polaire
by Wed Jun 14, 2017 3:16 am

» Butterfly effect : Lorenz equations
by Wed Jun 14, 2017 3:08 am

» Collision detection
by Tue Jun 13, 2017 5:09 am

» The Bees Laline Paull Epub Books
by Mon Oct 10, 2016 8:58 pm

» PANORAMIC for Mac OSX 10 is available
by Tue Aug 09, 2016 6:08 pm

» ide
by Sat Jul 16, 2016 12:27 am

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

 

 "Lights" game

Go down 
AuthorMessage
lodchjo




Number of posts : 10
Registration date : 2012-01-30

"Lights" game Empty
PostSubject: "Lights" game   "Lights" game EmptySun Jun 17, 2012 11:15 am

Hey!
Here's another brain breaker, play at own risk. Wink
The aim of the game is simple: the left image must be a reproduction of the smaller image on the right side of the screen.
How? it's easy to explain, but just 'a little bit' harder to do:
Click on a white or black square and it will switch, along with the squares next to it. Sometimes that is helpful, sometimes not really. You'll see, it's fun! Wink
The game shows the minimum of steps required. (If you can do a puzzle in less steps, just let me know.)
Good luck and have fun!
Lode

"Lights" game 380313_3655212177685_1057289535_n

Code:

label switch, init, chng, nxt, prv, abt
label unu, du, tri, kvar, kvin, ses, sep, ok, nau, dek
label dunu, ddu, dtri, dkvar, dkvin, dses, dsep, dok, dnau, ddek
label ddunu, dddu, ddtri, ddkvar, ddkvin
dim x,y,z, klr(25), a(5), mov, level$(25), doel$(25), lvl, req(25),test$
level$(1)="0101010101010101010101010":doel$(1)="1111111111111111111111111":req(1)=13
level$(2)="0010000100111110010000100":doel$(2)="0000001110010100111000000":req(2)=9
level$(3)="0111010101110111010101110":doel$(3)="1101111011000001101111011":req(3)=12
level$(4)="0001100011000001100011000":doel$(4)="1110011100110110011100111":req(4)=12
level$(5)="1010110101101011010110101":doel$(5)="0111001110011100111001110":req(5)=18
level$(6)="0010000100111110010000100":doel$(6)="1101111011001001101111011":req(6)=13
level$(7)="1100010110011101011011000":doel$(7)="1101110011000001001111011":req(7)=3
level$(8)="0000001010000000101000000":doel$(8)="1101110101011101010111011":req(8)=14
level$(9)="1000101010001000101010001":doel$(9)="1111110001100011000111111":req(9)=23
level$(10)="0000001110011100111000100":doel$(10)="0010001110011100111000000":req(10)=35
level$(11)="1110100110111100011011101":doel$(11)="1111110111010001011111111":req(11)=18
level$(12)="0100101000000011100010001":doel$(12)="1110011000000011100011100":req(12)=9
level$(13)="0000011000000111100000000":doel$(13)="1101110011000001001111011":req(13)=7
level$(14)="0100000101011101010000010":doel$(14)="0000000000001000000000000":req(14)=16
level$(15)="0010000100110110010000100":doel$(15)="1101111111011101111111011":req(15)=21
level$(16)="0110000101110111010000110":doel$(16)="0100001011000001101000010":req(16)=8
level$(17)="1101101010011100101011011":doel$(17)="0011000111010101110001100":req(17)=17
level$(18)="0000001110111100111000000":doel$(18)="0100100100100000010001001":req(18)=13
level$(19)="1011110111101110000010111":doel$(19)="0000011110100101001011110":req(19)=12
level$(20)="0110010001101001000101100":doel$(20)="0100010010110011001001000":req(20)=8
level$(21)="0001011110011100111101000":doel$(21)="0111000100111110010001110":req(21)=32
level$(22)="0000001110010100101000010":doel$(22)="1111110001111011111111111":req(22)=11
level$(23)="0000001101011010110100000":doel$(23)="0101001010010100101001010":req(23)=11
level$(24)="1111111111111111111111111":doel$(24)="0000001000111110100000000":req(24)=10
lvl=1
caption 0,"Lights"
border_small 0
color 0,100,150,100
width 0,500
height 0,400
for x = 1 to 5
for y = 1 to 5
z= (x-1)*5+y
picture z
picture z+35
top z, y*50
left z, x*50
width z,40
height z,40
top z+35, 40+y*10
left z+35, 350+x*10
width z+35,8
height z+35,8
next y
next x
gosub init
on_click 1,unu
on_click 2,du
on_click 3,tri
on_click 4,kvar
on_click 5,kvin
on_click 6,ses
on_click 7,sep
on_click 8,ok
on_click 9,nau
on_click 10,dek
on_click 11,dunu
on_click 12,ddu
on_click 13,dtri
on_click 14,dkvar
on_click 15,dkvin
on_click 16,dses
on_click 17,dsep
on_click 18,dok
on_click 19,dnau
on_click 20,ddek
on_click 21,ddunu
on_click 22,dddu
on_click 23,ddtri
on_click 24,ddkvar
on_click 25,ddkvin
main_menu 26
sub_menu 27 : caption 27,"Reset" : parent 27, 26
on_click 27, init
sub_menu 28 : caption 28,"Swap puzzle" : parent 28, 26
on_click 28, chng
sub_menu 29 : caption 29,"Previous puzzle" : parent 29, 26
on_click 29, prv
sub_menu 30 : caption 30,"Next puzzle" : parent 30, 26
on_click 30, nxt
sub_menu 31 : caption 31,"About" : parent 31, 26
on_click 31, abt
alpha 34
caption 34,"Make:"
top 34,30:left 34,345
end

unu:
 a(1)=1
 a(2)=2
 a(3)=6
 z=3
 gosub switch
return

du:
 a(1)=2
 a(2)=1
 a(3)=7
 a(4)=3
 z=4
 gosub switch
return

tri:
 a(1)=3
 a(2)=2
 a(3)=4
 a(4)=8
 z=4
 gosub switch
return

kvar:
 a(1)=4
 a(2)=3
 a(3)=5
 a(4)=9
 z=4
 gosub switch
return

kvin:
 a(1)=5
 a(2)=4
 a(3)=10
 z=3
 gosub switch
return

ses:
 a(1)=6
 a(2)=1
 a(3)=11
 a(4)=7
 z=4
 gosub switch
return

sep:
 a(1)=7
 a(2)=6
 a(3)=8
 a(4)=2
 a(5)=12
 z=5
 gosub switch
return

ok:
 a(1)=8
 a(2)=7
 a(3)=9
 a(4)=13
 a(5)=3
 z=5
 gosub switch
return

nau:
 a(1)=9
 a(2)=8
 a(3)=10
 a(4)=14
 a(5)=4
 z=5
 gosub switch
return

dek:
 a(1)=10
 a(2)=9
 a(3)=5
 a(4)=15
 z=4
 gosub switch
return

dunu:
 a(1)=11
 a(2)=12
 a(3)=16
 a(4)=6
 z=4
 gosub switch
return

ddu:
 a(1)=12
 a(2)=11
 a(3)=13
 a(4)=17
 a(5)=7
 z=5
 gosub switch
return

dtri:
 a(1)=13
 a(2)=12
 a(3)=14
 a(4)=18
 a(5)=8
 z=5
 gosub switch
return

dkvar:
 a(1)=14
 a(2)=13
 a(3)=15
 a(4)=19
 a(5)=9
 z=5
 gosub switch
return

dkvin:
 a(1)=15
 a(2)=14
 a(3)=10
 a(4)=20
 z=4
 gosub switch
return

dses:
 a(1)=16
 a(2)=17
 a(3)=11
 a(4)=21
 z=4
 gosub switch
return

dsep:
 a(1)=17
 a(2)=16
 a(3)=18
 a(4)=22
 a(5)=12
 z=5
 gosub switch
return

dok:
 a(1)=18
 a(2)=17
 a(3)=19
 a(4)=23
 a(5)=13
 z=5
 gosub switch
return

dnau:
 a(1)=19
 a(2)=18
 a(3)=20
 a(4)=24
 a(5)=14
 z=5
 gosub switch
return

ddek:
 a(1)=20
 a(2)=19
 a(3)=25
 a(4)=15
 z=4
 gosub switch
return

ddunu:
 a(1)=21
 a(2)=16
 a(3)=22
 z=3
 gosub switch
return

dddu:
 a(1)=22
 a(2)=21
 a(3)=23
 a(4)=17
 z=4
 gosub switch
return

ddtri:
 a(1)=23
 a(2)=22
 a(3)=24
 a(4)=18
 z=4
 gosub switch
return

ddkvar:
 a(1)=24
 a(2)=23
 a(3)=25
 a(4)=19
 z=4
 gosub switch
return

ddkvin:
 a(1)=25
 a(2)=24
 a(3)=20
 z=3
 gosub switch
return

switch:
mov=mov+1
caption 0, "Puzzle "+str$(lvl)+". You used " + str$(mov)+" / " +str$(req(lvl))+" necessary moves."
for x=1 to z
if klr(a(x))=0
 color a(x),255,255,255
 klr(a(x))=1
else
 color a(x),0,0,0
 klr(a(x))=0
end_if
next x
test$=""
for x=1 to 25
 test$=test$+str$(klr(x))
next x
if test$=doel$(lvl) then message "Congratulations!!"+ str$(mov)+" / " +str$(req(lvl))+" Up to the next level!":lvl=lvl+1:gosub init
return

init:
if lvl>24 then lvl=1
mov=0
for x=1 to 25
klr(x)=val(mid$(doel$(lvl),x,1))
if klr(x)=1
 color x+35, 255,255,255
else
 color x+35,0,0,0
end_if
next x
for x=1 to 25
klr(x)=val(mid$(level$(lvl),x,1))
if klr(x)=1
 color x,255, 255,255
else
 color x,0,0,0
end_if
next x
caption 0, "Puzzle "+str$(lvl)+". You used " + str$(mov)+" / " +str$(req(lvl))+" necessary moves."
return

chng:
 test$=doel$(lvl)
 doel$(lvl)=level$(lvl)
 level$(lvl)=test$
 gosub init
return

nxt:
lvl=lvl+1
if lvl>24 then lvl=1
gosub init
return

prv:
lvl=lvl-1
if lvl<1 then lvl=24
gosub init
return

abt:
message "'Lights' game. Developed by Lode Van de Velde."+chr$(13)+chr$(13)+"©️ 2012 EspoSoft <lodchjo@yahoo.com>"
return
Back to top Go down
 
"Lights" game
Back to top 
Page 1 of 1
 Similar topics
-
» A Sokoban game
» Where is the code for the checkers game on the site

Permissions in this forum:You cannot reply to topics in this forum
Discussion forum about PANORAMIC language :: Panoramic for Windows :: Source code (snippets)-
Jump to: