My game doesn't go
Good morning I can't understand why my game doesn't go, this is the full code: init = function() player = object x = 0 y = 0 speed = 1 end end initCamera = function() camera = object x = 0 y = 0 end end initCoin = function() coin1 = object end randomizeCoinPos = function() coin1.x = randRange(-200, 200) coin1.y = randRange(-100, 100) end score = 0 end
update = function() if keyboard.UP then player.y += player.speed end if keyboard.DOWN then player.y -= player.speed end if keyboard.RIGHT then player.x += player.speed end if keyboard.LEFT then player.x -= player.speed end end updateCamera = function() camera.x = clamp(player.x, -200, 200) camera.y = clamp(player.y, -650, 650) end update = function() if distance(player.x, player.y, coin1.x, coin1.y) < 25 then score += 1 randomizeCoinPos = function() coin1.x = randRange(-200, 200) coin1.y = randRange(-100, 100) end end
draw = function() screen.clear("rgb(57,0,587)") screen.drawMap("polonuovo", 0-camera.x,0-camera.y,1000,1500) screen.drawSprite("alessandro", player.x-camera.x, player.y-camera.y, 30, 30) screen.drawSprite("coin", coin1.x, coin1.y, 20, 20) screen.drawText("Coins: " + score, 120, 80, 16, "rgb(170,57,94)") end
checkCollision = function(x, y, map_name, map_draw_width, map_draw_height) local grid_x = floor((x + map_draw_width / 2) / (map_draw_width / maps[map_name].width)) local grid_y = floor((y + map_draw_height / 2) / (map_draw_height / maps[map_name].height)) return maps[map_name].get(grid_x, grid_y) end
distance = function(x1, y1, x2, y2) local a = x2 - x1 local b = y2 - y1 local c = sqrt(pow(a, 2) + pow(b, 2)) return c end
clamp = function(value, lower_limit, upper_limit) local val = max(value, lower_limit) val = min(val, upper_limit) return val end
randRange = function(low, high) return (high - low) * random.next() + low end