public static SpriteMario CreateHuDMario(Sprint4 game) { SpriteMario sprite = new SpriteMario(game); sprite.Info.manual = true; return(sprite); }
public SpritePipe(Sprint4 game) : base(game) { SpriteUtils.SetDefaultProperties(this, "Sprites/Obstacles/pipetop"); this.Info.bounds = game.bounds; this.Info.spriteWidth = 32; this.Info.numFrames = 1; }
/* * Mushroom is a different sprite in that it is hidden behind a block before it is shown. * it is added to the main sprite collection when you call MushroomAppear(). * * if you want the mushroom to be instantly visible, add it to the sprite collection * as normal. It will be still if you do this unless you call Move(); */ public SpriteFireFlower(Sprint4 game) : base(game) { this.Info.layer = 0.5f; this.Info.harmfulIndex = -1; SpriteUtils.SetDefaultProperties(this, "Sprites/Items/fireflower"); }
public SpriteBrokenBrick(Sprint4 game, int frame) : base(game) { this.Info.frameDelay = 10; this.Info.bounds = game.bounds; this.Info.spriteWidth = 8; this.Info.currentFrame = frame; this.Info.bounds = game.bounds; SpriteUtils.SetDefaultProperties(this, "Sprites/Blocks/broken_brick2"); switch (frame) { case 0: this.Info.velocity.X = -1; break; case 1: this.Info.velocity.X = 1; break; case 2: this.Info.velocity.X = 1; this.Info.velocity.Y = -2; break; case 3: this.Info.velocity.X = -1; this.Info.velocity.Y = -2; break; default: this.Info.velocity.X = 1; break; } }
public static SpriteBrickBlock CreateBrickItem(Sprint4 game, SpriteCollection item) { SpriteBrickBlock sprite = new SpriteBrickBlock(game); sprite.item = item; return(sprite); }
public SpriteCoin(Sprint4 game) : base(game) { this.Info.frameDelay = 12; this.Info.harmfulIndex = -1; SpriteUtils.SetDefaultProperties(this, "Sprites/Items/coin"); }
public SpriteYouWin(Sprint4 game) : base(game) { this.RegisterState(SpriteStates.Sheets.NORMAL, SpriteStates.Sprites.IDLE, "Sprites/HuD/youwin"); this.SetSheetState(SpriteStates.Sheets.NORMAL); this.SetSpriteState(SpriteStates.Sprites.IDLE); this.Info.spriteWidth = this.current.Width; this.Info.numFrames = 1; }
public SpriteQuestionBlock(Sprint4 game) : base(game) { this.Info.frameDelay = 12; this.RegisterState(SpriteStates.Sheets.QUESTION, SpriteStates.Sprites.IDLE, "Sprites/Blocks/question"); this.RegisterState(SpriteStates.Sheets.USED, SpriteStates.Sprites.IDLE, "Sprites/Blocks/used"); this.SetSheetState(SpriteStates.Sheets.QUESTION); this.SetSpriteState(SpriteStates.Sprites.IDLE); }
protected SpriteCollection(Sprint4 game) { name = this.GetType().Name; this.game = game; this.Info = new SpriteInfo(game); this.Info.position.X = 50; this.Info.position.Y = 200; }
public HuDLayer(Sprint4 game) : base(0f) { this.name = "HuD"; this.gameInputK = new InputControllerKeyboard(); this.gameInputG = new InputControllerGamePad(PlayerIndex.One); KeyListener exit = new ExitKeyListener(game); this.gameInputK.RegisterKeyListener(Keys.Q, exit); this.gameInputG.RegisterKeyListener(Buttons.Back, exit); this.gameInputK.RegisterKeyListener(Keys.R, new ResetKeyListener(game)); this.InputControllers.Add(this.gameInputK); this.InputControllers.Add(this.gameInputG); SpriteText gameScore = new SpriteText(game, 15, 15, Color.Black); SpriteText gameCoins = new SpriteText(game, 215, 15, Color.Black); SpriteText gameLives = new SpriteText(game, 465, 15, Color.Black); SpriteText gameTime = new SpriteText(game, 700, 15, Color.Black); gameScore.Text = delegate() { int numZeros = 6 - (game.Mario.points.ToString().Length); if (game.Mario.points == 0) { numZeros = 6; } string points = "Mario\n"; for (int i = 0; i < numZeros; i++) { points += "0"; } return(string.Format(points + "{0}", game.Mario.points)); }; gameCoins.Text = delegate() { return(string.Format(" x {0}", game.Mario.coins)); }; gameLives.Text = delegate() { return(string.Format(" x {0}", game.Mario.lives)); }; gameTime.Text = delegate() { return(string.Format("Time\n {0}", game.TimeLeft)); }; this.AddSpriteText(gameScore); this.AddSpriteText(gameCoins); this.AddSpriteText(gameLives); this.AddSpriteText(gameTime); }
public static SpriteMario CreateMario(Sprint4 game) { if (SpriteFactory.mario != null) { return(SpriteFactory.mario); } return(SpriteFactory.mario = new SpriteMario(game)); }
public SpritePointText(Sprint4 game, int points, SpriteCollection sprite) { this.text = new SpriteText(game, (int)sprite.Info.position.X, (int)sprite.Info.position.Y - 25, Color.Black); text.Text = delegate() { return(string.Format("+" + points)); }; currentTime = 0; }
/* * Mushroom is a different sprite in that it is hidden behind a block before it is shown. * it is added to the main sprite collection when you call StarAppear(). * * if you want the star to be instantly visible, add it to the sprite collection * as normal. It will be still if you do this unless you call Move(); */ public SpriteStar(Sprint4 game) : base(game) { this.Info.layer = 1; this.RegisterState(SpriteStates.Sheets.NORMAL, SpriteStates.Sprites.IDLE, "Sprites/Items/star"); this.SetSheetState(SpriteStates.Sheets.NORMAL); this.SetSpriteState(SpriteStates.Sprites.IDLE); this.Info.bounce = true; }
public CollisionLayer(Sprint4 game) : base(1f) { this.game = game; this.name = "Collision"; this.SortMode = SpriteSortMode.FrontToBack; this.BlendMode = BlendState.AlphaBlend; this.Initialize(); }
public SpriteBrickBlock(Sprint4 game) : base(game) { this.Info.frameDelay = 10; this.RegisterState(SpriteStates.Sheets.BRICK, SpriteStates.Sprites.IDLE, "Sprites/Blocks/brick"); this.RegisterState(SpriteStates.Sheets.BROKEN, SpriteStates.Sprites.IDLE, "Sprites/Blocks/broken_brick"); this.RegisterState(SpriteStates.Sheets.USED, SpriteStates.Sprites.IDLE, "Sprites/Blocks/used"); this.SetSheetState(SpriteStates.Sheets.BRICK); this.SetSpriteState(SpriteStates.Sprites.IDLE); }
public SpriteBackground(Sprint4 game) : base(game) { SpriteUtils.SetDefaultProperties(this, "Sprites/Background"); //this.Info.scale = 1.5f; this.Info.layer = 0; this.Info.scale = 1f; this.Info.numFrames = 1; this.Info.spriteWidth = 515; this.Info.paralaxLayer = 0.6f; }
public SpriteGoomba(Sprint4 game) : base(game) { this.Info.frameDelay = 8; this.Info.harmfulIndex = 1; this.RegisterState(SpriteStates.Sheets.NORMAL, SpriteStates.Sprites.IDLE, "Sprites/Enemies/Goomba/idle"); this.RegisterState(SpriteStates.Sheets.NORMAL, SpriteStates.Sprites.DEAD, "Sprites/Enemies/Goomba/dead"); this.SetSheetState(SpriteStates.Sheets.NORMAL); this.SetSpriteState(SpriteStates.Sprites.IDLE); this.Info.bounce = true; }
/* * Mushroom is a different sprite in that it is hidden behind a block before it is shown. * it is added to the main sprite collection when you call MushroomAppear(). * * if you want the mushroom to be instantly visible, add it to the sprite collection * as normal. It will be still if you do this unless you call Move(); */ public SpriteMushroom(Sprint4 game, String path) : base(game) { this.Info.layer = 0.5f; this.Info.harmfulIndex = -1; if (path.Contains("oneupshroom")) { this.oneUp = true; } SpriteUtils.SetDefaultProperties(this, path); this.Info.bounce = true; }
public SpriteMario(Sprint4 game) : base(game) { this.Info.frameDelay = 7; this.RegisterStates(); this.SetSheetState(SpriteStates.Sheets.NORMAL); this.StateMachineAction = new StateMachineMarioAction(this); this.StateMachinePowerup = new StateMachineMarioPowerup(this); this.Info.bounds = game.bounds; this.SetPosition(5, this.GetStartHeight()); //2 floor tiles, 2 scale }
public GameOverLayer(Sprint4 game) : base(0f) { this.game = game; this.SortMode = SpriteSortMode.Deferred; this.BlendMode = BlendState.Opaque; this.gameOver = SpriteFactory.CreateGameOver(game); int w = this.gameOver.Info.spriteWidth; int h = this.gameOver.Info.spriteHeight; int cx = game.GetViewport().Right / 2; int cy = game.GetViewport().Bottom / 2; this.gameOver.SetPosition(cx - (w / 2), cy - (h / 2)); }
public YouWinLayer(Sprint4 game) : base(0f) { this.game = game; this.SortMode = SpriteSortMode.Deferred; this.BlendMode = BlendState.AlphaBlend; this.youWin = SpriteFactory.CreateYouWin(game); int w = this.youWin.Info.spriteWidth; int h = this.youWin.Info.spriteHeight; int cx = game.GetViewport().Right / 2; int cy = game.GetViewport().Bottom / 2; this.youWin.SetPosition(cx - (w / 2), cy - (h / 2)); }
private static int resolveValue(Sprint4 game, string token, SpriteCollection sprite) { int scale = 1; Match m = Regex.Match(token, "([\\d]+)[a-zA-Z]+"); if (m.Length > 0) { scale = int.Parse(Regex.Replace(token, "[^\\d]", "")); token = Regex.Replace(token, "[\\d]", ""); } int value; if (token == "w") { value = sprite.Info.spriteWidth; } else if (token == "h") { value = sprite.Info.spriteHeight; } else if (token == "left") { value = game.GetViewport().Left; } else if (token == "right") { value = game.GetViewport().Right; } else if (token == "top") { value = game.GetViewport().Top; } else if (token == "bottom") { value = game.GetViewport().Bottom; } else { //Console.WriteLine("parsing {0}", token); value = int.Parse(token); } return(value * scale); }
public SpriteText(Sprint4 game, int x, int y, Color c) { if (FONT_ARIAL == null) { FONT_ARIAL = game.Content.Load <SpriteFont>("Fonts/arial"); } /*if (FONT_MARIO == null) * { * FONT_MARIO = game.Content.Load<SpriteFont>("Fonts/mariofont"); * }//*/ this.game = game; this.X = x; this.Y = y; this.Color = c; Text = () => ""; }
private static bool revealItem(Sprint4 game, SpriteCollection item) { if (item is IRevealable) { int destY = (((int)(item.Info.position.Y)) - item.Info.spriteHeight) - 1; if (item.Info.bounds == null || item.Info.bounds == default(Rectangle)) { item.Info.bounds = game.bounds; } item.Info.manual = true; item.Info.velocity.Y = -1; SpriteLayer.CollisionLayer.AddSprite(item); while (item.Info.position.Y > destY) { Console.WriteLine("Waiting for {0} to be revealed. Its velocity is {1}", item.name, item.Info.velocity.Y); Thread.Sleep(200); } Console.WriteLine("{0} has been revealed", item.name); item.Info.velocity.Y = 0; item.Info.manual = false; return(true); } return(false); }
public static Task <bool> RevealItem(Sprint4 game, SpriteCollection item) { return(Task.Factory.StartNew(() => revealItem(game, item))); }
public static SpriteBrickBlock CreateBrick(Sprint4 game) { return(new SpriteBrickBlock(game)); }
public static SpriteStar CreateStar(Sprint4 game) { SpriteStar star = new SpriteStar(game); return(star); }
public static SpriteMushroom Create1UP(Sprint4 game) { return(new SpriteMushroom(game, "Sprites/Items/oneupshroom")); }
public static SpriteMushroom CreateMushroom(Sprint4 game) { return(new SpriteMushroom(game, "Sprites/Items/supershroom")); }
/*public static SpriteKoopa CreateKoopa(Sprint3 game, string color) * { * if (!color.Equals("Red") && !color.Equals("Green")) * { * Console.WriteLine("[Error] CreateKoopa called with color not Red or Green"); * return null; * } * * return new SpriteKoopa(game, color); * }//*/ public static SpriteCoin CreateCoin(Sprint4 game) { return(new SpriteCoin(game)); }