The goal is to end up with only one frog. FIrst you touch a frog, then an empty Lilly pad to jump to. One lilly pad will be randomly empty when game starts, You can only jump over one frog, which will remove it. The game will highlight available pads to jump to.
Hope you enjoy playing it. This is the first thing I've coded in a long while, and it was fun to make. I don't think it's too bad for a couple hours work. If you have questions or suggestions please post them.
Note: The instructions and insult names in the game I got/adapted from the wooden peg game in the restaurant, I think 'Egnoramoose' means ignorant, which is the level I get to most of the time...
- Dav
Code: Select all
'Frogjump.txt v1.1 (ipad/iphone)
'A triangle peg jump type puzzle game
'Coded by Dav, SEP/2017
'HOW TO PLAY: Tap on a frog and jump over another.
'You can only jump to an empty spot, and over 1 frog.
'The goal is to get rid of as many frogs as possible.
'Leave only ONE frog to beat the game and be a genius.
'Credits: Used rbytes all devices method/code.
'initialize program
randomize
option base 1
set toolbar off
get orientation ort
set orientation vertical
get screen size sw,sh
'detect device for screen settings
if lowstr$(device_type$())="ipad" then
rw=1!rh=1
else
rw=sw/768!rh=sh/1024
end if
graphics
graphics clear 0,.5,0
'======
restart:
'======
x$=chr$(58673) 'frog emoji
'make an array for button data, 15 frogs
dim bv$(15)!for t=1 to 15!bv$(t)=x$!next t
'mark one random button empty
bv$(rnd(15)+1)=""
gosub drawinfo 'show title, instructions
'make a restart button
set buttons custom
set buttons font size 36*rw
draw color 0,0,1
fill color 1,1,0
button "restart" text "restart" at 325*rw,900*rh
'make a quit button
draw color 0,0,0
fill color 1,.5,.5
button "quit" text "Quit" at 25*rw,25*rh
'===
main: 'main loop...
'===
selected=0
gosub drawboard
gosub checkifmovesleft
second:
do
for t=1 to 16
if button_pressed(str$(t)) then
'if first choice...
if selected=0 then
'only select an x$ (frog) pad
if bv$(t)=x$ then
selected=1 ! selbtn=t ! but(t)
'show jump options
gosub showjumps
notes set "115:sg7"!notes play
goto second 'now get second choice
end if
else 'making second choice
'only jump to blank pads
if bv$(t)="" then
gosub checkandmove
notes set "125:sab"!notes play
'notes set "120:tg1a"!notes play
goto main
else
'clear previous highlighted btn
selected=0!gosub drawboard!selected=1
'set new one now...
selbtn=t!but(t)
gosub showjumps
notes set "115:sg7"!notes play
goto second
end if
end if
end if
next t
if button_pressed("restart") then goto restart
if button_pressed("quit") then
set orientation ort ! end
end if
until 0
end
'===========
checkandmove:
'===========
'====== logic for btn 1
if selbtn=1 then
if t=4 then
if bv$(2)=x$ then
bv$(1)=""!bv$(2)=""!bv$(4)=x$
end if
end if
if t=6 then
if bv$(3)=x$ then
bv$(1)=""!bv$(3)=""!bv$(6)=x$
end if
end if
end if
'====== logic for btn 2
if selbtn=2 then
if t=7 then
if bv$(4)=x$ then
bv$(2)=""!bv$(4)=""!bv$(7)=x$
end if
end if
if t=9 then
if bv$(5)=x$ then
bv$(2)=""!bv$(5)=""!bv$(9)=x$
end if
end if
end if
'====== logic for btn 3
if selbtn=3 then
if t=8 then
if bv$(5)=x$ then
bv$(3)=""!bv$(5)=""!bv$(8)=x$
end if
end if
if t=10 then
if bv$(6)=x$ then
bv$(3)=""!bv$(6)=""!bv$(10)=x$
end if
end if
end if
'====== logic for btn 4
if selbtn=4 then
if t=1 then
if bv$(2)=x$ then
bv$(4)=""!bv$(2)=""!bv$(1)=x$
end if
end if
if t=6 then
if bv$(5)=x$ then
bv$(4)=""!bv$(5)=""!bv$(6)=x$
end if
end if
if t=13 then
if bv$(8)=x$ then
bv$(4)=""!bv$(8)=""!bv$(13)=x$
end if
end if
if t=11 then
if bv$(7)=x$ then
bv$(4)=""!bv$(7)=""!bv$(11)=x$
end if
end if
end if
'====== logic for btn 5
if selbtn=5 then
if t=12 then
if bv$(8)=x$ then
bv$(5)=""!bv$(8)=""!bv$(12)=x$
end if
end if
if t=14 then
if bv$(9)=x$ then
bv$(5)=""!bv$(9)=""!bv$(14)=x$
end if
end if
end if
'====== logic for btn 6
if selbtn=6 then
if t=1 then
if bv$(3)=x$ then
bv$(6)=""!bv$(3)=""!bv$(1)=x$
end if
end if
if t=4 then
if bv$(5)=x$ then
bv$(6)=""!bv$(5)=""!bv$(4)=x$
end if
end if
if t=13 then
if bv$(9)=x$ then
bv$(6)=""!bv$(9)=""!bv$(13)=x$
end if
end if
if t=15 then
if bv$(10)=x$ then
bv$(6)=""!bv$(10)=""!bv$(15)=x$
end if
end if
end if
'====== logic for btn 7
if selbtn=7 then
if t=2 then
if bv$(4)=x$ then
bv$(7)=""!bv$(4)=""!bv$(2)=x$
end if
end if
if t=9 then
if bv$(8)=x$ then
bv$(7)=""!bv$(8)=""!bv$(9)=x$
end if
end if
end if
'====== logic for btn 8
if selbtn=8 then
if t=3 then
if bv$(5)=x$ then
bv$(8)=""!bv$(5)=""!bv$(3)=x$
end if
end if
if t=10 then
if bv$(9)=x$ then
bv$(8)=""!bv$(9)=""!bv$(10)=x$
end if
end if
end if
'====== logic for btn 9
if selbtn=9 then
if t=2 then
if bv$(5)=x$ then
bv$(9)=""!bv$(5)=""!bv$(2)=x$
end if
end if
if t=7 then
if bv$(8)=x$ then
bv$(9)=""!bv$(8)=""!bv$(7)=x$
end if
end if
end if
'====== logic for btn 10
if selbtn=10 then
if t=8 then
if bv$(9)=x$ then
bv$(10)=""!bv$(9)=""!bv$(8)=x$
end if
end if
if t=3 then
if bv$(6)=x$ then
bv$(10)=""!bv$(6)=""!bv$(3)=x$
end if
end if
end if
'====== logic for btn 11
if selbtn=11 then
if t=4 then
if bv$(7)=x$ then
bv$(11)=""!bv$(7)=""!bv$(4)=x$
end if
end if
if t=13 then
if bv$(12)=x$ then
bv$(11)=""!bv$(12)=""!bv$(13)=x$
end if
end if
end if
'====== logic for btn 12
if selbtn=12 then
if t=5 then
if bv$(8)=x$ then
bv$(12)=""!bv$(8)=""!bv$(5)=x$
end if
end if
if t=14 then
if bv$(13)=x$ then
bv$(12)=""!bv$(13)=""!bv$(14)=x$
end if
end if
end if
'====== logic for btn 13
if selbtn=13 then
if t=4 then
if bv$(8)=x$ then
bv$(13)=""!bv$(8)=""!bv$(4)=x$
end if
end if
if t=6 then
if bv$(9)=x$ then
bv$(13)=""!bv$(9)=""!bv$(6)=x$
end if
end if
if t=11 then
if bv$(12)=x$ then
bv$(13)=""!bv$(12)=""!bv$(11)=x$
end if
end if
if t=15 then
if bv$(14)=x$ then
bv$(13)=""!bv$(14)=""!bv$(15)=x$
end if
end if
end if
'====== logic for btn 14
if selbtn=14 then
if t=5 then
if bv$(9)=x$ then
bv$(14)=""!bv$(9)=""!bv$(5)=x$
end if
end if
if t=12 then
if bv$(13)=x$ then
bv$(14)=""!bv$(13)=""!bv$(12)=x$
end if
end if
end if
'====== logic for btn 15
if selbtn=15 then
if t=6 then
if bv$(10)=x$ then
bv$(15)=""!bv$(10)=""!bv$(6)=x$
end if
end if
if t=13 then
if bv$(14)=x$ then
bv$(15)=""!bv$(14)=""!bv$(13)=x$
end if
end if
end if
return
'========
showjumps:
'========
if selbtn=1 then
if bv$(2)=x$ and bv$(4)="" then but(4)
if bv$(3)=x$ and bv$(6)="" then but(6)
end if
if selbtn=2 then
if bv$(4)=x$ and bv$(7)="" then but(7)
if bv$(5)=x$ and bv$(9)="" then but(9)
end if
if selbtn=3 then
if bv$(5)=x$ and bv$(8)="" then but(8)
if bv$(6)=x$ and bv$(10)="" then but(10)
end if
if selbtn=4 then
if bv$(2)=x$ and bv$(1)="" then but(1)
if bv$(5)=x$ and bv$(6)="" then but(6)
if bv$(7)=x$ and bv$(11)="" then but(11)
if bv$(8)=x$ and bv$(13)="" then but(13)
end if
if selbtn=5 then
if bv$(8)=x$ and bv$(12)="" then but(12)
if bv$(9)=x$ and bv$(14)="" then but(14)
end if
if selbtn=6 then
if bv$(3)=x$ and bv$(1)="" then but(1)
if bv$(9)=x$ and bv$(13)="" then but(13)
if bv$(5)=x$ and bv$(4)="" then but(4)
if bv$(10)=x$ and bv$(15)="" then but(15)
end if
if selbtn=7 then
if bv$(4)=x$ and bv$(2)="" then but(2)
if bv$(8)=x$ and bv$(9)="" then but(9)
end if
if selbtn=8 then
if bv$(5)=x$ and bv$(3)="" then but(3)
if bv$(9)=x$ and bv$(10)="" then but(10)
end if
if selbtn=9 then
if bv$(5)=x$ and bv$(2)="" then but(2)
if bv$(8)=x$ and bv$(7)="" then but(7)
end if
if selbtn=10 then
if bv$(9)=x$ and bv$(8)="" then but(8)
if bv$(6)=x$ and bv$(3)="" then but(3)
end if
if selbtn=11 then
if bv$(7)=x$ and bv$(4)="" then but(4)
if bv$(12)=x$ and bv$(13)="" then but(13)
end if
if selbtn=12 then
if bv$(8)=x$ and bv$(5)="" then but(5)
if bv$(13)=x$ and bv$(14)="" then but(14)
end if
if selbtn=13 then
if bv$(8)=x$ and bv$(4)="" then but(4)
if bv$(9)=x$ and bv$(6)="" then but(6)
if bv$(14)=x$ and bv$(15)="" then but(15)
if bv$(12)=x$ and bv$(11)="" then but(11)
end if
if selbtn=14 then
if bv$(9)=x$ and bv$(5)="" then but(5)
if bv$(13)=x$ and bv$(12)="" then but(12)
end if
if selbtn=15 then
if bv$(10)=x$ and bv$(6)="" then but(6)
if bv$(14)=x$ and bv$(13)="" then but(13)
end if
return
'========
drawboard:
'========
draw color 0,0,1
fill color 1,1,1
for b=1 to 15
but(b)
next b
return
'=======
drawinfo:
'=======
'a litte background
for y = 1 to 500
'draw text chr$(58435) at rnd(sw)*rw,rnd(sh)*rh
next y
'draw screen info
draw color .7,1,.7
draw font size 36*rw
draw text "FROG JUMP PUZZLE" at 230*rw,30*rh
draw font size 24*rw
draw text "(Touch frog to move, then the pad to jump to)" at 60*rw,650*rh
draw text "Jump all but one frog." at 240*rw,700*rh
draw text "Jump each frog to remove it." at 200*rw, 725*rh
draw text "Leave only one -- you're a genius." at 155*rw,750*rh
draw text "Leave two and you're pretty smart." at 155*rw,775*rh
draw text "Leave three and you are just plain dumb." at 125*rw,800*rh
draw text "Leave four or more and you're just a plain" at 95*rw,825*rh
draw text "EG-NO-RA-MOOSE!" at 265*rw,850*rh
return
'===============
checkifmovesleft:
'===============
'if no moves left, restart
if movesleft= 0 then
'count how many frogs left
bc=0
for b=1 to 15
if bv$(b)=x$ then bc=bc+1
next b
'show number
set buttons font size 36*rw
draw color 1,1,1
fill color 0,0,1
tx$=str$(bc)&" left = "
if bc>3 then tx$=tx$&"EGNORAMOOSE!"
if bc=3 then tx$=tx$&"Plain Dumb!"
if bc=2 then tx$=tx$&"Pretty Smart!"
if bc=1 then tx$=tx$&"GENIUS!"
tl=text_width(tx$)
button "over" text tx$ at (sw/2-(tl/2))*rw,(sh/2-100)*rh
'notes set "111:h(d3fa)(dga#)(dfa)"
'notes play ! pause 3
button "over" delete
goto restart
end if
return
'===============================
def but(n) 'draws puzzle buttons
draw color 0,1,0
set buttons font size 56*.rw
set buttons custom
if .selected = 1 then
fill color .5,1,.5
else
fill color 0,.8,0
end if
if n=1 then button n text .bv$(n) at 350*.rw,100*.rh size 80*.rw,80*.rh
if n=2 then button n text .bv$(n) at 270*.rw,210*.rh size 80*.rw,80*.rh
if n=3 then button n text .bv$(n) at 430*.rw,210*.rh size 80*.rw,80*.rh
if n=4 then button n text .bv$(n) at 190*.rw,320*.rh size 80*.rw,80*.rh
if n=5 then button n text .bv$(n) at 350*.rw,320*.rh size 80*.rw,80*.rh
if n=6 then button n text .bv$(n) at 510*.rw,320*.rh size 80*.rw,80*.rh
if n=7 then button n text .bv$(n) at 110*.rw,430*.rh size 80*.rw,80*.rh
if n=8 then button n text .bv$(n) at 270*.rw,430*.rh size 80*.rw,80*.rh
if n=9 then button n text .bv$(n) at 430*.rw,430*.rh size 80*.rw,80*.rh
if n=10 then button n text .bv$(n) at 590*.rw,430*.rh size 80*.rw,80*.rh
if n=11 then button n text .bv$(n) at 30*.rw,540*.rh size 80*.rw,80*.rh
if n=12 then button n text .bv$(n) at 190*.rw,540*.rh size 80*.rw,80*.rh
if n=13 then button n text .bv$(n) at 350*.rw,540*.rh size 80*.rw,80*.rh
if n=14 then button n text .bv$(n) at 510*.rw,540*.rh size 80*.rw,80*.rh
if n=15 then button n text .bv$(n) at 670*.rw,540*.rh size 80*.rw,80*.rh
end def
'=================
def movesleft
'returns 1 if any moves left on board
m=0 'default to no moves left
'btn 1
if .bv$(1)=.x$ and .bv$(2)=.x$ and .bv$(4)="" then m=1
if .bv$(1)=.x$ and .bv$(3)=.x$ and .bv$(6)="" then m=1
'btn2
if .bv$(2)=.x$ and .bv$(4)=.x$ and .bv$(7)="" then m=1
if .bv$(2)=.x$ and .bv$(5)=.x$ and .bv$(9)="" then m=1
'btn 3
if .bv$(3)=.x$ and .bv$(5)=.x$ and .bv$(8)="" then m=1
if .bv$(3)=.x$ and .bv$(6)=.x$ and .bv$(10)="" then m=1
'btn 4
if .bv$(4)=.x$ and .bv$(2)=.x$ and .bv$(1)="" then m=1
if .bv$(4)=.x$ and .bv$(5)=.x$ and .bv$(6)="" then m=1
if .bv$(4)=.x$ and .bv$(7)=.x$ and .bv$(11)="" then m=1
if .bv$(4)=.x$ and .bv$(8)=.x$ and .bv$(13)="" then m=1
'btn 5
if .bv$(5)=.x$ and .bv$(8)=.x$ and .bv$(12)="" then m=1
if .bv$(5)=.x$ and .bv$(9)=.x$ and .bv$(14)="" then m=1
'btn 6
if .bv$(6)=.x$ and .bv$(3)=.x$ and .bv$(1)="" then m=1
if .bv$(6)=.x$ and .bv$(9)=.x$ and .bv$(13)="" then m=1
if .bv$(6)=.x$ and .bv$(5)=.x$ and .bv$(4)="" then m=1
if .bv$(6)=.x$ and .bv$(10)=.x$ and .bv$(15)="" then m=1
'btn 7
if .bv$(7)=.x$ and .bv$(4)=.x$ and .bv$(2)="" then m=1
if .bv$(7)=.x$ and .bv$(8)=.x$ and .bv$(9)="" then m=1
'btn 8
if .bv$(8)=.x$ and .bv$(5)=.x$ and .bv$(3)="" then m=1
if .bv$(8)=.x$ and .bv$(9)=.x$ and .bv$(10)="" then m=1
'btn 9
if .bv$(9)=.x$ and .bv$(5)=.x$ and .bv$(2)="" then m=1
if .bv$(9)=.x$ and .bv$(8)=.x$ and .bv$(7)="" then m=1
'btn 10
if .bv$(10)=.x$ and .bv$(9)=.x$ and .bv$(8)="" then m=1
if .bv$(10)=.x$ and .bv$(6)=.x$ and .bv$(3)="" then m=1
'btn 11
if .bv$(11)=.x$ and .bv$(7)=.x$ and .bv$(4)="" then m=1
if .bv$(11)=.x$ and .bv$(12)=.x$ and .bv$(13)="" then m=1
'btn 12
if .bv$(12)=.x$ and .bv$(8)=.x$ and .bv$(5)="" then m=1
if .bv$(12)=.x$ and .bv$(13)=.x$ and .bv$(14)="" then m=1
'btn 13
if .bv$(13)=.x$ and .bv$(8)=.x$ and .bv$(4)="" then m=1
if .bv$(13)=.x$ and .bv$(9)=.x$ and .bv$(6)="" then m=1
if .bv$(13)=.x$ and .bv$(14)=.x$ and .bv$(15)="" then m=1
if .bv$(13)=.x$ and .bv$(12)=.x$ and .bv$(11)="" then m=1
'btn 14
if .bv$(14)=.x$ and .bv$(9)=.x$ and .bv$(5)="" then m=1
if .bv$(14)=.x$ and .bv$(13)=.x$ and .bv$(12)="" then m=1
'btn 15
if .bv$(15)=.x$ and .bv$(10)=.x$ and .bv$(6)="" then m=1
if .bv$(15)=.x$ and .bv$(14)=.x$ and .bv$(13)="" then m=1
.movesleft=m
end def