Removed due to stupid error (reserved word used as variable name)
Version 2 is uploaded
Memory game using touch statement; runs on all iDevices
-
- Posts: 814
- Joined: Tue Apr 09, 2013 12:23 pm
- My devices: iPhone,iPad
Windows - Location: Groningen, Netherlands
- Flag:
Memory game using touch statement; runs on all iDevices
Last edited by Henko on Mon May 06, 2013 12:16 pm, edited 1 time in total.
Re: Memory game using touch statement; runs on all iDevices
Nice Game Oldie
While trying it out in a 6x6 i got an
error message... ( see the attached
"print-screen" )
While trying it out in a 6x6 i got an
error message... ( see the attached
"print-screen" )
- Attachments
-
- image.jpg (172.26 KiB) Viewed 6287 times
-
- Posts: 814
- Joined: Tue Apr 09, 2013 12:23 pm
- My devices: iPhone,iPad
Windows - Location: Groningen, Netherlands
- Flag:
Re: Memory game using touch statement; runs on all iDevices
Welcome on this board Operator, even if it is to point at my bugs!Operator wrote:Nice Game Oldie
While trying it out in a 6x6 i got an
error message... ( see the attached
"print-screen" )
I knew about the bug,the remedy is to add the following statement in the function get_xy, just before the end def statement :
if xy(1)>size then xy(1)=size ! if xy(2)>size then xy(2)=size
Bugs are part of life!
If you have an iPad, try my oil company simulation game. It would be impossible to program that in Basic! for more than one reason.
Hope you pick up here!
Kind regards, henk O.
- Mr. Kibernetik
- Site Admin
- Posts: 4786
- Joined: Mon Nov 19, 2012 10:16 pm
- My devices: iPhone, iPad, MacBook
- Location: Russia
- Flag:
Re: Memory game using touch statement; runs on all iDevices
I implemented this fix, but still have similar errorHenko wrote:I knew about the bug,the remedy is to add the following statement in the function get_xy, just before the end def statement :
if xy(1)>size then xy(1)=size ! if xy(2)>size then xy(2)=size
-
- Posts: 814
- Joined: Tue Apr 09, 2013 12:23 pm
- My devices: iPhone,iPad
Windows - Location: Groningen, Netherlands
- Flag:
Re: Memory game using touch statement; runs on all iDevices
I am unable to reproduce the error, not on my iPad and not on my iPhone. And in fact the indices can never be lower than 1 and neve higher than "size" . I suspect that the error message is caused by another bug in the program (or in Basic?). I will investigate further.Mr. Kibernetik wrote:I implemented this fix, but still have similar errorHenko wrote:I knew about the bug,the remedy is to add the following statement in the function get_xy, just before the end def statement :
if xy(1)>size then xy(1)=size ! if xy(2)>size then xy(2)=size
- Mr. Kibernetik
- Site Admin
- Posts: 4786
- Joined: Mon Nov 19, 2012 10:16 pm
- My devices: iPhone, iPad, MacBook
- Location: Russia
- Flag:
Re: Memory game using touch statement; runs on all iDevices
I found what was the problem with this error.
Try touching top toolbar, and you will understand what happens - negative Y is allowed.
Try touching top toolbar, and you will understand what happens - negative Y is allowed.
-
- Posts: 814
- Joined: Tue Apr 09, 2013 12:23 pm
- My devices: iPhone,iPad
Windows - Location: Groningen, Netherlands
- Flag:
Re: Memory game using touch statement; runs on all iDevices
Thanks for debugging ☺ i'll look into it.Mr. Kibernetik wrote:I found what was the problem with this error.
Try touching top toolbar, and you will understand what happens - negative Y is allowed.
- rbytes
- Posts: 1338
- Joined: Sun May 31, 2015 12:11 am
- My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet - Location: Calgary, Canada
- Flag:
- Contact:
Re: Memory game using touch statement; runs on all iDevices
I am trying the memory game on my iPad Air, and I am finding that touching a square doesn't reveal that square. Sometimes the one revealed is the next one to the right of the one I touch, sometimes it is one down and one to the right.
The only thing that gets me down is gravity...
-
- Posts: 814
- Joined: Tue Apr 09, 2013 12:23 pm
- My devices: iPhone,iPad
Windows - Location: Groningen, Netherlands
- Flag:
Re: Memory game using touch statement; runs on all iDevices
You are right, i get the same error when using the code in the programs section. The version on my tablet has the correct behaviour. It's uploaded below.ricardobytes wrote:I am trying the memory game on my iPad Air, and I am finding that touching a square doesn't reveal that square. Sometimes the one revealed is the next one to the right of the one I touch, sometimes it is one down and one to the right.
Code: Select all
' Memory game using new touch statement (version june07,2015)
'
option base 1
dim m(8,8),xy(2)
gosub init_prog ' initialization
cls ! turns=0
tab_gen(m,t_size,sc) ' generate table with values
disp(m,t_size,sc) ' display the tableau
loop6:
get_xy(xy,t_size,sc) ' get first touch
i1=xy(1) ! j1=xy(2)
file "test_mem" print i1,j1
if m(i1,j1)>0 then loop6 ' already been guessed
disp_vak(m,i1,j1,sc,1) ' display in red (1)
pause .2 ' needed to separate two touches
loop7:
get_xy(xy,t_size,sc) ' get second touch
i2=xy(1) ! j2=xy(2)
if m(i2,j2)>0 then loop7 ' already been guessed
turns=turn(turns,t_size,sc) ' count turns and print them
if m(i1,j1)=m(i2,j2) then ' equal numbers!
suc=suc+1
m(i1,j1)=-m(i1,j1) ! m(i2,j2)=-m(i2,j2)
disp_vak(m,i2,j2,sc,0) ! disp_vak(m,i1,j1,sc,0)
else
disp_vak(m,i2,j2,sc,1) ! pause 1
fill_vak(i1,j1,sc,.5,.5,.5) ! fill_vak(i2,j2,sc,.5,.5,.5)
end if
if suc=t_size*t_size/2 then
draw text "Congratulations!!" at 5*sc,(10+12*t_size)*sc
pause 3 ! stop
end if
goto loop6
end
def turn(turns,t_size,sc)
turns=turns+1 ! t$=turns
y1=(5+12*t_size)*sc ! y2=(15+12*t_size)*sc
fill rect 5*sc,y1 to 40*sc,y2
draw text "turns : " & t$ at 5*sc,(5+12*t_size)*sc
turn=turns
end def
def disp_vak(m(,),i,j,sc,ind)
if ind=1 then
n$=-m(i,j) ! draw color .7,0,0
else
n$=m(i,j) ! draw color 0,.7,0
end if
fill_vak(i,j,sc,.8,.8,.8)
draw text n$ at (12*i-6)*sc,(12*j-7)*sc
end def
def fill_vak(i,j,sc,r,g,b)
fill color r,g,b
fill rect (12*i-9)*sc,(12*j-9)*sc to (1+12*i)*sc,(1+12*j)*sc
end def
def get_xy(xy(),t_size,sc)
loop_xy:
x=touch_x(0) ! y=touch_y(0) ! if y<0 then y=0
if x=-1 then loop_xy
xy(1)=1+floor(x/sc/12) ! xy(2)=1+floor(y/sc/12)
if xy(1)>t_size then xy(1)=t_size
if xy(2)>t_size then xy(2)=t_size
end def
def tab_gen(m(,),t_size,sc)
for k=1 to t_size*t_size/2
for d=1 to 2
loop5: i=1+rnd(t_size) ! j=1+rnd(t_size)
if m(i,j) then loop5 else m(i,j)=-k
next d
next k
draw size 3
for i=0 to t_size
draw line (2+12*i)*sc,2*sc to (2+12*i)*sc,(2+12*t_size)*sc
draw line 2*sc,(2+12*i)*sc to (2+12*t_size)*sc,(2+12*i)*sc
next i
end def
def disp(m(,),t_size,sc)
fill color .5,.5,.5
draw color 0,.5,0
draw font size 4*sc
graphics lock
for i=1 to t_size
for j=1 to t_size
if m(i,j)>0 then
n$=m(i,j)
draw text n$ at (12*i-6)*sc,(12*j-7)*sc
else
fill rect (12*i-9)*sc,(12*j-9)*sc to (1+12*i)*sc,(1+12*j)*sc
end if
next j
next i
graphics unlock
end def
def cls()
graphics clear .8,.8,.8
end def
init_prog:
randomize
graphics
cls
file "test_mem" delete
fill color .8,.8,.8 ! draw color 0,0,0
loop1:
maxx=screen_width() ! maxy=screen_height()
if maxx>maxy then
draw text "Please rotate to portrait" at 10,100
goto loop1
end if
cls
sc=maxx/100
draw text "Select size of tableau" at sc*10,sc*5
button "4" title "4x4" at sc*10,sc*20 size sc*15,40
button "6" title "6x6" at sc*40,sc*20 size sc*15,40
button "8" title "8x8" at sc*70,sc*20 size sc*15,40
loop2:
for i=4 to 8 step 2
i$=i
if button_pressed(i$) then loop3
next i
goto loop2
loop3:
t_size=i$
fill rect sc*10,sc*5 to sc*20,sc*8
button "4" delete ! button "6" delete ! button "8" delete !
return
- rbytes
- Posts: 1338
- Joined: Sun May 31, 2015 12:11 am
- My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet - Location: Calgary, Canada
- Flag:
- Contact:
Re: Memory game using touch statement; runs on all iDevices
Nice game! My memory turns out to be wonderful, but very short.
The only thing that gets me down is gravity...