0®']Îï}WÿÍu§ðp8·d%qy‰;]ÉA¦ösï÷ôôô”°ÂVl†3240 and tik%7==0 then player_update() rats_update() if tik%10==0 then timer=timer-1 if timer<20 then sfx(7) end if timer<=0 then eek_init() end end end camx=pl.x-5 camy=pl.y-3 if #cheeses<=0 then bonus_init() end cls(8) map(camx,camy,11,8,0,32,-1,2) hud() cheeses_draw() cats_draw() rats_draw() stars_draw() player_draw() end over_init=function() tik=0 TIC=Over end function Over() tik=tik+1 if tik>180 then score,lives,round,x2,nextmeat,high=0,3,1,1,100,20000 title_init() end rect(0,32,176,128,0) text("GAME OVER",6,10,12) end function player_update() oldx=pl.x oldy=pl.y if btn(2) and mget(pl.x-1,pl.y)==2 then pl.xd=-1 pl.yd=0 pl.r=3 elseif btn(3) and mget(pl.x+1,pl.y)==2 then pl.xd=1 pl.yd=0 pl.r=1 elseif btn(0) and mget(pl.x,pl.y-1)==2 then pl.yd=-1 pl.xd=0 pl.r=0 elseif btn(1) and mget(pl.x,pl.y+1)==2 then pl.yd=1 pl.xd=0 pl.r=2 end if btn(4) then sfx(3) timer=timer-1 table.insert(stars,{ x=pl.x,y=pl.y,t=300 }) end pl.x=pl.x+pl.xd pl.y=pl.y+pl.yd if mget(pl.x,pl.y)<=1 then pl.x=oldx pl.y=oldy pl.xd=0 pl.yd=0 end end function player_draw() spr(3,80,80,0,1,0,pl.r,2,2) radar(pl.x,pl.y,2) end function cheeses_draw() for id,o in pairs(cheeses) do if o.x==pl.x and o.y==pl.y then if o.s==9 then sfx(1) score=score+nextmeal*x2 nextmeal=nextmeal+100 end if o.s==11 then sfx(2) x2=2 score=score+nextmeal*x2 nextmeal=nextmeal+100 end table.remove(cheeses,id) end if inview(o) then spr(o.s,(o.x-camx)*16,32+(o.y-camy)*16,6,1,0,0,2,2) end radar(o.x,o.y,3) end end function cats_draw() for id,o in pairs(cats) do if inview(o) then spr(43,(o.x-camx)*16,32+(o.y-camy)*16,6,1,0,0,2,2) end if o.x==pl.x and o.y==pl.y then eek_init() end end end function stars_draw() for id,o in pairs(stars) do o.t=o.t-1 if o.t<=0 then table.remove(stars,id) end if inview(o) then spr(13,(o.x-camx)*16,32+(o.y-camy)*16,6,1,0,0,2,2) end end end function redirect(o) m=math.random(4) if mget(o.x,o.y-1)>1 and m==1 then o.yd=-1 o.xd=0 o.r=0 end if mget(o.x+1,o.y)>1 and m==2 then o.xd=1 o.yd=0 o.r=1 end if mget(o.x,o.y+1)>1 and m==3 then o.yd=1 o.xd=0 o.r=2 end if mget(o.x-1,o.y)>1 and m==4 then o.xd=-1 o.yd=0 o.r=3 end end function rats_update() for id,o in pairs(rats) do oldx=o.x oldy=o.y o.x=o.x+o.xd o.y=o.y+o.yd if mget(o.x,o.y)<=1 then o.x=oldx o.y=oldy redirect(o) end if hitstars(o) then o.xd=0 o.yd=0 o.r=math.random(0,3) else redirect(o) end if o.x==pl.x and o.y==pl.y then eek_init() end end end function rats_draw() for id,o in pairs(rats) do if inview(o) then spr(5,(o.x-camx)*16,32+(o.y-camy)*16,0,1,0,o.r,2,2) end radar(o.x,o.y,9) end end eek_init=function() music(-1) sfx(5) tik=0 TIC=eek end function eek() tik=tik+1 spr(41,80,80,0,1,0,0,2,2) if tik>180 and lives>0 then lives=lives-1 nextmeal=100 level_init() tik=200 TIC=Game end if tik>180 and lives<=0 then over_init() end end bonus_init=function() music(2,-1,-1,false) tik=0 TIC=bonus end function bonus() tik=tik+1 if tik>120 then if tik%4==0 then timer=timer-1 score=score+20 sfx(6) end end rect(0,0,266,24,8) if timer<=0 then round=round+1 level_init() cheeses_init() nextmeal=100 x2=1 tik=200 TIC=Game end hud() end function hitstars(o) for id,i in pairs(stars) do if o.x==i.x and o.y==i.y then return true end end end function inview(a) if a.x=camx and a.y=camy then return true end end function cheeses_init() cheeses={} for i=1,9 do repeat _x=math.random(0,29) _y=math.random(0,15) until mget(_x,_y)==2 c={x=_x,y=_y,s=9} table.insert(cheeses,c) end repeat _x=math.random(0,29) _y=math.random(0,15) until mget(_x,_y)==2 c={x=_x,y=_y,s=11} table.insert(cheeses,c) end function level_init() timer=100 pl={x=12,y=11,xd=0,yd=-1,r=0} stars={} cats={} for i=1,2 do repeat _x=math.random(0,29) _y=math.random(0,10) until mget(_x,_y)==2 c={x=_x,y=_y,} table.insert(cats,c) end rats={ {x=10,y=13,r=0,xd=0,yd=-1}, {x=12,y=13,r=0,xd=0,yd=-1}, {x=14,y=13,r=0,xd=0,yd=-1} } if round>=2 then table.insert(rats,{x=8,y=13,r=0,xd=0,yd=-1}) end if round>=3 then table.insert(rats,{x=6,y=13,r=0,xd=0,yd=-1}) end end function radar(x,y,c) rect(176+(x*2),88+(y*2),2,2,c) end function hud() if score>=high then sfx(2) high=high+20000 lives=lives+1 end if score>pmem(0) then pmem(0,score) end rect(176,88,60,34,0) text("SCORE",1,0,12) sc=string.sub("000000"..score,-6) text(sc,7,0,12) text("HIGH",16,0,12) hi=string.sub("000000"..pmem(0),-6) text(hi,21,0,12) if lives>0 then for l=1,4 do if lives>=l then spr(7,152+(16*l),10,0,1,0,0,2,2) end end end text("TIME",1,2,12) rect(40,16,100,8,0) rect(40,17,timer,6,4) text("NEXT\nMEAL",23,4,12) text(nextmeal,24,6,12) if tik%60<=30 and x2>1 then text("X2",26,7,12) end text("ROUND",23,9,12) text(round,24,10,12) end function text(str,x,y,c) poke4 (0x3ff0*2+12,c) poke4 (0x3ff0*2+13,c+1) font(str,x*8,(y*8),0,8,8,true,1) poke4 (0x3ff0*2+12,12) poke4 (0x3ff0*2+13,13) end function Attract() tik=tik+1 if tik>480 then title_init() end if btnp(4) then start_init() end cls(8) hud() rect(0,32,176,128,4) text("TIC RAT RACE",5,5,0) text("PUSH a TO START",4,16,0) i=[[ - INSTRUCTIONS - DODGE CATS AND RED RATS TO EAT 10 CHEESES BEFORE TIMES ROUNS OUT. ]] text(string.sub(i,1,math.floor(tik/3)).."hi",1,7,2) end function Title() tik=tik+1 if tik>240 then attract_init() end if btnp(4) then start_init() end cls(8) hud() rect(0,32,176,128,1) spr(64,48,48,0,1,0,0,9,5) text("@1981 COMMODORE",1,13,12) text(" 2022 LOSTCADESOFT",1,14,12) text(" BY BGELAIS",1,15,12) end function start_init() cheeses_init() level_init() score,lives,round,x2,nextmeat=0,3,1,1,100 sfx(1) tik=0 TIC=Start end function Start() tik=tik+1 if btnp(4) then game_init() end cls(8) hud() rect(0,32,176,128,0) text("PUSH",4,5,12) text([[ a TO START BONUS RAT FOR 20000 PTS ---------------------- c d e MOVE RAT f a STAR SCREEN ]],0,7,12) text("_ _",2,5,2) if tik%30<=15 then text("_ _",2,5,8) end end