Learn to Code via Tutorials on Repl.it!

← Back to all posts
Graphics with Go
Lord_Poseidon

Getting started with graphics development in Golang on repl.it

Introduction

Who doesn't love golang? some people, maybe.But no can resist the cuteness of the gopher. Fact.

https://storage.googleapis.com/replit/images/1554188001496_b0ed474d1ded6473b090ec87088ecf8e.pn

What I want to say is... I've found a way to do graphics in Go on repl.it. This post teaches you how to make a sample gopher screensaver using a framework called pixel.

https://storage.googleapis.com/replit/images/1554188058370_76c7f7a05f0a3963485e0e638499f234.pn

Please note that much of the code is from the original tutorials. It strongly recommended to go through them if you do want to make a game in go. To be honest, this is more of a half-baked amalgamation of @eankeen 's original pygame tutorial and the tutorials

The final result will look like this:

https://storage.googleapis.com/replit/images/1554188108706_2e6b2e16497f79b500b7152c4e5e3a60.gi

A bit glitchy.Don't know why

Getting started

First, start by making a polygott repl here. Or even better, fork my repl at https://repl.it/@Lord_Poseidon/NarrowCrookedExternalcommand. You would see a makefile. Paste this there and make a folder called src

Thanks to @superwhiskers for this code. The reason we are doing this is because repl does not have a Go package manager yet .That makefile gets our dependencies, then runs the code in the folder src .

create a file main.go in src folder and code away!!

my code is mostly from the original tutorials here but these are the changes:

Code changes:

just standard edge detection, speed changing, movement and delay.

Path:

the tutorials assume that the source directory is the working directory. This is not the case with us. You have to do src/hiking.png even if you already are in src directory.
Also, I had to resize the original image to make it smaller

Size of the window:

the tutorials assume 1074 by 768 pixels. We at repl.it have only 800 by 600


Thanks again to @superwhiskers and @eankeen. If you do decide to make a game in go,let me know in the comments

Voters
programmeruser
Nick4422
luseufert5
timmy_i_chen
eankeen
SamWhite3
Lord_Poseidon
Comments
hotnewtop
tom0099

How do i fix wireless displays connections in windows 10 http://fixwindows10connections.com thanks for the share this basic information.