Log In  

Cart #34769 | 2017-01-02 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
6

1.0.1: Quick fix for the title screen

main inspiration

The main slowdown factor of the whole thing is this:

for x=0,127 do
        for y=0,127 do
            if brd[x][y] != 0 then
                pset(x,y,brd[x][y])
            end
        end
    end

I have to copy everything from the board to the screen, every frame. Maybe someone could help with a more efficient way to do that?

Sometimes, very rarely, snakes just crash into themselves when nothing happens. Should maybe fix that.

The stupid AI is surprisingly good at beating me. I should probably practice some curve fever.

Feedback is greatly appreciated!

P#34763 2017-01-02 16:40 ( Edited 2017-01-04 13:24)

Hey there!

SojaBird here from the original CF dev team.
Great job on recreating CF in pico!
Today I was just about to do the same as my first practise game in pico.
Keep it up!

As for the slowdown, maybe there is a way you can write data into the (shared) sprite-sheet and draw that instead of setting pixels every time.
Or, mark which pixels were changed so you only have to change a few pixels instead of the whole playfield.

Best regards,
SojaBird, CF3 dev.

P#34877 2017-01-03 17:50 ( Edited 2017-01-03 22:50)

@SojaBird Thanks! I think the shared spritesheet is too small though :(

P#34895 2017-01-04 04:38 ( Edited 2017-01-04 09:38)

@eis Hmm I see. You could maybe not clear the whole screen but only parts that are changed (rectfill and then reapply the pixels.
I'm also facing the same issue now but will continue to look for other solutions.
I'm not sure about the impact of multi-dimentional arrays in Lua, but you could rewrite the brd to be a single-dimention array (at least that's what I have out of habbit).

P#34903 2017-01-04 08:24 ( Edited 2017-01-04 13:24)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-04-16 22:45:19 | 0.019s | Q:21