Comments (4)
Hi @everyfan, assisted mouse support was introduced in release 1.21, exposing the underlying SDL2 events to tilengine with the SDL_SetSDLCallback function. This API function is briefly documented but easy to use, and there's a fully working example in the main repository: https://github.com/megamarc/Tilengine/blob/master/samples/TestMouse.c.
You'll need the SDL2 development headers because the example interfaces directly with the SDL2 library.
from tilengine.
Hi Marc.
I have a problem with this, it has to do with the window factor.
In TestMouse.c
#define WIDTH 400 // I only take the width to simplify
Next, Window.c
Line 180 in dd88613
wnd_width = 400 * 3; then wnd_width equal to 1200
The SDL_Mouse coordinates correspond to the window(w=1200), not the sprite(x= 180 y=166)
The solution is simple, get the factor and then divide that factor to the mouse coordinate:
If Window.c
factor = 3
Then TestMouse.c
if (entity->enabled &&
mouse->x / factor >= entity->x && mouse->y / factor >= entity->y &&
Is it possible to change the API, to return the factor, or better, to transform a coordinate according to the factor?
from tilengine.
from tilengine.
@daltomi: of course that's a bug! Thanks for pointing it. I'll fix it. Mouse input should return the coordinates in framebuffer space, not in window space. Window scaling factor shouldn't affect the returned value.
@everyfan: the SDL2 bridge to handle events is implemented into the main library, but not into the python binding.
from tilengine.
Related Issues (20)
- Tiled integration HOT 2
- real game source code HOT 1
- Getter for Layers, Tilemaps, Sprites, Tiles, ..., user data for callbacks, palette tile attribute, multiple tilesets per tilemap, and bug with TLN_SetTilemapTile()
- Pausing Specific Animations HOT 3
- Issues with custom overlay HOT 5
- Steps to reproduce the crash on exit in TLN_DeleteTileset
- Map layer with multiple .tsx files causes memory issues HOT 1
- TLN_GetTilemapTileset2 returns None/NULL HOT 5
- Sprite rotation capabilities HOT 1
- Memory corruption in "shooter" example HOT 3
- Crash when resuming animation HOT 1
- Unable to build on MacOS HOT 1
- non-initialized blinking borders when switching to fullscreen HOT 2
- V bindings HOT 1
- Tileset ordering in tmx file causing exception HOT 1
- Get tile returns incorrect tiles info type HOT 1
- Unable to build Tilengine HOT 1
- Actor.c from Samples dir, doesn't work HOT 1
- Access violation error with more than 6 tilesets HOT 3
- How to build it? HOT 1
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 tilengine.