/// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { using (Game1 game = new Game1()) { game.Run(); } }
public ObjectSpawner(Game1 game) : base(game) { this.game = game; random = new Random(); Reset(); }
public Background(Game1 game) : base(game) { back = new List<BackgroundElement>(); farBack = new List<BackgroundElement>(); int statX = 0; Texture2D tex = game.Content.Load<Texture2D>(@"Backgrounds/bg_0"); for (int i = 0; i < 4; i++) { BackgroundElement b = new BackgroundElement(game, tex, 0.3f, statX, 0.2f, 0.27f); this.farBack.Add(b); statX += (int)(tex.Bounds.Width * b.scale); } statX = 0; tex = game.Content.Load<Texture2D>(@"Backgrounds/bg_1"); for (int i = 0; i < 4; i++) { BackgroundElement b = new BackgroundElement(game, tex, 0.3f, statX, 0.4f, 0.32f); this.farBack.Add(b); statX += (int)(tex.Bounds.Width * b.scale); //Console.WriteLine("Covered in terrains: {0} rad, left uncovered: {1}", angle - 4.4f, 2 * Math.PI - angle + 4.4f); } }
public AscentTerrain(Game1 game, float startAngle, double terrianHeight, bool hasFly) : base(game, startAngle, terrianHeight, hasFly) { texture = game.Content.Load<Texture2D>(@"Terrains/gr_2"); origin.X = texture.Width / 2 * scale; origin.Y = texture.Height / 2 * scale; boxCollider = new Rectangle(0, 0, (int)(texture.Bounds.Width * scale), (int)(texture.Bounds.Height * scale)); offsetAngle = 0.029f; // create list of smaller colliders that will act as steps: /* * -------| * ------------| * ----------------| * ----------------------| */ stepColliders = new List<Rectangle>(); widthStep = (int)(texture.Width * scale / 4); int heightOffset = (int)(texture.Height * scale / 4); heightStep = (int)(heightOffset / 4); for (int i = 0; i < 4; i++) { Rectangle step = new Rectangle(0, 0, widthStep * (i + 1), heightStep); stepColliders.Add(step); } }
public PlainTerrain(Game1 game, float startAngle, double terrianHeight, bool hasFly) : base(game, startAngle, terrianHeight, hasFly) { texture = game.Content.Load<Texture2D>(@"Terrains/gr_0"); origin.X = texture.Width / 2 * scale; origin.Y = texture.Height / 2 * scale; boxCollider = new Rectangle(0, 0, (int)(texture.Bounds.Width * scale), (int)(texture.Bounds.Height * scale)); offsetAngle = 0.03f; }
public ScoreDisplay(Game1 game) : base(game) { currentPoints = 0; currentSize = 50; timeElapsed = 0; this.game = game; pointsPosition = new Vector2(20, 15); sizePosition = new Vector2(20, 65); timerPosition = new Vector2(game.screenWidth - 450, game.screenHeight - 50); }
public BackgroundElement(Game1 game, Texture2D texture, float alpha, int startX, float movementOffset, float yOffset) : base(game) { this.game = game; this.texture = texture; this.alpha = alpha; this.position.X = startX; this.movementOffset = movementOffset; this.yOffset = yOffset; scale = 0.25f; }
public MeteorBig(Game1 game) : base(game) { texture = game.Content.Load<Texture2D>(@"ObjectsAnimations/MeteorBig/bm_0"); position.X = game.screenWidth - 50; position.Y = 10; origin.X = texture.Width / 2 * scale; origin.Y = texture.Height / 2 * scale; rotationAngle = 0.9f; scale = 0.05f; Initialize(); }
public Terrain(Game1 game, float startAngle, double terrianHeight, bool hasFly) : base(game) { this.game = game; angle = startAngle; tHeight = terrianHeight; Random r = new Random(); float flyOffset = (float)r.NextDouble() * 0.055f; // max offfset angle if (hasFly) { fly = new Fly(game, startAngle + flyOffset, this); } isOnScreen = false; }
public MeteorSmall(Game1 game) : base(game) { this.game = game; texture = game.Content.Load<Texture2D>(@"ObjectsAnimations/MeteorSmall/sm_0"); Random r = new Random(); position.X = r.Next(game.screenWidth); position.Y = -10; scale = 0.13f; boxCollider = new Rectangle(0, 0, (int)(texture.Bounds.Width * scale * 0.6f), (int)(texture.Bounds.Height * scale * 0.6f)); Initialize(); }
public Earth(Game1 game) : base(game) { this.game = game; this.position = new Vector2(game.screenWidth * 0.5f, game.screenHeight * 6.97f); // earth center texture = game.Content.Load<Texture2D>(@"Earth"); origin.X = texture.Width / 2; origin.Y = texture.Height / 2; radius = texture.Bounds.Height * 0.5f * scale; lowestH = 0.01; secondH = 0.08; thirdH = 0.15; topH = 0.2; Initialize(); }
public Fly(Game1 game, float startAngle, Terrain terrain) : base(game) { this.game = game; this.terrain = terrain; this.position = new Vector2(); Random r = new Random(); scale = 0.5f; //position.X = r.Next(game.screenWidth); position.Y = game.screenHeight * 0.5f; positionAngle = startAngle; texture = game.Content.Load<Texture2D>(@"ObjectsAnimations/Fly/fl_0"); origin.X = texture.Width * 2 * scale; origin.Y = terrain.position.Y - 100; boxCollider = new Rectangle(0, 0, (int)(texture.Bounds.Width * scale), (int)(texture.Bounds.Height * scale)); Initialize(); }
public VolcanoTerrain(Game1 game, float startAngle, double terrianHeight, bool hasFly) : base(game, startAngle, terrianHeight, hasFly) { texture = game.Content.Load<Texture2D>(@"Terrains/vo_0"); origin.X = texture.Width / 2 * scale; origin.Y = texture.Height / 2 * scale; boxCollider = new Rectangle(0, 0, (int)(texture.Bounds.Width * scale), (int)(texture.Bounds.Height * scale)); // create list of smaller colliders that will act as steps and lava: /* * |---| * |---| * -------| |---| |------ * ------------| |------------- * ----------------| |----------------- * ----------------------| |------------------------ */ stepCollidersAscend = new List<Rectangle>(); widthStep = (int)(texture.Width * scale / 10); int heightOffset = (int)(texture.Height * scale / 4); heightStep = (int)(heightOffset / 4); for (int i = 0; i < 4; i++) { Rectangle step = new Rectangle(0, 0, widthStep * (i + 1), heightStep); stepCollidersAscend.Add(step); } stepCollidersDescend = new List<Rectangle>(); for (int i = 0; i < 4; i++) { Rectangle step = new Rectangle(0, 0, widthStep * (i + 1), heightStep); stepCollidersDescend.Add(step); } lavaCollider = new Rectangle(0, 0, (int)(boxCollider.Width * 0.02), (int)(texture.Bounds.Height * scale)); offsetAngle = 0.055f; volcanoAnimation = Textures.VolcanoAnimation; VolcanoAnimationController.PlayAnimation(volcanoAnimation); }
public LavaPitTerrain(Game1 game, float startAngle, double terrianHeight, bool hasFly) : base(game, startAngle, terrianHeight, hasFly) { texture = game.Content.Load<Texture2D>(@"Terrains/lp_0"); origin.X = texture.Width / 2 * scale; origin.Y = texture.Height / 2 * scale; // colliders boxCollider = new Rectangle(0, 0, (int)(texture.Bounds.Width * scale), (int)(texture.Bounds.Height * 0.9f * scale)); /* * --| |--- * --| |--- * --|=====|--- */ pitCollider = new Rectangle(0, 0, (int)(boxCollider.Width * 0.8f), (int)(boxCollider.Height * 0.66f)); leftRidgeCollider = new Rectangle(0, 0, (int)(boxCollider.Width * 0.1f), boxCollider.Height); rightRidgeCollider = new Rectangle(0, 0, (int)(boxCollider.Width * 0.1f), boxCollider.Height); offsetAngle = 0.035f; }
public Bird(Game1 game) : base(game) { this.game = game; this.position = new Vector2(); Random r = new Random(); position.X = r.Next(game.screenWidth); position.Y = 0; startPosition = position; target = new Vector2(); scale = 0.3f; texture = game.Content.Load<Texture2D>("ObjectsAnimations/Bird/d_FLAP_0"); origin.X = texture.Width / 2 * scale; origin.Y = texture.Height / 2 * scale; boxCollider = new Rectangle(0, 0, (int)(texture.Bounds.Width * 0.8f * scale), (int)(texture.Bounds.Height * 0.4f * scale)); game.birdSpawnedSound.Play(); Initialize(); }
public Player(Game1 game) : base(game) { this.game = game; scoreDisplay = new ScoreDisplay(game); scoreDisplay.currentSize = (int)(scale * 1000); angle = MIN_ANGLE; this.position = new Vector2(); position.X = game.earth.radius * (float)Math.Cos(angle) + game.screenWidth * 0.4f; position.Y = 100; texture = game.Content.Load<Texture2D>(@"PlayerAnimations/Idle/t_IDLE_0"); origin.X = texture.Width / 2 * scale; origin.Y = texture.Height / 2 * scale; boxCollider = new Rectangle(0, 0, (int)(texture.Bounds.Width * scale * colliderOffsetX), (int)(texture.Bounds.Height * scale * colliderOffsetY)); jumpingTime = new TimeSpan(); crouchingTime = new TimeSpan(); Initialize(); }
static void Main() { using (var game = new Game1()) game.Run(); }