Main Menu

Mario demo

Started by LemonWizard, June 05, 2009, 09:50:49 PM

Previous topic - Next topic

LemonWizard

PlayBASIC Code: [Select]
; PROJECT : Project1
; AUTHOR : LemonWizard
; CREATED : 6/5/2009
; EDITED : 6/5/2009
; ---------------------------------------------------------------------


;Mario Engine Tester BETA V 1.0

;make the level
dim level(20, 15)
for tempy=1 to 15
for tempx=1 to 20
level(tempx, tempy)=readdata()
next tempx
next tempy


;Initiate graphics
openscreen 640, 480, 32, 1
;open the screen in a resolution of 640 by 480
dim tiles(11)
tiles(1)=loadnewimage("floor.bmp")
tiles(2)=loadnewimage("brick.bmp")
tiles(3)=loadnewimage("sky.bmp")
tiles(4)=loadnewimage("block2.bmp")
tiles(5)=loadnewimage("pipetopleftside.bmp")
tiles(6)=loadnewimage("pipetoprightside.bmp")
tiles(7)=loadnewimage("pipeleftside.bmp")
tiles(8)=loadnewimage("piperightside.bmp")
tiles(9)=loadnewimage("cloud.bmp")
tiles(10)=loadnewimage("hill.bmp")
tiles(11)=newimage(32, 32)
rendertoimage tiles(11)
cls rgb(255,255,255)
imagemaskcolour tiles(11), rgb(255, 255, 255)
rendertoscreen


Dim mariosmallrun(3)
for temp=1 to 3
mariosmallrun(temp)=loadnewimage("smallmariorun"+str$(temp)+".bmp" )
imagemaskcolour mariosmallrun(temp), rgb(255, 255, 255)
next temp
;set the frame rate cap to 30
setfps 30
;initiate mario's x and y
mariox=32
marioy=getscreenheight()-64
;set mario's position
mario=1 ;1 standing
animcounter=1
animrate=5 ;set the animation rate for mario's frames
defaultspeed=5

main:

rendertoscreen
;draw the floor
for tempy=1 to 15
for tempx=1 to 20
a=level(tempx, tempy)
if a <> 11
drawimage tiles( level(tempx, tempy) ), (tempx-1)*32, (tempy-1)*32, 0
else
drawimage tiles( level(tempx, tempy) ), (tempx-1)*32, (tempy-1)*32, 1
endif
next tempx
next tempy


drawimage mariosmallrun(mario), mariox, marioy, 1
sync
cls rgb(0,0,0)
if leftkey()
mariox=mariox-defaultspeed

animcounter=animcounter+1
if animcounter >animrate then animcounter=1

if animcounter=animrate
mario=mario+1
animcounter=1
if mario >3 then mario=1
endif
endif

if rightkey()
mariox=mariox+defaultspeed
animcounter=animcounter+1
if animcounter >animrate then animcounter=1

if animcounter=animrate
mario=mario+1
animcounter=1
if mario >3 then mario=1
endif


endif


goto main


;map data
;1=floor
;2=brick
;3=sky
;4=block
;5=pipetopleft
;6=pipetopright
;7=pipebottomleft
;8=pipebottomright
;9=cloud (will overwrite anything in it's way)
;10=hill (will overwrite anything in it's way)
;11=transparent
data 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
data 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
data 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
data 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
data 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
data 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
data 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
data 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
data 3, 3, 3, 3, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
data 3, 3, 3, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
data 3, 3, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 5, 6, 3, 3, 3
data 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 8, 3, 3, 3
data 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 8, 3, 3, 3
data 3, 3, 3, 3, 3, 10, 11, 11, 3, 3, 3, 3, 3, 3, 3, 7, 8, 3, 3, 3
data 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1





I was bored...and curios.

ATLUS

#1
and mario jumping, double jumping, triple jumping and etc. =)
PlayBASIC Code: [Select]
; PROJECT : Project1
; AUTHOR : LemonWizard
; CREATED : 05.06.2009
; EDITED : 06.06.2009
; ---------------------------------------------------------------------


;Mario Engine Tester BETA V 1.0

;make the level
dim level(20, 15)
for tempy=1 to 15
for tempx=1 to 20
level(tempx, tempy)=readdata()
next tempx
next tempy


;Initiate graphics
openscreen 640, 480, 32, 1
;open the screen in a resolution of 640 by 480
dim tiles(11)
tiles(1)=loadnewimage("floor.bmp")
tiles(2)=loadnewimage("brick.bmp")
tiles(3)=loadnewimage("sky.bmp")
tiles(4)=loadnewimage("block2.bmp")
tiles(5)=loadnewimage("pipetopleftside.bmp")
tiles(6)=loadnewimage("pipetoprightside.bmp")
tiles(7)=loadnewimage("pipeleftside.bmp")
tiles(8)=loadnewimage("piperightside.bmp")
tiles(9)=loadnewimage("cloud.bmp")
tiles(10)=loadnewimage("hill.bmp")
tiles(11)=newimage(32, 32)
rendertoimage tiles(11)
cls rgb(255,255,255)
imagemaskcolour tiles(11), rgb(255, 255, 255)
rendertoscreen


Dim mariosmallrun(3)
for temp=1 to 3
mariosmallrun(temp)=loadnewimage("smallmariorun"+str$(temp)+".bmp" )
imagemaskcolour mariosmallrun(temp), rgb(255, 255, 255)
next temp
;set the frame rate cap to 30
setfps 60
;initiate mario's x and y
mariox=32
marioy=getscreenheight()-64
;set mario's position
mario=1 ;1 standing
animcounter=1
animrate=5 ;set the animation rate for mario's frames
defaultspeed=5
spd_j=0
acsl=-1
f_ju=0
main:

rendertoscreen
;draw the floor
for tempy=1 to 15
for tempx=1 to 20
a=level(tempx, tempy)
if a <> 11
drawimage tiles( level(tempx, tempy) ), (tempx-1)*32, (tempy-1)*32, 0
else
drawimage tiles( level(tempx, tempy) ), (tempx-1)*32, (tempy-1)*32, 1
endif
next tempx
next tempy


drawimage mariosmallrun(mario), mariox, marioy, 1
sync
cls rgb(0,0,0)
if leftkey()
mariox=mariox-defaultspeed

animcounter=animcounter+1

if animcounter >animrate then animcounter=1

if animcounter=animrate
mario=mario+1
animcounter=1
if mario >3 then mario=1
endif
endif

if rightkey()
mariox=mariox+defaultspeed
animcounter=animcounter+1

if animcounter >animrate then animcounter=1

if animcounter=animrate
mario=mario+1
animcounter=1
if mario >3 then mario=1
endif


endif

if spacekey()=true
spd_j=-10
f_ju=1

endif
if f_ju=1
if spd_j<=100
marioy=marioy+spd_j
spd_j=spd_j-acsl
endif
endif
if marioy>=getscreenheight()-64
marioy=getscreenheight()-64
f_ju=0
endif

goto main


;map data
;1=floor
;2=brick
;3=sky
;4=block
;5=pipetopleft
;6=pipetopright
;7=pipebottomleft
;8=pipebottomright
;9=cloud (will overwrite anything in it's way)
;10=hill (will overwrite anything in it's way)
;11=transparent
data 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
data 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
data 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
data 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
data 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
data 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
data 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
data 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
data 3, 3, 3, 3, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
data 3, 3, 3, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
data 3, 3, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 5, 6, 3, 3, 3
data 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 8, 3, 3, 3
data 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 8, 3, 3, 3
Login required to view complete source code


LemonWizard


kevin


I re-worked your example a bit. 
See -> Mario Demo