0,]']±>Sï}WÿÍu§ðp8·d%qy)6o;]ÉA¦ösï÷ôöô”°ÂVl†3 max_row and row < ROWS-1 then score = score + 10 max_row = row end elseif btnp(1) then frog:move(0, 1, 2) elseif btnp(2) then frog:move(-1, 0, 3) elseif btnp(3) then frog:move(1, 0, 1) end -- limit frog to game screen if frog.x < 0 then frog.x=0 end if frog.x > GW-8 then frog.x=GW-8 end if frog.y > GH-8 then frog.y=GH-8 end if frog.anim_timer > 0 then frog.anim_timer = frog.anim_timer - 1 else frog.frame = 1 end elseif frog.state == "dying" then if t%10 == 0 then if frog.frame == #frog.frames then if lives > 0 then frog:set_state("alive") else game_over() end else frog.frame = frog.frame + 1 end end end update_timer() end function update_objects() if game_state ~= "play" then return end for _, car in ipairs(cars) do car.x = car.x + car.dx * speed_scale if car.dx < 0 and car.x+car.w*8 < 0 then car.x=GW elseif car.dx>0 and car.x>GW then car.x = -8*car.w end end for _, log in ipairs(logs) do log.x = log.x + log.dx * speed_scale if log.x > GW then log.x = -8*#log.parts end end for _, group in ipairs(turtles) do group.x = group.x + group.dx * speed_scale if group.x + 8*group.size < 0 then group.x = GW end end if t%20 == 0 then turtle_frame = turtle_frame % #TURTLE_FRAMES + 1 end end function update_timer() if t%20 == 0 then timer = timer - 1 if timer == 0 then game_over() end end end function check_collisions() if game_state ~= "play" or frog.state ~= "alive" then return end local frog_end_x = frog.x+8 local collides=false local carried=false for _, car in ipairs(cars) do local car_left = car.x local car_right = car.x + car.w*8 if frog.y == car.y and frog.x < car_right and frog_end_x > car_left then collides = true end end for _, log in ipairs(logs) do local log_end_x = log.x + 8*#log.parts if frog.x >= log.x-6 and frog_end_x <= log_end_x+6 and frog.y==log.y then frog.x = frog.x+log.dx*speed_scale carried=true end end for _, group in ipairs(turtles) do local group_end_x = group.x + 8*group.size local submerged = group.sinks and TURTLE_FRAMES[turtle_frame] == 0 if (not submerged) and frog.x >= group.x-6 and frog_end_x <= group_end_x+6 and frog.y==group.y then frog.x = frog.x+group.dx*speed_scale carried=true end end if frog.y//8 == 1 then local grid_x = math.floor(frog.x/8 + 0.5) local captured_leaf = false for _, leaf in ipairs(leaves) do if leaf.x == grid_x then if leaf.captured then break end leaf.captured = true captured_leaf = true max_row = 0 if all_leaves_captured() then score = score + 200 game_state = "level_complete" sfx(2, 64, 35) else frog.x = frog.START_X frog.y = frog.START_Y score = score + 50 speed_scale = speed_scale + 0.08 timer = math.min(timer + math.floor(START_TIME*0.1), START_TIME) sfx(2, 62, 30) end end end if not captured_leaf then collides = true end end local hazard = fget(mget(frog.x/8, frog.y/8), 1) if collides or ((not carried) and hazard) then frog:set_state("dying") lives = lives - 1 sfx(1) end end function update() update_player() update_objects() check_collisions() t=t+1 end function draw_transition_text(text, size) local width=print(text,0,-18, 12, false, size) local x = (240-width)//2 local y = (136-24)//2 print(text, x, y, 12, false, size) local s = "Press " local width=print(s,0,-18, 12) print(s, (240-width)//2, y+size*6+2, 12) end function draw() cls(0) for y=0, 136, 2 do line(0, y, 240, y, 15) end rectb(GAME_X-1, GAME_Y-1, GAME_WIDTH+2, GAME_HEIGHT+2, 14) clip(GAME_X, GAME_Y, GAME_WIDTH, GAME_HEIGHT) map(0, 0, GAME_WIDTH//8, GAME_HEIGHT//8, GAME_X, GAME_Y) for _, car in ipairs(cars) do gspr(car.id, car.x, car.y, 0, 1, 0,0,car.w,car.h) end for _, log in ipairs(logs) do for i, part in ipairs(log.parts) do gspr(part, log.x + (i-1)*8, log.y, 0, 1, 0, 0, 1, 1) end end for _, group in ipairs(turtles) do local x = group.x local id if group.sinks then id = TURTLE_FRAMES[turtle_frame] else id = TURTLE_FRAMES[1] end if id ~= 0 then for i=1, group.size do gspr(id, x + (i-1)*8, group.y,0,1,0,0,1,1) end end end for _, leaf in ipairs(leaves) do local id if leaf.captured then id = SPR.FROG_FACE else id = SPR.LEAF end gspr(id, leaf.x*8, 8, 0,1,0,0,1,1) end if game_state == "play" then gspr(frog.frames[frog.frame],frog.x,frog.y,0, 1,0,frog.rotate,1,1) end if game_state == "gameover" then cls(15) draw_transition_text("GAME OVER", 2) end if game_state == "level_complete" then draw_transition_text("Level complete", 1) end clip() print("High score: "..tostring(high_score), 80, 2, 12) print("Score: "..tostring(score), 50, 126, 12) print("Level: "..tostring(level), 150, 126, 12) print("Lives: ", 7, 30, 12) for i = 1, lives do spr(256, 15, 30 + i * 22, 0, 1, 0, 0, 1, 1) end print("Time:", 207, 30, 12) local full_height = 80 local current_fill = timer / START_TIME local current_height = math.floor(full_height * current_fill) rect(215, 40 + full_height - current_height, 5, current_height, 2) end high_score = 0 new_game() function TIC() update() draw() end