0DPq$HUUiUU(UD**U}]z] _2TvͫgE#޼xFD43TvxF!CvΊV4#ffSg0 003<030333303303333333303333223 33033233333#3#333333#333 0#2333 023# 33 23# #23# 2333233033 3323233333#33333##33233033 3323203333#33333##33233033 33232 3333#33333##3#23033 3323223 3#33333##32#033 3323232#33333##033 3323233333##03 3233#000000300!!""" ""!"""""""""""""""!!""" ""!""""""""""""""" ̈̈ ̈̈ 00000""""""""""!"""""""""!" !"""""""""""!!""""""""""!" f " !$%#%!  "%%!"%  !!" !""  !" !"         //////////////////       //////////////////@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@PPPPPPPPPPPPPPPPPPPPPPPPPPPPPP  0  0  &0           IiIiIiIiIiIi I IIif(D&? "" ," , " "  """"" " " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 000000000 000000000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3< 3< 03 0 0 0 0 03 033 0 0 0 0 033 33 33 0 0 0 0 0 0 0 0 0 0 0 0 0 0 33 3333 03333 0333 ΌΌ333 0 0 0 0 ΌΌ330 0 0 0 0000330000 333 0333 03333 3333 33 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0000 000 000 0000 ,0z]]HUUiUU(UD**Uee88})=3-- title: PAC-MAN 80 (Alpha) -- author: Weeppiko -- desc: PAC-MAN Port for TIC-80 -- script: lua --GlobalVariables SCRWID=240 SCRHEI=136 VIEWX=0 VIEWY=0 --GameVariables SCORE=0 LIFES=3 LEVEL=1 PCDOTS=0 PLAYER=nil GHOSTS=nil -- shorthands pi=math.pi tau=pi*2 sin=math.sin cos=math.cos rad=math.rad deg=math.deg abs=math.abs min=math.min max=math.max floor=math.floor ceil=math.ceil rand=math.random seed=math.randomseed atan=math.atan atan2=math.atan2 sqrt=math.sqrt tbladd=table.insert tblrmv=table.remove tblsrt=table.sort tblpop=table.pop unpack=table.unpack insign=1e-10 strfrm=string.format seed(tstamp()) cocreate=coroutine.create costatus=coroutine.status coresume=coroutine.resume coyield=coroutine.yield -- utils function round(x) return floor(x+0.5) end function dfloor(x) if floor(x+0.5)-x<=insign then return floor(x+0.5) else return floor(x) end end function clamp(x,f,l) return min(max(x,f),l) end function sign(v) if v<0 then return -1 elseif v>0 then return 1 else return 0 end end function mrepeat(t,l) return t-(floor(t/l)*l) end function pingpong(t,l) t=mrepeat(t,l*2) return l-abs(t-l) end function pointdist(x1,y1,x2,y2) return sqrt(((x2-x1)^2)+((y2-y1)^2)) end --tic80 utils function pal(i,c) poke4(0x03FF0*2+i,c or i) end function border(c) if c then poke(0x03FF8,c) else return peek(0x03FF8) end end function flag(x,y,f) return fget(mget(x,y),f) end --extended function xprint(s,x,y,a,b,...) print(s,x,y+1,b,...) return print(s,x,y,a,...) end function xmusic(t,f,r,l,b,s) music(t,f,r,l,1,b,s) end --game functions function getPhases() if LEVEL==1 then return {420,1200,420,1200,300,1200,300} elseif LEVEL>=2 and LEVEL<=4 then return {420,1200,420,1200,300} elseif LEVEL>=5 then return {300,1200,300,1200,300} end end function getPacManSpeed() if LEVEL==1 then return 0.8,0.9 elseif LEVEL>=2 and LEVEL<=4 then return 0.9,0.95 elseif LEVEL>=5 and LEVEL<=20 then return 1,1 elseif LEVEL>=21 then return 0.9,0 end end function getGhostSpeed() if LEVEL==1 then return 0.75,0.5,0.4 elseif LEVEL>=2 and LEVEL<=4 then return 0.85,0.55,0.45 elseif LEVEL>=5 and LEVEL<=20 then return 0.95,0.6,0.5 elseif LEVEL>=21 then return 0.95,0,0.5 end end function getSpurtLevel() if LEVEL==1 then if PCDOTS<=10 then return 2 elseif PCDOTS<=20 then return 1 else return 0 end elseif LEVEL==2 then if PCDOTS<=15 then return 2 elseif PCDOTS<=30 then return 1 else return 0 end elseif LEVEL>=3 and LEVEL<=5 then if PCDOTS<=20 then return 2 elseif PCDOTS<=40 then return 1 else return 0 end elseif LEVEL>=6 and LEVEL<=8 then if PCDOTS<=25 then return 2 elseif PCDOTS<=50 then return 1 else return 0 end elseif LEVEL>=9 and LEVEL<=11 then if PCDOTS<=30 then return 2 elseif PCDOTS<=60 then return 1 else return 0 end elseif LEVEL>=12 and LEVEL<=14 then if PCDOTS<=40 then return 2 elseif PCDOTS<=80 then return 1 else return 0 end elseif LEVEL>=15 and LEVEL<=18 then if PCDOTS<=50 then return 2 elseif PCDOTS<=100 then return 1 else return 0 end elseif LEVEL>=19 then if PCDOTS<=60 then return 2 elseif PCDOTS<=120 then return 1 else return 0 end end end function getSpurtSpeed() local a=getGhostSpeed() local s=getSpurtLevel() if LEVEL==1 then if s==1 then return 0.8 elseif s==2 then return 0.85 end elseif LEVEL>=2 and LEVEL<=4 then if s==1 then return 0.9 elseif s==2 then return 0.95 end elseif LEVEL>=5 then if s==1 then return 1 elseif s==2 then return 1.05 end end return a end function isGameOver() return LIFES<=0 end function isLevelCleared() return PCDOTS<=0 end function wait(t) while t>0 do t=t-1 coyield() end end function isTunnel(x,y) return y==14 and (x<=5 or x>=17) end --simple prototype class system function Prototype(pr) local cl={} cl.__index=cl local new=function(_,...) local i=setmetatable({},cl) if i.init then i:init(...) end return i end local meta={__index=pr,__call=new} return setmetatable(cl,meta) end --TimerClass Timer=Prototype() function Timer:init(t,l,f) self.mt=t self.ct=0 self.ml=l self.cl=0 self.fn=f end function Timer:update(s) if self.cl=self.mt then self.ct=self.ct%self.mt self.cl=self.cl+1 if self.fn then self:fn() end end else self.ct=0 end end function Timer:next() self:update(self.mt) end function Timer:ended() return self.cl>=self.ml and self.ml>0 end function Timer:setStepTime(t) self.mt=t end --Object Object=Prototype() function Object:init() self.spd=1 self.moving=false self.through=false self.x,self.y=0,0 self.mx,self.my=0,0 end function Object:updateMovement() if not self:isMoving() then return end local mx,my,s=self.mx,self.my,self.spd if self.x>mx then self.x=max(self.x-s,mx) end if self.xmy then self.y=max(self.y-s,my) end if self.y=1 then tc=tc%1;fps=fc;fc=0 end end function FPS() return fps end function DT() return dt end end --Run gameLoop=cocreate(function(stop) restartGame(true) while not stop do updateGame() stop=stop coyield() end end) function UPD() local ok,err=coresume(gameLoop) if not ok then error(err) end end function TIC() cls(0);STEP();UPD() drawGameObjects() drawGameHUD() xprint('FPS'..FPS(),0,0,12,2) border(0) end