Esempio n. 1
0
		public Game()
		{
			Engine engine = new Engine("Game", 1280, 720, fullscreen: true);
			Player player = new Player(64, 16, true);
			player.LoadAssets(engine);
			engine.SpawnObject("player", player);

			Ball ball = new Ball(12, 12, false);
			ball.LoadAssets(engine);
			engine.SpawnObject("ball", ball);

			Wall[] walls = {
				new Wall(0, 0, engine.Width, 10),
				new Wall(0, 0, 10, engine.Height),
				new Wall(engine.Width - 10, 0, 10, engine.Height), 
			};
			foreach (var wall in walls)
			{
				engine.SpawnObject("wall", wall);
			}
#if DEBUG
			engine.debugCollisions = true;
#endif
			engine.Run();
		}
Esempio n. 2
0
		//public static EnemyAirEasy enemyAir;

		public static void Init()
		{
			engine = new Engine("Game", 1280, 720, 60, false);

			Asset.BasePath = "../../assets/";

			players = new Player[4];

			Utils.LoadAssets(engine, "playerDefault", "playerDefault.png", 1, 1);
			Utils.LoadAssets(engine, "startHub", "base.png", 1, 1);
			currentEnvironment = new StartEnvironment(1280, 720);
			Utils.LoadAssets(engine, "hero", "images.png", 4, 4);
			players[0] = new PlayerAir(60, 80, true, "hero", EnviromentType.StartEnviroment);
			players[0].X = 600;
			players[0].Y = 130;
			players[1] = new PlayerFire(60, 80, false, "hero", EnviromentType.StartEnviroment);
			players[1].X = 800;
			players[1].Y = 330;
			players[2] = new PlayerEarth(60, 80, true, "hero", EnviromentType.StartEnviroment);
			players[2].X = 600;
			players[2].Y = 530;
			players[3] = new PlayerWater(60, 80, true, "hero", EnviromentType.StartEnviroment);
			players[3].X = 400;
			players[3].Y = 330;

			SpriteAsset sprite = new SpriteAsset("Montagna.png", 0, 0);
			Utils.LoadAssets(engine, "PlayerFire", "PlayerFire.png", 6, 4);
			Utils.LoadAssets(engine, "LeftFire", "LeftFire.png", 2, 4);

			Utils.LoadAssets(engine, "backgroundEarth", "backgroundEarth.png", 1, 1);
			Utils.LoadAssets(engine, "backgroundFire", "backgroundFire.png", 1, 1);
			Utils.LoadAssets(engine, "backgroundAir", "Montagna.png", 1, 1);
			Utils.LoadAssets(engine, "backgroundWater", "Fondale.png", 1, 1);

			/*Utils.LoadAssets(engine, "background", "background.png", 1, 1);
			enviromentEarth = new EnviromentEarth(1280, 720);

			EnemyEarth[] enemyEarths = new EnemyEarth[Utils.Randomize(3, 7)];
			for (int i = 0; i < enemyEarths.Length; i++)
			{
				int rX, rY;
				do
				{
					rX = Utils.Randomize(1, 15);
					rY = Utils.Randomize(1, 32);
				} while (enviromentEarth.tiles[Utils.GetPos(rX, rY, 14)].tileType != TileType.None);
				if (Utils.Randomize(0, 100) < 25)
					enemyEarths[i] = new EnemyEarthMedium(engine, rX * 80, rY * 80);
				else
					enemyEarths[i] = new EnemyEarthMedium(engine, rX * 80, rY * 80);
			}

			Utils.LoadAssets(engine, "background", "background.png", 1, 1);
			enviromentEarth = new EnviromentEarth(1280, 720);*/

			Utils.LoadAssets(engine, "undestrWall", "undestrWall.png", 1, 1);
			Utils.LoadAssets(engine, "destrWall", "destrWall.png", 1, 1);
			Utils.LoadAssets(engine, "cloud", "cloud.png", 1, 1);
			Utils.LoadAssets(engine, "blob", "Blob.png", 2, 3);
			Utils.LoadAssets(engine, "bullet", "EnemyHeart.png", 1, 2);

#if DEBUG
            engine.debugCollisions = true;
#endif
			engine.SpawnObject("startHub", currentEnvironment);
			engine.SpawnObject("player0", players[0]);
			engine.SpawnObject("player1", players[1]);
			engine.SpawnObject("player2", players[2]);
			engine.SpawnObject("player3", players[3]);
			//engine.SpawnObject("enemy", enemy);
			/*for (int i = 0; i < enviromentEarth.tiles.Length; i++)
			{
				engine.SpawnObject("wall" + i, enviromentEarth.tiles[i]);
			}
			for (int i = 0; i < enemyEarths.Length; i++)
			{
				engine.SpawnObject("enemy" + Utils.Randomize(0, Int32.MaxValue), enemyEarths[i]);
			}
			//engine.SpawnObject("enemyAir", enemyAir);*/

		}
