DDADAADDDDDADDDLLLDLDLDLDL3C4ODODOD?C3 "" "" "" "" "" "" ""`UPPUU  " ̈    "   3D   +"" YPUUUU PZUYU "̪ʪ̪̬̬ z   =; "" BDLDL LL L <<L L "DL઺ DL D DLޭ@DDL ",D DL @DDL Ѐ ̂D "$DDL @DDL @3$3C40C33C4 ""ݻ _UUUU_UUU/ O L << /" Dh-- title: Cat -- author: Wolfy_Cyberware -- desc: a world of cats with a lot of action -- script: lua -- saveid: caoscat t=0 debug = false --@math table simplified m = math mc, ms, mr, ma, mf, msq = m.cos, m.sin, m.random, m.abs, m.floor, m.sqrt s = string sf = s.format ti, tr = table.insert, table.remove local FPS={v=0,f=0,lT=-1000} function FPS:getValue() if (time()-self.lT <= 1000) then self.f=self.f+1 else self.v=self.f self.f=0 self.lT=time() end return self.v end function col(x, y) xy = mget(x//8, y//8) --colision check if xy < 1 then return 0 elseif xy < 16 then return 1 elseif xy < 194 then return 2 elseif xy == 194 then return 3 elseif xy < 198 then return 4 end end function pcol(n, m, n1, n2, n3) --check player colision if n.x+n1 > m.x+n2 and n.x-n1 < m.x+n2 and n.y+n1 > m.y+n3 and n.y-n1 < m.y+n3 then return true end end --@particles part={} --particles table function part:new(ty, x, y, sx, sy, t, v) ti(part, {tag = "part",ty = ty, x = x, y = y, sx = sx, sy = sy, t = t, mt = t, v = v}) end function part:updt()--update all particles for i, p in ipairs(self)do function remove(bool) if bool then tr(part, i) end end function vel(sx, sy) p.sy = p.sy * sy p.sx = p.sx * sx end p.x = p.x + p.sx p.y = p.y + p.sy if p.ty=="blood" then if col(p.x, p.y) == 1 then vel(0, 0) else vel(0.95, 1) p.sy=p.sy+0.05 end elseif p.ty=="blood2" then vel(0.95, 0.95) if col(p.x, p.y) == 1 then vel(0, 0) end p.sy=p.sy+0.025 elseif p.ty=="bone" then if col(p.x, p.y+1) == 1 then vel(1, -0.9) else p.sy=p.sy+0.1 end for w=-1, 1, 2 do if col(p.x+w, p.y) == 1 then vel(-0.9, 1)else vel(0.995, 1)end end elseif p.ty=="skull" then if col(p.x, p.y+1) == 1 then vel(1, -0.8) else p.sy=p.sy+0.1 end for w=-2, 2, 4 do if col(p.x+w, p.y) == 1 then vel(-0.9, 1)else vel(0.99, 1)end end elseif p.ty=="smoke" then vel(0.95, 0.95) if col(p.x, p.y) == 1 then vel(0, 0) end elseif p.ty=="wood" then vel(0.7, 1) p.sy=p.sy+0.1 if col(p.x, p.y+1) == 1 or col(p.x, p.y-1) == 1 then vel(1, -0.5) end if col(p.x+1, p.y) == 1 or col(p.x-1, p.y) == 1 then vel(-0.5, 1) end elseif p.ty=="flame" then vel(0.9, 1) p.sy = p.sy - (mr(1)/5) elseif p.ty=="healing" then vel(0.9, 0.9) elseif p.ty=="wish3" then vel(0.9, 0.9) elseif p.ty=="glass" then vel(0.9, 1) p.sy = p.sy + 0.2 if col(p.x, p.y+1) == 1 or col(p.x, p.y-1) == 1 then vel(1, -0.5) end if col(p.x+1, p.y) == 1 or col(p.x-1, p.y) == 1 then vel(0.5, 1) end elseif p.ty=="spark" then vel(0.95, 0.95) elseif p.ty == "punch" then vel(0.8, 0.8) end --time's up p.t = p.t - 1 remove(p.t <= 0) end end function part:draw() --draw all particles for i, p in ipairs(self)do if p.ty=="circ" then --type circle pix(p.x - p.sx, p.y - p.sy, p.v.c) if p.t > 15 then circ(p.x, p.y, p.v.r, p.v.c) elseif p.t > 5 then circb(p.x, p.y, p.v.r, p.v.c) else pix(p.x, p.y, p.v.c)end elseif p.ty=="blood" then --type blood line(p.x, p.y, p.x+p.sx, p.y+p.sy, 2) elseif p.ty=="blood2" then --type blood if p.t > p.mt/4 then circ(p.x, p.y, p.v, 2) else circb(p.x, p.y, p.v, 2) end elseif p.ty=="smoke" then --type smoke if p.t < p.mt/3 then r = p.v.r[3] c = p.v.c[3] elseif p.t < p.mt/1.5 then r = p.v.r[2] c = p.v.c[2] else r = p.v.r[1] c = p.v.c[1] end if p.t>p.mt/4 then circ(p.x, p.y, r, c) else circb(p.x, p.y, r-1, c)end elseif p.ty=="spark" then --type spark line(p.x, p.y, p.x-p.sx*3, p.y-p.sy*3, p.v.c[p.t%p.mt//(p.mt/3)+1]) elseif p.ty=="flame" then --type flame circ(p.x, p.y, 1 + (p.t / (p.mt / 2)), p.v.c[p.t%p.mt//(p.mt/3)+1]) elseif p.ty=="wood" then --type wood line(p.x, p.y, p.x+mc(t*p.sx), p.y+ms(t*p.sx), p.v.c) elseif p.ty=="bone" then --type bone line(p.x, p.y, p.x+mc(t*p.sx), p.y+ms(t*p.sx), 12) elseif p.ty=="skull" then --type skull spr(386, p.x-5, p.y-5, 0, 1, 0, t*p.sx/10) elseif p.ty=="txt" then --type damage_text c=0 if p.t<=p.mt/3 then c = p.v.c[1] elseif p.t c.x then c.sx=-2 else c.sy=2 end end end for j=1, 30 do part:new("smoke", b.x, b.y, mc(mr(-3, 3))*mr(5, 25)/15, ms(mr(-3, 3))*mr(5, 25)/15, mr(45, 90), {c = {4, 2, 15}, r = {3, 2, 2}}) end end elseif b.ty == "flame" then b.x = b.x + b.sx b.y = b.y + b.sy b.sx = b.sx * 0.9 b.sy = b.sy * 0.9 for j, c in ipairs(cats)do if pcol(b, c, 10, 4, 6) then dam(c)--damage and particles c.ft = 180 end end elseif b.ty == "explosion" then for j, c in ipairs(cats)do coll = (c.x-b.x)*(c.x-b.x) + (c.y-b.y)*(c.y-b.y) rad = msq(coll) if rad < 32 then dam(c)end for j=1, 30 do part:new("smoke", b.x, b.y, mc(mr(-10, 10))*mr(1, 20)/10, ms(mr(-10, 10))*mr(1, 20)/10, mr(45, 90), {c = {4, 3, 1}, r = {4, 3, 3}}) end end del(true, i) end b.t=b.t-1 del(b.t < 0, i) end end function proj:draw() for i, b in ipairs(self)do --projectiles design if b.ty=="bullet" then circ(b.x, b.y, 2, 4) circ(b.v.bx, b.v.by, 2, 4) elseif b.ty=="missile" then circ(b.x-b.sx*2, b.y-b.sy*2, 2, 7) circ(b.x-b.sx, b.y-b.sy, 2, 6) circ(b.x, b.y, 2, 6) elseif b.ty=="bomb" then circ(b.x, b.y, 2, 14) circ(b.x-1, b.y-1, 1, 13) circb(b.x, b.y, b.t//12, 12) line( b.x+mc(b.x/10)*4, b.y+ms(b.x/10)*4, b.x+mc(b.x/10)*4-b.sx, b.y+ms(b.x/10)*4-b.sy, 12) elseif b.ty=="flame" then circb(b.x, b.y, 2, 3) end end end --@item item={} function item:new(ty, x, y, sx, sy) ti(item, {tag = "item", ty=ty, x=x, y=y, sx=sx, sy=sy}) end function item:updt() for j, i in ipairs(self)do i.x = i.x + i.sx i.y = i.y + i.sy i.sy = i.sy + 0.1 i.sx = i.sx / 1.1 if col(i.x, i.y + 3) then i.sy = 0 i.y = i.y - 1 end if col(i.x, i.y - 3) then i.sy = 0 i.y = i.y + 1 end if col(i.x - 4, i.y) then i.sx = 0 i.x = i.x + 1 end if col(i.x + 4, i.y) then i.sx = 0 i.x = i.x - 1 end for l, p in ipairs(cats)do if pcol(i, p, 4, -6, 6) then tr(item, j) trace(p.ty.." id("..l..') '.. i.ty, 6) end end end end function item:draw() for j, i in ipairs(self)do function sp(id)spr(id, i.x-3, i.y-3, 0)end if i.type=="ammo" then sp(336)end end end --@guns -- type -- duration, max duration -- interval, precision, sprite -- impulse, bullet per click, weight -- damage gs={--revolver revolver={ ty="ranged", dur=6, maxdur=6, int=30, p=18, sp=368, imp=0.7, bpc=1, weight=0.05, dam=10, range = 8*14, name = "revolver" },--pistol pistol={ ty="ranged", dur=13, maxdur=13, int=10, p=14, sp=369, imp=0.5, bpc=1, weight=0.02, dam=2, range = 8*10, name = "pistol" },--shotgun shotgun={ ty="ranged", dur=8, maxdur=8, int=40, p=10, sp=370, imp=1.5, bpc=8, weight=0.05, dam=4, range = 8*6, name = "shotgun" },--smg smg={ ty="ranged", dur=30, maxdur=30, int=5, p=16, sp=371, imp=0.4, bpc=1, weight=0.05, dam=3, range = 8*8, name = "smg" },--sniper sniper={ ty="ranged", dur=3, maxdur=3, int=60, p=30, sp=372, imp=2, bpc=1, weight=0.07, dam=50, range = 8*24, name = "sniper" },--minigun minigun={ ty="ranged", dur=100, maxdur=100, int=3, p=12, sp=373, imp=0.4, bpc=1, weight=0.1, dam=2, range = 8*14, name = "minigun" },--missile missile={ ty="missile", dur=1, maxdur=1, int=100, p=20, sp=374, imp=3, bpc=1, weight=0.2, dam=75, range = 8*20, name = "missile" },--bomb bomb={ ty="grenade", dur=2, maxdur=2, int=30, p=1, sp=375, imp=1, bpc=1, weight=0.05, dam=50, range = 8*15, name = "bomb" },--knife knife={ ty="melee", dur=10, maxdur=10, int=10, p=1, sp=376, imp=-0.7, bpc=1, weight=0.05, dam=10, range = 8*2, name = "knife" },--hammer hammer={ ty="melee", dur=20, maxdur=20, int=20, p=1, sp=377, imp=-0.4, bpc=1, weight=0.05, dam=20, range = 8*2, name = "hammer" },--shield shield={ ty="defense", dur=30, maxdur=30, int=0, p=1, sp=378, imp=0.1, bpc=1, weight=0.2, dam=0, range = 8*16, name = "shield" },--hand hand={ ty="hand", dur=1, maxdur=1, int=10, p=1, sp=0, imp=-1, bpc=1, weight=0.02, dam=10, range = 8*2, name = "hand" },--flame thrower flamet={ ty="flame", dur=50, maxdur=50, int=1, p=20, sp=379, imp=0.1, bpc=3, weight=0.1, dam=1, range = 8*5, name = "flamet" } } --cats styles theme = { player = { {12, 4, 2, 3, 2}, {8, 8, 10, 11, 11}, {12, 13, 6, 7, 6}, {8, 8, 4, 12, 4} }, enemy = {{14, 14, 8, 12, 0}, {12, 2, 8, 13, 0}}} --cats buttons button = {{0, 1, 2, 3}, {7, 4, 6, 5}} --@cats cats={} function cats:new(ty, th, x, y, ig, b) ti(cats, { tag = "cat", ty = ty, --type of cat "player" or "enemy" th = th, --theme c = theme[ty][th], --colors hp = 100, --health points x = x, y = y, --pos X and Y sx = 0, sy = 0, --speed X and Y msx = 1.5, msy = 1, --max speed X and Y hx = 0, hy = 0, --head X and Y f = 0, j = 2, --flip and jump b = button[b], --buttons bool = {false, false, false, false}, --boolean buttons pts = 0, --points ht = 0, --hit time ft = 0, --fire time gx = 0, gy = 0, --gun pos X and Y gsx = 0, gsy = 0, --gun speed X and Y gr = 0, --gun rotate strength = 1, gt = 0, --gun time gun = { ty=gs[ig].ty, dur=gs[ig].dur, maxdur=gs[ig].maxdur, int=gs[ig].int, p=gs[ig].p, sp=gs[ig].sp, imp=gs[ig].imp, bpc=gs[ig].bpc, weight=gs[ig].weight, dam=gs[ig].dam, range=gs[ig].range, name=gs[ig].name}, --gun table v = {id=#cats} --extra variable }) end function color(c1, c2, c3, c4, c5) poke4(0x3ff0 * 2 + 11, c1) poke4(0x3ff0 * 2 + 10, c2) poke4(0x3ff0 * 2 + 9, c3) poke4(0x3ff0 * 2 + 8, c4) poke4(0x3ff0 * 2 + 5, c5) end function cats:draw() for i, p in ipairs(self)do color(11, 10, 9, 8, 5) if p.ty=="player" then sp = 256 else sp = 272 end --tail if p.hp > 0 then line(p.x+3+p.f, p.y+7, p.x-1+(p.f*9)-p.sx, p.y+6-(p.sy//1)*1.5, p.c[5]) end function draw(a, b) if col(p.x+3, p.y+8)==1 then --legs spr(sp+3+(t%6//3*ma(p.sx)), p.x+a, p.y+b, 0, 1, p.f) else spr(sp+5, p.x+a, p.y+b, 0, 1, p.f)end spr(sp, p.x+a, p.y-p.hy+b-p.sy, 0, 1, p.f)--body if col(p.x+3, p.y+14)==1 then an = p.hy-1-((i*8-t)//40%2) else an=-2 end spr(sp+1, p.x+p.hx+a, p.y+an+b, 0, 1, p.f)--head p.gx = p.x+3-p.f*7+p.gsx+p.sx*2 p.gy = p.y+p.gsy-1-p.sy//1 if p.gun.ty ~= "hand" then --show the gun spr(p.gun.sp, p.gx, p.gy, 0, 1, p.f, p.gr) end end color(p.c[5], p.c[5], p.c[5], p.c[5], p.c[5]) for j = -1, 1 do for k = -1, 1 do draw(j, k)end end if p.ht>0 then p.ht=p.ht-1 color(12, 12, 12, 12, 12) else color(p.c[1], p.c[2], p.c[3], p.c[4], 14)end draw(0, 0) if p.bool[ 3 ] then p.hx = -1 p.f = 1 elseif p.bool[ 4 ] then p.hx = 1 p.f = 0 else p.hx = 0 end if p.sy // 1 > 0.5 then p.hy = 1 elseif p.sy // 1 < -0.5 then p.hy = -1 else p.hy = 0 end end cats:UI() end function cats:UI() board = {} for i, p in ipairs(self)do sp = 256 if p.ty == "player" then ti(board, { x = p.x, y = p.y, sp = 257, gsp = p.gun.sp, c=p.c, hp = p.hp, dur = p.gun.dur, maxdur = p.gun.maxdur }) end --show hp color(11, 10, 9, 8, 5) rect(p.x-1, 116, 10, 1, 2) rect(p.x-1, 116, p.hp/10, 1, 5) rectb(p.x-1-1, 116-1, p.hp/10+2, 1+2, 15) end for j, b in ipairs(board)do if b.gsp == 0 then b.gsp = 385 end color(b.c[1], b.c[2], b.c[3], b.c[4]) spr(480, 2, 126-(j*9), 0, 1, 0, 0, 3, 1) spr(b.sp, 2, 126-(j*9), 0) spr(b.gsp, 9, 125-(j*12)+6, 0) print(b.dur .. " : " .. b.maxdur, 30, 126-(j*9), 12, false, 1, true) end end function cats:updt()--update the player for i, p in ipairs(self)do p.x = p.x + p.sx p.y = p.y + p.sy p.sy = p.sy + 0.15 + (p.gun.weight / p.strength) --player controls if p.ty == "player" then for j = 1, 4 do if btn(p.b[ j ]) and p.b ~= button[ 3 ] then p.bool[ j ] = true else p.bool[ j ] = false end end end self:AI(p)--artificial inteligence if p.bool[ 1 ] and p.j > 0 then --jump p.sy = -2.5 p.j = 0 for i=1, 3 do part:new("circ", p.x+3, p.y+8, mr(-1, 1)/10, mr(-5, -1)/20, mr(30, 40), {r=1, c=12})end end --left and right if p.bool[ 3 ] then p.sx = p.sx-0.5 elseif p.bool[ 4 ] then p.sx = p.sx+0.5 else p.sx = p.sx / 1.2 end --max speed if p.ty == "enemy" then p.msx = 1 end if p.sx > p.msx then p.sx = p.msx elseif p.sx < -p.msx then p.sx = -p.msx end if p.msx > 1.5 then p.msx = p.msx - 0.01 part:new("wish3", p.x + 3, p.y+2 + mr(0, 5), p.sx / 2, p.sy/2, mr(30, 50), 8 + (p.msx // 0.9)) end self:attack(p) self:hit(p) self:death(p, i) self:colision(p) end end --sensor that maps the player's coordinates radar = {{x=0,y=0}} function cats:AI(c) if c.ty == "player" then ti(radar, 1, {x = c.x, y = c.y}) end function control(b1, b2, b3, b4) w = {b1, b2, b3, b4} for i = 1, 4 do if w[ i ] == 1 then c.bool[ i ] = true elseif w[ i ] == 0 then c.bool[ i ] = false end end end rad = radar[1] --control of AI if c.ty == "enemy" then range = c.gun.range if rad.x > c.x then c.f=0 else c.f=1 end if rad.x < c.x - range then control(0, 0, 1, 0) elseif rad.x > c.x + 7 + range then control(0, 0, 0, 1) else control(0, 1, 0, 0) end if rad.y + 20 < c.y or col(c.x + 7 - (c.f*13), c.y + 4) == 1 or col(c.x + 7 - (c.f*13), c.y + 8) == 0 then control(1, 0, 2, 2) end end end function cats:attack(p) --player shoot --remove the gun if p.gun.dur <= 0 and p.gun.ty ~= "hand" then p.gun = gs.hand p.gt = 30 end if p.bool[ 2 ] and p.gt <= 0 then --[[ attacks ]] function kb()--knockback if p.f<1 then p.sx=-p.gun.imp else p.sx=p.gun.imp end p.sy=p.sy-ma(p.gun.imp) p.y = p.y - 1 end p.gt = p.gun.int kb() if p.gun.ty ~= "hand" then p.gun.dur = p.gun.dur - 1 end if p.gun.ty == "ranged" then --ranged for j=1, p.gun.bpc do proj:new("bullet", p.x+10-p.f*13, p.y+4, 4-p.f*8, mr(-5, 5)/p.gun.p/p.strength, p.f, p.gun.dam, 120, {bx=p.x, by=p.y})end for l=1, 2 do part:new("smoke", p.x+8-p.f*8, p.y+4, (2-p.f*4)/(mr(2, 8)/2), mr(-1, 1)/3, mr(10, 15), {r={2, 3, 2}, c={12, 13, 13}}) part:new("spark", p.x+8-p.f*8, p.y+4, (3-p.f*6)/(mr(2, 8)/2), mr(-5, 5)/15, mr(30, 60), {r={2, 3, 2}, c={3, 4, 12}})end elseif p.gun.ty == "melee" or p.gun.ty == "hand" then --melee if p.gun.ty == "hand" then part:new("punch", p.x+6 - (p.f*4), p.y + 3, 2 - (p.f*4)+p.sx, 0+p.sy, 10, {p.c[1], p.c[5]}) else part:new("wish", p.x+1 - (p.f*2), p.y + 3, 2 - (p.f*4), 0, 7, p.f) end proj:new("hit", p.x+14-p.f*16, p.y+4, (1-p.f*2)/2, 0, p.f, p.gun.dam*p.strength, 2, {bx=0, by=0}) elseif p.gun.ty == "missile" then --missile proj:new("missile", p.x+16-p.f*24, p.y+4, 4-p.f*8, mr(-5, 5)/p.gun.p/p.strength, p.f, p.gun.dam, 180) elseif p.gun.ty == "grenade" then proj:new("bomb", p.x+12-p.f*15, p.y+4, (3-p.f*6)/2, -2, p.f, p.gun.dam, 180, {bx=0, by=0}) elseif p.gun.ty == "flame" then proj:new("flame", p.x+13-p.f*21, p.y+4, (5-p.f*10)*mr(3, 5)/10, mr(-5, 5)/10, p.f, p.gun.dam, 15, 0) for l=1, 2 do part:new("smoke", p.x+8-p.f*8, p.y+4, (2-p.f*4)/(mr(2, 8)/2), mr(-1, 1)/3, mr(10, 20), {r={2, 3, 3}, c={4, 3, 2}})end end elseif p.gt > 0 then if p.ty == "enemy" then p.gt = p.gt - 0.5 else p.gt = p.gt - 1 end end end function cats:hit(p) --player hit if p.ft>0 then p.ft=p.ft-1 if t%10==0 then p.hp=p.hp-2 p.ht=10 --blood particles part:new("blood", p.x+4, p.y+4, mr(1, 50)/50, mr(-10, 5)/20, mr(120, 240), 2) --damage text particle part:new("txt", p.x, p.y, 0, -1, 30, {tx = 2, c = {2, 4, 12}}) for l=1, 2 do part:new("smoke", p.x+4, p.y+4, mr(-20, 20)/30, mr(-18, 2)/12, mr(15, 30), {r={2, 3, 3}, c={12, 4, 3}}) end end end end function cats:death(p, i) if mf(p.hp) <= 0 or p.y > 131 then trace(p.ty.. ' ' .." died!", 3) if p.gun.ty ~= "hand" then item:new(p.gun.name, p.x, p.y, mr(-3, 3), mr(-4, 0))end v=0 if p.y > 130 then v=-3 end tr(self, i) if p.ty == "player" then body:new("player", p.x, p.y, p.sx*2, -1+v, p.f, p.c) else body:new("enemy", p.x, p.y, p.sx*2, -1+v, p.f, p.c) end end end function cats:colision(p) --colision of the cats function ecol(a, b) --extend col return col(p.x + a, p.y + b) end if ecol(2, 7)==1 or ecol(5, 7)==1 then if p.sy>2 then for i=1, 3 do part:new("circ", p.x+3, p.y+7, mr(-3, 3)/10, mr(-5, 0)/50, mr(30, 40), {r=1, c=12})end end p.sy=0 p.y=p.y-1//1 p.sx=p.sx/1.5 p.j=1 --create particles if cat walk if ma(p.sx)>0.5 then part:new("circ", p.x+3, p.y+7, mr(-2, 2)/10, 0, 30, {r=1, c=12})end else p.j=0 end if ecol(2, 0)==1 or ecol(5, 0)==1 then p.sy=0 p.y=p.y+1//1 end if ecol(7, 3)==1 or ecol(3, 3)==4 then p.sx=0 p.x=p.x-1//1 end if ecol(0, 3)==1 or ecol(4, 3)==4 then p.sx=0 p.x=p.x+1//1 end end body = {} function body:new(ty, x, y, sx, sy, f, c) ti(self, {ty = ty, tag = "body", x = x, sx = sx, y = y, sy = sy, f = f, c = c}) end function body:updt() for i, b in ipairs(self)do function ecol(m, n) --extend col return col(b.x + m, b.y + n) end b.x = b.x + b.sx b.y = b.y + b.sy b.sy = b.sy + 0.1 b.sx = b.sx * 0.95 if ecol(4, 3)==1 then b.y = b.y - 1 b.sy = 0 elseif ecol(4, -1)==1 then b.y = b.y + 1 b.sy = 0 end if ecol(-1, 1)==1 then b.x = b.x + 1 b.sx = 0 elseif ecol(8, 1)==1 then b.x = b.x - 1 b.sx = 0 end end end function body:draw() for i, b in ipairs(self)do if ma(b.sx) > 0.1 then rx=mr(-30, 30)/30 ry=mr(-30, 30)/30 part:new("blood", b.x+3, b.y+3, rx, ry, mr(120, 240), 2) end if t%4==0 and (ma(b.sx) > 0.1 and ma(b.sy) > 0.2) then rx=mr(-10, 10)/30 ry=mr(-10, 10)/30 part:new("blood2", b.x+3, b.y+3, rx, ry, mr(30, 60), 2) end if b.ty == "player" then sp = 400 else sp = 416 end if b.sy > 0.5 then sp = sp+2 elseif b.sy < -0.5 then sp = sp+1 end color(b.c[5], b.c[5], b.c[5], b.c[5], b.c[5]) for x=-1, 1 do for y=-1, 1 do spr(sp, b.x+x, b.y+y, 0) end end color(b.c[1], b.c[2], b.c[3], b.c[4]) spr(sp, b.x, b.y, 0, 1, b.f) end end vehicle={} function vehicle:new(x, y) ti(self, { tag = "vehicle", x = x, sx = 0, y = y, sy = 0, ms = 2, drive = false, t = 0, hp = 30, f = 0 }) end function vehicle:updt() for i, h in ipairs(self)do h.x = h.x + h.sx h.y = h.y + h.sy for j, c in ipairs(cats)do if c.x + 2 > h.x and c.x < h.x + 10 and c.y + 2 > h.y-3 and c.y < h.y + 3 and h.t <= 0 and not h.drive then h.drive = true end if h.sx > h.ms then h.sx = h.ms elseif h.sx < -h.ms then h.sx = -h.ms end if h.drive and h.t <= 0 then if c.bool[4] then h.sx = h.sx + 0.2 h.f = 0 elseif c.bool[3] then h.sx = h.sx - 0.2 h.f = 1 else h.sx = h.sx * 0.9 end c.x = h.x+3 c.y = h.y-3 c.sy = 0 if c.bool[1] then h.t = 60 h.drive = false c.sy = -2 c.y = c.y - 1 end if ma(h.sx)>0.5 and t%3 == 0 then part:new("smoke", h.x+4+h.f*7, h.y+7, -h.sx/10, mr(-5, -1)/20, mr(15, 30), {r={1, 2, 2, 3}, c={12, 12, 13, 14}})end else h.t = h.t - 1 h.sx = h.sx * 0.97 end end if h.hp <= 10 and h.hp > 0 then h.hp = h.hp - 0.02 end if h.hp <= 0 then proj:new("explosion", h.x, h.y, 0, 0, 0, 75, 1, 0) tr(self, i) end self:col(h) end end function vehicle:col(h) if col(h.x+2, h.y+7) == 1 or col(h.x+14, h.y+7) == 1 then h.y = h.y - 1 h.sy = 0 else h.sy = h.sy + 0.2 end if col(h.x, h.y + 2) == 1 or col(h.x, h.y + 5) == 1 then if ma(h.sx) > 1 then h.hp = h.hp - 1 part:new("smoke", h.x+2, h.y, -h.sx/10, mr(-5, -1)/20, mr(15, 30), {r={2, 3, 2, 2}, c={12, 12, 13, 14}}) end h.x = h.x + 1 h.sx = -h.sx/3 elseif col(h.x+15, h.y + 2) == 1 or col(h.x+15, h.y + 5) == 1 then if ma(h.sx) > 1 then h.hp = h.hp - 1 part:new("smoke", h.x+14, h.y, -h.sx/10, mr(-5, -1)/20, mr(15, 30), {r={2, 3, 2, 2}, c={12, 12, 13, 14}}) end h.x = h.x - 1 h.sx = -h.sx/3 end end function vehicle:draw() for i, h in ipairs(self)do spr(464, h.x, h.y, 10, 1, h.f, 0, 2, 1) if h.hp <= 10 and t%2 == 0 then part:new("smoke", h.x+12-h.f*10, h.y, mr(-2, 2)/10, mr(-25, -5)/20, mr(10, 15), {r={1, 2, 2, 2}, c={4, 3, 2, 14}}) part:new("spark", h.x+12-h.f*10+mr(-3, 3), h.y, -h.sx, mr(-25, -5)/10, mr(10, 15), {c={3, 4, 4}}) elseif h.hp <= 20 and t%4 == 0 then part:new("smoke", h.x+12-h.f*10, h.y, mr(-2, 2)/10, mr(-25, -5)/20, mr(10, 15), {r={1, 2, 2, 1}, c={13, 13, 13, 13}})end end end --map e1, e2 = 128, 129 --#load function _load() --load or init function cats:new("player", 1, 8*3, 58, "shotgun", 1) cats:new("player", 2, 8*2, 58, "revolver", 2) --vehicle:new(120, 50) -- enemys for y=0, 16 do for x=0, 29 do xy=mget(x, y) if xy == e2 then cats:new("enemy", 2, x*8, y*8, "hand", 1) mset(x, y, mget(x, y-1)) end end end--]] trace("game start!", 5) end --#update function _update() --update the game cats:updt() body:updt() part:updt() proj:updt() item:updt() vehicle:updt() t=t+1 end --#draw function _draw() --draw everything color(11, 10, 9, 8, 14) cls(0) map(0, 0, 30, 17, 0, 0, 15, 1) part:draw() proj:draw() item:draw() cats:draw() body:draw() vehicle:draw() if debug then print(#part, 10, 10, 12) print("FPS: "..FPS:getValue(), 210, 10, 5, false, 1, true) end end --#game _load()function TIC()_update()_draw()end