Exemple #1
0
func main() {

	fmt.Println("starting")
	GT.EngineStart()

	simpleScene, _ := Graphics.NewBasicScene()
	node := Components.NewNode("new_image")

	// create a png based sprite
	rend := Components.NewSpriteRenderer()
	// myImagePath, _ := filepath.Abs("../Assets/Images/test.png")
	rend.SetImage(GT.AssetsImages + "test.png")

	// attach the sprite to our node, and transform if desired
	node.AddComponent(rend)

	node.Transform().Translate(400, 400, 0)
	node.Transform().Scale(.7, .7, 0)

	// attach the node to our scene
	simpleScene.RootNode.AddNode(node)

	// start the scene to render our setup
	simpleScene.Start()
}
Exemple #2
0
func main() {

	fmt.Println("starting")
	GT.EngineStart()

	s, _ := Graphics.NewBasicScene()

	// create text rendering components
	textRend := Components.NewTextRenderer()
	textRend.SetFont("Raleway")
	textRend.SetText("Hello World From GT!?")
	textRend.SetSize(14)
	textRend.SetColor(1, .2, .1, 1)

	textRend2 := Components.NewTextRenderer()
	textRend2.SetFont("Fantasque Sans Mono Regular")
	textRend2.SetSize(60)
	textRend2.SetText("Hello World Pt.2")

	// create nodes for them so we can apply transformation
	node1 := Components.NewNode("Text1")
	node1.Transform().Translate(100, 100, 0)
	node1.AddComponent(textRend)

	node2 := Components.NewNode("Text2")
	node2.Transform().Rotate(.3, 0, 0, 1)
	node2.Transform().Translate(150, 150, 0)
	node2.AddComponent(textRend2)

	s.RootNode.AddNode(node1)
	s.RootNode.AddNode(node2)

	s.Start()

}
Exemple #3
0
func main() {
	// create the foundation: a new window, basic scene, and game component (node)
	GT.EngineStart()
	probe := Opengl.Probe()
	Logging.Info("Max Texture Size: ", probe.MaxTextureSize)
	Logging.Info("Max Texture Image Units: ", probe.MaxTextureImageUnits)
	Logging.Info("Shader Version: ", probe.ShaderVersion)
}
Exemple #4
0
func main() {

	fmt.Println("starting")
	GT.EngineStart()

	simpleScene, _ := Graphics.New3DScene()

	node := Components.NewNode("new_image")
	node.AddComponent(&Spin{})
	node.Transform().Translate(-4, -3, 0)
	// create a model based on obj file
	rend := Components.NewModelRenderer()
	rend.SetModel(GT.AssetsModels+"textured_box.obj", GT.AssetsModels+"textured_box.mtl")
	node.AddComponent(rend)

	node2 := Components.NewNode("new_image2")
	// node2.AddComponent(&Spin{})
	// create a model based on obj file
	rend2 := Components.NewModelRenderer()
	rend2.SetModel(GT.AssetsModels+"walk.obj", GT.AssetsModels+"walk.mtl")
	node2.AddComponent(rend2)
	node2.Transform().Translate(4, -3, 0)
	node2.Transform().Rotate(.3, 0, 1, 0)

	node3 := Components.NewNode("new_image3")
	node3.AddComponent(&Spin{})
	// node2.AddComponent(&Spin{})
	// create a model based on obj file
	rend3 := Components.NewModelRenderer()
	rend3.SetModel(GT.AssetsModels+"test.obj", GT.AssetsModels+"test.mtl")
	node3.AddComponent(rend3)
	node3.Transform().Translate(4, 3, 0)
	node3.Transform().Rotate(.3, 0, 1, 0)

	node4 := Components.NewNode("new_image4")
	node4.AddComponent(&Spin{})
	rend4 := Components.NewModelRenderer()
	node4.AddComponent(rend4)
	// node2.AddComponent(&Spin{})
	// create a model based on obj file
	//node4.Transform().Translate(0, 0, 0)
	node4.Transform().Rotate(.3, 0, 1, 0)
	anim := Components.OBJAnimation(GT.AssetsModels + "SimpleAnimation")

	rend4.AnimationManager.AddAnimation(anim, "anim1")
	rend4.AnimationManager.SetCurrentAnimation("anim1")

	// attach the node to our scene
	simpleScene.RootNode.AddNode(node)
	simpleScene.RootNode.AddNode(node2)
	simpleScene.RootNode.AddNode(node3)
	simpleScene.RootNode.AddNode(node4)

	// start the scene to render our setup
	simpleScene.Start()
}
Exemple #5
0
func main() {

	fmt.Println("starting")

	// create the foundation: a new window, basic scene, and game component (node)
	GT.EngineStart()
	simpleScene, _ := Graphics.NewBasicScene()
	node := Components.NewNode("new_image")

	// create our renderer and our animation objects
	rend := Components.NewSpriteRenderer()

	manager := rend.AnimationManager // will be replaced by GetComponent(AnimationManager) when scripting etc.

	anim := Components.SpliceSpriteSheetAnimation(GT.AssetsImages+"Dog.png", 90, 58, 4, 1)

	// you can append other animations or images
	anim.AppendAnimation(Components.SpliceSpriteSheetAnimation(GT.AssetsImages+"Dog.png", 90, 58, 6, 2))
	anim.AppendAnimation(Components.SpliceSpriteSheetAnimation(GT.AssetsImages+"Dog.png", 90, 58, 5, 3))
	anim.AppendAnimation(Components.SpliceSpriteSheetAnimation(GT.AssetsImages+"Dog.png", 90, 58, 4, 4))
	anim.AppendAnimation(Components.SpliceSpriteSheetAnimation(GT.AssetsImages+"Dog.png", 90, 58, 3, 5))
	anim.AppendAnimation(Components.SpliceSpriteSheetAnimation(GT.AssetsImages+"Dog.png", 90, 58, 4, 6))

	anim.Append(GT.AssetsImages + "test.png")

	// if you can make use of a full sprite sheet for one animation, then use the SpliceFullSpriteSheetAnimation method
	//anim2.SpliceFullSpriteSheetAnimation(GT.AssetsImages+"tomatohead1.png", 12, 12)

	anim.SetFrequency(0.25, false) // set frequency of toggle to every 1/4 second
	// anim.SetFrequency(10, true) // set frequency of toggle to every 10 frames

	// you can swap images in the animation, or remove them by number in the list
	anim.Reorder(1, 27) // one-based input
	anim.Remove(1)      // remove test.png...

	manager.AddAnimation(anim, "dog_left_facing")
	manager.SetCurrentAnimation("dog_left_facing") // script components can make use of this...

	// animations can be retrieved for further configuration if desired
	anim = manager.GetAnimation("dog_left_facing")
	anim.SetAsOneTimeOnly(true)
	simpleScene.SetFPS(30)

	// attach the sprite to our node, and transform if desired
	node.AddComponent(rend)
	node.AddComponent(&RunLeft{}) // TODO: remove this for a scripting example
	//node.Transform().Scale(3, 3) // NOTE: scaling doesn't seem perfect for sub images/animations?
	node.Transform().Translate(400, 400, 0)

	// attach the node to our scene
	simpleScene.RootNode.AddNode(node)

	// start the scene to render our setup
	simpleScene.Start()

}
Exemple #6
0
func main() {

	// The logger now initializes in the Engine's start. That is where flags get parsed etc.
	GT.EngineStart()

	// TODO: test filtering and simultaneous outputs once implemented and configured
	Logging.Debug("debug")
	Logging.Info("info")

	// Note: this has been tested to work on multiple code call levels
	// so inserting debug logs in SimpleWindow.go as well as Scene.go
	// will place all info into GT/Logging/default.log
}
Exemple #7
0
func main() {

	fmt.Println("starting")
	GT.EngineStart()

	s, _ := Graphics.NewBasicScene()

	nodebak := Components.NewNode("Person")
	nodebak.Transform().Translate(100, 100)

	node := Components.NewNode("Person2")

	textRend := Components.NewTextRenderer()
	textRend.SetFont("Raleway")
	textRend.SetText("Hello World From GT!?")

	textRend.SetSize(14)
	textRend.SetColor(1, .2, .1, 1)
	node.Transform().Translate(150, 100)

	textRend2 := Components.NewTextRenderer()
	textRend2.SetFont("Fantasque Sans Mono Regular")
	textRend2.SetSize(60)
	textRend2.SetText("This is Second Font Fantasque Bold")

	rend := Components.NewSpriteRenderer()
	rend.SetImage(GT.AssetsImages + "test.png")
	nodebak.Transform().Scale(.5, .5)
	nodebak.Transform().Rotate(1.2)
	nodebak.AddComponent(rend)
	nodebak.AddComponent(textRend2)
	node.AddComponent(textRend)
	s.RootNode.AddNode(node)
	s.RootNode.AddNode(nodebak)

	s.Start()

}
Exemple #8
0
func main() {

	fmt.Println("starting")
	// // defer profile.Start(profile.CPUProfile).Stop()
	// w := Window.NewWindowedWindow("test", 600, 800)
	GT.EngineStart()
	s, _ := Graphics.NewBasicScene()
	g := TestGame{BaseScene: &s}

	// 500 sprites does about 38 fps on my laptop
	for i := 0; i < 500; i++ {
		nodebak := Components.NewNode("Person")
		nodebak.Transform().Translate(400, 400, 0)
		node := Components.NewNode("Person2")

		node.Transform().Translate(100, 100, 0)
		node.AddNode(nodebak)
		rend := Components.NewSpriteRenderer()
		rend.SetImage(GT.AssetsImages + "test.png")
		nodebak.Transform().Rotate(20, 0, 0, 1)
		nodebak.AddComponent(rend)

		rend2 := Components.NewSpriteRenderer()
		rend2.SetSubImage(GT.AssetsImages+"smiley.png", image.Rectangle{image.Point{30, 30}, image.Point{50, 50}})
		nodebak2 := Components.NewNode("Person")
		nodebak2.Transform().Translate(50, 50, 0)
		nodebak2.AddComponent(rend2)
		// sr := nodebak2.GetComponent("SpriteRenderer")
		// fmt.Println(sr)

		node.AddNode(nodebak2)

		g.BaseScene.RootNode.AddNode(node)
	}
	g.Start()

}