Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mouse support #36

Closed
mnml opened this issue Feb 3, 2017 · 12 comments
Closed

Mouse support #36

mnml opened this issue Feb 3, 2017 · 12 comments
Assignees
Labels
API Issues related to TIC80 API enhancement Improvement of existing feature or adding something new
Milestone

Comments

@mnml
Copy link

mnml commented Feb 3, 2017

Would it be possible to add an API function for polling mouse coords and buttons? Or maybe a memory location one could use to peek() the mouse data?

@nesbox nesbox self-assigned this Feb 3, 2017
@nesbox nesbox added enhancement Improvement of existing feature or adding something new API Issues related to TIC80 API labels Feb 3, 2017
@nesbox
Copy link
Owner

nesbox commented Feb 3, 2017

It's possible and I want to divide input methods, you can use gamepad input only or mouse/touch input only but not both.
I should think how to do it better.
Thanks

@mnml
Copy link
Author

mnml commented Feb 3, 2017

Well, for what it's worth, here's how PICO-8 does it. TIC has no stat() function, so the same method wouldn't really work... But maybe it'll give a few ideas?

@nesbox
Copy link
Owner

nesbox commented Feb 3, 2017

Here are my thoughts

I'm going to add cart metadata editor where you can define title, author, cover...
And also you will be able to define input method for the game: gamepad or mouse.

So, gamepad state takes 16 bit (8bit+8bit for two players) in memory.
We have 240*136=32640 pixels, it will take 15 bit to address mouse pointer/finger position and 1 bit for button/touch state (pressed/unpressed) to fit the same memory.

+-----------+-----------+
| gamepad 1 | gamepad 2 |
+-----------+-----------+
|   8 bit   |   8 bit   |
+-----------+----+------+
| mouse position |  btn |
+----------------+------+
|     15 bit     | 1bit |
+----------------+------+

@mnml
Copy link
Author

mnml commented Feb 3, 2017

Yeah, that seems fair. I was thinking right-click would be nice, but I don't see how it would fit in 16 bits, and it would make dealing with touchscreens difficult... So I'm happy with the 1-button compromise :)

@nesbox
Copy link
Owner

nesbox commented Feb 3, 2017

ok, will implement this "Cartridge metadata editor #37" before

@nesbox nesbox added this to the 0.18.0 milestone Feb 4, 2017
@HomineLudens
Copy link
Collaborator

So no mouse+keyboard? I am rather fought between your clean approach and the confort of a very common way of control.

@nesbox
Copy link
Owner

nesbox commented Feb 4, 2017

I thinks yes, I want to all the TIC games be playable on mobile devices where you can't use both gamepad+mouse.

@HomineLudens
Copy link
Collaborator

That make sense. I think I can live with it :)

@nesbox
Copy link
Owner

nesbox commented Feb 4, 2017

Added mouse support

mouse

Can't decide add mouse api function or let people calculate mouse XY by themselves like in example?

-- title:  mouse
-- author: nesbox
-- script: lua
-- input:  mouse

function mouse()
	local b=btn()return(b&0x7fff)%240,(b&0x7fff)//240,b>>15
end

function TIC()

	cls(12)

	local x,y,down=mouse()
	
	spr(1+down,x-16,y-16,-1,4)
	print("x="..x.." y="..y.." btn="..down)
end

@mnml
Copy link
Author

mnml commented Feb 5, 2017

API function, I think... That way, it would be consistent with gamepad input, which has btn() and btnp().

@HomineLudens
Copy link
Collaborator

I'm a lazy man... mouse is welcome

@nesbox
Copy link
Owner

nesbox commented Feb 6, 2017

done in .18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Issues related to TIC80 API enhancement Improvement of existing feature or adding something new
Projects
None yet
Development

No branches or pull requests

3 participants