public Projectile(double pX, double pY, double velX, double velY, PhysicsSprite.PlayerType creatorId, PhysicsSprite.GlowType glowType) { this.posX = pX; this.posY = pY; this.velX = velX / 100; this.velY = velY / 100; this.creatorId = creatorId; this.glowType = glowType; ani = new Animation(Game1.Instance.gameData.animations[getGlowFlyAniIndex(glowType)]); ani.start(); }
private bool playerGlowMatches(PhysicsSprite player, PhysicsSprite.GlowType glow) { return player.PlayerGlowType == glow; }
private int getGlowHitAniIndex(PhysicsSprite.GlowType glowType) { return (glowType == PhysicsSprite.GlowType.Red_Glow) ? ANI_RED_ORB_HIT : ANI_BLUE_ORB_HIT; }
private int getGlowFlyAniIndex(PhysicsSprite.GlowType glowType) { return (glowType == PhysicsSprite.GlowType.Red_Glow) ? ANI_RED_ORB_FLY : ANI_BLUE_ORB_FLY; }
private void affectPlayer(PhysicsSprite player) { //TODO: }
private void addScoreToPlayer(PhysicsSprite player) { //TODO: }
/// <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 base.Initialize(); audioSys.init(); gameData.init(Content); gameData.ScreenWidth = 256; gameData.ScreenHeight = 240; oldKeyState = Keyboard.GetState(); if (GamePad.GetCapabilities(PlayerIndex.One).IsConnected) oldPadState[0] = GamePad.GetState(PlayerIndex.One); if (GamePad.GetCapabilities(PlayerIndex.Two).IsConnected) oldPadState[1] = GamePad.GetState(PlayerIndex.Two); player1 = new PhysicsSprite(gameData.animations[PhysicsSprite.ANI_P1 + PhysicsSprite.ANI_RUN], gameData.animations[PhysicsSprite.ANI_RED_GLOW + PhysicsSprite.ANI_RUN], PhysicsSprite.PlayerType.Player1); player1.Ani.start(); gameData.sprites.Add(player1); player2 = new PhysicsSprite(gameData.animations[PhysicsSprite.ANI_P2 + PhysicsSprite.ANI_RUN], gameData.animations[PhysicsSprite.ANI_RED_GLOW + PhysicsSprite.ANI_RUN], PhysicsSprite.PlayerType.Player2); player2.Ani.start(); gameData.sprites.Add(player2); TileSet bgTileSet = gameData.getTileSet("bg"); ImageLayer bgLayer = new ImageLayer(gameData, bgTileSet); gameData.layers.Add(bgLayer); bgLayer.setSpeed(-0.25); TileSet subwayTileSet = gameData.getTileSet("subway"); TrainImageLayer subwayLayer = new TrainImageLayer(gameData, subwayTileSet, 10 * 1000, 30 * 1000, -4, -15); gameData.layers.Add(subwayLayer); subwayLayer.setSpeed(-4); subwayLayer.FixedYOffset = 120; subwayLayer.FixedXOffset = gameData.ScreenWidth; TileSet fenceTileSet = gameData.getTileSet("fence"); ImageLayer fenceLayer = new ImageLayer(gameData, fenceTileSet); gameData.layers.Add(fenceLayer); fenceLayer.setSpeed(-0.75); fenceLayer.FixedYOffset = gameData.ScreenHeight - fenceTileSet.height; mapLayer = new MapLayer(gameData, 16, 16); gameData.layers.Add(mapLayer); mapLayer.setSpeed(2.25); SpriteLayer spriteLayer = new SpriteLayer(gameData); gameData.layers.Add(spriteLayer); ProjectileLayer projectileLayer = new ProjectileLayer(gameData); gameData.layers.Add(projectileLayer); TileSet pipeTileSet1 = gameData.getTileSet("pipe1"); TrainImageLayer pipeLayer1 = new TrainImageLayer(gameData, pipeTileSet1, 2 * 1000, 10 * 1000, -6, -6); gameData.layers.Add(pipeLayer1); pipeLayer1.setSpeed(-6); pipeLayer1.FixedXOffset = gameData.ScreenWidth; TileSet pipeTileSet2 = gameData.getTileSet("pipe2"); TrainImageLayer pipeLayer2 = new TrainImageLayer(gameData, pipeTileSet2, 2 * 1000, 10 * 1000, -6, -6); gameData.layers.Add(pipeLayer2); pipeLayer2.setSpeed(-6); pipeLayer2.FixedXOffset = gameData.ScreenWidth; // Create RenderTargets after gameData.layers is populated renderTarget = new RenderTarget2D[gameData.layers.Count + 1]; for (int i = 0; i < gameData.layers.Count + 1; i++) { renderTarget[i] = new RenderTarget2D(graphics.GraphicsDevice, 256, 240, false, SurfaceFormat.Color, DepthFormat.Depth16); } setState(State.STATE_SPLASH); font = Content.Load<SpriteFont>("System"); score = 0; }