Giter VIP home page Giter VIP logo

Comments (19)

paked avatar paked commented on May 11, 2024

AFAIK there is no "Clicking Idiom" in ECS. @matiwinnetou correct me if I am wrong.

Clicking is something we desperately need though, I am a big fan of the propagation model from javascript/html though.

Would you mind if I took this PR?

from engo.

EtienneBruines avatar EtienneBruines commented on May 11, 2024

Be my guest. 👍

from engo.

paked avatar paked commented on May 11, 2024

@EtienneBruines what are your thoughts on implementing this handler at the World level?

from engo.

EtienneBruines avatar EtienneBruines commented on May 11, 2024

A ClickSystem, together with ClickComponents.

If an Entity has a ClickComponent, the ClickSystem will use the SpaceComponent and Mouse values to see if it's being clicked, and if so, either set some value at ClickComponent to CLICKED, or perhaps dispatch some Message?

Misread your message. At the World level... hmm. They'd have to register some kind of OnClick event, but who should do that? Systems could do that, I guess.

Or just dispatch a Message, and then everyone can Listen for those messages if he/she pleases?

from engo.

paked avatar paked commented on May 11, 2024

@EtienneBruines I think implementing this as a System is a good idea. Although, if we do this we may as well remodel the way key input works as well.

I believe going with the messaging model for this would serve us best.

from engo.

EtienneBruines avatar EtienneBruines commented on May 11, 2024

Well, with keys the state is kinda important: just clicked, holded, released, etc. And combinations of keys.

A click is simply a click.

from engo.

paked avatar paked commented on May 11, 2024

@EtienneBruines state can actually be important for clicks too.

Imagine a button: You want to act when the button has been released!

Imagine a shooting game: You want to act when the button is first pressed, and perhaps when it is continuously held down.

Either way however, this is irrelevant (for both clicks and key presses). Data can be transferred within a message which could be used to contain the state.

For example

engi.Mailbox.Listen("ScoreMessage", func(message engi.Message) {
    scoreMessage, isScore := message.(ScoreMessage)
    if !isScore {
        return
    }

    sc.scoreLock.Lock()
    if scoreMessage.Player != 1 {
        sc.PlayerOneScore += 1
    } else {
        sc.PlayerTwoScore += 1
    }

    log.Println("The score is now", sc.PlayerOneScore, "vs", sc.PlayerTwoScore)

    sc.upToDate = false
    sc.scoreLock.Unlock()
})

from engo.

EtienneBruines avatar EtienneBruines commented on May 11, 2024

Good point. Messages are kinda cheap anyway, so we could do that, yes.

from engo.

paked avatar paked commented on May 11, 2024

Thoughts @matiwinnetou?

from engo.

EtienneBruines avatar EtienneBruines commented on May 11, 2024

(We should also note that this should indeed also cover things like hover)

from engo.

EtienneBruines avatar EtienneBruines commented on May 11, 2024

Have you already started working on this, or can I create something with a ClickSystem and ClickComponent, which has some states (i.e. Clicked, Hovered, Focused, etc.)?

(I'm making a little game, and am in need of this; don't want to rush you, but also don't want to wait if you don't have time for it anyway; again: I do not mean this in a negative way, whatsoever. 😄 )

from engo.

paked avatar paked commented on May 11, 2024

@EtienneBruines feel free to take this.

from engo.

EtienneBruines avatar EtienneBruines commented on May 11, 2024

Tricky; currently at "how to handle zooming", and "how to handle scrolling to the sides".

The very basics work.

from engo.

paked avatar paked commented on May 11, 2024

👍

On Fri, Nov 27, 2015 at 8:20 AM Etienne Bruines [email protected]
wrote:

Tricky; currently at "how to handle zooming", and "how to handle scrolling
to the sides".

The very basics work.


Reply to this email directly or view it on GitHub
#59 (comment).

from engo.

EtienneBruines avatar EtienneBruines commented on May 11, 2024

Current status:

TODO

  • Rightclick.

from engo.

faide avatar faide commented on May 11, 2024

Etienne, Paked,

I am using the current head from paked/engi and I am using the MouseSystem and MouseComponent to handle clicks on a HUD entity of mine.

At the moment I note that the mouse component does not give me access to the "Mouse Released" event. If I try to use the mc.Clicked against my entity I receive a lot of events (I assume this is normal because my poor fingers are not quick enough to compete against 120fps...) and I'd like to receive only one because each click will launch actions and cost resources. I can (and did) implement some kind of filter based on timing but I find it brittle and error prone.

I would like to make the "mouse released inside your entity" available through the MouseComponent as mc.Released. I don't see the big picture yet so it is possible this event does not make a lot of sense and a better solution already exists... please just let me know if this is the case.

What do you think of it? If you are interested I'll propose a PR.

BTW I added to this issue instead of opening a new one because of the "click system" focus of my question

from engo.

paked avatar paked commented on May 11, 2024

@faide If you want to take a crack at this, I'd be happy to review the pull request!

from engo.

faide avatar faide commented on May 11, 2024

@paked I did first run here: #146

from engo.

paked avatar paked commented on May 11, 2024

Correct me if I'm wrong, but #146 fixed this.

from engo.

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.