MinceRo By Mince by PALMER28th Jun 2009 10:17
|
---|
Summary Mario clone By Mince. Game Covers; 2D Scrolling system. 3D BackDrop. Mouse Activated Menu XTrm Basic. Functions. Data Arrays. Data Types. System Window Control. Lock Pixels. Frame Description MinceRo a Mario Clone ish! Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com Rem Project: Mincero `Ver 1.20 Rem Created: 29/12/2007 12:53:13 `By Brett Palmer Aka MINCE `Theres bits in this old thing I wrote Years Back that May be of interest! `Folding Circles >http://www.FoldingCircles.co.uk set window on set window layout 1,0,0 set window title "Mincero Ver Beta 2.00 BY Mince 2008." minimize window hide window `m_locksystem()`My lock down thingy to stop bugs from switching in older ver of Windows. set dir "media" Rem ***** Main Source File ***** `Mario type game `Art That does not belong to Marios makers I gotfrom ggfm.com global test as byte test = 0 if cl$() = "test" then test = 1 m_init_fps() m_init_throttle() clswhitetoblack() gosub introscreen gosub backdrop gosub load_gfx gosub init_gamevars gosub init_world gosub init_player `test `gosub makelevelrnd gosub loadlevel gosub setup gosub go gosub storepos maximize window show window `test = 1 `------------------------------------- m_red() do m_sync_top() runoutoftime() logic() eupdate() gosub movementandcollision idlecontrol() fire()`New gosub controlfire`New render(scroll#,vscroll#) gosub controlenemys`Must come here directly after render!!!!!!(OnScreenObjectControl) playeronspikes()`Must come soon after render! playeronflag() playeronspring() flashcontrol() animatequestionmarks() if jump.effect = 0 then gosub sgravity debug() spincoins() info() popsmoke() showplayer() greensmoke() animateflag() m_pause() gosub controlpowerups controlejectedcoins() m_throttle(1,4050,0)`(Errorrange) (frequency) (showinfo) rotatebackground(0.025) m_controlmouse() loadsaveicons() slives() m_sync_bottum() loop `------------------------------------- end function runoutoftime() m_sync_top() if timecheck() = 1 dec lives,1 gosub setup`run out of time loose life endif endfunction function slives() if lives <0 gosub diesetup else xoff = 0 if syncready = 1 for l = 1 to lives paste image mridlepic(int(idleframe)),1+xoff,700,1 inc xoff,45 next l endif endif endfunction function animateflag() inc flagframecounter#,0.2 if int(flagframecounter#) >4 then flagframecounter# = 1.0 endfunction function loadsaveicons() if syncready = 1 paste image loadicon#,1,1,1 paste image saveicon#,1024-177,1,1 if m_showtime > 0 if mousex() >1 then if mousex() < 171 then if mousey() >1 then if mousey() < 64 paste image loadicon#,1,1,1 if mouseclick() >0 then loadgame() endif if mousex() > (1024-177) then if mousex() <1023 then if mousey() >1 then if mousey() < 66 paste image saveicon#,1024-177,1,1 if mouseclick() >0 then savegame() endif endif endif endfunction function popsmoke() for s = 1 to maxsmoke if smoke(s).flag = 1 if syncready = 1 then paste image smokepic(int(smoke(s).frame#)),smoke(s).x#,smoke(s).y#,1 inc smoke(s).frame#,0.5 if int(smoke(s).frame#) >5 then smoke(s).flag = 0 endif next s endfunction function greensmoke() for s = 1 to maxsmoke if gsmoke(s).flag = 1 if syncready = 1 then paste image gsmokepic(int(gsmoke(s).frame#)),gsmoke(s).x#,gsmoke(s).y#,1 inc gsmoke(s).frame#,0.5 if int(gsmoke(s).frame#) >8 then gsmoke(s).flag = 0 endif next s endfunction `SUBS movementandcollision: hplayery# = playery# if map(int(pmapx#),int(pmapy#)) = blank# then gosub storepos direction = getdir() move() scrollcontrolh()`HORIZE SCROLL DONE! Left Direction bit scetchy. scrollcontrolv()`VERT SCROLL NEEDS A BIT SMOOTHING. fjump() `bouncecontrol() `springbouncecontrol() `Headbutt Flag if hplayery# > playery# then headbuttposs = 1 else headbuttposs = 0`For Collision with ? Boxes Works out if going in the up direction. `Detect 4 Question Mark if headbuttposs = 1 `Coin if map(int(pmapx#),int(pmapy#)) = qm# jump.effect = 0 play sound brakeblocksound gosub ejectcoins map(int(pmapx#),int(pmapy#)) = qme# endif `Powerup `xmap# as float `ymap# as float `xscrn# as float `yscrn# as float `flag as integer `frame as integer `direction as integer `active as integer `time as integer`Only alive for limited time `offsetx as integer`Logic= if >62 then inc xmap#,1 `offsety as integer `offxcounter# as float`Logic= if>1 then if direction =1 then inc offsetx,0 counter=1:else dec offsetx,0 counter =1 `offycounter# as float `xspd# as float`used as a fractional spd (0.00-0.99). `yspd# as float `falling as integer if map(int(pmapx#),int(pmapy#)) = secretbox# jump.effect = 0 play sound brakeblocksound map(int(pmapx#),int(pmapy#)) = qme# powerup(pucounter).flag = 1 powerup(pucounter).active = 1 powerup(pucounter).xmap# = int(pmapx#) powerup(pucounter).ymap# = int(pmapy#) - 1 powerup(pucounter).offsetx = 0 powerup(pucounter).offsety = 0 powerup(pucounter).offxcounter# = 0 powerup(pucounter).offycounter# = 0 powerup(pucounter).time = 0 powerup(pucounter).direction = 1 powerup(pucounter).xspd# = 1 powerup(pucounter).yspd# = 1 inc pucounter,1 if pucounter > maxpowerups then pucounter = 1 endif endif return ejectcoins: `type cs `x# as float `y# as float `z# as float `flag as integer `x/y(spd#) `hdirection as integer `vdirection as integer `endtype `global dim coinsystem(maxcoins) as cs `Map loc = (int(pmapx#),int(pmapy#)) for coin = 1 to ejectcoins `For ejecting more than 1 coin coinsystem(ecoincounter).flag = 1 coinsystem(ecoincounter).x# = pcenterx - 20`tweaks coinsystem(ecoincounter).y# = playery# - 70`tweaks coinsystem(ecoincounter).xspd# = (1.5 + rnd(2)) + (rnd(10)/10)`get fraction (0.1)-(1.0) coinsystem(ecoincounter).yspd# = (1.5 + rnd(2)) + (rnd(10)/10) inc ecoincounter,1`EjectedCOINCOUNTER if ecoincounter > maxcoins then ecoincounter = 1 next coin return function controlejectedcoins() `type cs `x# as float `y# as float `z# as float `flag as integer `x/y(spd#) `hdirection as integer `vdirection as integer `endtype `global dim coinsystem(maxcoins) as cs `paste image coinpic(int(coinframe)),475,100,1 for c = 1 to maxcoins `Move active coins if coinsystem(c).flag = 1 xspd# = coinsystem(c).xspd#` + (rnd(10)/10) yspd# = coinsystem(c).yspd#` + (rnd(10)/10) if abs(coinsystem(c).x# - 475) >xspd# then if coinsystem(c).x# <475 then inc coinsystem(c).x#,xspd# else dec coinsystem(c).x#,xspd# if abs(coinsystem(c).y# - 100) >yspd# then if coinsystem(c).y# <100 then inc coinsystem(c).y#,yspd# else dec coinsystem(c).y#,yspd# if abs(int(coinsystem(c).x#) - 475)<10 then if abs(int(coinsystem(c).y#) - 100)<10 coinsystem(c).flag = 0 inc coins,1 inc cointolife,1 if cointolife => 100 cointolife = 0 inc lives,1 play sound collectpowerupsound endif play sound collectcoinsound inc time,2*1000`+ Time Seconds endif if syncready = 1 then paste image coinpic(int(coinframe)),coinsystem(c).x#,coinsystem(c).y#,1 endif next c endfunction function spincoins() `coinpic(coinframe) inc coinframe,0.2 if coinframe > 6 then coinframe = 1 endfunction controlenemys: remstart edat(enemynum).offsetx = 0 edat(enemynum).offsety = 0 edat(enemynum).offxcounter# = 0 edat(enemynum).offycounter# = 0 edat(enemynum).xspd# = 0.2 edat(enemynum).yspd# = 0.5 remend for speed = 1 to 3`Moves enemys (3*as fast),another way in increaseing speed of enemy you should only draw things on last loop for e = 1 to maxenemys if edat(e).active = 2 if edat(e).flag = 1 if edat(e).etype = 1`BUG `Move Enemys edat(e).falling = 0`Flag to on Ground(Going left has slight prob I fix later) if edat(e).direction = 0 then if map(int(edat(e).xmap#)+1,int(edat(e).ymap#)+1) = blank# then edat(e).falling = 1 if edat(e).direction = 1 then if map(int(edat(e).xmap#),int(edat(e).ymap#)+1) = blank# then edat(e).falling = 1 if edat(e).falling = 0 if edat(e).direction = 1 then if map(int(edat(e).xmap#)+1,int(edat(e).ymap#)) <> blank# edat(e).direction = 0`Hit something Turn Around. if edat(e).falling = 1 then edat(e).falling = 0 endif if edat(e).direction = 0 then if map(int(edat(e).xmap#),int(edat(e).ymap#)) <> blank# edat(e).direction = 1`Hit something Turn Around. if edat(e).falling = 1 then edat(e)falling = 0 endif inc edat(e).offxcounter#,edat(e).xspd# if edat(e).offxcounter# >1 if edat(e).direction = 1 edat(e).offxcounter# = 0.0 inc edat(e).offsetx,1 if edat(e).offsetx >62 inc edat(e).xmap#,1.0 edat(e).offsetx = 0 endif else edat(e).offxcounter# = 0.0 dec edat(e).offsetx,1 if edat(e).offsetx <0 dec edat(e).xmap#,1.0 edat(e).offsetx = 62 endif endif`direction endif else for fallloop = 1 to 3 inc edat(e).offycounter#,edat(e).yspd# if edat(e).offycounter#>1 edat(e).offycounter# = 0.0 inc edat(e).offsety,1 if edat(e).offsety >50 inc edat(e).ymap#,1.0 edat(e).offsety = 0 endif endif next fallloop endif `Get Enemy Location map to screen edat(e).xscrn# = (((62 * int(edat(e).xmap#)) - (scroll# * 62)) - smoothx) + edat(e).offsetx edat(e).yscrn# = (((50 * int(edat(e).ymap#)) - (vscroll# * 50)) - smoothy) + edat(e).offsety if edat(e).xscrn#< -62 then edat(e).active = 0 if edat(e).xscrn#> 1024 then edat(e).active = 0 if edat(e).yscrn#< -50 then edat(e).active = 0 if edat(e).yscrn#> 768 then edat(e).active = 0 `If still active show(ON SCREEN) & still alive(FLAG) then if edat(e).active = 2 if edat(e).direction = 1 then if syncready = 1 then paste image renemypic#(edat(e).frame),edat(e).xscrn#,edat(e).yscrn#+4,1 if edat(e).direction = 0 then if syncready = 1 then paste image lenemypic#(edat(e).frame),edat(e).xscrn#,edat(e).yscrn#+4,1 inc edat(e).frame,1 if edat(e).frame >4 then edat(e).frame = 1 cenemyx(e) = int(edat(e).xscrn#) + 31 cenemyy(e) = int(edat(e).yscrn#) + 29 osoc(osoccounter).objecttype = 2`Enemy osoc(osoccounter).xpos = cenemyx(e) osoc(osoccounter).ypos = cenemyy(e) osoc(osoccounter).enemynumber = e inc osoccounter,1 gosub killenemy endif`.active = 2 endif`.etype = Bug(1) `Bee Control if edat(e).etype = 2 `Get relevence to player and move towards a fire state. endif endif`.Flag endif`Active next e next speed return killenemy:`Or Player got killed ` pcenterx ` pcentery spotxsize = 30 spotysize = 30 if jump.flag = 1 if jump.time >15 if abs(cenemyx(e) - pcenterx) < spotxsize then if abs(cenemyy(e) - pcentery)< spotysize if pcentery < cenemyy(e) play sound epopsound `Bounce edat(e).flag = 0 edat(e).active = 0 bounce = 1 `POP smoke(smokecounter).flag = 1 smoke(smokecounter).x# = cenemyx(e)-31 smoke(smokecounter).y# = cenemyy(e)-10 smoke(smokecounter).frame# = 1 inc smokecounter,1 if smokecounter > maxsmoke then smokecounter = 1 else if flash = 0 if big = 0 play sound diesound dec lives,1 gosub setup else big = 0 weapon = 0 endif endif endif`above enemy? endif endif endif if edat(e).flag = 1 if abs(cenemyx(e) - pcenterx) < spotxsize then if abs(cenemyy(e) - pcentery)<spotysize if falling = 1 play sound epopsound edat(e).flag = 0 edat(e).active = 0 bounce = 1 `POP smoke(smokecounter).flag = 1 smoke(smokecounter).x# = cenemyx(e)-31 smoke(smokecounter).y# = cenemyy(e)-10 smoke(smokecounter).frame# = 1 inc smokecounter,1 if smokecounter > maxsmoke then smokecounter = 1 else`By now the only collision results in death if not flashing! if flash = 0 if big = 0 play sound diesound dec lives,1 gosub setup else big = 0 weapon = 0 endif endif endif`Falling endif`Collision endif`flag return controlpowerups: for speed = 1 to 4`four times as fast for e = 1 to maxpowerups if powerup(e).active = 1 if powerup(e).flag = 1 inc powerup(e).time,1 `Move Magic Mushrooms powerup(e).falling = 0 if powerup(e).direction = 0 then if map(int(powerup(e).xmap#)+1,int(powerup(e).ymap#)+1) = blank# then powerup(e).falling = 1 if powerup(e).direction = 1 then if map(int(powerup(e).xmap#),int(powerup(e).ymap#)+1) = blank# then powerup(e).falling = 1 if powerup(e).falling = 0 if powerup(e).direction = 1 then if map(int(powerup(e).xmap#)+1,int(powerup(e).ymap#)) <> blank# powerup(e).direction = 0`Hit something Turn Around. if powerup(e).falling = 1 then powerup(e).falling = 0 endif if powerup(e).direction = 0 then if map(int(powerup(e).xmap#),int(powerup(e).ymap#)) <> blank# powerup(e).direction = 1`Hit something Turn Around. if powerup(e).falling = 1 then powerup(e)falling = 0 endif inc powerup(e).offxcounter#,powerup(e).xspd# if powerup(e).offxcounter# >1 if powerup(e).direction = 1 powerup(e).offxcounter# = 0.0 inc powerup(e).offsetx,1 if powerup(e).offsetx >62 inc powerup(e).xmap#,1.0 powerup(e).offsetx = 0 endif else powerup(e).offxcounter# = 0.0 dec powerup(e).offsetx,1 if powerup(e).offsetx <0 dec powerup(e).xmap#,1.0 powerup(e).offsetx = 62 endif endif`direction endif else for fallloop = 1 to 3 inc powerup(e).offycounter#,powerup(e).yspd# if powerup(e).offycounter# >1 powerup(e).offycounter# = 0.0 inc powerup(e).offsety,1 if powerup(e).offsety >50 inc powerup(e).ymap#,1.0 powerup(e).offsety = 0 endif endif next fallloop endif `Get PowerUp Location map to screen powerup(e).xscrn# = (((62 * int(powerup(e).xmap#)) - (scroll# * 62)) - smoothx) + powerup(e).offsetx powerup(e).yscrn# = (((50 * int(powerup(e).ymap#)) - (vscroll# * 50)) - smoothy) + powerup(e).offsety if powerup(e).xscrn#< -62 then powerup(e).active = 0 if powerup(e).xscrn#> 1024 then powerup(e).active = 0 if powerup(e).yscrn#< -50 then powerup(e).active = 0 if powerup(e).yscrn#> 768 then powerup(e).active = 0 `Timed Life cycle if powerup(e).time > poweruplifetime then powerup(e).flag = 0`Too Late Its Gone! `If still active show(ON SCREEN) if powerup(e).active = 1 if powerup(e).direction = 1 then if syncready = 1 then if big = 0 then paste image powerup#,powerup(e).xscrn#,powerup(e).yscrn#+4,1 else paste image powerupfire#,powerup(e).xscrn#,powerup(e).yscrn#+4,1 if powerup(e).direction = 0 then if syncready = 1 then if big = 0 then paste image powerup#,powerup(e).xscrn#,powerup(e).yscrn#+4,1 else paste image powerupfire#,powerup(e).xscrn#,powerup(e).yscrn#+4,1 inc powerup(e).frame,1 if powerup(e).frame >4 then powerup(e).frame = 1 `Collect Powerup!? cpowerupx(e) = int(powerup(e).xscrn#) + 30 cpowerupy(e) = int(powerup(e).yscrn#) + 29 if abs(cpowerupx(e) - pcenterx) <30 then if abs(cpowerupy(e) - pcentery) <30 play sound collectpowerupsound powerup(e).flag = 0 powerup(e).active = 0 if big = 0 big = 1 else if weapon = 0 weapon = 1`Get Big Or Get Fire Power. else if firepower = firedelaystart firepower = 150 else firepower = 80 endif`firepower endif`weapon = 0 m_firedelay = firepower`set firedelay times endif`big = 0 endif endif endif endif next e next speed return function fire() `weptype as integer `x# as float `y# as float `spd# as float `flag as integer `mapx# as float `mapy# as float `frame# as float `direction as integer `active as integer `time as integer`Only alive for limited time `offsetx as integer`Logic= if >62 then inc xmap#,1 `offsety as integer `offxcounter# as float`Logic= if>1 then if direction =1 then inc offsetx,0 counter=1:else dec offsetx,0 counter =1 `offycounter# as float ` `I could just not wory about checking the map and just check for colision via what images are on `screen but I wont to try this way just to see first. `Screen x/y co-ords> `.xscrn# = (((62 * int(.xmap#)) - (scroll# * 62)) - smoothx) + .offsetx `.yscrn# = (((50 * int(.ymap#)) - (vscroll# * 50)) - smoothy) + .offsety `SO.. I think Map location> `map location = ((xscrn# - offsetx) + (scroll# * 62))) / 62 = xmap# `And that didnt work try again another day!. if weapon = 1 if m_firesys = 0 global m_firesys as integer m_firesys = 1 global firetimer as integer global fireoldtimer as integer firetimer = timer() fireoldtimer = firetimer global m_firedelay as integer m_firedelay = firepower endif firetimer = timer() if controlkey() = 1 `FIRE if firetimer => (fireoldtimer + m_firedelay)`Fire delay in ms play sound firesound `Look like fireing frame = 1 idle = 0 fireoldtimer = firetimer wep(wepcounter).flag = 1 wep(wepcounter).active = 1 ` wep(wepcounter).mapx# = pmapx# ` wep(wepcounter).mapy# = pmapy# wep(wepcounter).direction = direction wep(wepcounter).time = 0 ` wep(wepcounter).offsetx = int(scroll#) + xstep ` wep(wepcounter).offsety = int(vscroll#) + ystep ` wep(wepcounter).offxcounter# = 0 ` wep(wepcounter).offycounter# = 0 wep(wepcounter).frame# = 1.0 wep(wepcounter).spd# = 7 wep(wepcounter).x# = pcenterx - 8 wep(wepcounter).y# = pcentery - 8 inc wepcounter,1 if wepcounter > maxfireobjects then wepcounter = 1 endif else fireoldtimer = fireoldtimer - firedelay`Allows fire first time instant but if you hold fire it will restrict speed endif endif endfunction controlfire: `Here is how to implement a entity into this logic wold `using scroll# and vscroll together with mapx# and mapy# you get map location add the scroll offsets `and your there on screen. `If you compare the bug enemy move function to this 1 you will notice the over values, thease keep `everything running correctly. `To make a object move faster than 1 unit a time u must then subtract the over values `eg inc x,3 if then x>2 resulted in moving across u would loose 1 unit unless you follow example. `The offxcounter# is used to really slow and smooth things out and I probly wont use them in this sub. remstart for e = 1 to maxfireobjects if wep(e).flag = 1 inc wep(e).time,1 `Move in direction fired if wep(e).direction = 1`Right `inc wep(e).offxcounter#,speed# `wep(e).offxcounter# = 0.0 inc wep(e).offsetx,4 if wep(e).offsetx >62 over = wep(e).offsetx - 62 inc wep(e).mapx#,1.0 wep(e).offsetx = over endif else dec wep(e).offsetx,4 if wep(e).offsetx <0 over = abs(0 - wep(e).offsetx) dec wep(e).mapx#,1.0 wep(e).offsetx = 62 - over endif endif`direction `If flaged Work out screen co-ords wep(e).x# = (((62 * int(wep(e).mapx#) - (scroll# * 62)) - smoothx) + wep(e).offsetx wep(e).y# = (((50 * int(wep(e).mapy#) - (vscroll# * 50)) - smoothy) + (wep(e).offsety + 15) `Collision control. `Show image paste image shellgreen(int(wep(e).frame#)),wep(e).x#,wep(e).y#,1 `Animate Shell Frame. inc wep(e).frame#,0.3 if int(wep(e).frame#) > 4 then wep(e).frame# = 1.0 endif`flag = 1 `Life time check. if wep(e).time > 100 then wep(e).flag = 0 next e remend for s = 1 to maxfireobjects if wep(s).flag = 1 for osoccheck = 1 to osoccounter if abs(osoc(osoccheck).xpos - (int(wep(s).x#)+8)) < 30 then if abs(osoc(osoccheck).ypos - (int(wep(s).y#)+8)) <30 if osoc(osoccheck).objecttype = 2`Enemy play sound epopsound `(KILL ENEMY) edat(osoc(osoccheck).enemynumber).flag = 0 edat(osoc(osoccheck).enemynumber).active = 0 `POP Smoke `Smokey Bacon! smoke(smokecounter).flag = 1 smoke(smokecounter).x# = cenemyx(osoc(osoccheck).enemynumber) - 31 smoke(smokecounter).y# = cenemyy(osoc(osoccheck).enemynumber) - 10 smoke(smokecounter).frame# = 1 inc smokecounter,1 if smokecounter > maxsmoke then smokecounter = 1 `Green smoke gsmoke(gsmokecounter).flag = 1 gsmoke(gsmokecounter).x# = cenemyx(osoc(osoccheck).enemynumber) - 31 gsmoke(gsmokecounter).y# = cenemyy(osoc(osoccheck).enemynumber) - 10 gsmoke(gsmokecounter).frame# = 1 inc gsmokecounter,1 if gsmokecounter > maxsmoke then gsmokecounter = 1 wep(s).flag = 0`Remove Shell `REmove from osoc! osoc(osoccheck).objecttype = 99`Enemy removed! else`A block if osoc(osoccheck).objecttype = 1`Block wep(s).flag = 0 `Play Hit block sound play sound shellsound `Green smoke gsmoke(gsmokecounter).flag = 1 gsmoke(gsmokecounter).x# = int(wep(s).x#) gsmoke(gsmokecounter).y# = int(wep(s).y#) gsmoke(gsmokecounter).frame# = 1 inc gsmokecounter,1 if gsmokecounter > maxsmoke then gsmokecounter = 1 endif `else must been sumin now removed from osoc endif`osoc endif`collision next osoccheck if wep(s).direction = 1 inc wep(s).x#,wep(s).spd# else dec wep(s).x#,wep(s).spd# endif `Show if syncready = 1 then paste image shellgreen(int(wep(s).frame#)),wep(s).x#,wep(s).y#,1 `Collision with map `collision with enemy `timecheck inc wep(s).time,1 if wep(s).time > 150 then wep(s).flag = 0 `Animation inc wep(s).frame#,0.7 if int(wep(s).frame#) > 4 then wep(s).frame# = 1 endif`flag next s return function playeronspikes() if flash = 0 for osoccheck = 1 to osoccounter if osoc(osoccheck).objecttype = 3`Spike flag xspotsize = 32 yspotsize = 15 spikeoffset = 25 yosoc = osoc(osoccheck).ypos + spikeoffset`Floor pos feet = pcentery + 24`Feet pos if abs(osoc(osoccheck).xpos - pcenterx) <xspotsize then if abs(yosoc - feet)< yspotsize if big = 1 play sound screamsound big = 0 weapon = 0 firepower = firedelaystart flash = 1 flashtimer = timer() flasholdtimer = flashtimer flashcounter = 0 flashblank = 1 else`Your Dead if not flashing if flash = 0 if big = 0 play sound diesound dec lives,1 gosub setup else big = 0 weapon = 0 endif endif endif endif endif`Spikeflag next osoccheck endif`flash endfunction function playeronflag() for osoccheck = 1 to osoccounter if osoc(osoccheck).objecttype = 4 `redflag xspotsize = 32 yspotsize = 15 flagoffset = 25 yosoc = osoc(osoccheck).ypos + flagoffset`Floor pos feet = pcentery + 24`Feet pos if abs(osoc(osoccheck).xpos - pcenterx) <xspotsize then if abs(yosoc - feet)< yspotsize `Delete flag from map seems a easy way! or turn it green? map(osoc(osoccheck).xmap,osoc(osoccheck).ymap) = gcheckpointflag# play sound completelevelsound savecheckpoint() endif endif`Spikeflag next osoccheck endfunction function playeronspring() for osoccheck = 1 to osoccounter if osoc(osoccheck).objecttype = 6 `spring xspotsize = 32 yspotsize = 15 offset = 25 yosoc = osoc(osoccheck).ypos + offset`Floor pos feet = pcentery + 24`Feet pos if abs(osoc(osoccheck).xpos - pcenterx) <xspotsize then if abs(yosoc - feet)< yspotsize springbounce = 1 ` jump.flag = 1 ` jump.land = 0 ` jump.effect = 1 ` Change spring pic ` map(osoc(osoccheck).xmap,osoc(osoccheck).ymap) = ` play sound springsound endif endif`Spikeflag next osoccheck endfunction function flashcontrol() if flash = 1 flashtimer = timer() inc flashcounter,1 if flashcounter > 6 flashcounter = 0 if flashblank = 0 then flashblank = 1 else flashblank = 0 endif if flashtimer > flasholdtimer + 1000`1 second flash = 0 flashblank = 0 endif endif endfunction function eupdate() `xmap# as float `ymap# as float `xscrn# as float `yscrn# as float `flag as integer `direction as integer `active as integer 0 = off screen 1 = come into play 2 = active for e = 1 to maxenemys if edat(e).flag = 1 if edat(e).active = 0 if abs(edat(e).xmap# - pmapx#)<8 then if abs(edat(e).ymap# - pmapy#)<10 edat(e).active = 2 edat(e).xscrn# = (62 * int(edat(e).xmap#)) - (scroll# * 62) edat(e).yscrn# = (50 * int(edat(e).ymap#)) - (vscroll# * 50) endif endif endif next e endfunction function animatequestionmarks() inc qmfnum,0.100 if qmfnum > 6 then qmfnum = 1 endfunction function idlecontrol() inc idleframe,0.0100 if idleframe>4 then idleframe = 1 endfunction function timecheck() rval = 0 timestamp = timer() dec time,abs(timestamp-oldtimestamp) oldtimestamp = timestamp if time<0 play sound diesound rval = 1 endif endfunction rval go: show object bgob for a = 1 to 100 move camera 15 rotatebackground(0.025) fastsync next a return introscreen: mincero# = m_asignpic() load image "mincero.png",mincero# paste image mincero#,512-(382/2),20,1 m_brightgreen() center text 512,650,"LOADING." sync return backdrop: global bgob as integer bgob = 1 backdroppic# = m_asignpic() load image "sky.png",backdroppic# make object sphere bgob,1250 SET OBJECT bgob, 1, 0, 0, 1, 0, 1, 1 texture object bgob,backdroppic# global rotbg# as float global rotbgy# as float point camera 0,0,0 `show object bgob`test hide object bgob return function rotatebackground(speed#) rotbg# = wrapvalue(rotbg#+speed#)`rotate angle rotbgy# = wrapvalue(rotbgy#+speed#) rotate object bgob,0,rotbgy#,0 endfunction storepos: spmapx# = pmapx# spmapy# = pmapy# splayerx# = playerx# splayery# = playery# sxstep = xstep systep = ystep sscroll# = scroll# `svscroll#=vscroll# return restorepos: pmapx# = spmapx# pmapy# = spmapy# playerx# = splayerx# playery# = splayery# xstep = sxstep ystep = systep scroll# = sscroll# `vscroll# = svscroll# return restorex: pmapx# = spmapx# `pmapy# = spmapy# playerx# = splayerx# `playery# = splayery# xstep = sxstep `ystep = systep scroll# = sscroll# `vscroll# = svscroll# return function savecheckpoint() `ALL INFO I NEED ` checkp>>> `playermapx# as float `playermapy# as float `playerscreenx# as float `playerscreeny# as float `renderxstep as integer `renderystep as integer `renderscroll# as float `rendervscroll# as float `rendersmoothx as integer `rendersmoothy as integer `- `> checkpoint as checkp `spmapx# = pmapx# `spmapy# = pmapy# `splayerx# = playerx# `splayery# = playery# `sxstep = xstep `systep = ystep `sscroll# = scroll# `svscroll#=vscroll# checkpoint(1).playermapx# = pmapx# checkpoint(1).playermapy# = pmapy# checkpoint(1).playerscreenx# = playerx# checkpoint(1).playerscreeny# = playery# checkpoint(1).renderxstep = xstep checkpoint(1).renderystep = ystep checkpoint(1).renderscroll# = scroll# checkpoint(1).rendervscroll# = vscroll# checkpoint(1).rendersmoothx = smoothx checkpoint(1).rendersmoothy = smoothy checkpointflag = 1 `Update The Save array cache gamedat(1) = pmapx# gamedat(2) = pmapy# gamedat(3) = playerx# gamedat(4) = playery# gamedat(5) = xstep gamedat(6) = ystep gamedat(7) = scroll# gamedat(8) = vscroll# gamedat(9) = smoothx gamedat(10) = smoothy gamedat(11) = time gamedat(12) = coins gamedat(13) = level gamedat(14) = lives gamedat(15) = big gamedat(16) = weapon gamedat(17) = firepower gamedat(18) = frame gamedat(19) = direction endfunction function savegame()`save can be direclysaved saving esact position just call savecheckpoint() first, or just at checkpoints. `Save (Save array Cache). savecheckpoint() save array "game.dat",gamedat(25) save array "gameinfo.dat",map(0,0) endfunction function loadgame() load array "game.dat",gamedat(25) load array "gameinfo.dat",map(0,0) pmapx# = gamedat(1) pmapy# = gamedat(2) playerx# = gamedat(3) playery# = gamedat(4) xstep = gamedat(5) ystep = gamedat(6) scroll# = gamedat(7) vscroll# = gamedat(8) smoothx = gamedat(9) smoothy = gamedat(10) time = gamedat(11) coins = gamedat(12) level = gamedat(13) lives = gamedat(14) big = gamedat(15) weapon = gamedat(16) firepower = gamedat(17) frame = gamedat(18) direction = gamedat(19) savecheckpoint()`so if player dies hed continue from loaded position. endfunction function restorecheckpoint() pmapx# = checkpoint(1).playermapx# pmapy# = checkpoint(1).playermapy# playerx# = checkpoint(1).playerscreenx# playery# = checkpoint(1).playerscreeny# xstep = checkpoint(1).renderxstep ystep = checkpoint(1).renderystep scroll# = checkpoint(1).renderscroll# vscroll# = checkpoint(1).rendervscroll# smoothx = checkpoint(1).rendersmoothx smoothy = checkpoint(1).rendersmoothy endfunction function move() `spdcontrol `spdtimer=timer() `spdoldtime=spdtimer `spddelay=100`ms idle = 1 fstore = frame frame = 1`reset to standing position sspd = spdcounterdelay spdcounterdelay = 1 gosub storepos `Test Save checkpoint. if test = 1 if returnkey() = 1 savecheckpoint() wait 100 endif endif storestate# = spd# dec spd#,1 if spd#<0 then spd#=0 if spacekey() = 1 if jump.land = 0 then idle = 0 endif `ALSO WHEN FALLING if falling = 1 then idle = 0 `Slowly increase speed if rightkey() = 1 idle = 0 frame = fstore gosub framecontrol spd# = storestate# spdcounterdelay = sspd inc spdcounterdelay,1 if spdcounterdelay > player_excel_controlspd if (spd# + 1) < maxspd# then inc spd#,1 else spd# = maxspd# spdcounterdelay = 1 endif endif if leftkey() = 1 idle = 0 frame = fstore gosub framecontrol spd# = storestate# spdcounterdelay = sspd inc spdcounterdelay,1 if spdcounterdelay > player_excel_controlspd if (spd# + 1) < maxspd# then inc spd#,1 else spd# = maxspd# spdcounterdelay = 1 endif endif `Resulting> `x/y step allows flow from 1 map unit to another. over = 0 `move player in direction at spd# if direction = 0 if pmapx# > 0 if playerx# > hscrollfarleft `149 ` if map(int(pmapx#),int(pmapy#))=blank# dec playerx#,spd# dec xstep,int(spd#) if xstep <1 over = abs(0-xstep) dec pmapx#,1 xstep = maxxstep-over endif endif endif`pmapx>0 else`direction =1 if pmapx# <1024-16 if playerx# < hscrollfarright `862 ` if map(int(pmapx#+spd#),int(pmapy#))=blank# inc playerx#,spd# inc xstep,int(spd#) if xstep > maxxstep`blocksizex inc pmapx#,1 over = abs(maxxstep-xstep) xstep = 0+over endif endif endif`pmapx<1024 endif`direction `WALKING COLLISION ONLY! ¬ `LAND `PLACE ALL RENDERD BACKGROUND IMIGES INTO if <> then `BACKGROUND WALK if map(int(pmapx#),int(pmapy#)) <> blank# if map(int(pmapx#),int(pmapy#)) <> spikes# if map(int(pmapx#),int(pmapy#)) <> rcheckpointflag# if map(int(pmapx#),int(pmapy#)) <> gcheckpointflag# if map(int(pmapx#),int(pmapy#)) <> springpic# then gosub restorex endif endif endif endif `AIR Jump or Fall `BACKGROUND JUMP if pmapy# - int(pmapy#)>0.07`Find Decimal Difference if just within a small margin, `This will allow for jumping in between blocks 1 high above another. if jump.land = 0 then if map(int(pmapx#),int(pmapy#+1)) <> blank# if jump.land = 0 then if map(int(pmapx#),int(pmapy#+1)) <> spikes# if jump.land = 0 then if map(int(pmapx#),int(pmapy#+1)) <> rcheckpointflag# if jump.land = 0 then if map(int(pmapx#),int(pmapy#+1)) <> gcheckpointflag# if jump.land = 0 then if map(int(pmapx#),int(pmapy#+1)) <> springpic# then gosub restorex endif`gf endif`rf endif`spikes endif`blank `BACKGROUND FALL if falling = 1 then if map(int(pmapx#),int(pmapy#+1)) <> blank# if map(int(pmapx#),int(pmapy#+1)) <> spikes# if map(int(pmapx#),int(pmapy#+1)) <> rcheckpointflag# if map(int(pmapx#),int(pmapy#+1)) <> gcheckpointflag# if map(int(pmapx#),int(pmapy#+1)) <>springpic then gosub restorex endif`gf endif`rf endif`spikes endif`blank endif`pmapy# - int(pmapy#)>0.07 endfunction framecontrol: `global frame as integer `global framedelay as integer`Time in ms `global framecounter as integer `global frametimer as integer`new `global oldframetimer as integer`old `oldframetimer = timer() `frametimer = timer() frametimer = timer() if frametimer> oldframetimer + framedelay oldframetimer = frametimer inc frame,1 if frame > 6 then frame = 1 endif return function getdir()`?da fk for image rep d = direction if leftkey() = 1 then d = 0 if rightkey() = 1 then d = 1 direction = d d = direction endfunction d function scrollcontrolh()`Horizental Scroll `scroll# = 0.0 `scrolldir = 1`right `scrollspd# = 1.0 `scrollamount = 0 if playerx# >800 `scroll# = 0.0 scrolldir = 1`right scrollspd# = 1.0 scrollamount = 1 endif if playerx#<262 then if scroll#>0`fix (was 211) `scroll# = 0.0 scrolldir = 0`left scrollspd# = 1.0 scrollamount = 1 endif if scrollamount>0 if scrolldir = 1 inc smoothx,int(spd#) if smoothx > maxsmoothx smoothx = 0 inc scroll#,scrollspd# dec scrollamount,scrollspd# dec playerx#,62 endif else dec smoothx,int(spd#) if smoothx < 0 smoothx = maxsmoothx dec scroll#,scrollspd# dec scrollamount,scrollspd# inc playerx#,62 endif`smoothx<0 endif`scrolldir=1 endif`scrollamout>0 endfunction function scrollcontrolv()`Verticle Scroll Needs Work. `vscroll#=0.0 `vscrolldir=1`down `vscrollspd#=1.0 `vscrollamount =0 `V spd# here can only be gravity or jump so I don't know how I can Get this bit to work 100%. if playery# >600 `vscroll#=0.0 vscrolldir = 1`right vscrollspd# = 1.0 vscrollamount = 1 endif if playery# <200 then if vscroll#>0 `vscroll#=0.0 vscrolldir = 0`up vscrollspd# = 1.0 vscrollamount = 1 endif if vscrollamount>0 if vscrolldir = 1 inc smoothy,4`int(spd#)`_________--------FIX if smoothy >maxsmoothy smoothy = 0 inc vscroll#,vscrollspd# dec vscrollamount,vscrollspd# dec playery#,50`Block size endif else dec smoothy,4`int(spd#) if smoothy<0 smoothy = maxsmoothy dec vscroll#,vscrollspd# dec vscrollamount,vscrollspd# inc playery#,50`Block size endif`smoothx<0 endif`vscrolldir=1 endif`vscrollamout>0 endfunction function render(xscroll#,yscroll#) if test = 1 then mt = timer() `objecttype as integer `xpos as integer `ypos as integer `osoccounter as integer `maxosocobjects as integer `maxosocobjects = 2000 `osoccounter = 1 `dim osoc(maxosocobjects) as objectcontrol xblocksize = 62 yblocksize = 50 xblock = 1 yblock = 1 `lev = 1`needs to be worked out via pmapy! fix `offx =int(pmapx# -8)`offsets `offy =int(pmapy# -7)`offsets offy = int(yscroll#)`offsets offx = int(xscroll#) if offx < 0 then offx = 0 if offy < 0 then offy = 0 lock pixels osoccounter = 1 for x = 0 to 17`16 for y = 0 to 16 `15 `try some good old fashioned loop unrolling! dat = map(x+offx,y+offy) if dat <> blank# `Laser Gates type onscreen object control buffer. `the added values after brackets center the position. if dat = springpic# osoc(osoccounter).objecttype = 6`Spring Flag osoc(osoccounter).xpos = (x*xblocksize-smoothx) + 31 osoc(osoccounter).ypos = (y*yblocksize-smoothy) + 25 osoc(osoccounter).xmap = x+offx osoc(osoccounter).ymap = y+offy inc osoccounter,1 else if dat = rcheckpointflag# osoc(osoccounter).objecttype = 4`Check point flag osoc(osoccounter).xpos = (x*xblocksize-smoothx) + 31 osoc(osoccounter).ypos = (y*yblocksize-smoothy) + 25 osoc(osoccounter).xmap = x+offx osoc(osoccounter).ymap = y+offy inc osoccounter,1 else ` if dat <> gcheckpointflag# if dat <> spikes# then osoc(osoccounter).objecttype = 1 else osoc(osoccounter).objecttype = 3`For Map type block 1 = normal 3 = spikes osoc(osoccounter).xpos = (x*xblocksize-smoothx) + 31 osoc(osoccounter).ypos = (y*yblocksize-smoothy) + 25 osoc(osoccounter).xmap = x+offx osoc(osoccounter).ymap = y+offy inc osoccounter,1 ` endif`gflag endif`if a checkpoint dont worry rflag endif `dat = Spring `Forground to Background + Animation. if syncready = 1 if dat = gcheckpointflag# paste image gflag(int(flagframecounter#)),x*xblocksize-smoothx,y*yblocksize-smoothy,1 else if dat = rcheckpointflag# paste image rflag(int(flagframecounter#)),x*xblocksize-smoothx,y*yblocksize-smoothy,1 else if dat = secretbox# paste image qmframe(int(qmfnum)),x*xblocksize-smoothx,y*yblocksize-smoothy,1 else if dat = qm# paste image qmframe(int(qmfnum)),x*xblocksize-smoothx,y*yblocksize-smoothy,1 else paste image dat,x*xblocksize-smoothx,y*yblocksize-smoothy,1 endif endif endif endif` = rcheckpointflag endif`greenflag endif`syncready = 1 next y next x unlock pixels if test = 1 then if syncready = 1 then rendertime = timer() - mt endfunction function logic() `YARDE YARDA YEARDI endfunction function bouncecontrol() `Bounce control if bounce = 1 jump.flag = 1 jump.land = 0 jump.effect = 1 jump.time = 0 inc bouncetime,1 if bouncetime > bounceheight bounce = 0`reset bouncetime = 0 endif endif endfunction function springbouncecontrol() `Spring Bounce control if springbounce = 1 jump.flag = 1 jump.land = 0 jump.effect = 1 jump.time = - 50`FIX SPRING inc springbouncetime,1 if springbouncetime > springbounceheight springbounce = 0`reset springbouncetime = 0 endif endif endfunction function fjump() `The Flag Control if spacekey() = 1 if jump.land = 1 `reset cos spae pressed jump.flag = 1 jump.land = 0 jump.effect = 1 `gosub storepos endif else if bounce = 0 or springbounce = 0 jump.flag = 0 jump.effect = 0 endif endif if bounce = 0 or springbounce = 0 if jump.flag = 1 then inc jump.time,1 if jump.time>130/3 jump.effect = 0 endif endif `Test loc¬ springbouncecontrol() bouncecontrol() ``Bounce control `if bounce = 1 ` jump.flag = 1 ` jump.land = 0 ` jump.effect = 1 ` jump.time = 0 ` inc bouncetime,1 ` if bouncetime > bounceheight ` bounce = 0`reset ` bouncetime = 0 ` endif `endif `The Effect if jump.flag = 1 then if jump.effect = 1 `1 if map(int(pmapx#),int(pmapy#-0.02)) = blank# `or if map(int(pmapx#),int(pmapy#-0.02)) = upsidedownspikes# dec playery#,1 dec pmapy#,0.02 endif `2 if map(int(pmapx#),int(pmapy#-0.02)) = blank# dec playery#,1`1 pixel dec pmapy#,0.02`1/64 steps endif `3 if map(int(pmapx#),int(pmapy#-0.02)) = blank# dec playery#,1 dec pmapy#,0.02 else`On Last try need to increase height if a QM box or POWERUP then need to get close enough to Flag Hit box. if map(int(pmapx#),int(pmapy#-0.02)) = qm# dec playery#,1 dec pmapy#,0.02 else if map(int(pmapx#),int(pmapy#-0.02)) = secretbox# dec playery#,1 dec pmapy#,0.02 endif endif endif endif endfunction function debug()`System info Performance States if test = 1 text 100,210,"MAP POSITION("+str$(pmapx#,2)+","+str$(pmapy#,2)+")" text 100,230,"MAP LOGIC POSITION("+str$(int(pmapx#))+","+str$(int(pmapy#))+")" text 100,250,"MAP Xstep("+str$(xstep)+")" text 100,270,"Headbutt:"+str$(headbuttposs) text 100,290,"Loop Time("+str$(looptime)+")" text 100,310,"Ave Loop time("+str$(avelooptime#)+")" text 100,330,"Total Loops(+"+str$(loops)+")" text 100,350,"Render time("+str$(rendertime)+")" text 100,370,"Ave Render time("+str$(averendertime#)+")" text 100,390,"Mouse SYS Total Frame Time="+str$(m_elapsed)+" ms." text 100,410,"Mouse SYS Total Running Time="+str$(m_totalrunningtime/1000)+" Seconds." text 100,430,"AVE SYNC MEMORY TIME("+str$(avesynctimems#)+")" text 100,450,"SYNC MEMORY TIME("+str$(synctimems)+")" text 100,500,"FPS("+str$(m_fpsspeed)+")" endif endfunction function info() text 512,100,"TIME("+str$(time/1000)+")"`time ms>seconds text 512,120,"COINS["+str$(coins)+"]" paste image coinpic(int(coinframe)),475,100,1 endfunction sgravity: `fall while in air for loopdrop = 1 to 3 x = int(pmapx#) y = int(pmapy#) `text 400,200,"x="+str$(x) `if in air> `PLACE ALL BACKGROUND RENDERD IMAGES HERE TOO! if map(x,y+1) = blank# or map(x,y+1) = spikes# or map(x,y+1) = rcheckpointflag# or map(x,y+1) = gcheckpointflag# or map(x,y+1) =springpic# `Fall `text 100,100,"FALLING!"+str$(pmapx#,3)+" "+str$(pmapy#,3) inc pmapy#,0.02 `1/50 inc playery#,1 falling = 1 else if pmapy# - int(pmapy#) >0.04 `Fall cos in between a fall or not a fall so fall! `text 100,100,"FALLING!"+str$(pmapx#,3)+" "+str$(pmapy#,3) inc pmapy#,0.02 `1/50 inc playery#,1 falling = 1 else falling = 0 jump.land = 1 jump.effect = 1 if jump.flag = 0 then jump.time = 0 `only reset when .flag = 0 ie when spacebar let go. endif`>0.4 endif `soc(16,15) next loopdrop return function gravity() `fall while in air for loopdrop = 1 to 3 x = int(pmapx#) y = int(pmapy#) `text 400,200,"x="+str$(x) `if in air> `PLACE ALL BACKGROUND RENDERD IMAGES HERE TOO! if map(x,y+1) = blank# or map(x,y+1) = spikes# or map(x,y+1) = rcheckpointflag# or map(x,y+1) = gcheckpointflag# or map(x,y+1) =springpic# `Fall `text 100,100,"FALLING!"+str$(pmapx#,3)+" "+str$(pmapy#,3) inc pmapy#,0.02 `1/50 inc playery#,1 falling = 1 else if pmapy# - int(pmapy#) >0.04 `Fall cos in between a fall or not a fall so fall! `text 100,100,"FALLING!"+str$(pmapx#,3)+" "+str$(pmapy#,3) inc pmapy#,0.02 `1/50 inc playery#,1 falling = 1 else falling = 0 jump.land = 1 jump.effect = 1 if jump.flag = 0 then jump.time = 0 `only reset when .flag = 0 ie when spacebar let go. endif`>0.4 endif `soc(16,15) next loopdrop endfunction function showplayer() fnum = frame if flashblank = 0 if big = 0 pcenterx = int((playerx#-24)-smoothx) + 23 pcentery = int((playery#-smoothy)-5) + 31 if syncready = 1 if idle = 0 if direction = 1`Right if jump.land = 1 if syncready = 1 then paste image mror#(fnum),(playerx#-24)-smoothx,playery#-smoothy,1 else`.land if syncready = 1 then paste image mjr#,(playerx#-24)-smoothx,playery#-smoothy,1 endif`.land endif`direction if direction = 0`Left if jump.land = 1 if syncready = 1 then paste image mrol#(fnum),(playerx#-24)-smoothx,playery#-smoothy,1 else`.land if syncready = 1 then paste image mjl#,(playerx#-24)-smoothx,playery#-smoothy,1 endif`.land endif`direction else`idle if direction = 1 then paste image mridlepic(int(idleframe)),(playerx#-24)-smoothx,playery#-smoothy,1 else paste image mlidlepic(int(idleframe)),(playerx#-24)-smoothx,playery#-smoothy,1 endif`idle endif`syncready else` Big Show big Ver ------------------------------------ pcenterx = int((playerx#-24)-smoothx) + 26 pcentery = int((playery#-smoothy)-5) + 35 if syncready = 1 if idle = 0 if direction = 1`Right if jump.land = 1 if syncready = 1 then paste image bigmror#(fnum),(playerx#-24)-smoothx,(playery#-smoothy)-5,1 else`.land if syncready = 1 then paste image bigmjr#,(playerx#-24)-smoothx,(playery#-smoothy)-5,1 endif`.land endif`direction if direction = 0`Left if jump.land = 1 if syncready = 1 then paste image bigmrol#(fnum),(playerx#-24)-smoothx,(playery#-smoothy)-5,1 else`.land if syncready = 1 then paste image bigmjl#,(playerx#-24)-smoothx,(playery#-smoothy)-5,1 endif`land endif`direction else`idle if direction = 1 then paste image bigmridlepic(int(idleframe)),(playerx#-24)-smoothx,(playery#-smoothy)-5,1 else paste image bigmlidlepic(int(idleframe)),(playerx#-24)-smoothx,(playery#-smoothy)-5,1 endif`idle endif`syncready endif`Big endif`flashblank = 0 endfunction function clswhitetoblack() for r = 255 to 0 step -1 m_cls(r,r,r) fastsync next r endfunction load_gfx: global mariologo# as integer mariologo# = m_asignpic() load image "mariologo.png",mariologo# global loadicon# as integer global saveicon# as integer loadicon# = m_asignpic() load image "loadicon.png",loadicon# saveicon# = m_asignpic() load image "saveicon.png",saveicon# global spikes# as integer global grassleft# as integer global grassmid# as integer global grassright# as integer spikes# = 96 grassleft# = 97 grassmid# = 98 grassright# = 99 set dir "extra" load image "spikes.png",spikes# load image "grassleft.png",grassleft# load image "grassmidnew.png",grassmid# load image "grassright.png",grassright# set dir ".." global fblock# as integer global blank# as integer global block# as integer global qm# as integer`=? fblock# = 100`editor use load image "block1.png",fblock#`floor block blank# = 102`editor use load image "blank62x50.png",blank#`blank sky(Mainly for editor use also to read from map as a Blank#). block# = 101`editor use load image "block2.png",block#`sky block qm# = 103`editor use load image "questionmark.png",qm# `load image "questionmark.png",106`Error dis for enemy `Powerup global powerup# as integer powerup# = 107`editor use load image "pup1.png",powerup# freepic = m_asignpic() global powerupfire# as integer powerupfire# = freepic load image "pup2.png",powerupfire# global secretbox# as integer secretbox# = 108`editor use load image "questionmark.png",secretbox# `Load New Ani for QM? Boxes global dim qmframe(6) as integer global qmfnum as float`frame counter(A float for slow effect) qmfnum = 1 for qmpic = 1 to 6 qmframe(qmpic) = m_asignpic() load image "qm"+str$(qmpic)+".png",qmframe(qmpic) next qmpic qme# = m_asignpic() load image "questionmarkempty.png",qme# drainbsl# = 104`editor use drainbsr# = 105`editor use load image "drainbs1.png",drainbsl# load image "drainbs2.png",drainbsr# `Map Editor pics should load pics for thease anyway stop render crashing on error. global springpic# as integer springpic# = 94 load image "spring1.png",springpic# global gcheckpointflag# as integer gcheckpointflag# = 200`>>Has to be a value of at least 200 because of the use of valuse in editor.. load image "greenflag1.png",gcheckpointflag# global beemappic# as integer beemappic# = 93 load image "beeface1.png",beemappic# global rcheckpointflag# as integer rcheckpointflag# = 95 load image "redflag1.png",rcheckpointflag# global flagframecounter# as float flagframecounter# = 1 `Make spring data global maxsprings = 2000 type springs flag as integer frame as float mapx# as float mapy# as float endtype global dim springdat(maxsprings) as springs `Load Spring Frames global dim spring(3) as integer for s = 1 to 3 spring(s) = m_asignpic() load image "spring"+str$(s)+".png",spring(s) next s `Load green flag frames global dim gflag(4) as integer for f = 1 to 4 gflag(f) = m_asignpic() load image "greenflag"+str$(f)+".png",gflag(f) next f `Load green flag frames global dim rflag(4) as integer for f = 1 to 4 rflag(f) = m_asignpic() load image "redflag"+str$(f)+".png",rflag(f) next f `Load Coin Frames global dim coinpic(11) as integer global coinframe as float coinframe = 1 for cpnum = 1 to 6 coinpic(cpnum) = m_asignpic() load image "coin"+str$(cpnum)+".png",coinpic(cpnum) next cpnum `Load shells frames global dim shellgreen(4) as integer for s = 1 to 4 shellgreen(s) = m_asignpic() load image "wep1"+str$(s)+".png",shellgreen(s) next s `MINCERO `Jump global mjr# as integer global mjl# as integer mjr# = m_asignpic() load image "mariojr.png",mjr# mjl# = m_asignpic() load image "mariojl.png",mjl# `Big Jump set dir "big" global bigmjr# as integer global bigmjl# as integer bigmjr# = m_asignpic() load image "bmariojr.png",bigmjr# bigmjl# = m_asignpic() load image "bmariojl.png",bigmjl# set dir ".." `Big mro image frames walk set dir "big" global dim bigmror#(6) as integer`run/walk global dim bigmrol#(6) as integer`run/walk `Right for mrpic = 1 to 6 bigmror#(mrpic) = m_asignpic() load image "bmr"+str$(mrpic)+".png",bigmror#(mrpic)`Stand next mrpic `Left for mlpic = 1 to 6 bigmrol#(mlpic) = m_asignpic() load image "bml"+str$(mlpic)+".PNG",bigmrol#(mlpic) next mlpic set dir ".." `Mro image frames walk global dim mror#(6) as integer`run/walk global dim mrol#(6) as integer`run/walk `Right for mrpic = 1 to 6 mror#(mrpic) = m_asignpic() load image "mr"+str$(mrpic)+".png",mror#(mrpic)`Stand next mrpic `Left for mlpic = 1 to 6 mrol#(mlpic) = m_asignpic() load image "ml"+str$(mlpic)+".PNG",mrol#(mlpic) next mlpic `Idle global dim mridlepic(4) as integer global dim mlidlepic(4) as integer `Right for midle = 1 to 4 mridlepic(midle) = m_asignpic() load image "mridle"+str$(midle)+".png",mridlepic(midle) next midle `Left for midle = 1 to 4 mlidlepic(midle) = m_asignpic() load image "mlidle"+str$(midle)+".png",mlidlepic(midle) next midle `BIG Idle `Idle set dir "big" global dim bigmridlepic(4) as integer global dim bigmlidlepic(4) as integer `Right for midle = 1 to 4 bigmridlepic(midle) = m_asignpic() load image "bmridle"+str$(midle)+".png",bigmridlepic(midle) next midle `Left for midle = 1 to 4 bigmlidlepic(midle) = m_asignpic() load image "bmlidle"+str$(midle)+".png",bigmlidlepic(midle) next midle set dir ".." `Enemy global dim lenemypic#(4) as integer global dim renemypic#(4) as integer for epic = 1 to 4 lenemypic#(epic) = m_asignpic() load image "shrooml"+str$(epic)+".png",lenemypic#(epic) next epic for epic = 1 to 4 renemypic#(epic) = m_asignpic() load image "shroomr"+str$(epic)+".png",renemypic#(epic) next epic `Sound global mariomusic as integer global diesound as integer global jumpsound as integer global hitqmsound as integer global collectcoinsound as integer global epopsound as integer global brakeblocksound as integer global smashblocksound as integer global shellsound as integer global collectpowerupsound as integer global firesound as integer global completelevelsound as integer global screamsound as integer screamsound = 13 completelevelsound = 12 firesound = 11 collectpowerupsound = 10 shellsound = 9 smashblocksound = 8 brakeblocksound = 7 epopsound = 6 collectcoinsound = 5 hitqmsound = 4 jumpsound = 3 diesound = 2 mariomusic = 1 set dir "sound" load sound "mario.wav",mariomusic loop sound mariomusic set sound volume mariomusic,90 load sound "collectcoin.wav",collectcoinsound load sound "die.wav",diesound load sound "pop.wav",epopsound load sound "smash.wav",brakeblocksound load sound "smash.wav",smashblocksound load sound "shell.wav",shellsound load sound "fire.wav",firesound load sound "collectpowerup.wav",collectpowerupsound load sound "winner.wav",completelevelsound load sound "scream.wav",screamsound set dir ".." return makelevelrnd: `logic = 768/5 `153.6 = 153 `So 153 levels down with 5*50 height will be created `the level then can be saved as a image 1024*768! lev=6 for level = 0 to 70 for mxfloor = 0 to 1024 dat = fblock# `dat=0 map(mxfloor,lev)=dat next mxfloor inc lev,10 next level `fill blanks with random blocks for x =0 to 1024 for y = 0 to 768 if map(x,y) = 0 then map(x,y) = blank# if rnd(5) = 0 then if y>2 then map(x,y) = block# next y next x return loadlevel: load array "level.dat",levdat(1024,1024) enemy# = 106 enemynum = 0 `translate for Map Co-ord sys cos cant be botherd to change Editor to match this Platformer yet. for x = 0 to 1024-2 for y = 0 to 768-2 map(x,y) = levdat(y+2,x+2)`yeah mad init Editor saves in German. next y next x `Done! `Now filter Map to find Enemy Data `xmap# as float `ymap# as float `xscrn# as float `yscrn# as float `flag as integer `direction as integer `active as integer 0 = off screen 1 = come into play 2 = active `offsetx as integer`Logic= if >62 then inc xmap#,1 `offsety as integer `offxcounter# as float`Logic= if>1 then if direction =1 then inc offsetx,0 counter=1:else dec offsetx,0 counter =1 `offycounter# as float `xspd# as float`used as a fractional spd (0.00-0.99). `yspd# as float `maxenemys as integer `maxenemys = 1000 `global dim edat(maxenemys) for mapx = 0 to 1024 for mapy = 0 to 768 `Detect for Enemy Data(BUG) if map(mapx,mapy) = 106 `enemy#=106 map(mapx,mapy) = 102`SET TO BLANK# inc enemynum,1 edat(enemynum).etype = 1`Bug edat(enemynum).xmap# = mapx edat(enemynum).ymap# = mapy edat(enemynum).flag = 1`Set to Alive edat(enemynum).frame = 1 edat(enemynum).direction = 1`Needs to be set in editor. edat(enemynum).active = 0 edat(enemynum).offsetx = 0 edat(enemynum).offsety = 0 edat(enemynum).offxcounter# = 0 edat(enemynum).offycounter# = 0 edat(enemynum).xspd# = 1`I find using fractions is a good way of getting good control of spd. edat(enemynum).yspd# = 1 edat(enemynum).falling = 0 endif `BEE = 93 if map(mapx,mapy) = 93 `enemy#=106 map(mapx,mapy) = 102`SET TO BLANK# inc enemynum,1 edat(enemynum).etype = 2`Bee edat(enemynum).xmap# = mapx edat(enemynum).ymap# = mapy edat(enemynum).flag = 1`Set to Alive edat(enemynum).frame = 1 edat(enemynum).direction = 1`Needs to be set in editor. edat(enemynum).active = 0 edat(enemynum).offsetx = 0 edat(enemynum).offsety = 0 edat(enemynum).offxcounter# = 0 edat(enemynum).offycounter# = 0 edat(enemynum).xspd# = 1`I find using fractions is a good way of getting good control of spd. edat(enemynum).yspd# = 1 edat(enemynum).falling = 0 endif `Detect Powerup`s if map(mapx,mapy) = 107`powerup# = 107 map(mapx,mapy) = 108`secret qm? box powerup(pucounter).xmap# = mapx powerup(pucounter).ymap# = mapy powerup(pucounter).flag = 1`Set to Alive powerup(pucounter).frame = 1 powerup(pucounter).direction = 1`Needs to be set in editor. powerup(pucounter).active = 0 powerup(pucounter).offsetx = 0 powerup(pucounter).offsety = 0 powerup(pucounter).offxcounter# = 0 powerup(pucounter).offycounter# = 0 powerup(pucounter).xspd# = 2 + (rnd(10)/10)`I find using fractions is a good way of getting good control of spd. powerup(pucounter).yspd# = 1 powerup(pucounter).falling = 0 powerup(pucounter).time = 0 inc pucounter,1 endif next mapy next mapx `All Done! return `Functions function m_asignpic() if m_asign_pic_sys = 0 global m_asign_pic_sys as integer global m_asign_pic_returnval as integer m_asign_pic_sys = 1 endif for loc = 1000 to 10000 if image exist(loc) = 0 m_asign_pic_returnval = loc endif next loc endfunction m_asign_pic_returnval function m_locksystem() disable escapekey disable systemkeys endfunction function m_unlocksystem() enable systemkeys enable escapekey minimize window show mouse `Free up memory m_stopallmusic() for im = 1 to 10000 if image exist(im) then delete image im if sound exist(im) then delete sound im if object exist(im) then delete object im if music exist(im) then delete music im next im m$="Thank You For Playing." c$="MINCERO Beta V0.01" EXIT PROMPT m$,c$ sync end endfunction function m_stopallmusic() for a = 1 to 1000 if music playing(a) then stop music a next a endfunction function m_cls(r,g,b) bitsperpixel = bitmap depth()/8 displayx = 1024 displayy = 768 if minceclsflag = 0 global minceclsflag as integer `global workA as dword global m_mcol as dword `workA = make memory(displayx*displayy*bitsperpixel) minceclsflag = 1`Mince Tools Running. endif m_mcol = rgb(r,g,b) lock backbuffer address = get backbuffer ptr() `fill memory workA, m_mcol,backbuffer ptr() displayx*displayy*bitsperpixel`cls `*address = workA fill memory address, m_mcol, displayx*displayy*bitsperpixel`cls bitmap depth()/8 unlock backbuffer endfunction function exitgame() if escapekey() = 1 then m_unlocksystem() endfunction Function m_pause() if lower$(inkey$())="p" center text 512,350,"!PAUSE!" sync wait 150 do i$ = inkey$() if lower$(i$) = "p" oldtimestamp = timer() exit endif`Pressed "P" loop wait 150 endif endfunction function m_controlmouse() if m_mincemousesys <> 99 global m_mincemousesys as integer m_mincemousesys = 99 global m_mousetimer as integer global m_mouseoldtimer as integer global m_showtime as integer global m_mousexpos as integer global m_mousexposstore as integer global elapsed as integer global m_totalrunningtime as integer m_totalrunningtime = 0 m_mousetimer = timer() m_mouseoldtimer = m_mousetimer m_mousexpos = mousex() m_mousexposstore = m_mousexpos m_showtime = 3 * 1000`Show Mouse For 3 Seconds endif m_mousetimer = timer() m_mousexpos = mousex() m_elapsed = abs(m_mousetimer - m_mouseoldtimer) `Movement Detector if abs(m_mousexpos - m_mousexposstore) > 5 m_showtime = 3 * 1000 m_mousexposstore = m_mousexpos endif if m_showtime > 0 show mouse paste image mariologo#,512-80,1,1 dec m_showtime,m_elapsed else hide mouse endif inc m_totalrunningtime,m_elapsed m_mouseoldtimer = timer() endfunction function m_init_fps() if check display mode(1024,768,16) = 1 then set display mode 1024,768,16 else end global skip as byte skip = 0 global sframes as byte sframes = 0 global maxsframes as byte maxsframes = 10 global syncready as byte syncready = 0 hide mouse maximize window sync on backdrop off if test = 0 sync rate 80 global srate as byte srate = 80 else global srate as byte srate = 0 sync rate 0 endif global ssrate as byte`used to throttle system ssrate = srate `M_sys Debug info if test = 1 global toptime as integer global bottomtime as integer global rtime as integer global averendertime# as float global rendertime as integer global avelooptime# as float global looptime as integer global totallooptime# as float global totalrendertime# as float global loops as integer global renders as integer global synctimems as integer global avesynctimems# as float avesynctimems# = 0.000001 `global ot as integer loops = 0 renders = 0 endif endfunction function m_init_throttle() global throttletimer as integer global throttlenewtimer as integer global m_fpsspeed as integer m_fpsspeed = screen fps() throttletimer = timer() throttlenewtimer = throttletimer endfunction function m_throttle(error,delay,show) m_frameskipcontrol() throttlenewtimer = timer() m_fpsspeed = screen fps() if show = 1 then text 510,90,"FPS("+str$(m_fpsspeed)+")" if throttlenewtimer > throttletimer + delay `text 100,100,"ADJUSTING FPS" throttletimer = throttlenewtimer if abs(m_fpsspeed - srate) > error if screen fps() > srate`Then Slow Down! if ssrate >15 then dec ssrate,1 sync rate ssrate else `Speedup! if ssrate <92 then inc ssrate,1 endif endif endif endfunction function m_frameskipcontrol() if inkey$() = "=" then if sframes < maxsframes inc sframes,1 play sound collectpowerupsound wait 200 endif if inkey$() = "-" then if sframes >0 dec sframes,1 play sound collectpowerupsound wait 200 endif endfunction function m_sync_top() syncready = 0 if skip+1 => sframes then syncready = 1 if skip => sframes ` fastsync skip = 0 endif inc skip,1 toptime = timer() endfunction function m_sync_bottum() ` global toptime as integer ` global bottomtime as integer ` global rtime as integer ` global totalframes as integer ` global averendertime as float ` global rendertime as integer ` global avelooptime# as float ` global looptime# as integer ` global loops as integer ` global renders as integer if test = 1 inc loops,1 bottomtime = timer() looptime = (bottomtime - toptime) - rendertime inc totallooptime#,looptime if syncready = 1 inc totalrendertime#,rendertime inc renders,1 endif avelooptime# = totallooptime# / loops averendertime# = totalrendertime# / renders endif if syncready = 1 ot = timer() fastsync if test = 1 synctimems = timer() - ot avesynctimems# = (synctimems / renders) endif endif endfunction function m_brightgreen() ink rgb(100,255,100),0`Bright Green! endfunction function m_red() ink rgb(255,0,0),0`Bright Green! endfunction function m_green() ink rgb(0,255,0),0`Bright Green! endfunction function m_blue() ink rgb(0,0,255),0`Bright Green! endfunction init_world: global dim map(1024,768) as integer return init_player: global lives as integer lives = 3 global health as integer`may not need fix global score as integer score = 0 global hiscore as integer hiscore = score`load this return init_gamevars: `Bounce global bounce as byte global bouncetime as integer global bounceheight as integer `Spring Bounce global springbounce as byte global springbouncetime as integer global springbounceheight as integer dim levdat(1024,1024) `fix if more contain pic values more than 255 then change to integer `PLAYER VARS global direction as byte global spd# as float global spdcounterdelay as integer global maxspd# as float global maxwalkspd as byte`pos no need global maxrunspd as byte`pos no need global walk AS byte`pos no need `Player Exceleration control global player_excel_controlspd as integer global idle as integer global idleframe as float global frame as byte global framedelay as integer`Time in ms global framecounter as integer global frametimer as integer`new global oldframetimer as integer`old oldframetimer = timer() frametimer = timer() global playerx# as float`Actual screen rep of pmapx global playery# as float`Actual screen rep of pmapy `Headbutt use Global hplayery# as float global pmapx# as float`Blocks of 62 x50 global pmapy# as float`Blocks of 62x 50 using fractions ie if 1(block)=50(pixels) then 100/50=move eg inc pmapy,100/50 global dim soc(16,15) as integer global spdtimer as integer global spdoldtime as integer global spddelay as integer `Size of player values for smooth transition from 1 block pos to another. global xstep as integer global ystep as integer global maxxstep as integer global maxystep as integer global vscroll# as float global vscrolldir as integer global vscrollspd# as float global vscrollamount as integer global scroll# as float global scrolldir as integer global scrollspd# as float global scrollamount as integer global smoothx as integer global maxsmoothx as integer global smoothy as integer global maxsmoothy as integer global hscrollfarleft = 149 global hscrollfarright = 862 `JUMP type jt flag as integer time as integer effect as integer land as integer endtype global jump as jt `Coin system global maxcoins as integer maxcoins = 2000 global ejectcoins as integer`May not need ejectcoins = 1 global ecoincounter as integer ecoincounter = 1 type cs x# as float y# as float z# as float flag as byte xspd# as float yspd# as float hdirection as byte vdirection as byte endtype global dim coinsystem(maxcoins) as cs `Coins global coins as integer global cointolife as integer cointolife = 0 coins = 0 `World global world as integer `sys global falling as byte global headbuttposs as byte `Time global time as integer global timestamp as integer global oldtimestamp as integer `Enemy sys type enem etype as integer`Define type of enemy xmap# as float ymap# as float xscrn# as float yscrn# as float flag as integer frame as integer direction as integer active as integer offsetx as integer |