Birth of a game
Posted: Sat Sep 15, 2018 10:22 am
Found on internet. Interesting game.
This is just a working setup of the game, kind of template.
In a couple of days i hope to have coded the remaining functions.
This is just a working setup of the game, kind of template.
In a couple of days i hope to have coded the remaining functions.
Code: Select all
' digipuzzle (from internet)
' rules of the game:
' - fill each empty cell with a 0 or 1
' - at most two equal numbers next to each other (hor. or vert.)
' - each row and column must have an equal number of 0's and 1's
' - rows and columns must be unique
' touching a cell changes its content cylclic into blank, 0, and 1
'
option base 1
input "size of puzzle: ":N ' = number of rows and columns
N=min(12,2*floor(N/2)) ! m=N/2 ! ds=60
dim v$(N,N)
gui_init()
do
make_new_puzzle()
do
fld$=get_user_event$()
event_handler(fld$)
until puzzle_solved()
until next_puzzle()
end
def gui_init()
graphics ! graphics clear 1,1,1 ! draw color 0,0,0 ! draw size 3
for i=0 to .N
draw line 20,20+60*i to 20+60*.N,20+60*i
draw line 20+60*i,20 to 20+60*i,20+60*.N
next i
for i=1 to .N ! for j=1 to .N
field i&"-"&j text "" at 21+60*(j-1),21+60*(i-1) size 58,58
field i&"-"&j font size 30
next j ! next i
end def
def make_new_puzzle() ' generate a new valid digipuzzle
end def
def get_user_event$() ' returns touched field or stop
end def
def event_handler(f$) ' process puzzle progress
end def
def puzzle_solved() ' check if correctly completed
end def
def next_puzzle() ' returns 1 if user wants another one
end def