mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
Rename input -> Input
This commit is contained in:
parent
8994bf4fad
commit
a9e323d02c
@ -39,22 +39,22 @@ const (
|
|||||||
MouseButtonMax
|
MouseButtonMax
|
||||||
)
|
)
|
||||||
|
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +66,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
|
||||||
}
|
}
|
||||||
|
@ -21,10 +21,10 @@ import (
|
|||||||
"runtime"
|
"runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
var currentUI *UI
|
var current *UI
|
||||||
|
|
||||||
func Current() *UI {
|
func Current() *UI {
|
||||||
return currentUI
|
return current
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -57,7 +57,7 @@ func init() {
|
|||||||
f()
|
f()
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
currentUI = u
|
current = u
|
||||||
}
|
}
|
||||||
|
|
||||||
type UI struct {
|
type UI struct {
|
||||||
@ -65,7 +65,7 @@ type UI struct {
|
|||||||
scale int
|
scale int
|
||||||
actualScale int
|
actualScale int
|
||||||
glContext *opengl.Context
|
glContext *opengl.Context
|
||||||
input input
|
input Input
|
||||||
funcs chan func()
|
funcs chan func()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ func New(width, height, scale int, title string) (*UI, error) {
|
|||||||
y := (videoMode.Height - height*scale) / 3
|
y := (videoMode.Height - height*scale) / 3
|
||||||
|
|
||||||
ch := make(chan struct{})
|
ch := make(chan struct{})
|
||||||
ui := currentUI
|
ui := current
|
||||||
window := ui.window
|
window := ui.window
|
||||||
window.SetFramebufferSizeCallback(func(w *glfw.Window, width, height int) {
|
window.SetFramebufferSizeCallback(func(w *glfw.Window, width, height int) {
|
||||||
close(ch)
|
close(ch)
|
||||||
@ -135,7 +135,7 @@ func (u *UI) SwapBuffers() {
|
|||||||
u.window.SwapBuffers()
|
u.window.SwapBuffers()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UI) Input() *input {
|
func (u *UI) Input() *Input {
|
||||||
return &u.input
|
return &u.input
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user