Log In  

According to the manual

> Additionally, when X, Y are not specified, printing text below 122 causes the console to scroll. This can be disabled during runtime with POKE(0x5f36,0x40).

However I've got a cart that has a performance issue as soon as the print leaves the screen.

Cart #gejegufku-0 | 2022-07-07 | Code ▽ | Embed ▽ | No License
2

Adding in

poke(0x5f36,0x40) to the cart fixes the issue so the performance issue is to do with screen scrolling.

To see in the above cart press X to start the game and wait for the ship to leave the bottom of the screen

P#114042 2022-07-07 22:42 ( Edited 2022-07-07 22:44)

Also a BBS bug. When in preview > showed the line as a block quote but when viewing the post it just shows as >

P#114043 2022-07-07 22:43
1

The screen scrolling / performance issue is coming from:

function _update60()
    print(state)
    print(state.update)

print() always modifies the cursor position, so once your enemy's y-position is >= 122, so is the cursor. This is why setting poke(0x5f36,0x40) fixes the issue, since no x/y args are passed to those calls (which causes the cursor to scroll).

You never see it while the program is running is because it happens in-between the last time the framebuffer was flipped to the screen (automatically by Pico-8 at the end of _draw()) and when you cleared the framebuffer by calling cls(). If you stop the program by pressing ESC to enter the console, you can catch it in the act:

If you need debug info from your update funcs, try launching Pico-8 from a terminal and using printh to print to the host console instead.

Hope that helps! :)

P#114175 2022-07-10 22:00 ( Edited 2022-07-10 22:23)

Another way to debug is to have a dedicated debug function. You assign it the value you want to read/debug in the update function and then on the draw function you tell pico-8 to print it. It is simple and easy to use.

P#114177 2022-07-10 22:16
1

I'll second @ridgekuhn suggestion of the printh() for debugging...it helps a ton to the point where I now rely on it. Printing on the game screen is helpful for loop-type things but the terminal debug is far more valuable and you can put printh() all over the place without worry - just remove them when you're all done :)

I recently realized I can launch PICO-8 from the terminal in VSCode and have it in a sidebar. Files/functions on the left, code in the middle, terminal for debugging on the right. It's made a huge difference for the sanity of my coding.

But even if you're not using an external IDE and use your regular OS terminal, it'll keep things better organized. That's how I did it for a long time until I started in the IDE terminal.

P#114182 2022-07-11 00:28 ( Edited 2022-07-11 00:28)

I do normally use printh. Very good spot though @ridgekuhn

P#114198 2022-07-11 14:33

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-28 17:34:55 | 0.067s | Q:25