public Player(World world, Vector2 position) : base(world, position, new Vector2(MAX_SPEED_X, 0), new Vector2(SIZE_X, SIZE_Y), new List<AnimationSet> { new AnimationSet("Run", TextureBin.Get("RunGreenHat"), 5, 16, 2, true, 0), }, "Run", true, true, HEALTH) { }
public Zombie(World world, Vector2 position) : base(world, position, new Vector2(0, 0), new Vector2(SIZE_X, SIZE_Y), new List<AnimationSet> { new AnimationSet("Main", TextureBin.Get("Zombie"), 3, 16, 3, true, 0), }, "Main", true, true, HEALTH) { }
public Laser(World world, Vector2 position, Vector2 direction) : base(world, position, direction, new Vector2(1, 1), TextureBin.Get("Pixel"), false, false, 99) { this.Direction = direction; this.Velocity = world.Player.Velocity + direction * LASER_SPEED; this.DamageInflicted = LASER_DAMAGE; this.timeLeft = LASER_LIFESPAN; this.CollidesWithTerrain = false; Vector2 side = Vector2.Normalize(MathExtra.GetPerpendicularVector(this.Velocity)); Vector2 p1 = this.Position + side * THICKNESS; Vector2 cp1 = p1 + side * (THICKNESS + COLLISION_FORGIVENESS); Vector2 p2 = this.Position - side * THICKNESS; Vector2 cp2 = p2 - side * (THICKNESS + COLLISION_FORGIVENESS); endPoints.Add(p1); endPoints.Add(p2); // the collision endpoints are more forgiving collisionEndPoints.Add(cp1); collisionEndPoints.Add(cp2); for (int i = 0; i < endPoints.Count; i++) endPoints[i] += Velocity; for (int i = 0; i < collisionEndPoints.Count; i++) collisionEndPoints[i] += Velocity; }
/// <summary> /// Makes a new unanimated object. /// </summary> /// <param name="world">The world in which the object exists.</param> /// <param name="position">The position of the object.</param> /// <param name="velocity">The velocity at which the object is moving initially.</param> /// <param name="size">The size of the object.</param> /// <param name="texture">The texture of the object.</param> public GameObject(World world, Vector2 position, Vector2 velocity, Vector2 size, Texture2D texture, bool gravitable, bool collidesWithTerrain, int health) : this(world, position, velocity, size, new List<AnimationSet> { new AnimationSet("_", texture, 1, texture.Width, 1, false, 0) }, "_", gravitable, collidesWithTerrain, health) { }
public TerrainGenerator(World world) { this.world = world; if (Engine.FirstPlay) NextPatterns.Add(TerrainPattern.Tutorial); else NextPatterns.Add(TerrainPattern.Flat); }
public static void ParticleBurstGravitySpin(World world, Vector2 position, int amount) { for (int i = 0; i < amount; i++) { Particle n = new ShrinkParticle(world, TextureBin.Get("Pixel"), position + MathExtra.GetRandomUnitVector() * MathExtra.RandomFloat() * 10, MathExtra.GetRandomUnitVector() * MathExtra.RandomFloat() * 20, 40 + MathExtra.RandomInt(40), 10); n.StretchScalar = 10; n.Acceleration = MathExtra.GetRandomUnitVector() * 1f; world.Particles.Add(n); } }
public Particle(World world, Texture2D texture, Vector2 position, Vector2 velocity, int life) { World = world; Position = position; Velocity = velocity; Sprite = texture; Life = life; LifeStart = life; SpriteOrigin = new Vector2(texture.Width / 2, texture.Height / 2); }
/// <summary> /// Makes a new animated object. /// </summary> /// <param name="world"></param> /// <param name="position"></param> /// <param name="velocity"></param> /// <param name="size"></param> /// <param name="animations">All the animations of the object.</param> /// <param name="startAnimation">The name of the first animation to play of this object.</param> /// <param name="gravitable"></param> public GameObject(World world, Vector2 position, Vector2 velocity, Vector2 size, List<AnimationSet> animations, String startAnimation, bool gravitable, bool collidesWithTerrain, int health) { this.world = world; this.Position = position; this.Velocity = velocity; this.Size = size; this.gravitable = gravitable; this.Animations = animations; this.CurAnimation = GetAnimationByName(startAnimation); this.CollidesWithTerrain = collidesWithTerrain; this.Health = health; }
public Vampire(World world, Vector2 position, EnemyPattern pattern) : base(world, position, Vector2.Zero, new Vector2(SIZE_X, SIZE_Y), new List<AnimationSet> { new AnimationSet("Main", TextureBin.Get("FlyerRed2"), 3, 16, 3, true, 0) }, "Main", false, false, HEALTH) { attackPattern = pattern; if (position.Y < world.Player.Position.Y) { maxHeight = Engine.ScreenResolution.Y - position.Y; minHeight = position.Y; } else maxHeight = position.Y; minHeight = (Engine.ScreenResolution.Y - position.Y) * 2; }
public SuperZombie(World world, Vector2 position) : base(world, position) { Size *= 2; }
/// <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); PrimitiveBatch = new PrimitiveBatch(GraphicsDevice); TextureBin.LoadContent(Content); SoundBin.LoadSounds(Content); world = new World(ScreenResolution.X, ScreenResolution.Y); }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { // Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) this.Exit(); Input.Update(); world.Update(); if (ShouldReset) { world = new World(ScreenResolution.X, ScreenResolution.Y); ShouldReset = false; FirstPlay = false; } base.Update(gameTime); }
public Block(World world, Vector2 position, Vector2 size) : base(world, position, Vector2.Zero, size, TextureBin.Get("Pixel"), false, false, 99) { }
public void Update(World world) { // if not panning, just follow our target, otherwise pan if (!InPan) { // but we might just be centered on a point, so check that we have a target. if (target != null) position = target.Position; } else { // to avoid a jarring jump, we need to update the pan position to match up with the // target's position if we have one. if (target != null) nextPos = target.Position; position = position.PushTowards(nextPos, PAN_SPEED * Vector2.One); if (position == nextPos) nextPos = Vector2.Zero; } // if we are still in the middle of zooming to a spot if (InZoomTransition) { Zoom = nextZoom > Zoom ? Math.Min(Zoom + ZOOM_SPEED, nextZoom) : Math.Max(Zoom - ZOOM_SPEED, nextZoom); // done zooming? if (Zoom == nextZoom) nextZoom = 0; } }
public ShrinkParticle(World world, Texture2D texture, Vector2 position, Vector2 velocity, int life, int stretch) : base(world, texture, position, velocity, life) { startStretch = stretch; }