// spawn a projectile at a position with a rotation from a specific space ship public void spawnProjectile(Vector2 position, float rotation, SpaceShip spaceShip) { if (spaceShip == null) { return; } // get the colour of the projectile SpriteAnimation projectileAnimation = null; if (spaceShip.colour == SpaceShipColour.Red) { projectileAnimation = m_projectileAnimations[0]; } else if (spaceShip.colour == SpaceShipColour.Blue) { projectileAnimation = m_projectileAnimations[1]; } else if (spaceShip.colour == SpaceShipColour.Green) { projectileAnimation = m_projectileAnimations[2]; } else if (spaceShip.colour == SpaceShipColour.Yellow) { projectileAnimation = m_projectileAnimations[3]; } // create the projectile and store it m_projectiles.Add(new Projectile(position, rotation, projectileAnimation, spaceShip, m_settings)); m_laserSound.Play(); }
public Form1() { InitializeComponent(); bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height); g = Graphics.FromImage(bmp); pictureBox1.Image = bmp; brushwhite = new SolidBrush(Color.White); brushred = new SolidBrush(Color.Red); brushgreen = new SolidBrush(Color.Green); brushyellow = new SolidBrush(Color.Yellow); brushblue = new SolidBrush(Color.Blue); aster1 = new MyAsters(180, 200); aster2 = new MyAsters(220, 450); aster3 = new MyAsters(800, 170); aster4 = new MyAsters(610, 510); ship = new SpaceShip(492, 325); bullet = new MyBullet(492, 240); gun = new MyGun(490, 325); star1 = new MyStars(50, 110); star2 = new MyStars(400, 60); star3 = new MyStars(650, 100); star4 = new MyStars(880, 275); star5 = new MyStars(770, 400); star6 = new MyStars(865, 570); star7 = new MyStars(380, 500); star8 = new MyStars(70, 510); }
// add a corresponding number of points to a player's score (based on space ship object) public void addPoints(SpaceShip player, ScoreType scoreType) { if (player == null) { return; } addPoints(player.playerNumber, scoreType); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); background = Content.Load <Texture2D>("back"); screenCenter = new Vector2(Window.ClientBounds.Width / 2, Window.ClientBounds.Height / 2); var shipTexture = Content.Load <Texture2D>("spaceship"); player = new SpaceShip(Content.Load <Texture2D>("spaceship"), new Vector2(screenCenter.X - shipTexture.Width / 2, screenCenter.Y - shipTexture.Height / 2), Color.White); }
//játék ideiglenes elindítása private void buttonStart_Click(object sender, RoutedEventArgs e) { buttonStart.IsEnabled = false; for (int i = 0; i < 10; i++) { asteroids.Add(new Asteroid(drawingArea)); gameObject.Add(asteroids.Last()); } spaceShip = new SpaceShip(drawingArea); gameObject.Add(spaceShip); timer.Start(); }
public Projectile(Vector2 position, float rotation, SpriteAnimation projectileAnimation, SpaceShip projectileSource, GameSettings settings) { m_projectile = projectileAnimation; this.position = position; this.rotation = rotation; m_projectileSource = projectileSource; m_settings = settings; // set the acceleration and velocity of the projectile m_acceleration = 9.0f; m_velocity.X = (float) (m_acceleration * Math.Cos(MathHelper.ToRadians(m_rotation - 90))); m_velocity.Y = (float) (m_acceleration * Math.Sin(MathHelper.ToRadians(m_rotation - 90))); m_offset = new Vector2(2.0f, 2.0f); m_size = new Vector2(4.0f, 4.0f); }
public Projectile(Vector2 position, float rotation, SpriteAnimation projectileAnimation, SpaceShip projectileSource, GameSettings settings) { m_projectile = projectileAnimation; this.position = position; this.rotation = rotation; m_projectileSource = projectileSource; m_settings = settings; // set the acceleration and velocity of the projectile m_acceleration = 9.0f; m_velocity.X = (float)(m_acceleration * Math.Cos(MathHelper.ToRadians(m_rotation - 90))); m_velocity.Y = (float)(m_acceleration * Math.Sin(MathHelper.ToRadians(m_rotation - 90))); m_offset = new Vector2(2.0f, 2.0f); m_size = new Vector2(4.0f, 4.0f); }
public SpaceShipSystem(int numberOfSpaceShips, SpriteSheetCollection spriteSheets, ProjectileSystem projectileSystem, GameSettings settings, ContentManager content) { this.numberOfSpaceShips = numberOfSpaceShips; if(spriteSheets != null) { m_spaceShipSprites = spriteSheets.getSpriteSheet("SpaceShip"); } m_projectileSystem = projectileSystem; m_settings = settings; // initialize all space ships if(m_settings == null || content == null || m_spaceShipSprites == null) { return; } m_spaceShips = new SpaceShip[m_maxSpaceShips]; m_spaceShips[0] = new SpaceShip(PlayerIndex.One, new Vector2(settings.screenWidth * 0.2f, settings.screenHeight * 0.2f), 135, m_spaceShipSprites, projectileSystem, settings, content); m_spaceShips[1] = new SpaceShip(PlayerIndex.Two, new Vector2(settings.screenWidth * 0.8f, settings.screenHeight * 0.8f), -45, m_spaceShipSprites, projectileSystem, settings, content); m_spaceShips[2] = new SpaceShip(PlayerIndex.Three, new Vector2(settings.screenWidth * 0.2f, settings.screenHeight * 0.8f), 45, m_spaceShipSprites, projectileSystem, settings, content); m_spaceShips[3] = new SpaceShip(PlayerIndex.Four, new Vector2(settings.screenWidth * 0.8f, settings.screenHeight * 0.2f), -135, m_spaceShipSprites, projectileSystem, settings, content); }
private static void LoadSpaceObjects() { //TODO: optimize objects spreading LoadBackgroundStars(); SpaceObjectList.Add(new Ufo(new Point(Width / 2, 0))); SpaceShip = new SpaceShip(new Point(0, Height / 2)); SpaceShip.MessageDie += Finish; SpaceObjectList.Add(SpaceShip); SpawnAsteroids(MaxBigAsteroidsCount, MaxMediumAsteroidsCount, MaxSmallAsteroidsCount); SmallEnergyPack SmallEnergyPack = new SmallEnergyPack(new Point(Width, Random.Next(0, Height))); SpaceObjectList.Add(SmallEnergyPack); }
public PlayingState() { spaceShip = new SpaceShip(); bullets = new GameObjectList(); rocks = new GameObjectList(); score = new Score(); for (int i = 0; i < 19; i++) { this.rocks.Add(new Rock(Rock.randomRockSize())); } this.Add(new SpriteGameObject("spr_background")); this.Add(bullets); this.Add(rocks); this.Add(spaceShip); this.Add(score); }
public PlayingState() { SpriteGameObject background = new SpriteGameObject("spr_background"); spaceShip = new SpaceShip(); bullets = new GameObjectList(); rocks = new GameObjectList(); score = new Score(); this.Add(background); this.Add(spaceShip); this.Add(bullets); this.Add(rocks); this.Add(score); for (int i = 0; i < 20; i++) { rocks.Add(new Rock()); } }
public SpaceShipSystem(int numberOfSpaceShips, SpriteSheetCollection spriteSheets, ProjectileSystem projectileSystem, GameSettings settings, ContentManager content) { this.numberOfSpaceShips = numberOfSpaceShips; if (spriteSheets != null) { m_spaceShipSprites = spriteSheets.getSpriteSheet("SpaceShip"); } m_projectileSystem = projectileSystem; m_settings = settings; // initialize all space ships if (m_settings == null || content == null || m_spaceShipSprites == null) { return; } m_spaceShips = new SpaceShip[m_maxSpaceShips]; m_spaceShips[0] = new SpaceShip(PlayerIndex.One, new Vector2(settings.screenWidth * 0.2f, settings.screenHeight * 0.2f), 135, m_spaceShipSprites, projectileSystem, settings, content); m_spaceShips[1] = new SpaceShip(PlayerIndex.Two, new Vector2(settings.screenWidth * 0.8f, settings.screenHeight * 0.8f), -45, m_spaceShipSprites, projectileSystem, settings, content); m_spaceShips[2] = new SpaceShip(PlayerIndex.Three, new Vector2(settings.screenWidth * 0.2f, settings.screenHeight * 0.8f), 45, m_spaceShipSprites, projectileSystem, settings, content); m_spaceShips[3] = new SpaceShip(PlayerIndex.Four, new Vector2(settings.screenWidth * 0.8f, settings.screenHeight * 0.2f), -135, m_spaceShipSprites, projectileSystem, settings, content); }
// get the score colour based on the space ship colour public Color getColour(SpaceShip spaceShip) { if (spaceShip == null) { return(Color.White); } switch (spaceShip.colour) { case SpaceShipColour.Red: return(m_colourRed); case SpaceShipColour.Blue: return(m_colourBlue); case SpaceShipColour.Green: return(m_colourGreen); case SpaceShipColour.Yellow: return(m_colourYellow); } return(Color.White); }
public PlayingState() { ship = new SpaceShip(); bullets = new GameObjectList(); rocks = new GameObjectList(); score = new Score(); string[] rock = new string[] { "spr_rock1", "spr_rock2", "spr_rock3" }; this.Add(new SpriteGameObject("spr_background")); this.Add(ship); this.Add(bullets); this.Add(rocks); this.Add(score); for (int i = 0; i < rockAmount; i++) { rockType = rock[GameEnvironment.Random.Next(3)]; this.rocks.Add(new Rock(rockType)); } }
// add a corresponding number of points to a player's score (based on space ship object) public void addPoints(SpaceShip player, ScoreType scoreType) { if(player == null) { return; } addPoints(player.playerNumber, scoreType); }
public LaserShooting(SpaceShip spaceShip) : base(spaceShip.X, spaceShip.Y, 1.5 * spaceShip.VX, 1.5 * spaceShip.VY) { }
public void TimeInPlayer(int time) { PlayerTimer = time; Player = new SpaceShip(new Point(500, 500), ScreenDim); }
// spawn a projectile at a position with a rotation from a specific space ship public void spawnProjectile(Vector2 position, float rotation, SpaceShip spaceShip) { if(spaceShip == null) { return; } // get the colour of the projectile SpriteAnimation projectileAnimation = null; if(spaceShip.colour == SpaceShipColour.Red) { projectileAnimation = m_projectileAnimations[0]; } else if(spaceShip.colour == SpaceShipColour.Blue) { projectileAnimation = m_projectileAnimations[1]; } else if(spaceShip.colour == SpaceShipColour.Green) { projectileAnimation = m_projectileAnimations[2]; } else if(spaceShip.colour == SpaceShipColour.Yellow) { projectileAnimation = m_projectileAnimations[3]; } // create the projectile and store it m_projectiles.Add(new Projectile(position, rotation, projectileAnimation, spaceShip, m_settings)); m_laserSound.Play(); }
// get the score colour based on the space ship colour public Color getColour(SpaceShip spaceShip) { if(spaceShip == null) { return Color.White; } switch(spaceShip.colour) { case SpaceShipColour.Red: return m_colourRed; case SpaceShipColour.Blue: return m_colourBlue; case SpaceShipColour.Green: return m_colourGreen; case SpaceShipColour.Yellow: return m_colourYellow; } return Color.White; }