static void Main(string[] args) { Window2D window = new Window2D(ScreenWidth, ScreenHeight, true, "Pew Pew - VikingStein 2.5D - By Metaldemon", ScreenWidth, ScreenHeight); MainGameLoop = new GameLoop(new LoadState()); Glfw.SwapInterval(false); new Thread(_LoadMusic).Start(); MainGameLoop.Start(window); ContentManager.DisposeAll(); }
static void Main(string[] args) { Window2D window = new Window2D(ScreenWidth, ScreenHeight, true, "Pew Pew - VikingStein 2.5D - By Metaldemon", ScreenWidth, ScreenHeight); MainGameLoop = new GameLoop(new LoadState()); Glfw.SwapInterval(false); new Thread(_LoadMusic).Start(); MainGameLoop.Start(window); ContentManager.DisposeAll(); }
public static World LoadMap(string file, Window2D window) { World w = new World(); List <Light> lightBuffer = new List <Light>(); StreamReader sr = new StreamReader(GameUtils.GetAppPath() + file); w.Construct(int.Parse(sr.ReadLine()), int.Parse(sr.ReadLine())); w.levelCaptionTop = sr.ReadLine(); w.levelCaptionBottom = sr.ReadLine(); string line = string.Empty; int lightcount = 0; while ((line = sr.ReadLine()) != "END") { if (line.StartsWith("light")) { lightcount++; string[] split = line.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries); lightBuffer.Add(new Light(new Vector2(0, 0), new Color4(byte.Parse(split[1]), byte.Parse(split[2]), byte.Parse(split[3]), 255), int.Parse(split[4]), split[5] == "true")); lightBuffer[lightBuffer.Count - 1].isActivated = split[6] == "true"; if (split.Length > 7) { lightBuffer[lightBuffer.Count - 1].width = int.Parse(split[7]); lightBuffer[lightBuffer.Count - 1].direction = int.Parse(split[8]); lightBuffer[lightBuffer.Count - 1].rotationSpeed = int.Parse(split[9]); } FontHandler.AddText(new Text("LOADING NEXT LEVEL...", "loading", new Vector2(400, 300), 1f)); string dots = string.Empty; for (int i = 0; i < lightcount; i++) { dots += "."; } FontHandler.AddText(new Text("PLUGGING IN THE LIGHTS", "loading2", new Vector2(400, 350), 0.8f)); FontHandler.AddText(new Text(dots, "loading3", new Vector2(400, 400), 0.8f)); window.PrepDraw(); FontHandler.Draw(); window.EndDraw(); FontHandler.TextList = new List <Text>(); } } int x = 0, y = 0; while ((line = sr.ReadLine()) != "END" && line != null) { for (x = 0; x < line.Length; x++) { if (char.IsNumber(line[x])) { byte nr = byte.Parse(line[x].ToString()); Light l = lightBuffer[nr]; l.Position = new Vector2(x * 32, y * 32); w.lightList.Add(l); w.gameGrid.AddTile("floor", x, y); continue; } switch (line[x]) { case '*': w.collisionGameGrid.AddTile("wall", x, y); break; case 'V': w.gameGrid.AddTile("floorv", x, y); w.collisionGameGrid.AddTile("door1", x, y); break; case 'H': w.gameGrid.AddTile("floorh", x, y); w.collisionGameGrid.AddTile("door2", x, y); break; case 'P': w.gameGrid.AddTile("floor", x, y); w.player = new Player("player", new Vector2(x * 32, y * 32)); break; case 'B': w.gameGrid.AddTile("rail", x, y); Light yellow2 = new Light(new Vector2(x * 32, y * 32), Color4.Yellow, 16f, false); yellow2.anglestep = 36f; w.lightList.Add(yellow2); w.EnemyList.Add(new Enemy(new Vector2(x * 32, y * 32), w, true)); w.EnemyList[w.EnemyList.Count - 1].Rotation = 0f; break; case 'W': w.gameGrid.AddTile("floor", x, y); w.EnemyList.Add(new Enemy(new Vector2(x * 32, y * 32), w)); w.EnemyList[w.EnemyList.Count - 1].Rotation = 0f; break; case 'A': w.gameGrid.AddTile("floor", x, y); w.EnemyList.Add(new Enemy(new Vector2(x * 32, y * 32), w)); w.EnemyList[w.EnemyList.Count - 1].Rotation = -90f; break; case 'S': w.gameGrid.AddTile("floor", x, y); w.EnemyList.Add(new Enemy(new Vector2(x * 32, y * 32), w)); w.EnemyList[w.EnemyList.Count - 1].Rotation = 180f; break; case 'D': w.gameGrid.AddTile("floor", x, y); w.EnemyList.Add(new Enemy(new Vector2(x * 32, y * 32), w)); w.EnemyList[w.EnemyList.Count - 1].Rotation = 90f; break; case 'T': w.collisionGameGrid.AddTile("terminal", x, y); w.lightList.Add(new Light(new Vector2((x - 1) * 32, y * 32), Color4.Green, 25f, false)); w.lightList[w.lightList.Count - 1].anglestep = 36f; w.lightList.Add(new Light(new Vector2((x + 1) * 32, y * 32), Color4.Green, 25f, false)); w.lightList[w.lightList.Count - 1].anglestep = 36f; w.lightList.Add(new Light(new Vector2(x * 32, (y - 1) * 32), Color4.Green, 25f, false)); w.lightList[w.lightList.Count - 1].anglestep = 36f; w.lightList.Add(new Light(new Vector2(x * 32, (y + 1) * 32), Color4.Green, 25f, false)); w.lightList[w.lightList.Count - 1].anglestep = 36f; break; case 'O': w.gameGrid.AddTile("off", x, y); Light red = new Light(new Vector2(x * 32, y * 32), Color4.Red, 25f, false); red.anglestep = 36f; w.lightList.Add(red); break; case 'R': w.gameGrid.AddTile("rail", x, y); Light yellow = new Light(new Vector2(x * 32, y * 32), Color4.Yellow, 16f, false); yellow.anglestep = 36f; w.lightList.Add(yellow); break; case 'M': w.collisionGameGrid.AddTile("mask", x, y); break; case 'E': w.gameGrid.AddTile("floor", x, y); Light red2 = new Light(new Vector2(x * 32, y * 32), Color4.Red, 50f, false); red2.anglestep = 36f; red2.isActivated = true; Light green = new Light(new Vector2(x * 32, y * 32), Color4.Green, 50f, false); green.anglestep = 36f; green.isActivated = false; w.lightList.Add(green); w.lightList.Add(red2); break; case ' ': w.gameGrid.AddTile("floor", x, y); break; default: Console.WriteLine("Unrecognized block in map. wtf?"); break; } } y++; } w.Build(window); return(w); }
static void Main(string[] args) { Window2D window = new Window2D(800, 600, true, "Infiltration - Cyberpunk GameJam - By Metaldemon", 800, 600); ContentManager.LoadTexture(GetAppPath() + "\\content\\Floor.png", "floor"); ContentManager.LoadTexture(GetAppPath() + "\\content\\Wall.png", "wall"); ContentManager.LoadTexture(GetAppPath() + "\\content\\Guy.png", "player"); ContentManager.LoadTexture(GetAppPath() + "\\content\\Turret.png", "turret"); ContentManager.LoadTexture(GetAppPath() + "\\content\\Particle.png", "particle"); ContentManager.LoadTexture(GetAppPath() + "\\content\\Terminal.png", "terminal"); ContentManager.LoadTexture(GetAppPath() + "\\content\\FloorOff.png", "off"); ContentManager.LoadTexture(GetAppPath() + "\\content\\FloorOn.png", "on"); ContentManager.LoadTexture(GetAppPath() + "\\content\\Door1.png", "door1"); ContentManager.LoadTexture(GetAppPath() + "\\content\\Door2.png", "door2"); ContentManager.LoadTexture(GetAppPath() + "\\content\\font.png", "font"); ContentManager.LoadTexture(GetAppPath() + "\\content\\terminalscreen.png", "terminalscreen"); ContentManager.LoadTexture(GetAppPath() + "\\content\\FloorV.png", "floorv"); ContentManager.LoadTexture(GetAppPath() + "\\content\\FloorH.png", "floorh"); ContentManager.LoadTexture(GetAppPath() + "\\content\\Maskwall.png", "mask"); ContentManager.LoadTexture(GetAppPath() + "\\content\\Rail.png", "rail"); fire = new Sound(GetAppPath() + "\\content\\audio\\fire.wav"); ouch = new Sound(GetAppPath() + "\\content\\audio\\ouch.wav"); boom = new Sound(GetAppPath() + "\\content\\audio\\boom.wav"); hacking = new Sound(GetAppPath() + "\\content\\audio\\hacking.wav"); complete = new Sound(GetAppPath() + "\\content\\audio\\complete.wav"); hit = new Sound(GetAppPath() + "\\content\\audio\\hit.wav"); fire.Gain = ouch.Gain = boom.Gain = hacking.Gain = complete.Gain = hit.Gain = 0.5f; if (music == null) { FontHandler.AddText(new Text("Loading game...", "loading", new Vector2(400, 300), 1f)); window.PrepDraw(); FontHandler.Draw(); window.EndDraw(); FontHandler.TextList = new List <Text>(); new Thread(_LoadAudio).Start(); } restart: World world = Loader.LoadMap("\\content\\maps\\map00.txt", window); world.map = 00; double totalTime = 0.0; double delta = 0.0; while (window.IsOpen) { Glfw.SwapInterval(false); totalTime += Glfw.GetTime(); delta = (float)Glfw.GetTime(); Glfw.SetTime(0.0); world.Update((float)delta / 3); if (music != null && music.Gain < 0.6f) { music.Gain += 0.0001f; } window.PrepDraw(); if (world.incrementMap || world.restartMap) { int newmap = world.map; if (world.incrementMap) { newmap++; } world.map = newmap; world.incrementMap = false; if (newmap == 15) { while (window.IsOpen) { int ypos = 100; FontHandler.AddText(new Text("THE WINNER IS YOU", "yay1", new Vector2(400, ypos), 0.8f)); ypos += 75; FontHandler.AddText(new Text("YOU COMPLETED THE GAME IN:", "yay2", new Vector2(400, ypos), 0.8f)); ypos += 75; FontHandler.AddText(new Text(Math.Round(totalTime, 2) + " SECONDS", "yay3", new Vector2(400, ypos), 0.8f)); ypos += 75; FontHandler.AddText(new Text("THANK YOU FOR PLAYING THIS GAME", "yay4", new Vector2(400, ypos), 0.8f)); ypos += 75; FontHandler.AddText(new Text("NOW PLAY OTHER CYBERPUNK GAMEJAM GAMES", "yay5", new Vector2(400, ypos), 0.8f)); ypos += 75; FontHandler.AddText(new Text("-METALDEMON", "yay6", new Vector2(400, ypos), 0.8f)); ypos += 75; FontHandler.AddText(new Text("PS: PRESS SPACE TO PLAY AGAIN", "yay7", new Vector2(400, ypos), 0.8f)); ypos += 75; window.PrepDraw(); FontHandler.Draw(); window.EndDraw(); FontHandler.TextList = new List <Text>(); if (Input.GetState(0).Keyboard[Key.Space]) { goto restart; } } Environment.Exit(0); } if (newmap < 10) { world = Loader.LoadMap("\\content\\maps\\map0" + newmap + ".txt", window); } else { world = Loader.LoadMap("\\content\\maps\\map" + newmap + ".txt", window); } world.map = newmap; world.incrementMap = false; continue; } GL.PushMatrix(); { GL.Translate(cameraPosition.X, cameraPosition.Y, 0); world.Draw(); } GL.PopMatrix(); GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.OneMinusDstColor, BlendingFactorDest.One); GL.Color4(0, 0, 0, 0.0f); GL.Begin(BeginMode.TriangleFan); GL.Vertex2(400, 300); GL.Color4(1f - (world.player.health / 255f), 0, 0, 0.2f); GL.Vertex2(0, 0); GL.Vertex2(800, 0); GL.Vertex2(800, 600); GL.Vertex2(0, 600); GL.Vertex2(0, 0); GL.End(); GL.Disable(EnableCap.Blend); FontHandler.Draw(); window.EndDraw(); } }