mirror of
https://github.com/yeslayla/golang-game-framework.git
synced 2025-07-07 11:13:47 +02:00
Initial commit
This commit is contained in:
18
rendering/camera2d.go
Normal file
18
rendering/camera2d.go
Normal file
@ -0,0 +1,18 @@
|
||||
package rendering
|
||||
|
||||
import "github.com/manleydev/golang-game-framework/core"
|
||||
|
||||
type Camera2D interface {
|
||||
GetZoom() float64
|
||||
SetZoom(float64)
|
||||
|
||||
GetOffset() core.Vector2
|
||||
SetOffset(core.Vector2)
|
||||
|
||||
GetModifiers() Camera2DModifiers
|
||||
}
|
||||
|
||||
type Camera2DModifiers struct {
|
||||
Zoom float64
|
||||
Offset core.Vector2
|
||||
}
|
21
rendering/render2d.go
Normal file
21
rendering/render2d.go
Normal file
@ -0,0 +1,21 @@
|
||||
package rendering
|
||||
|
||||
import (
|
||||
"github.com/manleydev/golang-game-framework/core"
|
||||
)
|
||||
|
||||
type Renderer2D interface {
|
||||
DrawTexture2D(DrawTexture2DInput) error
|
||||
|
||||
Draw() error
|
||||
Update() error
|
||||
Destroy()
|
||||
SetCamera(*Camera2D) error
|
||||
}
|
||||
|
||||
type DrawTexture2DInput struct {
|
||||
Texture Texture2D
|
||||
Rect core.Rect2D
|
||||
Position core.Vector2
|
||||
Rotation float64
|
||||
}
|
37
rendering/standard_camera2d.go
Normal file
37
rendering/standard_camera2d.go
Normal file
@ -0,0 +1,37 @@
|
||||
package rendering
|
||||
|
||||
import "github.com/manleydev/golang-game-framework/core"
|
||||
|
||||
type StandardCamera2D struct {
|
||||
zoom float64
|
||||
offset core.Vector2
|
||||
}
|
||||
|
||||
func (camera *StandardCamera2D) GetZoom() float64 {
|
||||
return camera.zoom
|
||||
}
|
||||
func (camera *StandardCamera2D) SetZoom(zoom float64) {
|
||||
camera.zoom = zoom
|
||||
}
|
||||
|
||||
func (camera *StandardCamera2D) GetOffset() core.Vector2 {
|
||||
return camera.offset
|
||||
}
|
||||
func (camera *StandardCamera2D) SetOffset(offset core.Vector2) {
|
||||
camera.offset = offset
|
||||
}
|
||||
|
||||
func (camera *StandardCamera2D) GetModifiers() Camera2DModifiers {
|
||||
return Camera2DModifiers{
|
||||
Zoom: camera.zoom,
|
||||
Offset: camera.offset,
|
||||
}
|
||||
}
|
||||
|
||||
func NewStandardCamera() *Camera2D {
|
||||
var camera Camera2D = &StandardCamera2D{
|
||||
zoom: 1,
|
||||
offset: core.Vector2{},
|
||||
}
|
||||
return &camera
|
||||
}
|
9
rendering/texture2d.go
Normal file
9
rendering/texture2d.go
Normal file
@ -0,0 +1,9 @@
|
||||
package rendering
|
||||
|
||||
import "github.com/manleydev/golang-game-framework/core"
|
||||
|
||||
type Texture2D interface {
|
||||
Destroy()
|
||||
GetCenter() core.Vector2
|
||||
GetRect() core.Rect2D
|
||||
}
|
Reference in New Issue
Block a user