I am happy to supply my
frogger templater no media required
video shown below of what I did with it
and available free from google play here
https://play.google.com/store/apps/details?id=my.frogger
This version uses mouse to move but easy enough to change to keyboard
// Project: Frogger Template by fubarpk
// Created: 2017-03-22
#constant xMax=1024
#constant yMax=600
#constant timePerGame=120
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "Frogger" )
SetWindowSize( xMax,yMax,0)
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( xMax, yMax ) // doesn't have to match the window
SetOrientationAllowed( 0, 0, 1, 1 ) //
//SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
playFrogger()
end
function playFrogger()
deleteSprite(900)
//createSprite(900,ellipse)
createSprite(900,0)
setSpritecolor(900,0,0,0,255)
SetSpriteSize(900,xMax,yMax)
SetSpriteDepth(900,9997)
//SetSpritePositionByOffset(900,xMax/2,yMax/2)
//DeleteSprite(901)
repeat
Print ("My Frogger template click mouse to Play")
sync()
until GetPointerState() = 1 //click mouse to play
high=0:score=0:bonusTime=0
bonusTime$="Time Left :"+str(bonusTime)
CreateText(1,bonusTime$)
SetTextSize(1,40)
SetTextPosition(1,10,0)
myHigh$="High :"+str(high)
CreateText(2,myHigh$)
SetTextSize(2,40)
SetTextDepth(2,0)
SetTextPosition(2,600,0)
myScore$="Score:"+str(score)
CreateText(3,myScore$)
SetTextSize(3,40)
SetTextDepth(3,0)
SetTextPosition(3,820,0)
frogSpr = CreateSprite(0)
SetSpriteSize(frogSpr,64,64)
changeFrogColor(frogSpr,1)
SetSpriteDepth(frogSpr,15)
do
elapsedTime#=Timer()
resetTimer()
repeat
SetSpriteDepth(900,10000)
score=crossRoadLevel(frogSpr,score)
if high<score then high = score
myScore$="Score:"+str(score):myHigh$="High :"+str(high)
SetTextString(2,myHigh$):SetTextString(3,myScore$)
sync()
//resetTimer()
score=crossRiverLevel(frogSpr,score)
if high<score then high = score
myScore$="Score:"+str(score):myHigh$="High :"+str(high)
SetTextString(2,myHigh$):SetTextString(3,myScore$)
//SetSpriteDepth(901,9998):SetSpriteDepth(902,9999)
SetSpriteAngle(frogSpr,0)
sync()
elapsedTime#=Timer()
until elapsedTime#>timePerGame //limited time per attempt
sync()
setSpritecolor(900,0,0,0,255)
gameOver()
score=0:changeFrogColor(frogSpr,1)
myScore$="Score:"+str(score)
SetTextString(3,myScore$)
loop
endfunction
function crossRoadLevel(frogSpr as integer,score as integer)
setSpritecolor(900,150,150,150,255)
for num = 1 to 5
DeleteSprite(num):deleteSprite(num+5):deleteSprite(num+10)
DeleteSprite(num+15):DeleteSprite(num+20)
rem top road moving right cars and trucks
createSprite(num,0)
SetSpriteSize(num,60,128)
SetSpriteColor(num,Random(1,255),Random(1,255),Random(1,255),255)
SetSpriteAngle(num,90)
createSprite(num+5,0)
SetSpriteSize(num+5,60,148)
SetSpriteColor(num+5,Random(1,255),Random(1,255),Random(1,255),255)
SetSpriteAngle(num+5,90)
rem bottom road moving left cars and trucks
createSprite(num+10,0)
SetSpriteSize(num+10,60,128)
SetSpriteColor(num+10,Random(1,255),Random(1,255),Random(1,255),255)
SetSpriteAngle(num+10,270)
createSprite(num+15,0)
SetSpriteSize(num+15,60,148)
SetSpriteColor(num+15,Random(1,255),Random(1,255),Random(1,255),255)
SetSpriteAngle(num+15,270)
placeVehicles(num)
next num
changeColor=placeBonusFruit(500)
SetSpriteDepth(frogSpr,15)
SetSpritePositionByOffset(frogSpr,xMax/2,yMax-40)
x#=GetSpriteXByOffset (frogSpr)
y#=GetSpriteYByOffset (frogSpr)
newx#=0:newy#=0
time#=timer()
repeat
until timer()-time#>1
FrogAnimNum=1
SetSpritePositionByOffset(frogSpr,xMax/2,yMax-40)
//PlaySprite( frogSpr, 10, 0, FrogAnimNum, FrogAnimNum )
SetSpriteAngle(frogSpr,0)
bonusTime=timePerGame-timer()
while GetSpriteYByOffset(frogSpr)-35>0 and bonusTime >0
bonusTime$="Time Left :"+str(bonusTime)
SetTextString(1,bonusTime$)
//if mouse pointer is down then move frogSpr towards it
if GetPointerState() = 1
//if GetSpritePlaying(frogSpr)=0 then PlaySprite( frogSpr, 5, 0, frogAnimNum,frogAnimNum+2 )
ft# = getFrameTime()*2
x#=GetPointerX():y# = GetPointerY()
cx#=GetSpriteXByOffset(frogSpr):cy# = getSpriteYbyOffset(frogSpr)
newx# = cx#-(cx#-x#)*ft#:newy# = cy#-(cy#-y#)*ft#
SetSpriteAngle(frogSpr,getAngle(x#,y#,cx# ,cy#))
SetSpritePositionByOffset(frogSpr,newx#,newy#)
endif
//if GetSpritePlaying(frogSpr)=0 then PlaySprite( frogSpr, 6, 0, frogAnimNum,frogAnimNum )
if moveVehicles(frogSpr)=1
//if GetSoundInstancePlaying(1)=0 then playSound(1,100,0)
time#=timer()
repeat
a=moveVehicles(frogSpr)
sync()
until timer()-time#>1
SetSpritePositionByOffset(frogSpr,xMax/2,yMax-40)
SetSpriteAngle(frogSpr,0)
endif
If GetSpriteCollision(frogSpr,500)=1 and GetSpriteVisible(500)=1
changeFrogColor(frogSpr,changeColor)
score=score+250
myScore$="Score:"+str(score)
SetTextString(3,myScore$)
SetSpriteVisible(500,0)
//if GetSoundInstancePlaying(2)=0 then PlaySound(2)
endif
//Print( ScreenFPS() )
bonusTime=timePerGame-timer()
Sync()
endwhile
if bonusTime>0 then score=score+(10*bonusTime)
endfunction score
function crossRiverLevel(frogSpr as integer,score as integer)
setSpritecolor(900,0,0,140,255)
rem y=105:y=210:y=395:y=495
for num = 1 to 5
DeleteSprite(num):deleteSprite(num+5):deleteSprite(num+10)
DeleteSprite(num+15):DeleteSprite(num+20)
rem top road moving
createSprite(num,0)
SetSpriteColor(num,139,69,19,255)
SetSpriteSize(num,128,64)
SetSpriteDepth(num,20)
createSprite(num+5,0)
SetSpriteColor(num+5,139,69,19,255)
SetSpriteSize(num+5,186,64)
SetSpriteDepth(num+5,20)
rem bottom river moving left Logs
CreateSprite(num+10,0)
SetSpriteColor(num+10,139,69,19,255)
SetSpriteSize(num+10,186,64)
SetSpriteDepth(num+10,20)
CreateSprite(num+15,0)
SetSpriteColor(num+15,139,69,19,255)
SetSpriteSize(num+15,128,64)
SetSpriteDepth(num+15,20)
rem 5 crocodiles
CreateSprite(num+20,0)
SetSpriteColor(num+20,128,128,128,255)
SetSpriteSize(num+20,128,64)
SetSpriteDepth(num+20,20)
placeLogs(num)
next num
//change colour of frog if eats fruit
changeColor=placeBonusFruit(500)
SetSpriteDepth(frogSpr,15)
//SetSpriteAnimation(frogSpr,96,96,18)
//PlaySprite( frogSpr, 10, 0, FrogAnimNum, FrogAnimNum )
time#=timer()
repeat
until timer()-time#>1
SetSpritePositionByOffset(frogSpr,xMax/2,yMax-40)
//PlaySprite( frogSpr, 10, 0, FrogAnimNum, FrogAnimNum )
SetSpriteAngle(frogSpr,0)
bonusTime=timePerGame-timer()
while GetSpriteYByOffset(frogSpr)-35>0 and bonusTime >0
bonusTime$="Time Left :"+str(bonusTime)
SetTextString(1,bonusTime$)
//if mouse pointer is down then move frogSpr towards it
if GetPointerState() = 1
//if GetSpritePlaying(frogSpr)=0 then PlaySprite( frogSpr, 5, 0, frogAnimNum,frogAnimNum+2 )
ft# = getFrameTime()*2
x#=GetPointerX():y# = GetPointerY()
cx#=GetSpriteXByOffset(frogSpr):cy# = getSpriteYbyOffset(frogSpr)
newx# = cx#-(cx#-x#)*ft#:newy# = cy#-(cy#-y#)*ft#
SetSpriteAngle(frogSpr,getAngle(x#,y#,cx# ,cy#))
SetSpritePositionByOffset(frogSpr,newx#,newy#)
endif
//if GetSpritePlaying(frogSpr)=0 then PlaySprite( frogSpr, 6, 0, frogAnimNum,frogAnimNum )
rem move logs go here 30 568
//a=moveLogs(frogSpr)
if moveLogs(frogSpr)=0 and GetSpriteYByOffset(frogSpr)<536 and GetSpriteYByOffset(frogSpr)>50
//if GetSoundInstancePlaying(3)=0 then PlaySound(3)
time#=timer()
repeat
a=moveLogs(frogSpr)
sync()
until timer()-time#>1
SetSpritePositionByOffset(frogSpr,xMax/2,yMax-40)
SetSpriteAngle(frogSpr,0)
endif
if GetSpriteXByOffset(frogSpr)<0 or GetSpriteXByOffset(frogSpr)>xMax
//if GetSoundInstancePlaying(3)=0 then PlaySound(3):rem change later
time#=timer()
repeat
a=moveLogs(frogSpr)
sync()
until timer()-time#>1
SetSpritePositionByOffset(frogSpr,xMax/2,yMax-40)
SetSpriteAngle(frogSpr,0)
endif
If GetSpriteCollision(frogSpr,500)=1 and GetSpriteVisible(500)=1
changeFrogColor(frogSpr,changeColor)
score=score+250
myScore$="Score:"+str(score)
SetTextString(3,myScore$)
SetSpriteVisible(500,0)
//if GetSoundInstancePlaying(2)=0 then PlaySound(2)
endif
bonusTime=timePerGame-timer()
sync()
endwhile
if bonusTime>0 then score=score+(10*bonusTime)
endfunction score
function getAngle(x1#, y1#, x2#, y2#)
result# = ATanFull(x1# - x2#, y1# - y2#)
endfunction result#
function placeVehicles(num as integer)
//randomly place vehicles watching/repeating for collisions
rem y=105:y=210:y=395:y=495
SetSpritePositionByOffset(num,random2(-xMax,xMax),105)
SetSpritePositionByOffset(num+5,random2(-xMax,xMax),210)
SetSpritePositionByOffset(num+10,random2(xMax,xMax*2),395)
SetSpritePositionByOffset(num+15,random2(xMax,xMax*2),495)
for check= 1 to num
while GetSpriteCollision(num,check)=1 and num <> check
SetSpritePositionByOffset(num,random2(-xMax,xMax),105)
check=1
endwhile
while GetSpriteCollision(num+5,check+5)=1 and num <> check
SetSpritePositionByOffset(num+5,random2(-xMax,xMax),210)
check=1
endwhile
while GetSpriteCollision(num+10,check+10)=1 and num <> check
SetSpritePositionByOffset(num+10,random2(0,xMax*2),395)
check=1
endwhile
while GetSpriteCollision(num+15,check+15)=1 and num <> check
SetSpritePositionByOffset(num+15,random2(0,xMax*2),495)
check=1
endwhile
next check
endfunction
function moveVehicles(frogSpr as integer)
collision=0
for num = 1 to 5
SetSpritePositionByOffset(num,(GetSpriteXByOffset(num)+4),GetSpriteYByOffset(num))
if GetSpriteXByOffset(num)>xMax*2 then SetSpritePositionByOffset(num,-xMax,GetSpriteYByOffset(num))
if GetSpriteCollision( frogSpr, num ) then collision=1
next num
for num = 1 to 5
SetSpritePositionByOffset(num+5,(GetSpriteXByOffset(num+5)+4),GetSpriteYByOffset(num+5))
if GetSpriteXByOffset(num+5)>xMax*2 then SetSpritePositionByOffset(num+5,-xMax,GetSpriteYByOffset(num+5))
if GetSpriteCollision( frogSpr, num+5 ) then collision=1
next num
for num = 1 to 5
SetSpritePositionByOffset(num+10,(GetSpriteXByOffset(num+10))-4,GetSpriteYByOffset(num+10))
if GetSpriteXByOffset(num+10)<-xMax then SetSpritePositionByOffset(num+10,xMax*2,GetSpriteYByOffset(num+10))
if GetSpriteCollision( frogSpr, num+10 ) then collision=1
next num
for num = 1 to 5
SetSpritePositionByOffset(num+15,(GetSpriteXByOffset(num+15))-4,GetSpriteYByOffset(num+15))
if GetSpriteXByOffset(num+15)<-xMax then SetSpritePositionByOffset(num+15,xMax*2,GetSpriteYByOffset(num+15))
if GetSpriteCollision( frogSpr, num+15 ) then collision=1
next num
if collision=1 then PlaySprite( frogSpr, 6, 0, 6, 6 )
endfunction collision
function moveLogs(frogSpr as integer)
collision=0
for num = 1 to 5
SetSpritePositionByOffset(num,(GetSpriteXByOffset(num)+4),GetSpriteYByOffset(num))
if GetSpriteXByOffset(num)>xMax*2 then SetSpritePositionByOffset(num,-xMax,GetSpriteYByOffset(num))
if GetSpriteCollision( frogSpr, num )
SetSpritePositionByOffset(frogSpr,GetSpriteXByOffset(frogSpr)+4,GetSpriteYByOffset(frogSpr))
collision=1
endif
next num
for num = 1 to 5
SetSpritePositionByOffset(num+5,(GetSpriteXByOffset(num+5)+4),GetSpriteYByOffset(num+5))
if GetSpriteXByOffset(num+5)>xMax*2 then SetSpritePositionByOffset(num+5,-xMax,GetSpriteYByOffset(num+5))
if GetSpriteCollision( frogSpr, num+5 )
SetSpritePositionByOffset(frogSpr,GetSpriteXByOffset(frogSpr)+4,GetSpriteYByOffset(frogSpr))
collision=1
endif
next num
for num = 1 to 5
SetSpritePositionByOffset(num+10,(GetSpriteXByOffset(num+10))-4,GetSpriteYByOffset(num+10))
if GetSpriteXByOffset(num+10)<-xMax then SetSpritePositionByOffset(num+10,xMax*2,GetSpriteYByOffset(num+10))
if GetSpriteCollision( frogSpr, num+10 )
SetSpritePositionByOffset(frogSpr,GetSpriteXByOffset(frogSpr)-4,GetSpriteYByOffset(frogSpr))
collision=1
endif
next num
for num = 1 to 5
SetSpritePositionByOffset(num+15,(GetSpriteXByOffset(num+15))-4,GetSpriteYByOffset(num+15))
if GetSpriteXByOffset(num+15)<-xMax then SetSpritePositionByOffset(num+15,xMax*2,GetSpriteYByOffset(num+15))
if GetSpriteCollision( frogSpr, num+15 )
SetSpritePositionByOffset(frogSpr,GetSpriteXByOffset(frogSpr)-4,GetSpriteYByOffset(frogSpr))
collision=1
endif
next num
rem crocdiles
for num = 1 to 5
SetSpritePositionByOffset(num+20,(GetSpriteXByOffset(num+20)+2),GetSpriteYByOffset(num+20))
if GetSpriteXByOffset(num+20)>xMax*2 then SetSpritePositionByOffset(num+20,-xMax,GetSpriteYByOffset(num+20))
if GetSpriteCollision( frogSpr, num+20 )
SetSpritePositionByOffset(frogSpr,GetSpriteXByOffset(frogSpr)+2,GetSpriteYByOffset(frogSpr))
collision=1
endif
next num
endfunction collision
function createEllipse()
Render()
DrawEllipse(10,10,10,10,MakeColor(255,255,255),MakeColor(255,255,255),1)
Swap()
img = getimage(0,0,22,22)
sync()
endfunction img
function placeBonusFruit(spr as integer)
If getSpriteExists(spr) then DeleteSprite(spr)
CreateSprite(spr,createEllipse())
SetSpritePositionByOffset(spr,random(10,xMax-10),yMax/2)
SetSpriteDepth (spr,20)
ran=random (1,5)
select ran:
case 1:
SetSpriteColor(spr,113,161,25,255):rem green
endcase
case 2:
SetSpriteColor(spr,92,92,255,255):rem blue
endcase
case 3:
SetSpriteColor(spr,190,152,0,255):rem gold
endcase
case 4:
SetSpriteColor(spr,168,35,168,255):rem Purple
endcase
case 5:
SetSpriteColor(spr,246,125,0,255):rem Orange
endcase
endselect
color=ran
endfunction color
function changeFrogColor(spr as integer,num)
select num:
case 1:
SetSpriteColor(spr,113,161,25,255):rem green
endcase
case 2:
SetSpriteColor(spr,92,92,255,255):rem blue
endcase
case 3:
SetSpriteColor(spr,190,152,0,255):rem gold
endcase
case 4:
SetSpriteColor(spr,168,35,168,255):rem Purple
endcase
case 5:
SetSpriteColor(spr,246,125,0,255):rem Orange
endcase
endselect
endfunction
function placeLogs(num as integer)
//randomly place logs crocs etc repeating for collisions
rem y=105:y=210:y=395:y=495
SetSpritePositionByOffset(num,random2(-xMax,xMax),105)
SetSpritePositionByOffset(num+5,random2(-xMax,xMax),210)
SetSpritePositionByOffset(num+10,random2(xMax,xMax*2),395)
SetSpritePositionByOffset(num+15,random2(xMax,xMax*2),495)
SetSpritePositionByOffset(num+20,random2(-xMax,xMax),302)
for check= 1 to num
while GetSpriteCollision(num,check)=1 and num <> check
SetSpritePositionByOffset(num,random2(-xMax,xMax),105)
check=1
endwhile
while GetSpriteCollision(num+5,check+5)=1 and num <> check
SetSpritePositionByOffset(num+5,random2(-xMax,xMax),210)
check=1
endwhile
while GetSpriteCollision(num+10,check+10)=1 and num <> check
SetSpritePositionByOffset(num+10,random2(0,xMax*2),395)
check=1
endwhile
while GetSpriteCollision(num+15,check+15)=1 and num <> check
SetSpritePositionByOffset(num+15,random2(0,xMax*2),495)
check=1
endwhile
while GetSpriteCollision(num+20,check+20)=1 and num <> check
SetSpritePositionByOffset(num+20,random2(-xMax,xMax),302)
check=1
endwhile
next check
endfunction
function gameOver()
SetTextVisible(1,0)
time#=timer()
repeat
until timer()-time#>1
ClearScreen()
repeat
Print("Game Over click mouse to continue")
sync()
until GetPointerPressed() = 1
SetTextVisible(1,1)
endfunction
This version uses the keyboard
// Project: Frogger Template by fubarpk
// Created: 2017-03-22
#constant KEY_LEFT = 37 //the left arrow key scancode
#constant KEY_UP = 38 //the up arrow key scancode
#constant KEY_RIGHT = 39 //the right arrow key scancode
#constant KEY_DOWN = 40 //the down arrow key scancode
#constant xMax=1024
#constant yMax=600
#constant timePerGame=120
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "Frogger" )
SetWindowSize( xMax,yMax,0)
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( xMax, yMax ) // doesn't have to match the window
SetOrientationAllowed( 0, 0, 1, 1 ) //
//SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
playFrogger()
end
function playFrogger()
deleteSprite(900)
//createSprite(900,ellipse)
createSprite(900,0)
setSpritecolor(900,0,0,0,255)
SetSpriteSize(900,xMax,yMax)
SetSpriteDepth(900,9997)
//SetSpritePositionByOffset(900,xMax/2,yMax/2)
//DeleteSprite(901)
repeat
Print ("My Frogger template click space to Play")
sync()
until GetRawKeyPressed(32) = 1 //click mouse to play
high=0:score=0:bonusTime=0
bonusTime$="Time Left :"+str(bonusTime)
CreateText(1,bonusTime$)
SetTextSize(1,40)
SetTextPosition(1,10,0)
myHigh$="High :"+str(high)
CreateText(2,myHigh$)
SetTextSize(2,40)
SetTextDepth(2,0)
SetTextPosition(2,600,0)
myScore$="Score:"+str(score)
CreateText(3,myScore$)
SetTextSize(3,40)
SetTextDepth(3,0)
SetTextPosition(3,820,0)
frogSpr = CreateSprite(0)
SetSpriteSize(frogSpr,64,64)
changeFrogColor(frogSpr,1)
SetSpriteDepth(frogSpr,15)
do
elapsedTime#=Timer()
resetTimer()
repeat
SetSpriteDepth(900,10000)
score=crossRoadLevel(frogSpr,score)
if high<score then high = score
myScore$="Score:"+str(score):myHigh$="High :"+str(high)
SetTextString(2,myHigh$):SetTextString(3,myScore$)
sync()
//resetTimer()
score=crossRiverLevel(frogSpr,score)
if high<score then high = score
myScore$="Score:"+str(score):myHigh$="High :"+str(high)
SetTextString(2,myHigh$):SetTextString(3,myScore$)
//SetSpriteDepth(901,9998):SetSpriteDepth(902,9999)
SetSpriteAngle(frogSpr,0)
sync()
elapsedTime#=Timer()
until elapsedTime#>timePerGame //limited time per attempt
sync()
setSpritecolor(900,0,0,0,255)
gameOver()
score=0:changeFrogColor(frogSpr,1)
myScore$="Score:"+str(score)
SetTextString(3,myScore$)
loop
endfunction
function crossRoadLevel(frogSpr as integer,score as integer)
setSpritecolor(900,150,150,150,255)
for num = 1 to 5
DeleteSprite(num):deleteSprite(num+5):deleteSprite(num+10)
DeleteSprite(num+15):DeleteSprite(num+20)
rem top road moving right cars and trucks
createSprite(num,0)
SetSpriteSize(num,60,128)
SetSpriteColor(num,Random(1,255),Random(1,255),Random(1,255),255)
SetSpriteAngle(num,90)
createSprite(num+5,0)
SetSpriteSize(num+5,60,148)
SetSpriteColor(num+5,Random(1,255),Random(1,255),Random(1,255),255)
SetSpriteAngle(num+5,90)
rem bottom road moving left cars and trucks
createSprite(num+10,0)
SetSpriteSize(num+10,60,128)
SetSpriteColor(num+10,Random(1,255),Random(1,255),Random(1,255),255)
SetSpriteAngle(num+10,270)
createSprite(num+15,0)
SetSpriteSize(num+15,60,148)
SetSpriteColor(num+15,Random(1,255),Random(1,255),Random(1,255),255)
SetSpriteAngle(num+15,270)
placeVehicles(num)
next num
changeColor=placeBonusFruit(500)
SetSpriteDepth(frogSpr,15)
time#=timer()
repeat
until timer()-time#>1
FrogAnimNum=1
x#=xMax/2:y#=yMax-40
SetSpritePosition(frogSpr,x#,y#)
bonusTime=timePerGame-timer()
while GetSpriteYByOffset(frogSpr)-35>0 and bonusTime >0
bonusTime$="Time Left :"+str(bonusTime)
SetTextString(1,bonusTime$)
x#=GetSpriteX(frogspr):y#=GetSpriteY(frogSpr)
if GetRawKeyState (KEY_Up)
y#=y#-5
endif
if GetRawKeyState (KEY_Down)
y#=y#+5
endif
if GetRawKeyState (KEY_Left)
x#=x#-5
endif
if GetRawKeyState (KEY_Right)
x#=x#+5
endif
SetSpritePosition(frogSpr,x#,y#)
if moveVehicles(frogSpr)=1
x#=xMax/2:y#=yMax-40
SetSpritePosition(frogSpr,x#,y#)
endif
If GetSpriteCollision(frogSpr,500)=1 and GetSpriteVisible(500)=1
changeFrogColor(frogSpr,changeColor)
score=score+250
myScore$="Score:"+str(score)
SetTextString(3,myScore$)
SetSpriteVisible(500,0)
endif
bonusTime=timePerGame-timer()
Sync()
endwhile
if bonusTime>0 then score=score+(10*bonusTime)
endfunction score
function crossRiverLevel(frogSpr as integer,score as integer)
setSpritecolor(900,0,0,140,255)
for num = 1 to 5
DeleteSprite(num):deleteSprite(num+5):deleteSprite(num+10)
DeleteSprite(num+15):DeleteSprite(num+20)
rem top road moving
createSprite(num,0)
SetSpriteColor(num,139,69,19,255)
SetSpriteSize(num,128,64)
SetSpriteDepth(num,20)
createSprite(num+5,0)
SetSpriteColor(num+5,139,69,19,255)
SetSpriteSize(num+5,186,64)
SetSpriteDepth(num+5,20)
rem bottom river moving left Logs
CreateSprite(num+10,0)
SetSpriteColor(num+10,139,69,19,255)
SetSpriteSize(num+10,186,64)
SetSpriteDepth(num+10,20)
CreateSprite(num+15,0)
SetSpriteColor(num+15,139,69,19,255)
SetSpriteSize(num+15,128,64)
SetSpriteDepth(num+15,20)
rem 5 crocodiles
CreateSprite(num+20,0)
SetSpriteColor(num+20,128,128,128,255)
SetSpriteSize(num+20,128,64)
SetSpriteDepth(num+20,20)
placeLogs(num)
next num
//change colour of frog if eats fruit
changeColor=placeBonusFruit(500)
SetSpriteDepth(frogSpr,15)
time#=timer()
repeat
until timer()-time#>1
x#=xMax/2:y#=yMax-40
SetSpritePosition(frogSpr,x#,y#)
bonusTime=timePerGame-timer()
while GetSpriteYByOffset(frogSpr)-35>0 and bonusTime >0
bonusTime$="Time Left :"+str(bonusTime)
SetTextString(1,bonusTime$)
x#=GetSpriteX(frogspr):y#=GetSpriteY(frogSpr)
if GetRawKeyState (KEY_Up)
y#=y#-5
endif
if GetRawKeyState (KEY_Down)
y#=y#+5
endif
if GetRawKeyState (KEY_Left)
x#=x#-5
endif
if GetRawKeyState (KEY_Right)
x#=x#+5
endif
SetSpritePosition(frogSpr,x#,y#)
if moveLogs(frogSpr)=0 and GetSpriteY(frogSpr)<yMax-80
if y#>40
x#=xMax/2:y#=yMax-40
SetSpritePosition(frogSpr,x#,y#)
endif
endif
if x#<-40 or x#>xMax
x#=xMax/2:y#=yMax-40
SetSpritePosition(frogSpr,x#,y#)
endif
If GetSpriteCollision(frogSpr,500)=1 and GetSpriteVisible(500)=1
changeFrogColor(frogSpr,changeColor)
score=score+250
myScore$="Score:"+str(score)
SetTextString(3,myScore$)
SetSpriteVisible(500,0)
endif
bonusTime=timePerGame-timer()
sync()
endwhile
if bonusTime>0 then score=score+(10*bonusTime)
endfunction score
function placeVehicles(num as integer)
//randomly place vehicles watching/repeating for collisions
rem y=105:y=210:y=395:y=495
SetSpritePositionByOffset(num,random2(-xMax,xMax),105)
SetSpritePositionByOffset(num+5,random2(-xMax,xMax),210)
SetSpritePositionByOffset(num+10,random2(xMax,xMax*2),395)
SetSpritePositionByOffset(num+15,random2(xMax,xMax*2),495)
for check= 1 to num
while GetSpriteCollision(num,check)=1 and num <> check
SetSpritePositionByOffset(num,random2(-xMax,xMax),105)
check=1
endwhile
while GetSpriteCollision(num+5,check+5)=1 and num <> check
SetSpritePositionByOffset(num+5,random2(-xMax,xMax),210)
check=1
endwhile
while GetSpriteCollision(num+10,check+10)=1 and num <> check
SetSpritePositionByOffset(num+10,random2(0,xMax*2),395)
check=1
endwhile
while GetSpriteCollision(num+15,check+15)=1 and num <> check
SetSpritePositionByOffset(num+15,random2(0,xMax*2),495)
check=1
endwhile
next check
endfunction
function moveVehicles(frogSpr as integer)
collision=0
for num = 1 to 5
SetSpritePositionByOffset(num,(GetSpriteXByOffset(num)+4),GetSpriteYByOffset(num))
if GetSpriteXByOffset(num)>xMax*2 then SetSpritePositionByOffset(num,-xMax,GetSpriteYByOffset(num))
if GetSpriteCollision( frogSpr, num ) then collision=1
next num
for num = 1 to 5
SetSpritePositionByOffset(num+5,(GetSpriteXByOffset(num+5)+4),GetSpriteYByOffset(num+5))
if GetSpriteXByOffset(num+5)>xMax*2 then SetSpritePositionByOffset(num+5,-xMax,GetSpriteYByOffset(num+5))
if GetSpriteCollision( frogSpr, num+5 ) then collision=1
next num
for num = 1 to 5
SetSpritePositionByOffset(num+10,(GetSpriteXByOffset(num+10))-4,GetSpriteYByOffset(num+10))
if GetSpriteXByOffset(num+10)<-xMax then SetSpritePositionByOffset(num+10,xMax*2,GetSpriteYByOffset(num+10))
if GetSpriteCollision( frogSpr, num+10 ) then collision=1
next num
for num = 1 to 5
SetSpritePositionByOffset(num+15,(GetSpriteXByOffset(num+15))-4,GetSpriteYByOffset(num+15))
if GetSpriteXByOffset(num+15)<-xMax then SetSpritePositionByOffset(num+15,xMax*2,GetSpriteYByOffset(num+15))
if GetSpriteCollision( frogSpr, num+15 ) then collision=1
next num
endfunction collision
function moveLogs(frogSpr as integer)
collision=0
for num = 1 to 5
SetSpritePositionByOffset(num,(GetSpriteXByOffset(num)+4),GetSpriteYByOffset(num))
if GetSpriteXByOffset(num)>xMax*2 then SetSpritePositionByOffset(num,-xMax,GetSpriteYByOffset(num))
if GetSpriteCollision( frogSpr, num )
SetSpritePosition(frogSpr,GetSpriteX(frogSpr)+4,GetSpriteY(frogSpr))
collision=1
endif
next num
for num = 1 to 5
SetSpritePositionByOffset(num+5,(GetSpriteXByOffset(num+5)+4),GetSpriteYByOffset(num+5))
if GetSpriteXByOffset(num+5)>xMax*2 then SetSpritePositionByOffset(num+5,-xMax,GetSpriteYByOffset(num+5))
if GetSpriteCollision( frogSpr, num+5 )
SetSpritePosition(frogSpr,GetSpriteX(frogSpr)+4,GetSpriteY(frogSpr))
collision=1
endif
next num
for num = 1 to 5
SetSpritePositionByOffset(num+10,(GetSpriteXByOffset(num+10))-4,GetSpriteYByOffset(num+10))
if GetSpriteXByOffset(num+10)<-xMax then SetSpritePositionByOffset(num+10,xMax*2,GetSpriteYByOffset(num+10))
if GetSpriteCollision( frogSpr, num+10 )
SetSpritePosition(frogSpr,GetSpriteX(frogSpr)-4,GetSpriteY(frogSpr))
collision=1
endif
next num
for num = 1 to 5
SetSpritePositionByOffset(num+15,(GetSpriteXByOffset(num+15))-5,GetSpriteYByOffset(num+15))
if GetSpriteXByOffset(num+15)<-xMax then SetSpritePositionByOffset(num+15,xMax*2,GetSpriteYByOffset(num+15))
if GetSpriteCollision( frogSpr, num+15 )
SetSpritePosition(frogSpr,GetSpriteX(frogSpr)-4,GetSpriteY(frogSpr))
collision=1
endif
next num
rem crocodiles
for num = 1 to 5
SetSpritePositionByOffset(num+20,(GetSpriteXByOffset(num+20)+2),GetSpriteYByOffset(num+20))
if GetSpriteXByOffset(num+20)>xMax*2 then SetSpritePositionByOffset(num+20,-xMax,GetSpriteYByOffset(num+20))
if GetSpriteCollision( frogSpr, num+20 )
SetSpritePosition(frogSpr,GetSpriteX(frogSpr)+2,GetSpriteY(frogSpr))
collision=1
endif
next num
endfunction collision
function createEllipse()
Render()
DrawEllipse(10,10,10,10,MakeColor(255,255,255),MakeColor(255,255,255),1)
Swap()
img = getimage(0,0,22,22)
sync()
endfunction img
function placeBonusFruit(spr as integer)
If getSpriteExists(spr) then DeleteSprite(spr)
CreateSprite(spr,createEllipse())
SetSpritePositionByOffset(spr,random(10,xMax-10),yMax/2)
SetSpriteDepth (spr,20)
ran=random (1,5)
select ran:
case 1:
SetSpriteColor(spr,113,161,25,255):rem green
endcase
case 2:
SetSpriteColor(spr,92,92,255,255):rem blue
endcase
case 3:
SetSpriteColor(spr,190,152,0,255):rem gold
endcase
case 4:
SetSpriteColor(spr,168,35,168,255):rem Purple
endcase
case 5:
SetSpriteColor(spr,246,125,0,255):rem Orange
endcase
endselect
color=ran
endfunction color
function changeFrogColor(spr as integer,num)
select num:
case 1:
SetSpriteColor(spr,113,161,25,255):rem green
endcase
case 2:
SetSpriteColor(spr,92,92,255,255):rem blue
endcase
case 3:
SetSpriteColor(spr,190,152,0,255):rem gold
endcase
case 4:
SetSpriteColor(spr,168,35,168,255):rem Purple
endcase
case 5:
SetSpriteColor(spr,246,125,0,255):rem Orange
endcase
endselect
endfunction
function placeLogs(num as integer)
//randomly place logs crocs etc repeating for collisions
SetSpritePositionByOffset(num,random2(-xMax,xMax),105)
SetSpritePositionByOffset(num+5,random2(-xMax,xMax),210)
SetSpritePositionByOffset(num+10,random2(xMax,xMax*2),395)
SetSpritePositionByOffset(num+15,random2(xMax,xMax*2),495)
SetSpritePositionByOffset(num+20,random2(-xMax,xMax),302)
for check= 1 to num
while GetSpriteCollision(num,check)=1 and num <> check
SetSpritePositionByOffset(num,random2(-xMax,xMax),105)
check=1
endwhile
while GetSpriteCollision(num+5,check+5)=1 and num <> check
SetSpritePositionByOffset(num+5,random2(-xMax,xMax),210)
check=1
endwhile
while GetSpriteCollision(num+10,check+10)=1 and num <> check
SetSpritePositionByOffset(num+10,random2(0,xMax*2),395)
check=1
endwhile
while GetSpriteCollision(num+15,check+15)=1 and num <> check
SetSpritePositionByOffset(num+15,random2(0,xMax*2),495)
check=1
endwhile
while GetSpriteCollision(num+20,check+20)=1 and num <> check
SetSpritePositionByOffset(num+20,random2(-xMax,xMax),302)
check=1
endwhile
next check
endfunction
function gameOver()
SetTextVisible(1,0)
time#=timer()
repeat
until timer()-time#>1
ClearScreen()
repeat
Print("Game Over click mouse to continue")
sync()
until GetPointerPressed() = 1
SetTextVisible(1,1)
endfunction
fubar