{"author_link":"\/users\/gonutz","author_name":"gonutz","author_uid":"gonutz","comments":[],"epoch":1524142939,"event":"LD41","format":"md","ldjam_node_id":81337,"likes":9,"metadata":{"p_key":"108728","p_author":"gonutz","p_authorkey":"1004280","p_urlkey":"324623","p_title":"Write Your Game in Go","p_cat":"LDJam ","p_event":"LD41","p_time":"1524142939","p_likes":"9","p_comments":"0","p_status":"WAYBACK","us_key":"1004280","us_name":"gonutz","us_username":"gonutz","event_start":"1524182400","event_key":"72","event_name":"LD 41"},"node":{"_collation":{"body_sanitizer":"TextUtils::SanitizeHTML via existing importer","event":"LD41","removed_author":false},"_superparent":73256,"_trust":5,"author":4280,"body":"Here is my [cross-platform Go game prototyping library](https:\/\/github.com\/gonutz\/prototype) in action.\n\n![video.gif](\/\/\/raw\/8b0\/1\/z\/f2b3.gif)\n\nThis little space ship was created in only 47 lines of code:\n\n    package main\n    \n    import \"github.com\/gonutz\/prototype\/draw\"\n    \n    func main() {\n    \tx, y := 60, 240\n    \tvar bullets []bullet\n    \tdraw.RunWindow(\"Game\", 640, 480, func(window draw.Window) {\n    \t\t\/\/ handle input\n    \t\tif window.IsKeyDown(draw.KeyRight) {\n    \t\t\tx += 3\n    \t\t} else if window.IsKeyDown(draw.KeyLeft) {\n    \t\t\tx -= 3\n    \t\t}\n    \t\tif window.IsKeyDown(draw.KeyUp) {\n    \t\t\ty -= 2\n    \t\t} else if window.IsKeyDown(draw.KeyDown) {\n    \t\t\ty += 2\n    \t\t}\n    \t\tif window.WasKeyPressed(draw.KeySpace) {\n    \t\t\tbullets = append(bullets, bullet{x: x + 15, y: y, life: 1})\n    \t\t}\n    \n    \t\t\/\/ update world\n    \t\tn := 0\n    \t\tfor i := range bullets {\n    \t\t\tbullets[i].x += 6\n    \t\t\tbullets[i].life -= 0.01\n    \t\t\tif bullets[i].life >= 0 {\n    \t\t\t\tbullets[n] = bullets[i]\n    \t\t\t\tn++\n    \t\t\t}\n    \t\t}\n    \t\tbullets = bullets[:n]\n    \n    \t\t\/\/ render\n    \t\tfor _, b := range bullets {\n    \t\t\twindow.FillEllipse(b.x-5, b.y-5, 10, 10, draw.RGBA(0, 1, 0, b.life))\n    \t\t}\n    \t\twindow.FillRect(x-20, y-20, 40, 40, draw.Red)\n    \t})\n    }\n    \n    type bullet struct {\n    \tx, y int\n    \tlife float32\n    }\n\nIf you love the Go programming language as much as I do, why not create your game in Go? Give it a try. If you have any questions or suggestions for improvement, hit me up!","comments":4,"comments-timestamp":"2018-04-19T13:35:46Z","created":"2018-04-19T12:57:21Z","files":[],"files-timestamp":0,"id":81337,"love":9,"love-timestamp":"2018-04-19T17:52:53Z","meta":[],"modified":"2018-04-19T17:52:53Z","name":"Write Your Game in Go","node-timestamp":"2018-04-19T13:02:19Z","parent":75685,"parents":[1,5,9,73256,75685],"path":"\/events\/ludum-dare\/41\/no-brain-jogging\/write-your-game-in-go-4","published":"2018-04-19T13:02:19Z","scope":"public","slug":"write-your-game-in-go-4","subsubtype":"","subtype":"","type":"post","version":225991},"node_metadata":{"n_key":"81337","n_urlkey":"324623","n_parent":"75685","n_path":"\/events\/ludum-dare\/41\/no-brain-jogging\/write-your-game-in-go-4","n_slug":"write-your-game-in-go-4","n_type":"post","n_subtype":"","n_subsubtype":"","n_author":"4280","n_created":"1524142641","n_modified":"1524160373","n_version":"225991","n_status":"WAYBACK"},"source_url":"https:\/\/ldjam.com\/events\/ludum-dare\/41\/no-brain-jogging\/write-your-game-in-go-4","text":"Here is my [cross-platform Go game prototyping library](https:\/\/github.com\/gonutz\/prototype) in action.\n\n![video.gif](\/\/\/raw\/8b0\/1\/z\/f2b3.gif)\n\nThis little space ship was created in only 47 lines of code:\n\n    package main\n    \n    import \"github.com\/gonutz\/prototype\/draw\"\n    \n    func main() {\n    \tx, y := 60, 240\n    \tvar bullets []bullet\n    \tdraw.RunWindow(\"Game\", 640, 480, func(window draw.Window) {\n    \t\t\/\/ handle input\n    \t\tif window.IsKeyDown(draw.KeyRight) {\n    \t\t\tx += 3\n    \t\t} else if window.IsKeyDown(draw.KeyLeft) {\n    \t\t\tx -= 3\n    \t\t}\n    \t\tif window.IsKeyDown(draw.KeyUp) {\n    \t\t\ty -= 2\n    \t\t} else if window.IsKeyDown(draw.KeyDown) {\n    \t\t\ty += 2\n    \t\t}\n    \t\tif window.WasKeyPressed(draw.KeySpace) {\n    \t\t\tbullets = append(bullets, bullet{x: x + 15, y: y, life: 1})\n    \t\t}\n    \n    \t\t\/\/ update world\n    \t\tn := 0\n    \t\tfor i := range bullets {\n    \t\t\tbullets[i].x += 6\n    \t\t\tbullets[i].life -= 0.01\n    \t\t\tif bullets[i].life >= 0 {\n    \t\t\t\tbullets[n] = bullets[i]\n    \t\t\t\tn++\n    \t\t\t}\n    \t\t}\n    \t\tbullets = bullets[:n]\n    \n    \t\t\/\/ render\n    \t\tfor _, b := range bullets {\n    \t\t\twindow.FillEllipse(b.x-5, b.y-5, 10, 10, draw.RGBA(0, 1, 0, b.life))\n    \t\t}\n    \t\twindow.FillRect(x-20, y-20, 40, 40, draw.Red)\n    \t})\n    }\n    \n    type bullet struct {\n    \tx, y int\n    \tlife float32\n    }\n\nIf you love the Go programming language as much as I do, why not create your game in Go? Give it a try. If you have any questions or suggestions for improvement, hit me up!","title":"Write Your Game in Go","wayback_source":[]}