// derp. // this is from the Learning XNA 4.0 book, really: public virtual void Draw(Camera camera) { Matrix[] transforms = new Matrix[model.Bones.Count]; // probably not relevant to spaceships? unless I add moving parts? model.CopyAbsoluteBoneTransformsTo(transforms); foreach (ModelMesh mesh in model.Meshes) { foreach (BasicEffect be in mesh.Effects) { be.EnableDefaultLighting(); be.Projection = camera.projection; be.View = camera.view; be.World = GetWorld() * mesh.ParentBone.Transform; } mesh.Draw(); } }
/// <summary> /// Allows the game component to perform any initialization it needs to before starting /// to run. This is where it can query for any required services and load content. /// </summary> public override void Initialize() { // TODO: Add your initialization code here normalCol.A = 128; OurCamera = new Camera(game, new Vector3(0, 0, 50), Vector3.Zero, Vector3.Up); ; colors = new Color[maxEntries]; targetColors = new Color[maxEntries]; colorSetAt = new TimeSpan[maxEntries]; for (int i = 0; i < maxEntries; ++i) { targetColors[i] = (colors[i] = normalCol); // colorSetAt[i] = new GameTime(); // not necessary; colorSetAt[i] isn't relevant until targetColors[i]!=colors[i] and will be set at the same time as targetColors[i] } entries = new Dictionary<string, string>(maxEntries); entries.Add("New Game", "newGame"); entries.Add("Quit Game", "exit"); entries.Add("*Space Shooter*", "noop"); entries.Add("by", "noop"); entries.Add("Greg Velichansky", "noop"); moveSelection(0, null); // draw something as selected to start with, eh? base.Initialize(); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here stars = new SkyBox(this); Components.Add(stars); camera = new Camera(this, new Vector3(0, 0, 50), Vector3.Zero, Vector3.Up); //Components.Add(camera); // actually -- why the heck is the camera its own game component? Whatever... it doesn't need to be for my purposes. // we want the bullets to move before the models run their Update() calls // that's to avoid having the bullets taking one move before collision detection is ever run, which spoils point-blank shots :V bulletManager = new ModelManager(this); Components.Add(bulletManager); modelManager = new ModelManager(this); Components.Add(modelManager); gameMenu = new MainMenu(this); Components.Add(gameMenu); screen.Push(gameScreen.gameMenu); // start at the main menu? debugcons = new IOConsole(this); Components.Add(debugcons); IOConsole.instance = debugcons; dispatcher = new Dispatcher(this); Components.Add(dispatcher); // for the sake of completeness... not sure if it'll use any of the actual game component interface, actually hud = new HUD(this, font); Components.Add(hud); base.Initialize(); }