Good ole Rockman spectrum
// Project: rockman
// Created: 2018-11-30
// show all errors
SetErrorMode(2)
#constant screenwidth=1024
#constant screenheight=768
// set window properties
SetWindowTitle( "rockman" )
SetWindowSize( screenwidth, screenheight, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( screenwidth, screenheight ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
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
global floorspr, liftspr, breakablespr, skullspr, collectablespr, playerspr, dyingspr, playergravityspr, enemyspr
global TIME, SCORE, SCREEN, LIVES
global TIMEV, SCOREV, SCREENV, LIVESV
global TIMEValue, SCOREValue, SCREENValue$, LIVESValue
global tilesize, checkbonuses, playerfall, fallspeed#
global collectablescount, collectablescurrent, gameover
tilesize=(screenheight/16)+8
type _player
x#
y#
spr
endtype
global player as _player
global originalplayerpositionx#,originalplayerpositiony#
global oldplayerpositionx#,oldplayerpositiony#
type _enemy
spr1 // open mouth
spr2 // closed mouth
x#
y#
endtype
global enemies as _enemy[1] // two enemies
type _blocks
spr
x#
y#
typ# // 1 - breakable/movable , 2 - solid/wall, 3 - gravitywall, 4-skull
value
endtype
global blocks as _blocks[16,9]
global level = 1
lives=5
// information bar
global informationbar, informationbarx#
informationbar=CreateText("Hello, welcome to Rockman Revamped... Go through each level collecting the mushrooms without getting caught or hitting a skull... Press Left/Right Cursor keys to move.... Press SPACE to hit a rock thats on the ground in front of you... R to reset this level...ESC to go back to main menu...")
SetTextSize(informationbar,15)
informationbarx#=screenwidth
// end of information bar setup
// Level text setup
global leveltext,leveltextshadow
leveltext=CreateText("")
leveltextshadow=CreateText("")
SetTextSize(leveltext,150)
SetTextSize(leveltextshadow,150)
SetTextBold(leveltext,1)
SetTextBold(leveltextshadow,1)
// end of level text setup
//level=1
buildsprites()
Createmaps()
level=1
buildmap(level)
// frame step counters
global framestep#,enemystep#
framestep#=timer()
enemystep#=timer()
gamemode=0 // levelup message
do
oldplayerpositionx# = player.x#
oldplayerpositiony# = player.y#
displayscreen()
displayplayer()
checkplayermoves()
checkplayercollisions()
checkmushroomcounters()
checktimer("enemy",enemystep#,2)
checktimer("time",framestep#,1)
Render2DFront()
// Print( ScreenFPS() )
Sync()
loop
function updateenemypositions()
// which tile position is the player in
px = (player.x#/tilesize)-1
py = (player.y#/tilesize)-1
// which tile position is the enemy number 1 in
enemy1x = (enemies[0].x#/tilesize)-1
enemy1y = (enemies[0].y#/tilesize)-1
if enemy1x = px and enemy1y=py
//crash
else
if px < enemy1x then dec enemies[0].x#,tilesize
if py < enemy1y then dec enemies[0].y# ,tilesize
if px > enemy1x then inc enemies[0].x# ,tilesize
if py > enemy1y then inc enemies[0].y# ,tilesize
endif
endfunction
function checktimer(function$,ft#, time#)
if (function$="time")
if (timer()-ft#) > time#
framestep# = timer()
dec timevalue
endif
endif
if (function$="enemy")
if (timer()-ft#) > time#
enemystep# = timer()
updateenemypositions()
endif
endif
endfunction
function checkmushroomcounters()
if collectablescurrent>=collectablescount
//level up - we collected all mushrooms for this level
print("LEVEL UP")
sync()
sleep(1000)
inc level
preparenextlevel(level,0)
endif
endfunction
function checkplayercollisions()
bx = (player.x#/tilesize)-1
by = (player.y#/tilesize)-1
// typ# // 0- empty space, 1 - breakable/movable , 2 - solid/wall, 3 - gravitywall, 4-skull, 5 collectable, 6- ghost
if (blocks[bx,by].typ#=2 or blocks[bx,by].typ# = 4 or blocks[bx,by].typ# = 1 or blocks[bx,by].typ#=5) // if the left brick is an obsticle of some sort then dont move
player.x# = oldplayerpositionx#
player.y# = oldplayerpositiony#
// if there is a breakabove block in front then check if can move it on
// which way facing?
if GetSpriteFlippedH(player.spr) = 1
// facing left
if blocks[bx,by].typ#=1 // breakable block
if blocks[bx-1,by].typ#=0 // if the block in front of the breakable block is empty
// move it there
// sleep(1000)
// check any blocks underneath thats AIR
if by+1 <= 9
if blocks[bx-1,by+1].typ#=0
// need to move the block down until it reaches an obsiticle
newyold = by+1
for y=by+1 to 9
if blocks[bx-1,y].typ# = 0
newyold = y
else
exit
endif
next
blocks[bx,by].typ#=0
SetSpriteVisible(blocks[bx,by].spr,0)
blocks[bx-1,newyold].typ#=1
blocks[bx-1,newyold].spr = CloneSprite(breakablespr)
else
blocks[bx,by].typ#=0
SetSpriteVisible(blocks[bx,by].spr,0)
blocks[bx-1,by].typ#=1
blocks[bx-1,by].spr = CloneSprite(breakablespr)
endif
endif
endif
endif
else
// facing right
if blocks[bx,by].typ#=1 // breakable block
if blocks[bx+1,by].typ#=0 // if the block in front of the breakable block is empty
// move it there
// sleep(1000)
// check any blocks underneath thats AIR
if by+1<=9
if blocks[bx+1,by+1].typ#=0
// need to move the block down until it reaches an obsiticle
newyold = by+1
for y=by+1 to 9
if blocks[bx+1,y].typ# = 0
newyold = y
else
exit
endif
next
blocks[bx,by].typ#=0
SetSpriteVisible(blocks[bx,by].spr,0)
blocks[bx+1,newyold].typ#=1
blocks[bx+1,newyold].spr = CloneSprite(breakablespr)
else
blocks[bx,by].typ#=0
SetSpriteVisible(blocks[bx,by].spr,0)
blocks[bx+1,by].typ#=1
blocks[bx+1,by].spr = CloneSprite(breakablespr)
endif
endif
endif
endif
endif
else
// check falling
if by+1<=9
if blocks[bx,by+1].typ# = 0 // is the one underneah an air block
inc player.y#, tilesize
endif
// check if fall onto a skull
if blocks[bx,by+1].typ# = 4 // hits a skull
SetSpriteVisible(player.spr,0)
SetSpriteVisible(dyingspr,1)
t#=0
// display a death frame for a few seconds
repeat
updateborder(255,0,0,1)
SetSpritePosition(dyingspr,player.x#,player.y#)
sync()
inc t#
until t#>50
SetSpriteVisible(dyingspr,0)
player.x# = originalplayerpositionx#
player.y# = originalplayerpositiony#
SetSpritePosition(player.spr,player.x#,player.y#)
SetSpriteVisible(player.spr,1)
//reset player back to home position
preparenextlevel(level,0)
endif
// if there is a collectable as you go across and down
endif
if GetSpriteFlippedH(player.spr) = 0
else
endif
if by+1<9
if blocks[bx,by+1].typ# = 5
SetSpriteVisible(blocks[bx,by+1].spr,0) // hide the mushroom
blocks[bx,by+1].typ# = 0 // the mushroom space is now AIR which can move onto
inc scorevalue,25
inc collectablescurrent // keep a count of how many mushrooms collected
endif
endif
if blocks[bx,by].typ# = 3
SetSpriteVisible(player.spr,0)
SetSpriteVisible(playergravityspr,1)
SetSpritePosition(playergravityspr,player.x#,player.y#)
else
SetSpriteVisible(player.spr,1)
SetSpriteVisible(playergravityspr,0)
endif
endif
endfunction
function displayplayer()
SetSpritePosition(player.spr,player.x#,player.y#)
SetSpritePosition(enemies[0].spr1,enemies[0].x#,enemies[0].y#)
SetSpritePosition(enemies[1].spr1,enemies[1].x#,enemies[1].y#)
endfunction
function checkboundary(dir)
bx = (player.x#/tilesize)-1
by = (player.y#/tilesize)-1
print (bx)
print (by)
ret=0 // can move
if dir=0 and bx<1 then ret=1 // left
if dir=1 and bx>=15 then ret=1 // right
if dir=2 and by<1 then ret=1 // up
if dir=3 and by>=9 then ret=1 // down
endfunction ret
function checkplayermoves()
bx = (player.x#/tilesize)-1
by = (player.y#/tilesize)-1
if GetRawKeyPressed(37)
if checkboundary(0) = 0
if GetSpriteFlippedH(player.spr) = 0
SetSpriteFlip(player.spr,1,0) // turn the sprite left
SetSpriteFlip(dyingspr,1,0) // turn the dying sprite too - cause if hit any danger then we know this sprite is correct too
SetSpriteFlip(playergravityspr,1,0) // turn the dying sprite too - cause if hit any danger then we know this sprite is correct too
else
if bx-2>=0 or bx-1>=0
if blocks[bx-1,by].typ#=5 // hit a collectable, then collect it
SetSpriteVisible(blocks[bx-1,by].spr,0)
blocks[bx-1,by].typ#=0
inc collectablescurrent
else
dec player.x#,tilesize
endif
endif
if bx-2>0
if blocks[bx-2,by].typ#=5 // hit a collectable, then collect it
SetSpriteVisible(blocks[bx-2,by].spr,0)
blocks[bx-2,by].typ#=0
inc collectablescurrent
endif
endif
endif
else
player.x# = oldplayerpositionx#
endif
endif
// move right
if GetRawKeyPressed(39)
if checkboundary(1)=0
if GetSpriteFlippedH(player.spr) = 1
SetSpriteFlip(player.spr,0,0)
SetSpriteFlip(dyingspr,0,0) // turn the dying sprite too - cause if hit any danger then we know this sprite is correct too
SetSpriteFlip(playergravityspr,0,0) // turn the dying sprite too - cause if hit any danger then we know this sprite is correct too
else
if blocks[bx+1,by].typ#=5 // hit a collectable, then collect it
SetSpriteVisible(blocks[bx+1,by].spr,0)
blocks[bx+1,by].typ#=0
inc collectablescurrent
else
inc player.x#,tilesize
endif
if bx+2<16
if blocks[bx+2,by].typ#=5 // hit a collectable, then collect it
SetSpriteVisible(blocks[bx+2,by].spr,0)
blocks[bx+2,by].typ#=0
inc collectablescurrent
endif
endif
endif
else
player.x# = oldplayerpositionx#
endif
endif
// move up
if GetRawKeyPressed(38)
if checkboundary(2)=0
dec player.y#,tilesize
else
player.y# = oldplayerpositiony#
endif
endif
// omve down
if GetRawKeyPressed(40)
if checkboundary(3)=0
inc player.y#,tilesize
else
player.y# = oldplayerpositiony#
endif
endif
// hit a block in front of player facing
if GetRawKeyPressed(32)
bx = (player.x#/tilesize)-1
by = (player.y#/tilesize)-1
if GetSpriteFlippedH(player.spr)=1
if (blocks[bx-1,by].typ#) = 1
if (blocks[bx-1,by+1].typ#)=0
blocks[bx-1,by+1].spr = CloneSprite(breakablespr)
blocks[bx-1,by+1].typ#=1
SetSpriteVisible(blocks[bx-1,by].spr,0)
blocks[bx-1,by].typ# = 0
endif
else
if (blocks[bx-1,by+1].typ#)=1 // if the one in front is breakable
SetSpriteVisible(blocks[bx-1,by+1].spr,0)
blocks[bx-1,by+1].typ#=0
newyold=by+2
// check for any blocks underneat the breakable one, and drop it to that location
for y=by+2 to 9
if blocks[bx-1,y].typ# = 0
newy=y
else
exit
endif
next
if newyold=y
blocks[bx-1,newyold-1].typ# = 1
blocks[bx-1,by+1].typ# = 0
else
blocks[bx-1,newy].spr = CloneSprite(breakablespr)
blocks[bx-1,newy].typ# = 1
blocks[bx-1,by+1].typ# = 0
endif
endif
endif
else
if (blocks[bx+1,by].typ#) = 1
if (blocks[bx+1,by+1].typ#)=0
blocks[bx+1,by+1].spr = CloneSprite(breakablespr)
blocks[bx+1,by+1].typ#=1
SetSpriteVisible(blocks[bx+1,by].spr,0)
blocks[bx+1,by].typ# = 0
endif
else
if (blocks[bx+1,by+1].typ#)=1 // if the one in front is breakable
SetSpriteVisible(blocks[bx+1,by+1].spr,0)
blocks[bx+1,by].typ#=0
newyold=by+2
// check for any blocks underneat the breakable one, and drop it to that location
for y=by+2 to 9
if blocks[bx+1,y].typ# = 0
newy=y
else
exit
endif
next
if newyold=y // there are some empty spaces
// blocks[bx+1,newyold].spr = CloneSprite(breakablespr)
blocks[bx+1,newyold-1].typ# = 1
blocks[bx+1,by+1].typ# = 0
else
blocks[bx+1,newy].spr = CloneSprite(breakablespr)
blocks[bx+1,newy].typ# = 1
blocks[bx+1,by+1].typ# = 0
endif
endif
endif
endif
endif
endfunction
function displaylevelup()
SetTextString(leveltext,"LEVEL " + str(level))
SetTextString(leveltextshadow,"LEVEL " + str(level))
SetTextVisible(leveltext,1)
SetTextVisible(leveltextshadow,1)
SetTextColor(leveltext,255,255,0,255)
SetTextColor(leveltextshadow,255,0,0,255)
SetTextPosition(leveltextshadow,screenwidth/2-GetTextTotalWidth(leveltextshadow)/2,screenheight/2-GetTextTotalHeight(leveltextshadow)/2)
SetTextPosition(leveltext,screenwidth/2-GetTextTotalWidth(leveltext)/2+5,screenheight/2-GetTextTotalHeight(leveltext)/2+5)
SetTextDepth(leveltextshadow,0)
SetTextDepth(leveltextshadow,1)
endfunction
function preparenextlevel(level,reset)
collectablescurrent=0
if (level<=20 or gameover<>1)
if reset=0
checkbonuses=1
for x=0 to 16
for y=0 to 9
DeleteSprite(blocks[x,y].spr)
blocks[x,y].typ#=0
next
next
buildmap(level)
endif
else
repeat
if gameover=1
print("GAME OVER - PRESS SPACE TO RESTART")
else
print("YOU WIN - PRESS SPACE TO RESTART")
endif
sync()
until GetRawKeyPressed(32)
level=1
buildmap(level)
endif
endfunction
function displayscreen()
// display screen
updateborder(0,0,255,3)
// place the player
for y=0 to 9
for x=0 to 15
if GetSpriteExists(blocks[x,y].spr) then SetSpritePosition(blocks[x,y].spr,blocks[x,y].x#, blocks[x,y].y#)
next
next
// update scores and stuff
SetTextString(timev, pad(str(timevalue),"0",3))
SetTextString(scorev, pad(str(scorevalue),"0",6))
SetTextString(screenv, screenvalue$)
SetTextString(livesv, pad(str(livesvalue),"0",2))
// move a little information bar across
SetTextPosition(informationbar,informationbarx#,screenheight-20)
dec informationbarx#,2
endfunction
function resetscores(level)
// increase the time each level by a percentage of 20 - we need more time for difficult levels - correct!
timevalue=150
SetTextString(timev,str(timevalue))
if level=1
scorevalue=0
SetTextString(scorev,pad (str(scorevalue),"0",6))
endif
endfunction
function updateborder(redcolor, greencolor, bluecolor,gradient)
// top and bottom
for a=0 to tilesize
if gradient=1
DrawLine(a,a,screenwidth-a,a,MakeColor(redcolor-(a*4),greencolor,bluecolor),MakeColor(redcolor-(a*4),greencolor,bluecolor))
DrawLine(a,screenheight-30-a,screenwidth-a,screenheight-30-a,MakeColor(redcolor-(a*4),greencolor,bluecolor),MakeColor(redcolor-(a*4),greencolor,bluecolor))
DrawLine(a,a,a,screenheight-30-a,MakeColor(redcolor-(a*4),greencolor,bluecolor),MakeColor(redcolor-(a*4),greencolor,bluecolor))
DrawLine(screenwidth-a,a,screenwidth-a,screenheight-30-a,MakeColor(redcolor-(a*4),greencolor,bluecolor),MakeColor(redcolor-(a*4),greencolor,bluecolor))
endif
if gradient=2
DrawLine(a,a,screenwidth-a,a,MakeColor(redcolor,greencolor-(a*4),bluecolor),MakeColor(redcolor,greencolor-(a*4),bluecolor))
DrawLine(a,screenheight-30-a,screenwidth-a,screenheight-30-a,MakeColor(redcolor,greencolor-(a*4),bluecolor),MakeColor(redcolor,greencolor-(a*4),bluecolor))
DrawLine(a,a,a,screenheight-30-a,MakeColor(redcolor,greencolor-(a*4),bluecolor),MakeColor(redcolor,greencolor-(a*4),bluecolor))
DrawLine(screenwidth-a,a,screenwidth-a,screenheight-30-a,MakeColor(redcolor,greencolor-(a*4),bluecolor),MakeColor(redcolor,greencolor-(a*4),bluecolor))
endif
if gradient=3
DrawLine(a,a,screenwidth-a,a,MakeColor(redcolor,greencolor,bluecolor-(a*4)),MakeColor(redcolor,greencolor,bluecolor-(a*4)))
DrawLine(a,screenheight-30-a,screenwidth-a,screenheight-30-a,MakeColor(redcolor,greencolor,bluecolor-(a*4)),MakeColor(redcolor,greencolor,bluecolor-(a*4)))
DrawLine(a,a,a,screenheight-30-a,MakeColor(redcolor,greencolor,bluecolor-(a*4)),MakeColor(redcolor,greencolor,bluecolor-(a*4)))
DrawLine(screenwidth-a,a,screenwidth-a,screenheight-30-a,MakeColor(redcolor,greencolor,bluecolor-(a*4)),MakeColor(redcolor,greencolor,bluecolor-(a*4)))
endif
next
// scores bar
DrawBox(tilesize,tilesize*11,screenwidth-tilesize,(tilesize*11)+tilesize/2,MakeColor(0,0,200),MakeColor(0,0,200),MakeColor(0,0,200),MakeColor(0,0,200),1)
// display the scoring panels
SetTextPosition(time,180,tilesize*11)
SetTextPosition(timev,175,tilesize*11.5)
SetTextPosition(score,360,tilesize*11)
SetTextPosition(scorev,330,tilesize*11.5)
SetTextPosition(screen,560,tilesize*11)
SetTextPosition(screenv,595,tilesize*11.5)
SetTextPosition(lives,760,tilesize*11)
SetTextPosition(livesv,770,tilesize*11.5)
endfunction
function buildsprites()
// *********************************************
// Player Sprite
// *********************************************
swap()
//clear
DrawBox(0,0,tilesize,tilesize,MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),1)
//
DrawEllipse(tilesize/2,tilesize/2,tilesize/3,tilesize/2,MakeColor(255,255,255),MakeColor(255,255,255),1)
// one eye (side view)
DrawEllipse(tilesize/2+10,tilesize/2-10,4,4,MakeColor(0,0,0),MakeColor(0,0,0),1)
// nose
DrawEllipse(tilesize/2+20,tilesize/2-5,4,4,MakeColor(255,255,255),MakeColor(255,255,255),1)
// mouth
DrawEllipse(tilesize/2+10,tilesize/2+10,8,2,MakeColor(0,0,0),MakeColor(0,0,0),1)
//hat
for a=0 to 5
DrawLine(tilesize/2-10,a,tilesize/2+10,a,MakeColor(0,0,255),MakeColor(0,0,255))
next
for a=5 to 10
DrawLine(0,a,tilesize,a,MakeColor(0,0,255),MakeColor(0,0,255))
next
render()
playerspr=CreateSprite(GetImage(0,0,tilesize,tilesize))
SetSpriteVisible(playerspr,1)
SetSpritePosition(playerspr,-100,-100)
// *********************************************
// Player Sprite on gravity lift
// *********************************************
swap()
//clear
DrawBox(0,0,tilesize,tilesize,MakeColor(200,0,0),MakeColor(200,0,0),MakeColor(200,0,0),MakeColor(200,0,0),1)
//
DrawEllipse(tilesize/2,tilesize/2,tilesize/3,tilesize/2,MakeColor(255,255,255),MakeColor(255,255,255),1)
// one eye (side view)
DrawEllipse(tilesize/2+10,tilesize/2-10,4,4,MakeColor(0,0,0),MakeColor(0,0,0),1)
// nose
DrawEllipse(tilesize/2+20,tilesize/2-5,4,4,MakeColor(255,255,255),MakeColor(255,255,255),1)
// mouth
DrawEllipse(tilesize/2+10,tilesize/2+10,8,2,MakeColor(0,0,0),MakeColor(0,0,0),1)
//hat
for a=0 to 5
DrawLine(tilesize/2-10,a,tilesize/2+10,a,MakeColor(0,0,255),MakeColor(0,0,255))
next
for a=5 to 10
DrawLine(0,a,tilesize,a,MakeColor(0,0,255),MakeColor(0,0,255))
next
render()
playergravityspr=CreateSprite(GetImage(0,0,tilesize,tilesize))
SetSpriteVisible(playergravityspr,0)
SetSpriteDepth(playergravityspr,0)
//SetSpriteSize(playerspr,tilesize/2,tilesize)
//SetSpriteImage(playerspr,CreateTexture(64,64,MakeColor(255,255,255),100))
// *********************************************
// Player Gravity Sprite positioned in the gravity wall
// *********************************************
swap()
//clear
DrawBox(0,0,tilesize,tilesize,MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),1)
//
DrawEllipse(tilesize/2,tilesize/2,tilesize/3,tilesize/2,MakeColor(255,0,0),MakeColor(255,0,0),1)
// one eye (side view)
DrawEllipse(tilesize/2+10,tilesize/2-10,4,4,MakeColor(0,0,0),MakeColor(0,0,0),1)
// nose
DrawEllipse(tilesize/2+20,tilesize/2-5,4,4,MakeColor(255,255,255),MakeColor(255,255,255),1)
// mouth
DrawEllipse(tilesize/2+10,tilesize/2+10,8,2,MakeColor(0,0,0),MakeColor(0,0,0),1)
//hat
for a=0 to 5
DrawLine(tilesize/2-10,a,tilesize/2+10,a,MakeColor(0,0,255),MakeColor(0,0,255))
next
for a=5 to 10
DrawLine(0,a,tilesize,a,MakeColor(0,0,255),MakeColor(0,0,255))
next
render()
dyingspr=CreateSprite(GetImage(0,0,tilesize,tilesize))
SetSpriteVisible(dyingspr,1)
SetSpritePosition(dyingspr,-100,-100)
SetSpriteDepth(dyingspr,0)
// *********************************************
// mushroom spr
// *********************************************
swap()
DrawBox(0,0,tilesize,tilesize,MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),1)
//roof
DrawEllipse(tilesize/2,tilesize/2,tilesize/2-5,tilesize/2-10,MakeColor(255,0,0),MakeColor(255,0,0),1)
// blank bottom half out
DrawBox(0,tilesize/2,tilesize,tilesize,MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),1)
// draw some mushroom dots on its head
DrawBox(tilesize/2-10,tilesize/2-10,tilesize/2-5, tilesize/2-5, MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),1)
DrawBox(tilesize/2+10,tilesize/2-10,tilesize/2+15, tilesize/2-5, MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),1)
DrawBox(tilesize/2+10,tilesize/2-20,tilesize/2+15, tilesize/2-15, MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),1)
DrawBox(tilesize/2-10,tilesize/2-20,tilesize/2-15, tilesize/2-15, MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),1)
DrawBox(tilesize/2,tilesize/2-20,tilesize/2-5, tilesize/2-15, MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),1)
// stump
DrawBox(tilesize/2-9,tilesize/2,tilesize/2+9,tilesize,MakeColor(50,50,50),MakeColor(255,255,255),MakeColor(50,50,50),MakeColor(255,255,255),1)
// stump foot
DrawBox(10,tilesize-3,tilesize-10,tilesize,MakeColor(0,0,0),MakeColor(255,255,255),MakeColor(0,0,0),MakeColor(255,255,255),1)
render()
collectablespr=CreateSprite(getimage(0,0,tilesize,tilesize))
SetSpriteVisible(collectablespr,1)
SetSpritePosition(collectablespr,-100,-100)
// *********************************************
// skull spr
// *********************************************
swap()
DrawBox(0,0,tilesize,tilesize,MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),1)
DrawEllipse(tilesize/2,tilesize/2-10,tilesize/2,tilesize/3,MakeColor(155,155,155),MakeColor(255,255,255),1)
//jaw
DrawEllipse(tilesize/2,tilesize/2+10,tilesize/3,tilesize/3,MakeColor(255,255,255),MakeColor(255,255,255),1)
// eyes
DrawBox(tilesize/2-5,tilesize/2-15,tilesize/2-15,tilesize/2-10,MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),1)
DrawBox(tilesize/2+5,tilesize/2-15,tilesize/2+15,tilesize/2-10,MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),1)
//nose
DrawBox(tilesize/2-4,tilesize/2-5,tilesize/2+4,tilesize/2,MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),1)
DrawBox(tilesize/2-2,tilesize/2-10,tilesize/2+2,tilesize/2,MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),1)
DrawBox(tilesize/2-10,tilesize/2+10,tilesize/2+10,tilesize/2+15,MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),1)
// mouth
DrawBox(tilesize/2-15,tilesize/2+5,tilesize/2-5,tilesize/2+10,MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),1)
DrawBox(tilesize/2+15,tilesize/2+5,tilesize/2+5,tilesize/2+10,MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),1)
render()
skullspr=CreateSprite(getimage(0,0,tilesize,tilesize))
SetSpriteVisible(skullspr,1)
SetSpritePosition(skullspr,-100,-100)
// *********************************************
// Enemy Sprite - TO DO
// *********************************************
swap()
DrawBox(0,0,tilesize,tilesize,MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),1)
DrawEllipse(tilesize/2,tilesize/2,tilesize/2,tilesize/2,MakeColor(155,155,155),MakeColor(255,255,255),1)
//eye
DrawBox(tilesize/2-10,tilesize/2-10,tilesize/2-5,tilesize/2-5,MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),1)
DrawBox(tilesize/2+10,tilesize/2-10,tilesize/2+5,tilesize/2-5,MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),1)
//closemouth
DrawBox(tilesize/2-10,tilesize/2+10,tilesize/2+10,tilesize/2+12,MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),1)
render()
enemyspr=CreateSprite(getimage(0,0,tilesize,tilesize))
SetSpriteVisible(enemyspr,1)
SetSpritePosition(enemyspr,-100,-100)
// *********************************************
// floorspr
// *********************************************
floorspr=CreateSprite(0)
SetSpriteSize(floorspr,tilesize,tilesize)
SetSpriteImage(floorspr,createtexture(64,64,MakeColor(255,255,0),200,1))
SetSpriteVisible(floorspr,1)
SetSpritePosition(floorspr,-100,-100)
// *********************************************
// lift or no gravity sprite
// *********************************************
liftspr=CreateSprite(0)
setspritesize(liftspr,tilesize,tilesize)
SetSpriteColor(liftspr,200,0,0,255)
SetSpriteVisible(liftspr,1)
SetSpritePosition(liftspr,-100,-100)
// *********************************************
// breakable blocks
// *********************************************
breakablespr=CreateSprite(0)
SetSpriteSize(breakablespr,tilesize,tilesize)
SetSpriteImage(breakablespr,createtexture(64,64,MakeColor(0,255,0),250,0))
SetSpriteVisible(breakablespr,1)
SetSpritePosition(breakablespr,-100,-100)
timevalue=150
time=CreateText("TIME") : timev = CreateText(str(timevalue))
scorevalue=0
score=CreateText("SCORE") : scorev = CreateText(pad (str(scorevalue),"0",6))
screenvalue$="A"
screen=CreateText("SCREEN") : screenv = CreateText(screenvalue$)
livesvalue=5 // Start of a new game
lives=CreateText("LIVES") : livesv = CreateText(pad (str(livesvalue),"0",2))
SetTextSize(time,30)
SetTextSize(score,30)
SetTextSize(screen,30)
SetTextSize(lives,30)
SetTextSize(timev,50)
SetTextSize(scorev,50)
SetTextSize(screenv,50)
SetTextSize(livesv,50)
endfunction
function pad(num$, char$, amount)
n$ = ""
for a=1 to amount-len(num$)
n$=n$ + char$
next
n$=n$+num$
endfunction n$
function buildmap(level)
// typ# // 0- empty space, 1 - breakable/movable , 2 - solid/wall, 3 - gravitywall, 4-skull, 5 collectable
collectablescount=0
for x=0 to 15
for y=0 to 9
DeleteSprite(blocks[x,y].spr)
// DeleteSprite(player.spr)
next
next
s=OpenToRead("map level " + str(level) + ".dat")
screenvalue$=ReadLine(s)
SetTextString(screenv,screenvalue$)
passcode$ = readline(s)
for y=0 to 9
line$=ReadLine(s)
for x=0 to 15
blocks[x,y].value=val(mid(line$,x+1,1))
// print (blocks[x,y].value)
// sync()
//sleep(1000)
if blocks[x,y].value=0
blocks[x,y].x# = (x+1) * tilesize
blocks[x,y].y# = (y+1) * tilesize
blocks[x,y].spr = 0
blocks[x,y].typ# = 0
endif
if blocks[x,y].value=1
blocks[x,y].x# = (x+1) * tilesize
blocks[x,y].y# = (y+1) * tilesize
blocks[x,y].spr = CloneSprite(floorspr)
blocks[x,y].typ# = 2
endif
if blocks[x,y].value=2
blocks[x,y].x# = (x+1) * tilesize
blocks[x,y].y# = (y+1) * tilesize
blocks[x,y].spr = CloneSprite(liftspr)
blocks[x,y].typ# = 3
endif
if blocks[x,y].value=3
blocks[x,y].x# = (x+1) * tilesize
blocks[x,y].y# = (y+1) * tilesize
blocks[x,y].spr = CloneSprite(breakablespr)
blocks[x,y].typ# = 1
endif
if blocks[x,y].value=4
blocks[x,y].x# = (x+1) * tilesize
blocks[x,y].y# = (y+1) * tilesize
blocks[x,y].spr = CloneSprite(skullspr)
blocks[x,y].typ# = 4
endif
if blocks[x,y].value=5
blocks[x,y].x# = (x+1) * tilesize
blocks[x,y].y# = (y+1) * tilesize
blocks[x,y].spr = CloneSprite(collectablespr)
blocks[x,y].typ# = 5
inc collectablescount
endif
// player starting position
if blocks[x,y].value=6
player.x# = (x+1) * tilesize
player.y# = (y+1) * tilesize
if (level=1)
player.spr = CloneSprite(playerspr)
endif
SetSpriteDepth(player.spr,0)
originalplayerpositionx#=(x+1) * tilesize
originalplayerpositiony#=(y+1) * tilesize
oldplayerpositionx#=originalplayerpositionx#
oldplayerpositiony#=originalplayerpositiony#
endif
if blocks[x,y].value=7
enemies[0].x# = (x+1) * tilesize
enemies[0].y# = (y+1) * tilesize
if (level=1)
enemies[0].spr1 = CloneSprite(enemyspr)
endif
SetSpriteDepth(enemies[0].spr1,0)
endif
if blocks[x,y].value=8
enemies[1].x# = (x+1) * tilesize
enemies[1].y# = (y+1) * tilesize
if (level=1)
enemies[1].spr1 = CloneSprite(enemyspr)
endif
SetSpriteDepth(enemies[1].spr1,0)
endif
next
next
collectablescurrent=0
resetscores(level)
SetSpriteTransparency(player.spr,1)
// disposeobjects()
endfunction
function disposeobjects()
DeleteSprite(playerspr)
DeleteSprite(collectablespr)
DeleteSprite(liftspr)
DeleteSprite(skullspr)
DeleteSprite(breakablespr)
DeleteSprite(floorspr)
endfunction
function createmaps()
// 1 = floor
// 2 = lift/no gravity blocks
// 3 = breakables to push (left and right) or break ones underneath through
// 4 = skull
// 5 = mushroom (pick up all to win
// 6 = player
s=OpenToWrite("map level 1.dat")
WriteLine(s,"A")
WriteLine(s,"PASSCODE-GURU")
WriteLine(s,"0060002000000000")
WriteLine(s,"0111112000200500")
WriteLine(s,"0000002000233330")
WriteLine(s,"0528002330200000")
WriteLine(s,"0320002003233330")
WriteLine(s,"0023311100233330")
WriteLine(s,"0020200000455540")
WriteLine(s,"0111233433333333")
WriteLine(s,"0000250407000000")
WriteLine(s,"0000255500000000")
CloseFile(s)
s=OpenToWrite("map level 2.dat")
WriteLine(s,"B")
WriteLine(s,"PASSCODE-POOL")
WriteLine(s,"0022222002222200")
WriteLine(s,"0332223333222330")
WriteLine(s,"0333233253325330")
WriteLine(s,"5111211211121115")
WriteLine(s,"2000206250020002")
WriteLine(s,"2111211211121112")
WriteLine(s,"2533233253323352")
WriteLine(s,"2300200332020032")
WriteLine(s,"2003230002323002")
WriteLine(s,"2033253333523302")
CloseFile(s)
s=OpenToWrite("map level 3.dat")
WriteLine(s,"C")
WriteLine(s,"PASSCODE-IGLU")
WriteLine(s,"2005302630500000")
WriteLine(s,"2111012330111115")
WriteLine(s,"2502402034000000")
WriteLine(s,"1112001521001111")
WriteLine(s,"2052041120400000")
WriteLine(s,"2332320020515000")
WriteLine(s,"2050121111111000")
WriteLine(s,"2011125000002100")
WriteLine(s,"2032333333332510")
WriteLine(s,"1012000000002501")
CloseFile(s)
s=OpenToWrite("map level 4.dat")
WriteLine(s,"D")
WriteLine(s,"PASSCODE-PORT")
WriteLine(s,"2000000000000002")
WriteLine(s,"2222222222222222")
WriteLine(s,"2000000000000002")
WriteLine(s,"2050000000000402")
WriteLine(s,"2411511040050052")
WriteLine(s,"2000000000000002")
WriteLine(s,"2000000500400002")
WriteLine(s,"2050040222045042")
WriteLine(s,"2100000440110002")
WriteLine(s,"2640000000000002")
CloseFile(s)
s=OpenToWrite("map level 5.dat")
WriteLine(s,"E")
WriteLine(s,"PASSCODE-PORT")
WriteLine(s,"2000000020000000")
WriteLine(s,"2111111123333333")
WriteLine(s,"2322220321053001")
WriteLine(s,"2325522321330011")
WriteLine(s,"2322220321553411")
WriteLine(s,"2325220321311331")
WriteLine(s,"2325050321000411")
WriteLine(s,"2302225321003311")
WriteLine(s,"2454444424404444")
WriteLine(s,"2000000060000000")
CloseFile(s)
s=OpenToWrite("map level 6.dat")
WriteLine(s,"F")
WriteLine(s,"PASSCODE-OILS")
WriteLine(s,"0020002002000002")
WriteLine(s,"2023002332011112")
WriteLine(s,"2113333333302002")
WriteLine(s,"2033333333332111")
WriteLine(s,"2533333334332002")
WriteLine(s,"2033335553331112")
WriteLine(s,"2003333333332002")
WriteLine(s,"2000333333302111")
WriteLine(s,"2000000500002000")
WriteLine(s,"2000000400602000")
CloseFile(s)
s=OpenToWrite("map level 7.dat")
WriteLine(s,"G")
WriteLine(s,"PASSCODE-PIPE")
WriteLine(s,"2000000203000002")
WriteLine(s,"2333111202111332")
WriteLine(s,"2000000202000002")
WriteLine(s,"2111050232500002")
WriteLine(s,"2000000232000002")
WriteLine(s,"1111000230000002")
WriteLine(s,"0550030230000002")
WriteLine(s,"0000111211000002")
WriteLine(s,"0044000200455002")
WriteLine(s,"0000006200200002")
CloseFile(s)
s=OpenToWrite("map level 8.dat")
WriteLine(s,"H")
WriteLine(s,"PASSCODE-REEL")
WriteLine(s,"6222252223002225")
WriteLine(s,"2222222223003022")
WriteLine(s,"1111133333111022")
WriteLine(s,"2222200000222022")
WriteLine(s,"2222200000222022")
WriteLine(s,"2251333331111111")
WriteLine(s,"2222500002222225")
WriteLine(s,"1111133333111222")
WriteLine(s,"2225200000222222")
WriteLine(s,"2222200000225222")
CloseFile(s)
s=OpenToWrite("map level 9.dat")
WriteLine(s,"I")
WriteLine(s,"PASSCODE-LOVE")
WriteLine(s,"2000200620000152")
WriteLine(s,"2353233321100112")
WriteLine(s,"2353200321050002")
WriteLine(s,"2303233333011111")
WriteLine(s,"2353230002500152")
WriteLine(s,"2353233312100112")
WriteLine(s,"2333235012150002")
WriteLine(s,"2000203012133333")
WriteLine(s,"2111011112000000")
WriteLine(s,"2000500000000000")
CloseFile(s)
s=OpenToWrite("map level 10.dat")
WriteLine(s,"J")
WriteLine(s,"PASSCODE-IDEA")
WriteLine(s,"5002005005002005")
WriteLine(s,"0112111001112110")
WriteLine(s,"0122120000212210")
WriteLine(s,"0121121001211210")
WriteLine(s,"0520221111220250")
WriteLine(s,"0111220060221110")
WriteLine(s,"0521211111121250")
WriteLine(s,"0120252112520210")
WriteLine(s,"0111212222121110")
WriteLine(s,"5000211001120005")
CloseFile(s)
s=OpenToWrite("map level 11.dat")
WriteLine(s,"K")
WriteLine(s,"PASSCODE-LUCK")
WriteLine(s,"0000000000000020")
WriteLine(s,"3333333311111120")
WriteLine(s,"5023553000000022")
WriteLine(s,"3322330033111112")
WriteLine(s,"5032550300000002")
WriteLine(s,"3023333003111112")
WriteLine(s,"3322330030000022")
WriteLine(s,"3332550353333322")
WriteLine(s,"3033333303333320")
WriteLine(s,"3033333343511126")
CloseFile(s)
s=OpenToWrite("map level 12.dat")
WriteLine(s,"L")
WriteLine(s,"PASSCODE-CARS")
WriteLine(s,"2300000220000032")
WriteLine(s,"2300011221100032")
WriteLine(s,"2300001201000032")
WriteLine(s,"2300001221000032")
WriteLine(s,"2000051221500002")
WriteLine(s,"2111051221501112")
WriteLine(s,"2000051021500002")
WriteLine(s,"2111021221201112")
WriteLine(s,"2000424224240002")
WriteLine(s,"2000020220200600")
CloseFile(s)
s=OpenToWrite("map level 13.dat")
WriteLine(s,"M")
WriteLine(s,"PASSCODE-HELP")
WriteLine(s,"5225020000200020")
WriteLine(s,"2222023333211120")
WriteLine(s,"1031120000201120")
WriteLine(s,"2052333333330120")
WriteLine(s,"2112120000215020")
WriteLine(s,"2052123333211120")
WriteLine(s,"2112120000210020")
WriteLine(s,"2002125005210020")
WriteLine(s,"1112133333311121")
WriteLine(s,"5002000006000025")
CloseFile(s)
s=OpenToWrite("map level 14.dat")
WriteLine(s,"N")
WriteLine(s,"PASSCODE-LIFE")
WriteLine(s,"0003200000020000")
WriteLine(s,"0004250501123300")
WriteLine(s,"2502205521023000")
WriteLine(s,"2002222223022050")
WriteLine(s,"2140060021012000")
WriteLine(s,"2002330021012000")
WriteLine(s,"2532333321012144")
WriteLine(s,"2052055521010000")
WriteLine(s,"2502000021211110")
WriteLine(s,"1111444411015000")
CloseFile(s)
s=OpenToWrite("map level 15.dat")
WriteLine(s,"O")
WriteLine(s,"PASSCODE-OOPS")
WriteLine(s,"2000000020000000")
WriteLine(s,"2111111121112112")
WriteLine(s,"2125211121502100")
WriteLine(s,"2520202621112103")
WriteLine(s,"1121232110000100")
WriteLine(s,"1113152515111110")
WriteLine(s,"0002132310152100")
WriteLine(s,"5332152510102153")
WriteLine(s,"0002112110102100")
WriteLine(s,"1112002000002000")
CloseFile(s)
s=OpenToWrite("map level 16.dat")
WriteLine(s,"P")
WriteLine(s,"PASSCODE-DUAL")
WriteLine(s,"2500020000000022")
WriteLine(s,"2333223333110322")
WriteLine(s,"2352230000350322")
WriteLine(s,"2332103003010322")
WriteLine(s,"2352105005010322")
WriteLine(s,"2333103003010332")
WriteLine(s,"2002150330512002")
WriteLine(s,"3332230000322333")
WriteLine(s,"0003203333023000")
WriteLine(s,"5555200600025555")
CloseFile(s)
s=OpenToWrite("map level 17.dat")
WriteLine(s,"Q")
WriteLine(s,"PASSCODE-CLAW")
WriteLine(s,"0520012222100250")
WriteLine(s,"0025032222305200")
WriteLine(s,"0411012222101140")
WriteLine(s,"5200412222140025")
WriteLine(s,"0250032222300520")
WriteLine(s,"4110112222110114")
WriteLine(s,"2504012222104000")
WriteLine(s,"2500032222300050")
WriteLine(s,"1101112222111010")
WriteLine(s,"0040002262000405")
CloseFile(s)
s=OpenToWrite("map level 18.dat")
WriteLine(s,"R")
WriteLine(s,"PASSCODE-RAIN")
WriteLine(s,"2000002005020230")
WriteLine(s,"2111112000026235")
WriteLine(s,"2000002000121120")
WriteLine(s,"2353332000353320")
WriteLine(s,"2333332000355320")
WriteLine(s,"2300032110023320")
WriteLine(s,"2350532353330220")
WriteLine(s,"2304032000030220")
WriteLine(s,"2543032000444200")
WriteLine(s,"2000402022222200")
CloseFile(s)
s=OpenToWrite("map level 19.dat")
WriteLine(s,"S")
WriteLine(s,"PASSCODE-DONG")
WriteLine(s,"2600000000000002")
WriteLine(s,"2333330000000002")
WriteLine(s,"2333331111105002")
WriteLine(s,"2000000000000002")
WriteLine(s,"2111120000011110")
WriteLine(s,"2000000000000054")
WriteLine(s,"2050011111110304")
WriteLine(s,"2400000000000304")
WriteLine(s,"2001111111110300")
WriteLine(s,"2000000000002000")
CloseFile(s)
s=OpenToWrite("map level 20.dat")
WriteLine(s,"T")
WriteLine(s,"PASSCODE-IONG")
WriteLine(s,"2000000000000002")
WriteLine(s,"2000333233302002")
WriteLine(s,"2440000000005002")
WriteLine(s,"2404300000504032")
WriteLine(s,"2440000204000032")
WriteLine(s,"2000500205000032")
WriteLine(s,"2000400203000032")
WriteLine(s,"2055030200000502")
WriteLine(s,"2000404240054402")
WriteLine(s,"2000000260200002")
CloseFile(s)
endfunction
// Function to create a texture
//
// Inputs - Sizex - size of the texture to create - width
// Sizey - size of the texture to create - height
// Color - is the main color of the image
// Denisity - is a the depth of the texture - the lower the value, the more detail. higher value = no detail
//
// Returns the image for the resulting texture
//
// EG. CreateTexture ( 100, 100, makecolor(0,0,255), 100)
// This could create a DEEP water effect texture?
function createtexture(sizex# as float, sizey# as float, color, density as integer, brick)
r=random(0,6)
if r=0 then color = MakeColor(255,0,0)
if r=1 then color = MakeColor(255,255,0)
if r=2 then color = MakeColor(255,255,255)
if r=3 then color = MakeColor(0,255,0)
if r=4 then color = MakeColor(0,255,255)
if r=5 then color = MakeColor(0,0,255)
if r=6 then color = MakeColor(255,0,255)
swap()
if brick=0
drawbox(0,0,sizex#, sizey#, color, color,color,color, 1)
for a=0 to 3
DrawLine(1+a,1+a,sizex#,1+a,MakeColor(0,0,0),MakeColor(0,0,0))
DrawLine(1+a,1+a,1+a,sizey#,MakeColor(0,0,0),MakeColor(0,0,0))
next
else
drawbox(0,0,sizex#, sizey#, color, color,color,color, 1)
for a=sizey#/2-2 to (sizey#/2)+2
DrawLine(0,a,sizex#,a,MakeColor(0,0,0),MakeColor(0,0,0))
next
for a=sizey#/4-2 to (sizey#/4)+2
DrawLine(a,0,a,sizey#/2,MakeColor(0,0,0),MakeColor(0,0,0))
next
for a=sizey#/2-2 to (sizey#/2)+2
DrawLine(a,sizey#/2,a,sizey#,MakeColor(0,0,0),MakeColor(0,0,0))
next
endif
render()
img = getimage(0,0,sizex#, sizey#)
memblockid = CreateMemblockFromImage (img)
imgwidth = GetMemblockInt(memblockid, 0)
imgheight = GetMemblockInt(memblockid, 4)
size=GetMemblockSize(memblockid)
for offset=12 to size-4 step 4
r=GetMemblockByte(memblockid, offset)
g=GetMemblockByte(memblockid, offset+1)
b=GetMemblockByte(memblockid, offset+2)
a=GetMemblockByte(memblockid, offset+3)
strength=random(1,density)
SetMemblockByte (memblockid, offset, r-strength)
SetMemblockByte (memblockid, offset+1, g-strength)
SetMemblockByte (memblockid, offset+2, b-strength )
SetMemblockByte (memblockid, offset+3, a-strength)
next
deleteimage (img)
img = CreateImageFromMemblock(memblockid)
DeleteMemblock(memblockid)
endfunction img
No media required
Controls
Move around with cursors,
Collect all strawberries to pass to next level
If there any oddities then visit
https://forum.thegamecreators.com/thread/223354 to see how can improve it