// cm, collision motion, shows how controlling a physics body works by applying // velocity pushes instead of updating the body's location. It also demonstrates // how collisions with another physics body can affect camera/player movement. func cm() { cm := &cmtag{} var err error if cm.eng, err = vu.New("Collision Motion", 400, 100, 800, 600); err != nil { log.Printf("co: error intitializing engine %s", err) return } cm.eng.SetDirector(cm) defer cm.eng.Shutdown() cm.eng.Action() }
// sg tests the scene graph by building up a movable character that has multiple // layers of sub-parts. The scene graph works when changing the top level location, // orientation, and scale also affects the subparts. Sg also tests adding and removing // parts from a scene graph. The main classes being tested are vu.Scene and vu.Part, eg: // scene.AddPart() // scene.RemPart(sg.tr.part) // // Note that the movement keys move the character and not the camera in this example. func sg() { sg := &sgtag{} var err error if sg.eng, err = vu.New("Scene Graph", 400, 100, 800, 600); err != nil { log.Printf("sg: error intitializing engine %s", err) return } sg.run = 10 // move so many cubes worth in one second. sg.spin = 270 // spin so many degrees in one second. sg.eng.SetDirector(sg) // override user input handling. defer sg.eng.Shutdown() sg.eng.Action() }
// bb tests the engines handling of textures, billboarding and banners. // This example is used to see what type of effects can be generated // using simple textures. func bb() { bb := &bbtag{} var err error if bb.eng, err = vu.New("Billboarding & Banners", 400, 100, 800, 600); err != nil { log.Printf("bb: error intitializing engine %s", err) return } bb.run = 10 // move so many cubes worth in one second. bb.spin = 270 // spin so many degrees in one second. bb.eng.SetDirector(bb) // override user input handling. defer bb.eng.Shutdown() bb.eng.Action() }
// rl tests higher level graphics functionality. This includes: // vu culling/reducing the total objects rendered based on distance. See: // flr.plan.SetVisibleRadius(10) // flr.plan.SetVisibleDirection(true) // vu 2D overlay scene, in this case a minimap. See: // flr.mmap = rl.eng.AddScene(vu.XZtoXY) // flr.mmap.Set2D() // flr.mmap.SetOrthographic(-0.2, 100, -0.2, 75, 0, 10) // vu grid generation. See: // &grid.Dense{}, // &grid.Sparse{}, // &grid.Rooms{}, // // rl also tests camera movement that includes holding multiple movement keys // at the same time. The example does not have collision detection so you can // literally run through the maze. func rl() { rl := &rltag{} var err error if rl.eng, err = vu.New("Random Levels", 400, 100, 800, 600); err != nil { log.Printf("rl: error intitializing engine %s", err) return } rl.run = 5 // move so many cubes worth in one second. rl.spin = 270 // spin so many degrees in one second. rl.eng.SetDirector(rl) // override user input handling. defer rl.eng.Shutdown() rl.eng.Action() }
// cr, collision resolution, demonstrates simulated physics by having balls bounce // on a floor. The neat thing is that after the initial locations have been set // the physics simulation (vu/move) handles all subsequent position updates. func cr() { cr := &crtag{} var err error if cr.eng, err = vu.New("Collision Resolution", 400, 100, 800, 600); err != nil { log.Printf("cr: error intitializing engine %s", err) return } cr.run = 10 // move so many cubes worth in one second. cr.spin = 270 // spin so many degrees in one second. cr.eng.SetDirector(cr) // override user input handling. defer cr.eng.Shutdown() cr.eng.Action() }