Code Monkey home page Code Monkey logo

Comments (12)

nesbox avatar nesbox commented on August 28, 2024 1

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

from tic-80.

nesbox avatar nesbox commented on August 28, 2024

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

from tic-80.

mnml avatar mnml commented on August 28, 2024

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?

from tic-80.

nesbox avatar nesbox commented on August 28, 2024

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 |
+----------------+------+

from tic-80.

mnml avatar mnml commented on August 28, 2024

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

from tic-80.

nesbox avatar nesbox commented on August 28, 2024

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

from tic-80.

HomineLudens avatar HomineLudens commented on August 28, 2024

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

from tic-80.

nesbox avatar nesbox commented on August 28, 2024

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

from tic-80.

HomineLudens avatar HomineLudens commented on August 28, 2024

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

from tic-80.

mnml avatar mnml commented on August 28, 2024

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

from tic-80.

HomineLudens avatar HomineLudens commented on August 28, 2024

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

from tic-80.

nesbox avatar nesbox commented on August 28, 2024

done in .18

from tic-80.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.