Explore Code Snippets

Discover, preview, and use amazing code snippets shared by the community.

// if ship is near the black hole center, draw it smaller
	scale := 1.0
	if g.blackHoleX > 0 && g.blackHoleY > 0 {
		dx := g.playerLocation.X - g.blackHoleX
		dy := g.playerLocation.Y - g.blackHoleY
		distance := math.Sqrt(float64(dx*dx + dy*dy))
		if distance < 100 {
			scale = 0.1 + ((100 - distance) / 400) // 400 -> make this frame based to smooth it out. Why is ship getting smaller, then larger again ?
		}
	}