Esempio n. 3
0
        static void Main(string[] args)
        {
            Engine engine = new Engine("test", 1024, 768, 60, false, false);
            engine.debugCollisions = true;

            // set default directory for assets, will be appened to all assets's path
            Asset.BasePath = "..\\..\\Assets";

            // load repeating texture
            var repeatingGoblins = new SpriteAsset("goblins.png", 100, 100, 150, 150, repeatx: true, repeaty: true);
            // auto hitbox and spriteasset with repeatx or/and repeaty are NOT compatible
            var obj = new SpriteObject(repeatingGoblins.Width + 20, repeatingGoblins.Height + 100);
            obj.CurrentSprite = repeatingGoblins;

            obj.OnUpdate += sender =>
            {
                var s = (SpriteObject)sender;
                s.SpriteOffset += new Vector2(10f, 0f) * s.DeltaTime;
            };

            // text
            TextConfig.Default = new TextConfig(new Asset("font.png"), charToSprite);
            var semiTransparentText = new TextObject(0.66f, Color.Red, 0.8f);
            semiTransparentText.Text = "SEMI TRANSPARENT";
            semiTransparentText.Y = obj.Height;
            var bigText = new TextObject(1.1f, Color.CadetBlue);
            bigText.Text = "BIG TEXT";
            var semiTransparentTextMeasure = semiTransparentText.Measure();
            bigText.Y = semiTransparentTextMeasure.Y + semiTransparentText.Y;
            var bigTextMeasure = bigText.Measure();

            // hitboxes
            var spriteSheet = new SpriteAsset("rob.png");
            var tileWidth = spriteSheet.Width/22;
            var tileHeight = spriteSheet.Height/1;
            var spriteAsset = new SpriteAsset("rob.png", 0, 0, tileWidth, tileHeight);
            var spriteH = new SpriteObject(spriteAsset.Width, spriteAsset.Height, true);
            spriteH.Y = bigText.Y + bigTextMeasure.Y;
            spriteH.CurrentSprite = spriteAsset;
            spriteH.Scale = new Vector2(5f, 5f);

            // spawn gameobjects
            engine.SpawnObject("obj", obj);

            engine.SpawnObject("semiTransparentText", semiTransparentText);
            engine.SpawnObject("bigText", bigText);

            engine.SpawnObject("spriteH", spriteH);

            engine.Run();
        }
Esempio n. 4
0
		//public static EnemyAirEasy enemyAir;


		public static void Init()
		{
			engine = new Engine("Game", 1280, 720, 60, false);

			Asset.BasePath = "../../assets/";

			Utils.LoadAssets(engine, "playerDefault", "playerDefault.png", 1, 1);
			/*player = new PlayerEarth(60, 80, true, "playerDefault");*/
            Utils.LoadAssets(engine, "startHub", "base.png", 1, 1);
            startEnvironment = new StartEnvironment(1280, 720);
            Utils.LoadAssets(engine, "hero", "images.png", 4, 4);
            player = new PlayerAir(60, 80, true, "hero");
            player.X = 600;
            player.Y = 130;
            player2 = new PlayerFire(60, 80, true, "hero");
            player2.X = 800;
            player2.Y = 330;
            player3 = new PlayerEarth(60, 80, true, "hero");
            player3.X = 600;
            player3.Y = 530;
            player4 = new PlayerWater(60, 80, true, "hero");
            player4.X = 400;
            player4.Y = 330;
            

			/*Utils.LoadAssets(engine, "background", "background.png", 1, 1);
			enviromentEarth = new EnviromentEarth(1280, 720);

			EnemyEarth[] enemyEarths = new EnemyEarth[Utils.Randomize(3, 7)];
			for (int i = 0; i < enemyEarths.Length; i++)
			{
				int rX, rY;
				do
				{
					rX = Utils.Randomize(1, 15);
					rY = Utils.Randomize(1, 32);
				} while (enviromentEarth.tiles[Utils.GetPos(rX, rY, 14)].tileType != TileType.None);
				if (Utils.Randomize(0, 100) < 25)
					enemyEarths[i] = new EnemyEarthMedium(engine, rX * 80, rY * 80);
				else
					enemyEarths[i] = new EnemyEarthMedium(engine, rX * 80, rY * 80);
			}

			Utils.LoadAssets(engine, "background", "background.png", 1, 1);
			enviromentEarth = new EnviromentEarth(1280, 720);

		//	Utils.LoadAssets(engine, "undestrWall", "undestrWall.png", 1, 1);
		//	Utils.LoadAssets(engine, "destrWall", "destrWall.png", 1, 1);*/

#if DEBUG
			engine.debugCollisions = true;
#endif
            engine.SpawnObject("startHub", startEnvironment);
			engine.SpawnObject("player", player);
            engine.SpawnObject("player2", player2);
            engine.SpawnObject("player3", player3);
            engine.SpawnObject("player4", player4);
			//engine.SpawnObject("enemy", enemy);
			/*for (int i = 0; i < enviromentEarth.tiles.Length; i++)
			{
				engine.SpawnObject("wall" + i, enviromentEarth.tiles[i]);
			}
			for (int i = 0; i < enemyEarths.Length; i++)
			{
				engine.SpawnObject("enemy" + Utils.Randomize(0, Int32.MaxValue), enemyEarths[i]);
			}
			//engine.SpawnObject("enemyAir", enemyAir);*/

		}