my screen is black
there is nothing on my screen when i run my program. here's my code: PLAYER_SPEED = 6 APPLE_SPEED_MIN = 2 APPLE_SPEED_MAX = 5 SPAWN_INTERVAL = 0.8 PLAYER_WIDTH = 40 PLAYER_HEIGHT = 12 APPLE_RADIUS = 6 START_LIVES = 3
func init() -- player variables player_x = 0 player_y = screen.height/2 - 40 player_w = PLAYER_WIDTH player_h = PLAYER_HEIGHT
-- apples: each apple will be [x, y, vy] apples = new [] spawnTimer = SPAWN_INTERVAL score = 0 lives = START_LIVES gameOver = false .
func update() if gameOver then if keyboard.SPACE then init() . return .
-- player movement if keyboard.LEFT or keyboard.A then player_x -= PLAYER_SPEED . if keyboard.RIGHT or keyboard.D then player_x += PLAYER_SPEED .
-- clamp to screen halfW = screen.width/2 if player_x < -halfW + player_w/2 then player_x = -halfW + player_w/2 . if player_x > halfW - player_w/2 then player_x = halfW - player_w/2 .
-- spawn apples spawnTimer -= 1/60 if spawnTimer <= 0 then spawnTimer = SPAWN_INTERVAL ax = rnd(-screen.width/2 + APPLE_RADIUS, screen.width/2 - APPLE_RADIUS) vy = rnd(APPLE_SPEED_MIN, APPLE_SPEED_MAX) apple = new [ax, -screen.height/2 - 10, vy] apples.push(apple) .
-- update apples for i = apples.length-1 to 0 step -1 a = apples[i] a[1] += a[2] -- y += vy caught = false
-- check collision with basket
if a[1] >= player_y - player_h/2 - APPLE_RADIUS then
left = player_x - player_w/2
right = player_x + player_w/2
if a[0] >= left and a[0] <= right then
score += 1
apples.remove(i)
caught = true
.
.
-- missed apple
if not caught and a[1] > screen.height/2 + 20 then
lives -= 1
apples.remove(i)
if lives <= 0 then gameOver = true .
.
. .
func draw() -- background screen.fillRect(0,0,screen.width,screen.height,"#0B3B17")
-- ground screen.fillRect(0, screen.height/2 - 10, screen.width, 20, "#5C3A21")
-- player basket screen.fillRect(player_x, player_y, player_w, player_h, "#FFD166") screen.drawRect(player_x, player_y - player_h/2 + 2, player_w, player_h/2, "#FFA500")
-- apples for i = 0 to apples.length-1 a = apples[i] screen.fillCircle(a[0], a[1], APPLE_RADIUS, "#E63946") screen.drawCircle(a[0], a[1], APPLE_RADIUS, "#8B1A1A") screen.fillRect(a[0]-4, a[1]-APPLE_RADIUS-4, 6, 3, "#2A9D8F") .
-- HUD screen.drawText("Score: " + score, -screen.width/2 + 60, -screen.height/2 + 24, 18, "#FFFFFF") screen.drawText("Lives: " + lives, screen.width/2 - 70, -screen.height/2 + 24, 18, "#FFFFFF") screen.drawText("Move: ← → or A D Catch the apples!", 0, -screen.height/2 + 24, 14, "#DDD")
-- game over if gameOver then screen.setAlpha(0.6) screen.fillRect(0,0,screen.width,screen.height,"#000000") screen.setAlpha(1) screen.drawText("GAME OVER", 0, -20, 36, "#FFFFFF") screen.drawText("Final score: " + score, 0, 20, 20, "#FFFFFF") screen.drawText("Press SPACE to restart", 0, 60, 14, "#CCCCCC") . .
init()
please help me someone