paddy - touchscreen controls

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
unixfreak
Citizen
Posts: 82
Joined: Thu Oct 15, 2015 6:25 am
Location: Bristol, UK
Contact:

paddy - touchscreen controls

Post by unixfreak »

A small library i created recently to test some basic games on android devices
I will be adding more features to this in the future, but thought this could help someone as it is:
https://github.com/Jigoku/paddy

Basically, it draws a dpad to the screen which you can use to process input on a touchscreen.

At the moment it is just a dpad (it currently lacks a,b,x,y like most standard gamepads have).

Basically you use paddy.dpad.isDown("left") instead of love.keyboard.isDown("left") in your love.update() function.
There's an example file here (dpad only works on touch enabled device).
paddy_example-0.1.love
(16.49 KiB) Downloaded 532 times
BörnedByLOVE
Prole
Posts: 9
Joined: Wed Aug 16, 2017 9:56 pm

Re: paddy - touchscreen controls

Post by BörnedByLOVE »

Just put your example file on my mobile, and it looks and feels great!

Also like the keyboard analogy in the paddy.dpad.isDown-stuff.
All in one very readable and not too complex lua file. (I'm just starting with LÖVE.) Nice!

Looking forward to your next steps with paddy.
Darlex
Party member
Posts: 128
Joined: Sun Sep 24, 2017 10:02 am
Location: Chile
Contact:

Re: paddy - touchscreen controls

Post by Darlex »

Amazing! Feels great, Works great and Looks great. Thanks to help me to my game developing!
Hi! I wish you have an amazing day!
User avatar
D0NM
Party member
Posts: 250
Joined: Mon Feb 08, 2016 10:35 am
Location: Zabuyaki
Contact:

Re: paddy - touchscreen controls

Post by D0NM »

For those who want to add missing A and B keys,
just alter 1 line of code:

Code: Select all

paddy.dpad.canvas = love.graphics.newCanvas(paddy.dpad.w  + 400 ,paddy.dpad.h)
It makes the d-pad canvas wider. You need it to see your new A&B buttons.

And add 2 items into paddy.dpad.buttons table:

Code: Select all

{ name="a", x=paddy.buttonw*3, y=paddy.buttonh },
{ name="b", x=paddy.buttonw*4, y=paddy.buttonh },
If you want to see the buttons aliases on the screen, then add this line

Code: Select all

love.graphics.print(button.name, button.x+paddy.dpad.padding,  button.y+paddy.dpad.padding )	
before END of the 1st for loop.

-----
This is a nice and tidy lib. But there is another approach - to add touch controls to a popular input lib
as tactile.lua or so on/
Our LÖVE Gamedev blog Zabuyaki (an open source retro beat 'em up game). Twitter: @Zabuyaki.
:joker: LÖVE & Lua Video Lessons in Russian / Видео уроки по LÖVE и Lua :joker:
User avatar
unixfreak
Citizen
Posts: 82
Joined: Thu Oct 15, 2015 6:25 am
Location: Bristol, UK
Contact:

Re: paddy - touchscreen controls

Post by unixfreak »

Hey, thanks for suggesting that D0NM. I recently changed things a bit, not the best code. But it now supports two kinds of "widgets". One for the dpad, and one for a playstation/snes style button pad.

I also decided to change the paddy.dpad.isDown("left") to simply paddy.isDown("left"), so that this is shared for all buttons, eg;
paddy.isDown("a"). I might change it back yet when i can rewrite some parts of it.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 46 guests