public void StartProgram() { SnapsEngine.StartGameEngine(fullScreen: false, framesPerSecond: 60); TextBlockSprite tinyTextSprite = new TextBlockSprite( text: "Hello. I'm Tiny Text in the default font", fontSize: 20, color: SnapsColor.Blue); SnapsEngine.AddSpriteToGame(tinyTextSprite); TextBlockSprite giantTextSprite = new TextBlockSprite( text: "I'm Giant", fontSize: 200, fontFamily: "Impact", color: SnapsColor.Red); SnapsEngine.AddSpriteToGame(giantTextSprite); while (true) { tinyTextSprite.Top = 10; tinyTextSprite.CenterX = SnapsEngine.GameViewportWidth / 2.0; giantTextSprite.Bottom = SnapsEngine.GameViewportHeight - 10; giantTextSprite.CenterX = SnapsEngine.GameViewportWidth / 2.0; SnapsEngine.DrawGamePage(); } }
public void StartProgram() { SnapsEngine.StartGameEngine(fullScreen: false, framesPerSecond: 60); TextBlockSprite hypnoticTextSprite = new TextBlockSprite( text: "You are feeling sleepy", fontSize: 20, color: SnapsColor.Red); SnapsEngine.AddSpriteToGame(hypnoticTextSprite); double maxTextSize = 500; double minTextSize = 10; double textSizeUpdate = 0.2; double textSize = minTextSize; while (true) { hypnoticTextSprite.Top = 10; hypnoticTextSprite.CenterX = SnapsEngine.GameViewportWidth / 2.0; hypnoticTextSprite.CenterY = SnapsEngine.GameViewportHeight / 2.0; hypnoticTextSprite.RotationAngle = hypnoticTextSprite.RotationAngle + 1; hypnoticTextSprite.FontSize = textSize; textSize = textSize + textSizeUpdate; if (textSize > maxTextSize || textSize < minTextSize) { // reverse the direction of the update textSizeUpdate = -textSizeUpdate; } SnapsEngine.DrawGamePage(); } }
private void setupMessages() { titleBack = new TextBlockSprite(text: "Keep Up!!", fontSize: 320, fontFamily: "Impact", color: SnapsColor.Black); titleBack.RotationAngle = -20; SnapsEngine.AddSpriteToGame(titleBack); title = new TextBlockSprite(text: "Keep Up!!", fontSize: 320, fontFamily: "Impact", color: SnapsColor.Red); title.RotationAngle = -20; SnapsEngine.AddSpriteToGame(title); messageBack = new TextBlockSprite(text: "Keep Up!!", fontSize: 60, fontFamily: "Impact", color: SnapsColor.Black); SnapsEngine.AddSpriteToGame(messageBack); message = new TextBlockSprite(text: "Keep Up!!", fontSize: 60, fontFamily: "Impact", color: SnapsColor.Red); SnapsEngine.AddSpriteToGame(message); }
void setupGame() { SnapsEngine.SetBackgroundColor(SnapsColor.Black); SnapsEngine.StartGameEngine(fullScreen: false, framesPerSecond: 60); for (int i = 0; i < 100; i++) { ImageSprite starImage = new ImageSprite(imageURL: "ms-appx:///Images/star.png"); SnapsEngine.AddSpriteToGame(starImage); starImage.ScaleSpriteWidth(SnapsEngine.GameViewportWidth / 75); FallingSprite star = new FallingSprite(sprite: starImage, xSpeed: 0, ySpeed: 15, viewportWidth: SnapsEngine.GameViewportWidth, viewportHeight: SnapsEngine.GameViewportHeight); sprites.Add(star); } ImageSprite rocketImage = new ImageSprite(imageURL: "ms-appx:///Images/SpaceRocket.png"); SnapsEngine.AddSpriteToGame(rocketImage); rocketImage.ScaleSpriteWidth(SnapsEngine.GameViewportWidth / 15); rocketImage.CenterX = SnapsEngine.GameViewportWidth / 2.0; rocketImage.CenterY = SnapsEngine.GameViewportHeight / 2.0; rocket = new RocketSprite(sprite: rocketImage, game: this, xSpeed: 10, ySpeed: 10); sprites.Add(rocket); ImageSprite chasingAlienImage = new ImageSprite(imageURL: "ms-appx:///Images/purpleAlien.png"); SnapsEngine.AddSpriteToGame(chasingAlienImage); chasingAlienImage.Top = 10; chasingAlienImage.ScaleSpriteWidth(SnapsEngine.GameViewportWidth / 20); chasingAlienImage.CenterX = SnapsEngine.GameViewportWidth / 2.0; chasingAlienImage.Top = 0; chaser = new ChasingAlien(sprite: chasingAlienImage, game: this, target: rocket, xAcceleration: .3, yAcceleration: .3, friction: 0.99); sprites.Add(chaser); aliens.Add(chaser); int noOfAliens = 10; double alienWidth = SnapsEngine.GameViewportWidth / (noOfAliens * 2); double alienSpacing = (SnapsEngine.GameViewportWidth - alienWidth) / noOfAliens; double alienX = 0; double alienY = 100; for (int i = 0; i < noOfAliens; i = i + 1) { ImageSprite alienImage = new ImageSprite(imageURL: "ms-appx:///Images/greenAlien.png"); SnapsEngine.AddSpriteToGame(alienImage); alienImage.ScaleSpriteWidth(alienWidth); alienImage.CenterX = alienX; alienImage.Top = alienY; double xMin = alienX; double xMax = alienX + alienSpacing; LineAlien alien = new LineAlien(sprite: alienImage, game: this, xSpeed: 2, ySpeed: 0, target: rocket, xMax: xMax, xMin: xMin); sprites.Add(alien); aliens.Add(alien); alienX = alienX + alienSpacing; } ImageSprite missileImage = new ImageSprite(imageURL: "ms-appx:///Images/Missile.png"); missileImage.ScaleSpriteWidth(SnapsEngine.GameViewportWidth / 200); SnapsEngine.AddSpriteToGame(missileImage); MissileSprite missile = new MissileSprite(sprite: missileImage, rocket: rocket, xSpeed: 0, ySpeed: -15, aliens: aliens); sprites.Add(missile); rocket.Missiles.Add(missile); gameOverScreen = new ImageSprite(imageURL: "ms-appx:///Images/SpaceRocketsInSpaceGameOverScreen.png"); gameOverScreen.Hide(); SnapsEngine.AddSpriteToGame(gameOverScreen); gameOverScreen.Width = SnapsEngine.GameViewportWidth; gameOverScreen.Height = SnapsEngine.GameViewportHeight; messageBack = new TextBlockSprite(text: "", fontSize: 60, fontFamily: "Impact", color: SnapsColor.Black); SnapsEngine.AddSpriteToGame(messageBack); message = new TextBlockSprite(text: "", fontSize: 60, fontFamily: "Impact", color: SnapsColor.Red); SnapsEngine.AddSpriteToGame(message); titleScreen = new ImageSprite(imageURL: "ms-appx:///Images/SpaceRocketsInSpaceTitleScreen.png"); titleScreen.Hide(); SnapsEngine.AddSpriteToGame(titleScreen); titleScreen.Width = SnapsEngine.GameViewportWidth; titleScreen.Height = SnapsEngine.GameViewportHeight; }