Log In  

Hi all!

I am building a small pong clone for fun and I have an issue when I press the button to enable pause.

Basically the pause is enabling / disabling itself really fast.

This happens if I use btn() and also if I use btnp()...

The source code is available here:

Can you please help?

Thanks and happy hacking :)

P#38549 2017-03-22 10:00 ( Edited 2017-03-24 14:48)

I ran into this problem. I solved it by having a boolean is_pressed. If it's false, pause and set to true. The if statement for paused checks the state of the boolean before doing anything. Then at the end of the update loop, you can reset the boolean again.

P#38550 2017-03-22 10:03 ( Edited 2017-03-22 14:03)
:: ltpitt


How do you pause?

Is the pause affecting the game?

P#38555 2017-03-22 11:14 ( Edited 2017-03-22 15:14)

I don't use it for pause, as there's no functionality for pausing in my game but I did have the problem of pressing a key to get from one "scene" to another after which you could do an "action". But pressing the button to change "scene" would also make the "action" happen immediately because it was still reading the key press. Having a boolean that switched after the first "action" prevented the second "action" happening too quickly.

P#38560 2017-03-22 12:01 ( Edited 2017-03-22 16:01)
:: ltpitt

Mh I am not fully sure I understood...

Can you please jot some pseudo code as example?

P#38562 2017-03-22 12:40 ( Edited 2017-03-22 16:40)

There's really not much to explain but here it is in pseudo-code...

if button pressed and not is_pressed then
do something

at the start of the next update loop, set is_pressed back to false.

That's literally all it is.

The other way I considered is having a timer that activates so that button pressed are only re-registered after a few 100 milliseconds or something have passed. That would probably work too.

The basic aim is to just have two conditions be met rather than just btn().

P#38563 2017-03-22 12:46 ( Edited 2017-03-22 16:49)
:: ltpitt

Thanks for your input and kind explanation :)

I am going to implement now!

P#38566 2017-03-22 13:11 ( Edited 2017-03-22 17:11)
:: ltpitt

Nope, the behaviour stays the same :(

I'll look into timers, maybe

P#38567 2017-03-22 13:14 ( Edited 2017-03-22 17:14)

Well it probably won't be exact for your implementation. You just need to think about when you want to reset the boolean. The basic idea remains the same - two conditions need to be met rather than one.

P#38568 2017-03-22 13:16 ( Edited 2017-03-22 17:18)

I might have some time this weekend since I've mostly finished my to-do list for my little game - I'm doing Pong (well, a spin on Arkanoid really) like you :) If so, I'll throw together some code and post. I'm only on 6771 tokens so I want to add more stuff, but if I can't think of anything, I'll do some code for you. No promises though :D

I'm only on my first Pico-8 game too and I had to learn Lua at the same time so there might be a better way, mind.

P#38588 2017-03-22 19:48 ( Edited 2017-03-22 23:50)
:: ltpitt


Fantastic :D

I can't wait to see you pong....
I am terrible at LUA so I share your pain :)

Is your game available somewhere?

Did you try my version?

I just need to put a better solution for the AI and version 1.0 is complete :D

Thanks for your time and help.

P#38612 2017-03-23 10:00 ( Edited 2017-03-23 14:00)
:: sax3

Quick question (sorry to hijack your thread), but how do you post a thread without a cart?

I see the submit button, but it only allow cart submissions. I'm confused.

P#38617 2017-03-23 11:20 ( Edited 2017-03-23 15:20)

I'm avoiding other Pong games in case I get any doubts about my own version :D
My game isn't finished yet so it's not available anywhere yet - I'm not into this new-fangled "release versions as you go" mentality. I'll post it when I can't think of anything else to add!

P#38618 2017-03-23 11:21 ( Edited 2017-03-23 15:21)

@sax - I had that problem too to the point where I emailed the PICO-8 author asking how to do it. It's not obvious :)

  1. Click on "BBS" on the top bar.
  2. Then you've got "Voxatron", "PICO-8" and "user blogs" boxes at the top. Click on "PICO-8"
  3. Now there's labels at the top for tags to parts of the BBS. Click on "Discussions".
  4. Now you'll see a link on the top left of the BBS called "start new thread".

Not very user-friendly!

P#38619 2017-03-23 11:25 ( Edited 2017-03-23 15:25)
:: sax3

wow thanks :D

this looks like entering a cheat code to reach an hidden level o_o'

P#38679 2017-03-24 10:48 ( Edited 2017-03-24 14:48)

[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2020-06-06 12:04 | 0.034s | 4194k | Q:41