func drawCells() { if input.Zoom > 0 { gl.PointSize(gl.Float(float64(Width) / float64(*flagSize) * input.Zoom)) } gl.Color4f(1, 1, 1, 1) gl.Enable(gl.POINT_SMOOTH) gl.Begin(gl.POINTS) for i, j := 0, 0; i < (life.Size * life.Size); i, j = i+life.Size, j+1 { for k, v := range life.Cells[i : i+life.Size] { if v { gl.Vertex2f(gl.Float(k), gl.Float(j)) } } } gl.End() gl.Disable(gl.POINT_SMOOTH) }
func main() { RunGame(Title, Width*Scale, Height*Scale, func() { gl.PointSize(1.0 * Scale) x := 0 y := 0 dcolor := WHITE glfw.SetMouseButtonCallback(func(button, state int) { dcolor += 1 if dcolor > BLUE { dcolor = WHITE } }) glfw.SetMousePosCallback(func(mx, my int) { mx /= Scale my /= Scale if mx >= Width || my >= Height || mx < 0 || my < 0 { return } x = mx y = my if matrix != nil && dcolor != WHITE { (*matrix)[x][y].Color = dcolor (*matrix)[x][y].Intensity = 10 } }) glfw.SetKeyCallback(func(key, state int) { matrix = makeMatrix(Width, Height) }) matrix = makeMatrix(Width, Height) }, func() { matrix = NextMatrix(Width, Height, matrix) gl.Begin(gl.POINTS) drawMatrix(matrix, Scale, Scale) gl.End() }) }