Playdate 5

No *you’re* trying to distract yourself from the news.

Not a big one this time. Added a proper level, drawn out as a table:

local myLevel = {
    1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
    1,3,3,3,3,3,3,3,3,3,3,3,3,3,1,
    1,3,1,1,1,1,3,1,3,1,1,1,1,3,1,
    1,3,1,3,3,3,3,1,3,3,3,3,1,3,1,
    1,3,1,3,1,1,1,1,1,1,1,3,1,3,1,
    1,3,1,3,3,3,3,3,3,3,3,3,1,3,1,
    1,3,3,3,1,1,1,2,1,1,1,3,3,3,1,
    1,3,1,3,1,2,2,2,2,2,1,3,1,3,1,
    1,3,1,3,1,1,1,1,1,1,1,3,1,3,1,
    1,3,1,3,3,3,3,3,3,3,3,3,1,3,1,
    1,3,1,1,1,3,1,3,1,3,1,1,1,3,1,
    1,3,3,3,3,3,1,3,1,3,3,3,3,3,1,
    1,3,1,1,1,1,1,3,1,1,1,1,1,3,1,
    1,3,3,3,3,3,3,3,3,3,3,3,3,3,1,
    1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
}

.. and I updated the background PNG to match, with a wall, a blank space, and a space with a dot. It seems to make more sense to have the dots as part of the background than as loads of sprites – but then I may also need to create a “can walk here / can’t walk here” table for the map too, so maybe not.

Also added a timer, although I might need to change this to a frametimer?

-- init a timer for speed control
t = playdate.timer.new(1000) -- init a timer
t.repeats = true -- just in case..?
local ghostSpeed = 40 -- as a test

function playdate.update()
       
    if t.currentTime > ghostSpeed then
        moveGhosty()
        -- accelerate speed a bit
        if ghostSpeed > 0 then
            ghostSpeed = (ghostSpeed - 0.25)
        end
        t:reset()
    end    
    
    -- update sprite
    gfx.sprite.update()
    playdate.timer.updateTimers()
end 

The result: a ghosty in a proper, if simple, maze:


Posted

in

,

by