Comments (6)
User input events should just change a value on a component. The
appropriate systems will handle the component in the appropriate order.
On Jun 8, 2013 4:14 PM, "Gaen" [email protected] wrote:
Hi!
The thing that bothers me is that while all the systems operate within
main update loop, user input events such as clicks and key hits are
happening out of it. This means that a click, for example, can happen *
between* the updates. Or even if a user is fast enough, he can manage to
hit and release the mouse multipe times, still between the updates. And if
a user input handling system is checking inside it's update() if the button
is pressed, such clicks will be simply lost.[image: clicks]https://f.cloud.github.com/assets/1899551/628051/28bcd172-d077-11e2-92ee-4027d4448f18.png
It would be great to have some util that collects such events into a queue
and then allows systems to handle them correctly.—
Reply to this email directly or view it on GitHubhttps://github.com//issues/25
.
from ash.
Let's assume we have two asteroids overlapping each other, and click should destroy the asteroid. When user clicks twice in the area which belongs to both of the asteroids between the updates, some out-of-update-loop code will record two clicks into the first asteroid. After the update this asteroid will be destroyed by the first click and the second click will be lost, leaving the second asteroid intact. Or, if clicks are recorded into all asteroids that match the coordinates, both asteroids will be destroyed by the first click, which is wrong too.
But your answer gave me an idea to create some ClickComponent
instance for every click and allow systems to iterate through ClickNode
s, that might work.
from ash.
Here's the system I've implemented: https://gist.github.com/Gaen/5737335
It catches the events out-of-the-loop, converts them into entities and adds them to the engine, which allows other systems to process those events inside the loop and remove used events from the engine. The system itself executes in the loop after all input processing is done and removes all remaining event entities. So all mouse events live from the moment they happen to the mouse handling system update.
I don't think it's good for perfomance to create a new entity with a new component and then get it through the NodeList
and destroy it for every mouse move, but at least it works.
from ash.
Wow dude, this looks so over-engineered. I'm not sure that it's a good idea to try to fit everything in the boundaries of ash style. You could just implement some kind of click manager that operates outside of system update loop, reacts to clicks and sets a "clicked" flag to a relevant asteroid entity component to be processed by the system later. And for your overlapping asteroids case, just get the first one without the "clicked" flag set and toggle it. KISS, you know :)
from ash.
After having a good sleep I've realized all the crazyness of my code (: Yeah, I'm gonna rewrite it into something simple.
But I don't like the idea of putting game-related click processing logic into click manager, because click can select something, or destroy something, or build something depending on context - these are different kinds of logic that should be in a different systems.
I still do like the idea of putting events into some queue, handling this queue by systems and then clearing it for every update. It just shouldn't work through the engine, simple vector is good enough.
from ash.
Since you implemented this outside of the core code and simply include one line in the core code to initialise it, I suggest there's no need to edit the core code at all, you can initialise your mouse tracking independently of the core code and there's no need to add it to the core project.
from ash.
Related Issues (20)
- Should we enable developers to extend Ash to use more sophisticated rules for adding entities to node lists? HOT 14
- System.priority can be Number HOT 2
- Add ability to get all componentes on an Entity HOT 3
- systems communication HOT 2
- Scripting solutions with ASH. HOT 1
- Entity.clone() - possible error if component registered with BaseClass HOT 1
- entity.asNode(); HOT 1
- Robotlegs Ash Extension fails with latest robotlegs HOT 1
- NodeList.forEach
- ComponentMatchingFamily.componentAddedToEntity check added component HOT 1
- Avoid Vector/Array push() method HOT 4
- Please start adding version tags HOT 5
- SignalBase.removeAll()
- EntityStateMachine and EngineStateMachine has almost same code HOT 4
- Test file names does not match the class name been tested.
- EngineStateMachine changing states during Engine update HOT 1
- Removing entity that was removed before causes entity list change. HOT 2
- ASDoc
- Clear Next/Previous when removing Entity from EntityList 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 ash.