0,]']>S}Wup8d%qy)6o;]Asªe<3>????????????????? ////////////////////// !!""#$%%&&&'''(()**+++,,--.//cc DVFgH ZJk M ^  B0@PA2#s  d  U F 7 --M::4}4}33445K5K667*7*8[8[899,:,;;???????? BBBB BBwBBBB BsB BrBwBzBBzBB B BuB BvBzBOzOOOOz    zb cbbb cbbbb cbbb c c cHh ( H(HHh ( H(H ( H(H(H ( H(H(HHHHHHH ( (HH H HHH H HH(( ( (bb cbbb cbbb cbbb cbbb cbb cbbbbbbb@` @ @@` @ @ @ @ @ @ @ @@@@ @@ @ @@@ @ @@  3"@2"@2BR L?"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""","",,,"""",,"""","",,"""",""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""",",",""""""","""""""",""","",",""",""","",""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""",",","""""""""""""""""""""",","",""""""",""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""",,,,"""""""",,"""""","""",,"""",""","",""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""",",",",,"",",""","""""",",","""",""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """"""DDDDDID IDBBI$"B ")၈၈၈၈၈ LNLNLLLLLDLDLNLNLDDLDDLNLN၈AA@@DDDDDDDDANAN@N@NANAN@N@NANAN@N@NANAN@N@NDDDDDDDD၈HH@@@@DDDD@N@N@N@N@N@N@N@NDDDD၈@@@@DDDD@N@N@N@N@N@N@N@NDDDD၈@@ -- title: tic-80 mario fangame wip -- author: RetroManb -- desc: a quick thingy -- license: MIT License (change this to your license of choice) -- version: 0.1 -- script: lua _t = 0 E_OBJTYPES = { player = 0, block = 1, } OBJVARS = { [E_OBJTYPES.block] = { --block {"tx",0}, {"ty",0}, {"tile",1}, {"F_step",function(self) self.y = self.y+1 if self.y > self.ty*8 then mset(self.tx,self.ty,self.tile) deleteObj(self) return end end}, {"F_draw",function(self) spr(self.tile,self.x-camera.x,self.y-camera.y,0) end} }, } camera = { x=0, y=0 } objects = {} player = nil function xor(a,b) if a and b then return false end return a or b end function sign(x) if x > 0 then return 1 elseif x < 0 then return -1 end return 0 end function mgetF(x,y) return mget(x//8,y//8) end function remap(tile,x,y) local o=tile,0,0 if tile == 64 or tile == 68 or tile == 72 then o = o+(_t//8)%4 end if tile == 6 then o = 0 end return o end function OF_grounded(self) self.grounded = fget(mgetF(self.x-self.bbox.width/2,self.y+self.bbox.height/2),0) or fget(mgetF(self.x,self.y+self.bbox.height/2),0) or fget(mgetF(self.x+self.bbox.width/2-1,self.y+self.bbox.height/2),0) end function OF_mc(self,hcb,vcb) self.x = self.x+self.xsp if fget(mgetF(self.x+sign(self.xsp)*self.bbox.width/2,self.y-2),0) or fget(mgetF(self.x+sign(self.xsp)*self.bbox.width/2,self.y+self.bbox.height/2-1),0) then self.x = (self.x+sign(self.xsp)*self.bbox.width/2)//8*8 if self.xsp < 0 then self.x=self.x+8 end self.x = self.x-sign(self.xsp)*self.bbox.width/2 if hcb then hcb(self) end self.xsp = 0 end self.y = self.y+self.ysp local _o = 0 if self.type == E_OBJTYPES.player and self.ysp < 0 then _o = 2 end if fget(mgetF(self.x-self.bbox.width/2+_o,self.y+sign(self.ysp)*self.bbox.height/2),0) or fget(mgetF(self.x,self.y+sign(self.ysp)*self.bbox.height/2),0) or fget(mgetF(self.x+self.bbox.width/2-_o-1,self.y+sign(self.ysp)*self.bbox.height/2),0) then self.y = (self.y+sign(self.ysp)*self.bbox.height/2)//8*8 if self.ysp < 0 then self.y=self.y+8 end self.y = self.y-sign(self.ysp)*self.bbox.height/2 if vcb then vcb(self) end self.ysp = 0 end if fget(mgetF(self.x-self.bbox.width/2,self.y),0) then self.x = self.x+1 elseif fget(mgetF(self.x+self.bbox.width/2-1,self.y),0) then self.x = self.x-1 end end function addObject() local obj = { type = -1, x=0, y=0, sprite = { index = 384, xoff = 0, yoff = 0, ckey = 0, scale = 1, flip = 0, rotate = 0, w = 1, h = 1, }, bbox = { width = 6, height = 6, }, F_step = function(self) end, F_draw = function(self) spr( self.sprite.index, self.x-self.sprite.w*4+self.sprite.xoff-camera.x, self.y-self.sprite.h*4+self.sprite.yoff-camera.y, self.sprite.ckey, self.sprite.scale, self.sprite.flip, self.sprite.rotate, self.sprite.w, self.sprite.h ) end } objects[#objects+1] = obj return obj end function addObjectOfType(t) if t == E_OBJTYPES.player then return addPlayer() end local o = addObject() o.type = t local vars = OBJVARS[t] if vars then for i=1,#vars do o[vars[i][1]] = vars[i][2] end end return o end function addPlayer() player = addObject() player.type = E_OBJTYPES.player player.x = 24 player.y = 16 player.sprite.index = 256 player.sprite.yoff = -4 player.sprite.h = 2 --player.bbox.height = 14 player.xsp = 0 player.ysp = 0 player.grv = 0.24 player.grounded = false player.jumping = false player.dir = 1 player.animT = 0 player.F_hc = function(self) end player.F_vc = function(self) if self.ysp < 0 then sfx(34,"B-1") xx = self.x yy = self.y-8 if not fget(mgetF(xx,yy),1) then xx = self.x+self.dir*self.bbox.width/2-1 end if not fget(mgetF(xx,yy),1) then xx = self.x-self.dir*self.bbox.width/2 end if fget(mgetF(xx,yy),1) then local t = mget(xx//8,yy//8) if t == 5 then mset(xx//8,yy//8,0) sfx(35,-1,-1,3) else local b = addObjectOfType(E_OBJTYPES.block) b.x = xx//8*8 b.y = yy//8*8-4 b.tx = xx//8 b.ty = yy//8 b.tile = t if t == 4 then b.tile = 3 end mset(xx//8,yy//8,6) end end end end player.F_step = function(self) OF_grounded(self) --h movement local isMoving = xor(btn(2),btn(3)) local mSpd = 0.75 if btn(5) then mSpd = 1.75 end if isMoving then local a = 0.02 if self.grounded then if btn(5) then a = 0.03 end else a = 0.018 if (btn(2) and self.dir == 1) or (btn(3) and self.dir == -1) then a = 0.04 end end if btn(2) then self.xsp = self.xsp-a if self.grounded then self.dir = -1 end else self.xsp = self.xsp+a if self.grounded then self.dir = 1 end end if math.abs(self.xsp) > mSpd then if self.grounded then self.xsp = self.xsp-sign(self.xsp)*math.min(math.abs(self.xsp)-mSpd,0.06) else self.xsp = sign(self.xsp)*math.min(mSpd,math.abs(self.xsp)) end end elseif self.grounded then self.xsp = self.xsp - sign(self.xsp)*math.min(math.abs(self.xsp),0.04) end --gravity if not self.grounded then self.ysp = self.ysp + self.grv if self.ysp > 2.5 then self.ysp = 2.5 end end --jumping if self.grounded and btnp(4) then self.jumping = true self.ysp = -(2.25+math.min(0.4,math.abs(self.xsp/8))) self.grv = 0.07 sfx(33,"G-4") self.grounded = false end if (not self.grounded and not btn(4)) or (self.ysp >= 0) then self.jumping = false self.grv = 0.24 end --movement n collision OF_mc(self,self.F_hc,self.F_vc) --coins if fget(mgetF(self.x,self.y),2) or fget(mgetF(self.x,self.y+self.bbox.height/2),2) or fget(mgetF(self.x,self.y-self.bbox.height/2),2) then local tx = self.x//8 local ty = self.y//8 if not fget(mget(tx,ty),2) then ty = (self.y+self.bbox.height/2)//8 end if not fget(mget(tx,ty),2) then ty = (self.y-self.bbox.height/2)//8 end if fget(mget(tx,ty),2) then local bg = 0 local t = mget(tx,ty) if t == 68 then bg = 17 end if t == 72 then bg = 18 end mset(tx,ty,bg) sfx(32,"B-5",-1,0) end end --look if self.dir == 1 then self.sprite.flip = 0 elseif self.dir == -1 then self.sprite.flip = 1 end if self.grounded then self.sprite.index = 256 if math.abs(self.xsp) > 0 then self.animT = self.animT+math.abs(self.xsp)/5 self.sprite.index = 257+self.animT%2 else self.animT = 1 end else if self.ysp < 0 then self.sprite.index = 260 else self.sprite.index = 261 end end --self.sprite.index = self.sprite.index+8 end return player end function deleteObj(obj) for i=1,#objects do if objects[i] == obj then table.remove(objects,i) return true end end return false end function init() addPlayer() music(0) end function step() for i=1,#objects do local obj = objects[i] obj.F_step(obj) end end function draw() map(0,0,256,136,-camera.x,-camera.y,0,1,remap) for i=1,#objects do local obj = objects[i] obj.F_draw(obj) end end init() function TIC() cls(0) step() draw() --spr(288,0,0) _t=_t+1 end --[[wl = 100 function BDR(row) if row >= wl then poke(0x3FF9,math.sin((_t+row*4)/48)*3) else poke(0x3FF9,0) end end]]