0,]']±>Sï}WÿÍu§ðp8·d%qy)6o;]ÉA¦ösï÷ôôô”°ÂVl†3 0 then death_timer = death_timer - 1 if death_timer == 0 then p.x, p.y = p.spawn_x, p.spawn_y p.vx, p.vy = 0, 0 p.can_dash = true cam.y = (p.y // LEVEL_HEIGHT) * LEVEL_HEIGHT for _, g in ipairs(gems) do g.timer = 0 end end return end local dt = (slow_timer > 0 and 0.5 or 1.0) if slow_timer > 0 then slow_timer = slow_timer - 1 end local mx, my = p.x + 4, p.y + 4 local tile = get_t(mx, my) if tile >= 2 and tile <= 5 and p.debug == false then die() return end if tile == 17 then mset(mx // 8, my // 8, 18) p.spawn_x, p.spawn_y = (mx // 8) * 8, (my // 8) * 8 save_game() sfx(4) end if tile == 7 then sfx(1) create_explosion(mx, my, 12) p.spawn_y = p.spawn_y + LEVEL_HEIGHT p.spawn_x = 24 p.x, p.y = p.spawn_x, p.spawn_y p.vx, p.vy = 0, 0 p.level = p.level + 1 --fizzii01: This helps to determine which music track to play. The tracks are matched up to the levels. music(p.level) save_game() cam.y = (p.y // LEVEL_HEIGHT) * LEVEL_HEIGHT for _, g in ipairs(gems) do g.timer = 0 end return end if get_t(p.x+1, p.y+8) == 21 or get_t(p.x+6, p.y+8) == 21 then p.vy = -4.5 p.can_dash = true sfx(5) end for _, g in ipairs(gems) do if g.timer > 0 then g.timer = g.timer - 1 if g.anim_frame < 2 then g.anim_frame = g.anim_frame + 0.2 end elseif p.x+7 > g.tx*8 and p.x < g.tx*8+8 and p.y+7 > g.ty*8 and p.y < g.ty*8+8 then if not p.can_dash or p.dash_time > 0 or p.vy > 0 then p.can_dash, g.timer, slow_timer = true, 120, 15 p.vx, p.vy, p.dash_time = 0, -1.5, 0 sfx(6) end end end local cx, cy = math.floor(cam.x), math.floor(cam.y) for i, s in ipairs(sentries) do if p.x+7 > s.tx*8 and p.x < s.tx*8+8 and p.y > s.ty*8 and p.dash_time == 0 and death_timer == 0 then laser = i sfx(7,-1,-1,1) if p.debug == false then die() end end end update_physics(dt) local tx = math.max(0, math.min(1680, p.x - 120)) cam.x = cam.x + (tx - cam.x) * 0.1 cam.y = (p.y // LEVEL_HEIGHT) * LEVEL_HEIGHT end function update_physics(dt) if p.dash_time > 0 then p.dash_time = p.dash_time - dt else if btn(2) then p.vx = p.vx - p.accel * dt p.dir = 1 elseif btn(3) then p.vx = p.vx + p.accel * dt p.dir = 0 else p.vx = p.vx * 0.85 end p.vx = math.max(-p.max_speed, math.min(p.max_speed, p.vx)) p.vy = math.min(p.vy + p.gravity * dt, 3) if p.grounded and btnp(4) then p.vy = p.jump_force p.grounded = false sfx(1) end end if btnp(5) and p.can_dash then p.can_dash, p.dash_time = false, 10 sfx(2) if btn(0) then p.vy = -p.dash_up_speed p.vx = 0 else p.vx = (p.dir == 0 and p.dash_speed or -p.dash_speed) p.vy = 0 end end p.x = p.x + p.vx if is_solid(p.x+(p.vx>0 and 7 or 0), p.y+1) or is_solid(p.x+(p.vx>0 and 7 or 0), p.y+6) then p.x = math.floor(p.x // 8) * 8 + (p.vx < 0 and 8 or 0) p.vx = 0 end p.y = p.y + p.vy p.grounded = false if is_solid(p.x+1, p.y+(p.vy>0 and 8 or 0)) or is_solid(p.x+6, p.y+(p.vy>0 and 8 or 0)) then p.y = math.floor(p.y // 8) * 8 + (p.vy < 0 and 8 or 0) if p.vy > 0 then p.grounded, p.can_dash = true, true end p.vy = 0 end anim_timer = anim_timer + 0.15 if p.dash_time > 0 then p.sp = (p.dir == 0 and 262 or 263) elseif not p.grounded then p.sp = 261 elseif math.abs(p.vx) > 0.2 then p.sp = (p.dir == 0 and 257 or 259) + math.floor(anim_timer % 2) else p.sp = 256 end end function update_fx() for i=#particles, 1, -1 do local prt = particles[i] prt.x, prt.y, prt.life = prt.x + prt.vx, prt.y + prt.vy, prt.life - 1 if prt.life <= 0 then table.remove(particles, i) end end if p.dash_time > 0 and time() % 100 < 20 then table.insert(dash_trail, {x=p.x, y=p.y, sp=264, dir=p.dir, alpha=12}) end for i=#dash_trail, 1, -1 do dash_trail[i].alpha = dash_trail[i].alpha - 1 if dash_trail[i].alpha <= 0 then table.remove(dash_trail, i) end end end function draw_menu() cls(0) map(0, 119, 30, 17, 0, 0) local cy = (menu_option == 0) and 48 or 72 spr(254 + (time() // 250 % 2), 120, cy, 0) end function draw_game() cls(13) local cx, cy = math.floor(cam.x), math.floor(cam.y) map(0, cy // 8, 240, 17, -cx, 0) for _, g in ipairs(gems) do local gx, gy = g.tx*8 - cx, g.ty*8 - cy if g.timer == 0 then spr(19, gx, gy, 0) else local f = math.floor(g.anim_frame) if f <= 2 then spr(22 + f, gx, gy, 0) end end end for i, s in ipairs(sentries) do local sx, sy = s.tx*8 - cx, s.ty*8 - cy s.anim_frame=s.anim_frame+.1 if s.anim_frame >= 2 then s.anim_frame = 0 end if s.anim_frame < 1 then spr(9, sx, sy, 0) else spr(10, sx, sy, 0) end if i == laser then line(sx+4,sy+8,p.x-cx+4,p.y-cy,2) laser = nil end end for _, t in ipairs(dash_trail) do spr(t.sp, t.x-cx, t.y-cy, 0, 1, t.dir) end for _, prt in ipairs(particles) do rect(prt.x-cx, prt.y-cy, 1, 1, prt.col) end if death_timer == 0 then spr(p.sp, p.x - cx, p.y - cy, 0, 1, 0) end end init() function TIC() if state == MENU then update_menu() draw_menu() else update_game() draw_game() end --debug mode added by fizzii01 if p.debug == true then print("DEBUG MODE ON",0,0,2) print("X:",0,8,12) print(p.x,16,8,12) print("Y:",0,16,12) print(p.y,16,16,12) end end