Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Drawing;
- namespace func_rocket
- {
- public class LevelsTask
- {
- static readonly Physics StandardPhysics = new Physics();
- static double distance;
- static Rocket rocket = new Rocket(new Vector(200, 500), Vector.Zero, -0.5*Math.PI);
- static Vector target = new Vector(600, 200);
- public static Vector GravityWhiteHole(double x, double y)
- {
- var vector = new Vector(x - 600, y - 200);
- distance = Math.Sqrt(Math.Pow(600 - x, 2.0) + Math.Pow(200 - y, 2.0));
- return vector.Normalize() * (140 * distance) / (distance * distance + 1);
- }
- public static Vector GravityBlackHole(double x, double y)
- {
- var coorXOfAnomalies = (200 + 600) / 2.0;
- var coorYOfAnomalies = (500 + 200) / 2.0;
- var vector = new Vector(x - coorXOfAnomalies, y - coorYOfAnomalies);
- distance =
- Math.Sqrt(Math.Pow(coorXOfAnomalies - x, 2.0) + Math.Pow(coorYOfAnomalies - y, 2.0));
- return -1 * vector.Normalize() * (300 * distance) / (distance * distance + 1);
- }
- public static Level CreateLevel(string name, Gravity gravity)
- {
- return new Level(name, rocket, target, gravity, StandardPhysics);
- }
- public static IEnumerable<Level> CreateLevels()
- {
- yield return CreateLevel("Zero", (size, location) => Vector.Zero);
- yield return CreateLevel("Heavy", (size, location) => new Vector(0.0, 0.9));
- yield return new Level("Up", rocket, new Vector(700, 500),
- (size, location) => new Vector(0, -(300 / (size.Height - location.Y + 300.0))), StandardPhysics);
- yield return CreateLevel("WhiteHole",
- (size, location) => GravityWhiteHole(location.X, location.Y));
- yield return CreateLevel("BlackHole",
- (size, location) => GravityBlackHole(location.X, location.Y));
- yield return CreateLevel("BlackAndWhite",
- (size, location) => (GravityBlackHole(location.X, location.Y) + GravityWhiteHole(location.X, location.Y))/2);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement