This is one that only PocketCHIP people will be able to test and use.
By chance, I discovered that the mouse click (touchscreen) detection in Pico-8 looks at the entire screen on the PocketCHIP, not just the 128x128 viewport of the game.
So while the player will always only see the 128x128 box in the middle of the screen, you can detect when the person touches the screen to the left or right of that 128px box. So by all rights, you can make a Pico-8 game that uses touchscreen controls without requiring the player to touch the game screen area.
The width of the PocketCHIP screen is 480px total, so after some quick napkin math, I figured that there's about 176 pixels on each side. I made 2 collision boxes on either side of the game viewport (so -176 and 128, with a width of 176 and height of 127)
Then just a normal collision script combined with the handy mouse click detection function and boom, you have touch controls for your game.
The cart above just moves the little guy left/right and that's it - just proof of concept. Again, you'll have to try it on your PocketCHIP. This doesn't seem to work with the Pico8 client (at least on Windows)...even if you make your window super wide, it won't register the click.
Here's a YouTube video of it in action (couldn't figure out embedding):
https://www.youtube.com/watch?v=ogQWORouAHc
And now that I think about it, I think I might add this little feature to my Invader Overload cart. If you're using the auto-fire option, all you do is move left/right, so with this touch thing, you could play the game without ever having to press a key on the PocketCHIP keyboard.
This is pretty neat ! If you're going to use this mainstream, may I suggest that you also look for mouse clicks on the edge (0-7) and (120-127) so us Window users and such can also use your interesting paging technique no matter the hardware.
I couldn't get Windows to detect the mouse click even if my window was super wide with the viewport in the middle. I could only get this working on the touchscreen.
Also just realized that I mentioned using a collision and that's what in that demo cart, but all you really need to do is detect if the mouse click X value is <0 or >127 -- collision is pretty much overkill (but it's where my brain went first)
And I updated the cart to reflect the lesser code need.
Maybe also worth noting that I didn't write anything to handle a "single" click like btnp() does. You could easily add this feature by adding some sort of timer or variable, I'm sure. Right now it just behaves like btn()
Well now isn't there code to have the mouse in PICO, and it works Online too ? My suggestion was just to look for mouse clicks on the active screen of PICO:
LEFT PAGE
(0,0 - 7,127)
RIGHT PAGE
(120,0 - 127,127)
If this is still confusing, I can write the code if you like.
Hmm...if you care to extend it, that'd be great. But I am using mouse code...
I'm just using a function to get the X/Y of the mouse click, and then checking the X value. If there's extra magic needed to detect beyond that for non-PocketCHIP, it's not something I know how to investigate at this point.
(Plus I can't quite think of a case where you'd want to click outside the game viewport when playing on a desktop Windows/Mac. Although, I guess if you have a touchscreen monitor, maybe.)
Nono. It's not outside, it's on the edge. Here lemme doodle something for ya.
This is the 128x128 PICO screen. The blue squares represent the 16 tiles across and down.
The RED tiles represent the mouse click area where you can do pages and stuff.
So if you click the LEFT RED area, it would go back a page.
If you click the RIGHT RED area, it would go forward a page.
Since each area is horizontally a perfect tile (8-pixels across), you could make a nice LEFT or RIGHT facing arrow from your image tile editor and put it on the edges of the screen to show they can be clicked.
See ?
Okay, I see what you're saying...but I guess I'm not too concerned with what's inside the viewport.
My whole point was that Pico-8 can detect clicks outside the viewport on a touchscreen, which is not something I expected to work. I'm not trying to suggest how to use this within a game or program, just that it can be done.
By all rights, you could just check the mouse X value to see if it's less than 64 or greater than 64 to see if they clicked on the left or right side of the viewport - that would work regardless of platform or screen type.
True. I just - well, I like your games, and I was hoping you weren't all of a sudden going to write ones that work solely on the PocketCHIP.
Is why I mentioned the above.
Oh...no, no worries there, my friend. I just thought it was a cool discovery :)
Although I do plan on adding this type of support to games when it makes sense - like Invader Overload, which I just updated. Works pretty well and feels much better than using the keyboard.
But while these type of controls feel great, it will be hard to communicate to the player that such controls even exist. It's more like a "if you read the manual" type feature or just find out by accident...so it's far from something we should use as a sole method of input.
I remember years ago I was working on Dragonhunt. An interested client came to me and promised to fund the whole thing so it would be on the shelf in an Amiga store, but he wanted one thing that was the deal breaker.
He wanted to make this special joystick that only my game could use. He said then if anyone copies my game, without the joystick it wouldn't work.
I thought it was a pretty neat idea until I talked to Chris - and he said, don't do it. People will hate you for requiring dedicated hardware.
And when you mentioned you discovered a method for dedicated hardware, I thought all over again of dropping out the rest of the gaming community to this joystick.
I never did release the game, but I did make his joystick, virtually, on the right-hand side of the screen, where you could click buttons with the mouse.
Might not be such a bad idea to make virtual graphic click buttons today for the PICO to access with mouse with its limited arrows and (A) and (B) keyboard/joystick input.
I can't get this to work on my PocketCHIP, am I doing something wrong?
Oh wow this is very exciting! It's gonna be great to be able to use that excess screen space for something
@Ramayaben - The cart did have a bug in it...I forgot to init the mouse class. I just updated to v1.2 that includes it. I had already run the init from another cart, which apparently applies to all other carts so I didn't noticed it was missing. Sorry. Give it a try now.
Don't worry, I'll beta test again and let you know ;)
EDIT: Now works like a charm! Congrats here, this would be great for PocketCHIP users.
[Please log in to post a comment]