public static Sprite CreateCat( Vector2 location, Texture2D texture, Vector2 velocity, float rotation) { Sprite sprite = new Sprite("sprite", location, texture, SpriteCreators.spriteSourceRectangles["cat00"], velocity, BodyType.Dynamic, true); SpriteCreators.AddFrames(sprite, "cat", 10); /* * for (int i = 1; i <= 10; i++) * { * string key = "cat" + i.ToString().PadLeft(2, '0'); * sprite.AddFrame(SpriteCreators.spriteSourceRectangles[key]); * } */ sprite.Rotation = rotation; return(sprite); }
public static Sprite CreateDog( Vector2 location, Texture2D texture, Vector2 velocity, float rotation) { Sprite sprite = new Sprite("sprite", location, texture, SpriteCreators.spriteSourceRectangles["rover00"], velocity, BodyType.Dynamic, false); //FarseerPhysics.Common.Vertices verts = new FarseerPhysics.Common.Vertices(); Fixture bodyfixture = FixtureFactory.AttachRectangle(ConvertUnits.ToSimUnits(sprite.BoundingBoxRect.Width), ConvertUnits.ToSimUnits(sprite.BoundingBoxRect.Height), 1, Vector2.Zero, sprite.PhysicsBody); bodyfixture.Restitution = 1; bodyfixture.Friction = 1; SpriteCreators.AddFrames(sprite, "rover", 12); sprite.Rotation = rotation; return(sprite); }
/// <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 GameWorld.Initialize(0, 5700, this.Window.ClientBounds.Width, this.Window.ClientBounds.Height, new Vector2(0, 9.8f)); GameWorld.ViewPortXOffset = 0; SpriteCreators.Load("Content\\spritesheet.txt"); // Create the texture manager textureManager = new TextureManager(Content); // Now load the sprite creator factory helper factory = GameObjectFactory.Instance; factory.Initialize(textureManager); cannonManager = new CannonManager(); cannonGroups = new List <CannonGroups>(); client = new ClientNetworking(); client.Connect(); client.ActionHandler["shoot"] = new EventHandler(this.HandleNetworkShoot); client.ActionHandler["create"] = new EventHandler(this.HandleNetworkCreate); // Add a few sprite creators factory.AddCreator((int)GameObjectTypes.CAT, SpriteCreators.CreateCat); factory.AddCreator((int)GameObjectTypes.DOG, SpriteCreators.CreateDog); factory.AddCreator((int)GameObjectTypes.BOOM, SpriteCreators.CreateBoom); factory.AddCreator((int)GameObjectTypes.WOOD1, SpriteCreators.CreateWood1); factory.AddCreator((int)GameObjectTypes.WOOD2, SpriteCreators.CreateWood2); factory.AddCreator((int)GameObjectTypes.WOOD3, SpriteCreators.CreateWood3); factory.AddCreator((int)GameObjectTypes.WOOD4, SpriteCreators.CreateWood4); factory.AddCreator((int)GameObjectTypes.PLATFORM_LEFT, SpriteCreators.CreatePlatformLeft); factory.AddCreator((int)GameObjectTypes.PLATFORM_MIDDLE, SpriteCreators.CreatePlatformMiddle); factory.AddCreator((int)GameObjectTypes.PLATFORM_RIGHT, SpriteCreators.CreatePlatformRight); factory.AddCreator((int)GameObjectTypes.CANNON, SpriteCreators.CreateCannon); factory.AddCreator((int)GameObjectTypes.CANNONWHEEL, SpriteCreators.CreateCannonWheel); factory.AddCreator((int)GameObjectTypes.POWERMETERBAR, SpriteCreators.CreatePowerMeterBar); factory.AddCreator((int)GameObjectTypes.POWERMETERTAB, SpriteCreators.CreatePowerMeterTab); mapEditor = new MapEditor(Window, client, cannonManager, cannonGroups); base.Initialize(); }
public static Sprite CreatePlane(Vector2 location, Texture2D texture, Vector2 velocity, float rotation) { Sprite sprite = new Sprite("sprite", location, texture, SpriteCreators.spriteSourceRectangles["plane00"], velocity, BodyType.Static, false); //sprite.FrameTime = 0.06f; SpriteCreators.AddFrames(sprite, "plane", 3); sprite.Rotation = rotation; return(sprite); }
public static Sprite CreateSun(Vector2 location, Texture2D texture, Vector2 velocity, float rotation) { Sprite sprite = new Sprite("sprite", location, texture, SpriteCreators.spriteSourceRectangles["sun00"], velocity, BodyType.Static, true); sprite.PhysicsBody.CollidesWith = Category.None; sprite.FrameTime = 0.06f; SpriteCreators.AddFrames(sprite, "sun", 4); sprite.Rotation = rotation; return(sprite); }
public static Sprite CreateDog( Vector2 location, Texture2D texture, Vector2 velocity, float rotation) { Sprite sprite = new Sprite("sprite", location, texture, SpriteCreators.spriteSourceRectangles["rover00"], velocity, BodyType.Dynamic, false); //FarseerPhysics.Common.Vertices verts = new FarseerPhysics.Common.Vertices(); SpriteCreators.AddFrames(sprite, "rover", 12); sprite.Rotation = rotation; //option 1 with two fixtures //rects //45, 16, 153, 114 //0, 60, 45, 70 //sprite.PhysicsBodyFixture = FixtureFactory.AttachRectangle(ConvertUnits.ToSimUnits(153), ConvertUnits.ToSimUnits(114), 1, ConvertUnits.ToSimUnits(new Vector2(45, 16)), sprite.PhysicsBody); //sprite.PhysicsBodyFixture = FixtureFactory.AttachRectangle(ConvertUnits.ToSimUnits(45), ConvertUnits.ToSimUnits(70), 1, ConvertUnits.ToSimUnits(new Vector2(0, 60)), sprite.PhysicsBody); //option 2 with one fixture //rects //16, 12, 175, 125 sprite.PhysicsBodyFixture = FixtureFactory.AttachRectangle(ConvertUnits.ToSimUnits(175), ConvertUnits.ToSimUnits(100), 10, ConvertUnits.ToSimUnits(new Vector2(16, 12)), sprite.PhysicsBody); sprite.PhysicsBodyFixture.Friction = 15f; sprite.PhysicsBodyFixture.OnCollision += new OnCollisionEventHandler(sprite.HandleCollision); sprite.PhysicsBody.Mass = 30f; return(sprite); }
public static Sprite CreateCat( Vector2 location, Texture2D texture, Vector2 velocity, float rotation) { Sprite sprite = new Sprite("sprite", location, texture, SpriteCreators.spriteSourceRectangles["cat00"], velocity, BodyType.Dynamic, false); SpriteCreators.AddFrames(sprite, "cat", 10); sprite.Frame = rand.Next(0, 10); /* * for (int i = 1; i <= 10; i++) * { * string key = "cat" + i.ToString().PadLeft(2, '0'); * sprite.AddFrame(SpriteCreators.spriteSourceRectangles[key]); * } */ sprite.Rotation = rotation; //rects //9, 19, 95, 111 sprite.PhysicsBodyFixture = FixtureFactory.AttachRectangle(ConvertUnits.ToSimUnits(95), ConvertUnits.ToSimUnits(100), 1, ConvertUnits.ToSimUnits(new Vector2(9, 10)), sprite.PhysicsBody); sprite.PhysicsBodyFixture.OnCollision += new OnCollisionEventHandler(sprite.HandleCollision); return(sprite); }
/// <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 GameWorld.Initialize(0, 12234 - (1080 * 2), this.Window.ClientBounds.Width, this.Window.ClientBounds.Height, new Vector2(0, 9.8f)); GameWorld.ViewPortXOffset = 0; SpriteCreators.Load("Content\\spritesheet.txt"); MapLoaded = false; // Create the texture manager textureManager = new TextureManager(Content); //Create the audio manager AudioManager.Instance.Initialize(Content); // Now load the sprite creator factory helper factory = GameObjectFactory.Instance; factory.Initialize(textureManager); cannonManager = new CannonManager(); cannonGroups = new List <CannonGroups>(); client = new ClientNetworking(); client.Connect(); client.ActionHandler["shoot"] = new EventHandler(this.HandleNetworkShoot); client.ActionHandler["create"] = new EventHandler(this.HandleNetworkCreate); client.ActionHandler["plane"] = new EventHandler(this.HandleNetworkPlane); client.ActionHandler["createother"] = new EventHandler(this.HandleNetworkCreateOtherStuff); client.ActionHandler["reset"] = new EventHandler(this.HandleReset); client.ActionHandler["endgame"] = new EventHandler(this.HandleEndGame); client.ActionHandler["sendpoints"] = new EventHandler(this.HandleSendPoints); // Add a few sprite creators factory.AddCreator((int)GameObjectTypes.CAT, SpriteCreators.CreateCat); factory.AddCreator((int)GameObjectTypes.DOG, SpriteCreators.CreateDog); factory.AddCreator((int)GameObjectTypes.SUN, SpriteCreators.CreateSun); factory.AddCreator((int)GameObjectTypes.BOOM, SpriteCreators.CreateBoom); factory.AddCreator((int)GameObjectTypes.PUFF, SpriteCreators.CreatePuff); factory.AddCreator((int)GameObjectTypes.DINO, SpriteCreators.CreateDino); factory.AddCreator((int)GameObjectTypes.CLOUD1, SpriteCreators.CreateCloud1); factory.AddCreator((int)GameObjectTypes.CLOUD2, SpriteCreators.CreateCloud2); factory.AddCreator((int)GameObjectTypes.CLOUD3, SpriteCreators.CreateCloud3); factory.AddCreator((int)GameObjectTypes.CLOUD4, SpriteCreators.CreateCloud4); factory.AddCreator((int)GameObjectTypes.CLOUD5, SpriteCreators.CreateCloud5); factory.AddCreator((int)GameObjectTypes.CLOUD6, SpriteCreators.CreateCloud6); factory.AddCreator((int)GameObjectTypes.WOOD1, SpriteCreators.CreateWood1); factory.AddCreator((int)GameObjectTypes.WOOD2, SpriteCreators.CreateWood2); factory.AddCreator((int)GameObjectTypes.WOOD3, SpriteCreators.CreateWood3); factory.AddCreator((int)GameObjectTypes.WOOD4, SpriteCreators.CreateWood4); factory.AddCreator((int)GameObjectTypes.PLATFORM_LEFT, SpriteCreators.CreatePlatformLeft); factory.AddCreator((int)GameObjectTypes.PLATFORM_MIDDLE, SpriteCreators.CreatePlatformMiddle); factory.AddCreator((int)GameObjectTypes.PLATFORM_RIGHT, SpriteCreators.CreatePlatformRight); factory.AddCreator((int)GameObjectTypes.CANNON, SpriteCreators.CreateCannon); factory.AddCreator((int)GameObjectTypes.CANNONWHEEL, SpriteCreators.CreateCannonWheel); factory.AddCreator((int)GameObjectTypes.POWERMETERBAR, SpriteCreators.CreatePowerMeterBar); factory.AddCreator((int)GameObjectTypes.POWERMETERTAB, SpriteCreators.CreatePowerMeterTab); factory.AddCreator((int)GameObjectTypes.EXPLOSION1, SpriteCreators.CreateExplosion1); factory.AddCreator((int)GameObjectTypes.EXPLOSION1, SpriteCreators.CreateExplosion2); factory.AddCreator((int)GameObjectTypes.PLANE, SpriteCreators.CreatePlane); factory.AddCreator((int)GameObjectTypes.CATSPLODE, SpriteCreators.CreateCatsplode); factory.AddCreator((int)GameObjectTypes.DUSTSPLODE, SpriteCreators.CreateDustsplode); factory.AddCreator((int)GameObjectTypes.YOULOSE, SpriteCreators.CreateYouLose); factory.AddCreator((int)GameObjectTypes.YOUWIN, SpriteCreators.CreateYouWin); factory.AddCreator((int)GameObjectTypes.SCOREPLUS50, SpriteCreators.CreatePlus50); factory.AddCreator((int)GameObjectTypes.SCOREPLUS100, SpriteCreators.CreatePlus100); factory.AddCreator((int)GameObjectTypes.SCOREPLUS250, SpriteCreators.CreatePlus250); //factory.AddCreator((int)GameObjectTypes.EAHSCSLOGO, SpriteCreators.CreateEAHSCSLogo); mapEditor = new MapEditor(Window, client, cannonManager, cannonGroups, ScreenConfiguration); base.Initialize(); }
public static Sprite CreateWood4(Vector2 location, Texture2D texture, Vector2 velocity, float rotation) { return(SpriteCreators.CreateWood(4, location, texture, velocity, rotation)); }