Log In  

Cart [#29313#] | Code | 2016-09-24 | License: CC4-BY-NC-SA | Embed

Cart [#29204#] | Code | 2016-09-24 | License: CC4-BY-NC-SA | Embed
Cart [#29213#] | Code | 2016-09-24 | License: CC4-BY-NC-SA | Embed

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):

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.

P#29205 2016-09-23 22:09 ( Edited 2016-09-24 21:50)

:: dw817

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.

P#29208 2016-09-23 22:40 ( Edited 2016-09-24 02:40)

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.

P#29210 2016-09-23 22:43 ( Edited 2016-09-24 02:49)

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()

P#29214 2016-09-23 22:51 ( Edited 2016-09-24 02:51)
:: dw817

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:

(0,0 - 7,127)

(120,0 - 127,127)

If this is still confusing, I can write the code if you like.

P#29215 2016-09-23 22:52 ( Edited 2016-09-24 02:52)

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.)

P#29222 2016-09-23 23:12 ( Edited 2016-09-24 03:12)
:: dw817

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 ?

P#29223 2016-09-23 23:25 ( Edited 2016-09-24 03:25)

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.

P#29224 2016-09-23 23:42 ( Edited 2016-09-24 03:43)
:: dw817

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.

P#29225 2016-09-23 23:44 ( Edited 2016-09-24 03:44)

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.

P#29226 2016-09-23 23:51 ( Edited 2016-09-24 03:51)
:: dw817

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.

P#29228 2016-09-23 23:58 ( Edited 2016-09-24 03:59)

I can't get this to work on my PocketCHIP, am I doing something wrong?

P#29261 2016-09-24 11:08 ( Edited 2016-09-24 15:08)
:: zoy

Oh wow this is very exciting! It's gonna be great to be able to use that excess screen space for something

P#29270 2016-09-24 11:35 ( Edited 2016-09-24 15:35)

@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.

P#29314 2016-09-24 16:55 ( Edited 2016-09-24 20:55)

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.

P#29327 2016-09-24 17:50 ( Edited 2016-09-24 21:52)

[Please log in to post a comment]

About | Contact | Updates | Terms of Use
Follow Lexaloffle:        
Generated 2019-09-20 18:13 | 0.033s | 4194k | Q:67