示例#1
0
文件: server.go 项目: tbogdala/free
// StartNewGame starts a new game by generating the 'world' geography
// and waits for a player to connect.
func (s *Server) StartNewGame() {
	groggy.Log("INFO", "S: Server is initializing the world.")

	// build the landscape
	s.levelWidth = 5
	s.levelHeight = 5
	chunks := createNewLevelLandscape(s.levelWidth, s.levelHeight)
	s.landscapeMan.RegisterChunks(chunks)
}
示例#2
0
文件: main.go 项目: tbogdala/free
// setupTestAssets will load up the test prototypes in the assets manager
func setupTestAssets() {
	// setup a test cube for the goal
	goalCube := fizzle.CreateCube("diffuse", -0.5, -0.5, -0.5, 0.5, 0.5, 0.5)
	goalCube.Core.Shader = gameRenderer.Shaders["diffuse"]
	goalCube.Core.DiffuseColor = mgl.Vec4{0.95, 0.1, 0.1, 1.0}
	goalCube.Core.SpecularColor = mgl.Vec4{1.0, 0.0, 0.0, 1.0}
	goalCube.Core.Shininess = 4.8
	loadedAssets["goal"] = goalCube
	groggy.Logsf("INFO", "Asset loaded: goal (shader %d)", goalCube.Core.Shader.Prog)

	// setup a test cube for the player
	playerCube := fizzle.CreateCube("diffuse", -0.45, 0.0, -0.45, 0.45, 1.5, 0.45)
	playerCube.Core.Shader = gameRenderer.Shaders["diffuse"]
	playerCube.Core.DiffuseColor = mgl.Vec4{0.1, 0.1, 0.95, 1.0}
	playerCube.Core.SpecularColor = mgl.Vec4{0.0, 0.0, 1.0, 1.0}
	playerCube.Core.Shininess = 0.8
	loadedAssets["player"] = playerCube
	groggy.Log("INFO", "Asset loaded: player")

}
示例#3
0
文件: graphics.go 项目: tbogdala/free
// createWindow initializes the graphics libraries and creates the main window for the game.
// it pulls the settings for the window from the options structure passed in.
func createWindow(options *Options) (*glfw.Window, error) {
	// GLFW must be initialized before it's called
	err := glfw.Init()
	if err != nil {
		return nil, fmt.Errorf("Can't init glfw! %v", err)
	}

	// request a OpenGL 3.3 core context
	glfw.WindowHint(glfw.Samples, 0)
	glfw.WindowHint(glfw.ContextVersionMajor, 3)
	glfw.WindowHint(glfw.ContextVersionMinor, 3)
	glfw.WindowHint(glfw.OpenGLForwardCompatible, glfw.True)
	glfw.WindowHint(glfw.OpenGLProfile, glfw.OpenGLCoreProfile)

	// do the actual window creation
	mainWindow, err := glfw.CreateWindow(options.WindowWidth, options.WindowHeight, appWindowName, nil, nil)
	if err != nil {
		return nil, fmt.Errorf("Failed to create the main window! %v", err)
	}

	mainWindow.MakeContextCurrent()

	// set vsync options
	if options.VSyncEnabled {
		glfw.SwapInterval(1)
	} else {
		glfw.SwapInterval(0)
	}

	// make sure that all of the GL functions are initialized
	err = gl.Init()
	if err != nil {
		return nil, fmt.Errorf("Can't init gl! %v", err)
	}

	// write out the gl version for debug purposes
	version := gl.GoStr(gl.GetString(gl.VERSION))
	groggy.Log("INFO", "OpenGL version ", version)

	return mainWindow, nil
}