mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-13 20:42:07 +01:00
Hide Input
This commit is contained in:
parent
8319e0d41d
commit
87bdd1a994
@ -27,7 +27,7 @@ type canvas struct {
|
|||||||
window *glfw.Window
|
window *glfw.Window
|
||||||
scale int
|
scale int
|
||||||
graphicsContext *graphicsContext
|
graphicsContext *graphicsContext
|
||||||
input Input
|
input input
|
||||||
funcs chan func()
|
funcs chan func()
|
||||||
funcsDone chan struct{}
|
funcsDone chan struct{}
|
||||||
}
|
}
|
||||||
|
10
input.go
10
input.go
@ -21,22 +21,22 @@ import (
|
|||||||
"math"
|
"math"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Input struct {
|
type input struct {
|
||||||
keyPressed [KeyMax]bool
|
keyPressed [KeyMax]bool
|
||||||
mouseButtonPressed [MouseButtonMax]bool
|
mouseButtonPressed [MouseButtonMax]bool
|
||||||
cursorX int
|
cursorX int
|
||||||
cursorY int
|
cursorY int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *Input) IsKeyPressed(key Key) bool {
|
func (i *input) IsKeyPressed(key Key) bool {
|
||||||
return i.keyPressed[key]
|
return i.keyPressed[key]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *Input) IsMouseButtonPressed(button MouseButton) bool {
|
func (i *input) IsMouseButtonPressed(button MouseButton) bool {
|
||||||
return i.mouseButtonPressed[button]
|
return i.mouseButtonPressed[button]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *Input) CursorPosition() (x, y int) {
|
func (i *input) CursorPosition() (x, y int) {
|
||||||
return i.cursorX, i.cursorY
|
return i.cursorX, i.cursorY
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ var glfwKeyCodeToKey = map[glfw.Key]Key{
|
|||||||
glfw.KeyDown: KeyDown,
|
glfw.KeyDown: KeyDown,
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *Input) Update(window *glfw.Window, scale int) {
|
func (i *input) Update(window *glfw.Window, scale int) {
|
||||||
for g, u := range glfwKeyCodeToKey {
|
for g, u := range glfwKeyCodeToKey {
|
||||||
i.keyPressed[u] = window.GetKey(g) == glfw.Press
|
i.keyPressed[u] = window.GetKey(g) == glfw.Press
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user