public Parser(Game1 game) { this.game = game; blockFactory = new BlockFactory(game); itemFactory = new ItemFactory(game); enemyFactory = new EnemyFactory(game); latestCheckpoint = new List<Vector2>(); }
public Sprite(Scene scene, Vector2 position, Texture2D texture, Rectangle sourceRect, int timePerFrame, int numberOfFrames, bool isAnimated) { this.scene = scene; this.isAnimated = isAnimated; this.numberOfFrames = numberOfFrames; this.position = position; this.texture = texture; this.timePerFrame = timePerFrame; this.sourceRect = sourceRect; this.origin.X = 0; this.origin.Y = 0; Velocity = new Vector2(0, 0); blockFactory = new BlockFactory(scene.Game); itemFactory = new ItemFactory(scene.Game); enemyFactory = new EnemyFactory(scene.Game); this.sounds = new SoundMachine(scene.Game); // frameWidth = sourceRect.Width / numberOfFrames; frameWidth = 16; collisionBox = new CollisionBox(position.X, position.Y, 32, SourceRect.Height*2); }
public void PlaceBlockCommand() { if (mario.Coins > 0) { BlockFactory bf = new BlockFactory(game); Sprite newBlock = bf.MakeProduct(2); if (mario.Direction == 1) { newBlock.CollisionBox.Physics(new Vector2(mario.MarioVec_X + mario.CollisionBox.Width + 1, mario.MarioVec_Y - mario.CollisionBox.Height), Vector2.Zero, Vector2.Zero); } else { newBlock.CollisionBox.Physics(new Vector2(mario.MarioVec_X - 33, mario.MarioVec_Y - mario.CollisionBox.Height), Vector2.Zero, Vector2.Zero); } foreach (ISprite s in SSprites) { if (newBlock.CollisionBox.Intersect(newBlock.CollisionBox, s.CollisionBox)) { newBlock.alive = false; return; } } SSprites.Add(newBlock); Sprites.Add(newBlock); mario.Coins--; } }
public Block(Game1 game, int posX, int posY) { BlockFactory = new BlockFactory(game); }
public void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. screenHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height; screenWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width; backgroundTexture = game.Content.Load<Texture2D>("SMSearlysky"); reader = XmlReader.Create("map.xml"); sprites = new List<Sprite>(); spriteBatch = new SpriteBatch(game.GraphicsDevice); blockFactory = new BlockFactory(game); itemFactory = new ItemFactory(game); enemyFactory = new EnemyFactory(game); Parse(reader); keyboardCont = new KeyboardController(game, mario); gamePadCont = new GamePadController(game, mario); collision = new Collision(mario, this); MakeFloor(); // TODO: use this.Content to load your game content here }