Newbrict / engi

Oaktales engi fork
BSD 2-Clause "Simplified" License
0 stars 0 forks source link

key bindings #21

Open Newbrict opened 9 years ago

Newbrict commented 9 years ago

We need to create a middle layer between key_xxx.Down() and the actions bound to that key

for example if I want space to jump we need something that says if space is down then jumping and set that state somewhere.

paked commented 9 years ago

Also, there is a naming redundancy on Keys.KEY_DOWN (notice how key is repeated). This doesn't read well, and should be changed to just DOWN or Down. In fact, it's better go practice to use the latter version.

On Fri, 29 May 2015 2:09 pm Dimitar Dimitrov notifications@github.com wrote:

We need to create a middle layer between key_xxx.Down() and the actions bound to that key

for example if I want space to jump we need something that says if space is down then jumping and set that state somewhere.

— Reply to this email directly or view it on GitHub https://github.com/Newbrict/engi/issues/21.

paked commented 9 years ago

What do you envisage the API for this looking like? I'm think of a call like Keys.Set(Keys.Down, downHandlerFunc).

Newbrict commented 9 years ago

I would rather have a set of global flags set so multiple things can act on them instead of one centralized handler function

paked commented 9 years ago

@Newbrict I don't quite understand, could you provide an example?

Newbrict commented 9 years ago

Not sure if it's the best way.

We have raw inputs -> key bindings -> game inputs

game inputs would be like "jump, move left, move right, prone, open inventory" and we could have a slice/map/array/something which has booleans for whether or not they're active. For example:

inputs[JUMP] = true ... ... if inputs[JUMP] { ... }

inputs would be globally accessible within engi so the raw input handler would change the values according to user input, and wherever we need the game to react we can just read from inputs


If we bind each key to a handler function doesn't that make it too rigid? how would you do things like typing?

paked commented 9 years ago

Ok. I don't think they should be a simple boolean (not enough information can be stored in on or off), maybe keep with the Key struct and alias those.

Newbrict commented 9 years ago

Yeah wrapping it in a struct would be better, easily extensible.

paked commented 9 years ago

whoops wrong thread xD