Comments (12)
Added mouse support
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.
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.
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.
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.
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.
ok, will implement this "Cartridge metadata editor #37" before
from tic-80.
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.
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.
That make sense. I think I can live with it :)
from tic-80.
API function, I think... That way, it would be consistent with gamepad input, which has btn() and btnp().
from tic-80.
I'm a lazy man... mouse is welcome
from tic-80.
done in .18
from tic-80.
Related Issues (20)
- New release soon / more frequent releases? HOT 4
- The "X button to enter surf" needs a better input check HOT 6
- Better import screen error messages HOT 1
- Tiles in map editor does not update after editing tile HOT 1
- Scaling issue on web export on mobile
- Native Apple Silicon version and Black Borders
- `--fs` accepts files, not just folders; errors follow
- Command line not fully visible when using past commands HOT 2
- [Libretro] iOS support HOT 2
- Using surf, 'close game' should go back to surf and not console HOT 1
- Mouse sprite and ram aren't linked HOT 1
- keyword 'of' in javascript is not colored
- Segmentation fault HOT 6
- Segfault when saving after running HOT 7
- cccccbcrknfjjukihcdgfkchudgregenkrjrldtvjdfl
- tic80 behaves differently when run from source checkout HOT 3
- Keys getting stuck when grabbing the window
- PCM channel not working on exported builds HOT 1
- generic linux build/release (not only .deb) HOT 2
- TIC-80 cannot create new files "error: not found any language" HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tic-80.