This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // +build windows | |
| package lib | |
| func FindExe() (string,string){ | |
| return "C:\\Windows\\System32\\explorer.exe", "Windows" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //+build windows_test | |
| package lib | |
| import "testing" | |
| func TestFindExe(t * testing.T){ | |
| _, os := FindExe() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // +build linux darwin | |
| package lib | |
| func FindExe() (string, string){ | |
| return "/bin/bash","Unix" | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //+build unix_test | |
| package lib | |
| import "testing" | |
| func TestFindExe(t * testing.T){ | |
| _, os := FindExe() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func HandleEnt(e *entities.Entity) { | |
| for { | |
| time.Sleep(WaitTime) | |
| // set speed to move left, hence `-` sign | |
| e.Delta[0] = -e.Speed.X() | |
| // perform shift |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| go func() { | |
| for { | |
| wait := rand.Intn(20) | |
| timeOut := time.Duration(wait) * time.Second | |
| time.Sleep(timeOut) | |
| fmt.Println("Spawn") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| event.Bind(sc, event.Enter, char, func(c *entities.Entity, ev event.EnterPayload) event.Response { | |
| oldX, oldY := char.X(), char.Y() | |
| char.ShiftDelta() | |
| aboveGround := false | |
| hit := collision.HitLabel(char.Space, Ground) | |
| gameOver := collision.HitLabel(char.Space, Obstacle) | |
| if gameOver != nil { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sc.Window.SetTitle("Infinite Dash") | |
| char := entities.New(sc, | |
| entities.WithRect(floatgeom.NewRect2WH(100, 100, 16, 32)), | |
| entities.WithColor(color.RGBA{255, 0, 0, 255}), | |
| entities.WithSpeed(floatgeom.Point2{3, 7}), | |
| ) | |
| platform := floatgeom.NewRect2WH(0, 420, 640, 20) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func main() { | |
| oak.AddScene("firstScene", scene.Scene{ | |
| Start: func(sc *scene.Context) { | |
| // ... draw entities, bind callbacks ... | |
| }, | |
| }) | |
| oak.Init("firstScene") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const ( | |
| // The only collision label we need for this demo is 'ground', | |
| // indicating something we shouldn't be able to fall or walk through | |
| Ground collision.Label = 1 | |
| Obstacle collision.Label = 2 | |
| WaitTime time.Duration = 50 * time.Millisecond | |
| ) |