SimpleMind v1.0 - A simple Memory game (iPad only)

Post Reply
User avatar
Dav
Posts: 279
Joined: Tue Dec 30, 2014 5:12 pm
My devices: iPad Mini, iPod Touch.
Location: North Carolina, USA
Contact:

SimpleMind v1.0 - A simple Memory game (iPad only)

Post by Dav »

I made this for a friend. It's a simple memory game. Match pairs of pictures to remove them. Clear the board. There's one catch, if you uncover the clock picture, a timer will start and you will only have 60 seconds to clear the board or you will loose.

I used emoji for all the pictures.

- Dav

Code: Select all

'SimpleMind.txt
'A simple memory game.
'Find matching pics to clear the board.
'Find the timer and you'll have only 60 seconds left!
'Coded by Dav, SEP/2017

'NOTE: Only for ipad right now....

if lowstr$(device_type$())<>"ipad" then
  print "Sorry, game for iPad only."
  end
end if

randomize

option base 1

'======
restart:
'======

graphics
graphics clear

set buttons custom
set buttons font size 100
draw color .5,.5,.5
fill color 1,1,.8

'make data for 49 buttons
dim bv$(49) ! bv$(1)=chr$(57381) 'mark one as. timer
'fill the rest with emoji
c=2
for b=57350 to 57350+23
  bv$(c)=chr$(b) ! bv$(c+1)=chr$(b)
  c=c+2
next b

timer=0

'shuffle data up
for ctr = 1 to 49
  a=int(rnd(49))+1
  b=int(rnd(49))+1
  'swap those positions
  a$=bv$(a)!b$=bv$(b)
  bv$(a)=b$!bv$(b)=a$
next ctr

'draw buttons 
'keep x,y values
dim bx(49)!dim by(49)
bc=1
for x=30 to 650 step 100
   for y=130 to 800 step 100
     bx(bc)=x!by(bc)=y 'store x/y positions
     button str$(bc) text "?" at x,y size 100,100
     button str$(bc) show
     bc=bc+1
   next y
next x

'make giveup button
set buttons font size 56
button "giveup" text "Give up" at 275,875
set buttons font size 100

found=0

'===
main:
'===

selected=0
second:

do
  for t = 1 to 49
   if button_pressed(str$(t)) then

        'show button
        button str$(t) text bv$(t) at bx(t),by(t) size 100,100
        notes stop!notes set "115:sg7"!notes play

       if bv$(t)=chr$(57381) then 
          if timer=0 then
             found=found+1 
             timer=1!time reset
             notes stop!notes set "124:ha2"!notes play
             pause 1
          end if
          goto second
       end if

       'if first choice...
       if selected=0 then
          selected=1 ! selbtn=t 
          goto second  'now get second choice
       else  'making second choice
          pause .6
          'if both same....
          if bv$(t)=bv$(selbtn) and t<>selbtn then
            notes stop!notes set "116:qa6"!notes play
            'then hide them both
            button selbtn hide
            button t hide
            found=found+2
            goto main
          else
            button selbtn text "?" at bx(selbtn),by(selbtn) size 100,100
            button t text "?" at bx(t),by(t) size 100,100
            'notes set "125:sab"!notes play
            goto main
          end if
       end if

   end if
  next t
  if timer=1 then
    newtime=int(time())
    if newtime>59 then goto loser
    'only update every second, not comstantly
    if newtime<>oldtime then
      oldtime=newtime
      refresh off
      graphics clear
      draw color 1,0,0
      draw font size 56
      draw text str$(60-newtime)&" seconds left..." at 80,40
      draw color .5,.5,.5
      refresh on
    end if
  end if

  if found>47 then goto win '(allow for timer not found)

  if button_pressed("giveup") then goto loser

until 0

end

'===
win:
'===

graphics clear
draw font size 56
draw color 0,0,1
draw text "Good Job!" at 200,400

pause 4

goto restart


'====
loser:
'====

graphics clear
draw font size 56
draw color 0,0,0
draw text "You lost..." at 200,400
for t=1 to 49
   button str$(t) delete
   notes set "116:qa6"!notes play
   pause .035
next t

pause 4

goto restart
Attachments
Simplemind.jpg
Simplemind.jpg (100.2 KiB) Viewed 3122 times

Post Reply