Skip to content

Commit

Permalink
update the current version with the new sdl 4.5
Browse files Browse the repository at this point in the history
  • Loading branch information
ymohl-cl committed Mar 31, 2021
1 parent c1e9c13 commit 5e8a28e
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 26 deletions.
32 changes: 30 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
all:
IGNORED_FOLDER=.ignore
MODULE_NAME := $(shell go list -m)

go build .
all: install tools lint build

.PHONY: install
install:
@go mod download

.PHONY: build
build: test
@go build -a -ldflags '-extldflags "-static"' ./...

test:
@go test -count=1 ./...

.PHONY: lint
lint:
golint ./...

.PHONY: tools
tools:
go get -u golang.org/x/lint/golint

.PHONY: clean
clean:
@rm -rf ${IGNORED_FOLDER}

.PHONY: fclean
fclean: clean
@rm -rf ${BIN_FOLDER}
2 changes: 1 addition & 1 deletion drivers/drivers.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func Init(width, height int32, title string) (VSDL, error) {
V.widthScreen = width
V.heightScreen = height

V.window, err = sdl.CreateWindow(title, sdl.WINDOWPOS_CENTERED, sdl.WINDOWPOS_CENTERED, int(V.widthScreen), int(V.heightScreen), sdl.WINDOW_OPENGL)
V.window, err = sdl.CreateWindow(title, sdl.WINDOWPOS_CENTERED, sdl.WINDOWPOS_CENTERED, V.widthScreen, V.heightScreen, sdl.WINDOW_OPENGL)
if err != nil {
return V, err
}
Expand Down
9 changes: 9 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module github.com/ymohl-cl/game-builder

go 1.15

require (
github.com/veandco/go-sdl2 v0.4.5
golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5 // indirect
golang.org/x/tools v0.1.0 // indirect
)
30 changes: 30 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
github.com/veandco/go-sdl2 v0.4.5 h1:GFIjMabK7y2XWpr9sGvN7RDKHt7vrA7XPTUW60eOw+Y=
github.com/veandco/go-sdl2 v0.4.5/go.mod h1:OROqMhHD43nT4/i9crJukyVecjPNYYuCofep6SNiAjY=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5 h1:2M3HP5CCK1Si9FQhwnzYhXdG6DXeebvUHFpre8QvbyI=
golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7 h1:EBZoQjiKKPaLbPrbpssUfuHtwM6KV/vb4U85g/cigFY=
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.1.0 h1:po9/4sTYwZU9lPhi1tOrb4hCv3qrhiQ77LZfGa2OjwY=
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
1 change: 1 addition & 0 deletions objects/objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ type Object interface {
Draw(*sync.WaitGroup, *sdl.Renderer)
}

// Closer objects
func Closer(layers map[uint8][]Object) error {
var err error

Expand Down
6 changes: 3 additions & 3 deletions objects/text/p_text.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ func (T *Text) updateTextures(r *sdl.Renderer) error {
var surface *sdl.Surface

for id, color := range T.colors {
if surface, err = T.font.RenderUTF8_Solid(T.txt, color); err != nil {
if surface, err = T.font.RenderUTF8Solid(T.txt, color); err != nil {
return err
}
defer surface.Free()
Expand All @@ -23,7 +23,7 @@ func (T *Text) updateTextures(r *sdl.Renderer) error {
}

for id, color := range T.underColors {
if surface, err = T.font.RenderUTF8_Solid(T.txt, color); err != nil {
if surface, err = T.font.RenderUTF8Solid(T.txt, color); err != nil {
return err
}
defer surface.Free()
Expand All @@ -44,7 +44,7 @@ func (T *Text) updateTextureByStatus(s uint8, r *sdl.Renderer) error {
var surface *sdl.Surface

T.textures[s].Destroy()
if surface, err = T.font.RenderUTF8_Solid(T.txt, T.colors[s]); err != nil {
if surface, err = T.font.RenderUTF8Solid(T.txt, T.colors[s]); err != nil {
return err
}
defer surface.Free()
Expand Down
4 changes: 2 additions & 2 deletions scene/loader/i_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ func (l *DefaultLoader) GetLayers() (map[uint8][]objects.Object, *sync.Mutex) {
return l.layers, l.m
}

// KeyDownEvent provide key down to the scene
func (l *DefaultLoader) KeyDownEvent(keyDown *sdl.KeyDownEvent) {
// KeyboardEvent provide key down to the scene
func (l *DefaultLoader) KeyboardEvent(keyboard *sdl.KeyboardEvent) {
return
}

Expand Down
4 changes: 2 additions & 2 deletions scene/scene.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ type Scene interface {
Close() error
// GetLayers get objects list by layers order
GetLayers() (map[uint8][]objects.Object, *sync.Mutex)
// KeyDownEvent provide key down to the scene
KeyDownEvent(*sdl.KeyDownEvent)
// KeyboardEvent provide key down to the scene
KeyboardEvent(*sdl.KeyboardEvent)
// SetSwitcher can be called to change scene with index scene on
// first parameter and flag on true to close old scene and false to stop it only
SetSwitcher(func(uint8, bool) error)
Expand Down
21 changes: 5 additions & 16 deletions scripter/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ func (s *Script) events(E sdl.Event) {
err = s.mouseMotionEvent(E.(*sdl.MouseMotionEvent))
case *sdl.MouseButtonEvent:
err = s.mouseButtonEvent(E.(*sdl.MouseButtonEvent))
case *sdl.KeyDownEvent:
err = s.keyDownEvent(E.(*sdl.KeyDownEvent))
case *sdl.KeyUpEvent:
err = s.keyUpEvent(E.(*sdl.KeyUpEvent))
case *sdl.KeyboardEvent:
err = s.keyboardEvent(E.(*sdl.KeyboardEvent))
}
if err != nil {
panic(err)
Expand Down Expand Up @@ -82,20 +80,11 @@ func (s *Script) mouseButtonEvent(button *sdl.MouseButtonEvent) error {
return nil
}

// keyDownEvent : _
func (s *Script) keyDownEvent(keyDown *sdl.KeyDownEvent) error {
// keyboardEvent : _
func (s *Script) keyboardEvent(keyDown *sdl.KeyboardEvent) error {
if _, ok := s.list[s.current]; !ok {
return errors.New(errorIndexUndefined)
}
go s.list[s.current].KeyDownEvent(keyDown)
return nil
}

// keyUpEvent : _
func (s *Script) keyUpEvent(keyUp *sdl.KeyUpEvent) error {
if _, ok := s.list[s.current]; !ok {
return errors.New(errorIndexUndefined)
}
// go s.list[s.current].KeyDownEvent(keyDown)
go s.list[s.current].KeyboardEvent(keyDown)
return nil
}
1 change: 1 addition & 0 deletions scripter/script_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ func (s *Script) Switch(index uint8, closeOld bool) error {
return nil
}

// StopRun close the script
func (s *Script) StopRun() {
s.running = false
}

0 comments on commit 5e8a28e

Please sign in to comment.