Log In  

Hello, i started making my first game on pico8 (a simple topdown thingy) and i'm already stuck.

I want to draw my wide sprite, but the command line stays black, without outputting errors ?

I wonder what's wrong :/

thanks for the help!

P#69168 2019-10-22 14:30 ( Edited 2019-10-24 16:56)

Post the code or upload the cart. (Edit your original post and put it in there.)

Some guesses:

  • Possibly you have a cls() statement after your spr() or sspr() statement.
  • Possibly you've written a spr() or sspr() command in a loop you have created, and not either put it in the _draw() function, nor alternatively used flip() to send it from the buffer to the screen.
  • Possibly you have omitted the underscore from before the _draw() function.
  • Possibly you have used sspr() but got the sprite sheet coordinates wrong.

But really it could be a number of other things - without seeing the code it's hard to say.


Here is more detail regarding some of my guesses above; hopefully these details are more useful to a beginner:

Here is a link to the manual online.

Perhaps the first thing to grasp with pico-8 is that it has a game loop, consisting of the functions _update() and _draw(). (See Program Structure in the manual.) This constitutes a frame, and normally happens 30 times a second (or thereabouts).

In the game loop _update() runs before _draw().

Nothing is actually drawn until the end of the _draw() function. Instead a buffer is used. This allows a smooth "instant" update of the entire screen, rather than it having bits of it being drawn at noticeably different moments.

This means that if a cls() happens in either _update() or _draw() in an iteration of the game loop, then anything before that moment won't be displayed when the program does the actual draw at the end of the frame (at the end of the _draw() function).


An alternative to using the game loop is to set up your own (infinite) loop and use the flip() command to flip the screen buffer to the screen memory.

And if neither the _update() or _draw() function is used, and no flip() command is given, then when the progam exits (according to the wiki) the screen will be updated (presuming it exits in its natural course of execution, I guess).

See also:

wiki - flip
wiki - game loop

P#69170 2019-10-22 15:31 ( Edited 2019-10-23 07:19)
2

The immediately obvious thing is that you're missing the underscore from in front of _draw().

P#69197 2019-10-23 13:13

ppppffffff i must have been very tired then ~
thank you!

P#69229 2019-10-24 15:39

Hello! i didn't knew what was the best thing to do, so i just updated this.

I manage to fix my problem, but i now foresee i'm going to run into huge problems with my (non existant) animation system; is there one that's a standard or is brain hurty a normal animations thing ?

thank!

P#69231 2019-10-24 16:55
1

No, there isn't really a standard. Basic animation isn't too hard, though; you just need a number that cycles over a range, updating once per frame. Here's a pretty minimal example:

anim={
    frame_time=8,
    frames={ 1, 3, 1, 5 } -- tile numbers
}

frame=1
counter=1

function _update()
    counter+=1
    if counter>anim.frame_time then
        counter=1
        frame+=1
        if frame>#anim.frames then
            frame=1
        end
    end
end

function _draw()
    cls()
    spr(anim.frames[frame], 72, 72, 2, 2)
end

You'd need a table of different animations and to track frame data per actor, of course, but something along those lines will get you pretty far.

Background animation isn't too much harder. You need to modify the map rather than draw a sprite, so you need to keep track of which tiles need updated, but that's just another simple table.

P#69257 2019-10-25 14:55

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-29 06:18:04 | 0.008s | Q:16