public override void Show() { short oldX, oldY, oldXMap, oldYMap; DateTime timeStampFromClock = DateTime.Now; byte currentLevel = 1; bool gameOver = false; if (chosenPlayer == 1) //ChooseCharacter Character A { characterA.MoveTo(level.Start.X, level.Start.Y); } else if (chosenPlayer == 2) //ChooseCharacter Character B { characterB.MoveTo(level.Start.X, level.Start.Y); } audio.PlayMusic(0, -1); var timer = new Timer(this.DecreaseTime, null, 1000, 1000); //IN PROGRESS Draw Everything do { hardware.ClearScreen(); if (level == new Level("levels/level1.txt")) { hardware.DrawSprite(level.BackgroundA, 0, 0, level.XMap1, level.YMap1, MainController.SCREEN_WIDTH, MainController.SCREEN_HEIGHT); foreach (WallA wallA in level.wallA) { hardware.DrawSprite(SpriteA.TilesSheetA, (short)(wallA.X - level.XMap1), (short)(wallA.Y - level.YMap1), wallA.SpriteX, wallA.SpriteY, SpriteA.SPRITEA_WIDTH, SpriteA.SPRITEA_HEIGHT); } foreach (WallB wallB in level.wallB) { hardware.DrawSprite(SpriteA.TilesSheetA, (short)(wallB.X - level.XMap1), (short)(wallB.Y - level.YMap1), wallB.SpriteX, wallB.SpriteY, SpriteA.SPRITEA_WIDTH, SpriteA.SPRITEA_HEIGHT); } foreach (FloorA floorA in level.floorA) { hardware.DrawSprite(SpriteA.TilesSheetA, (short)(floorA.X - level.XMap1), (short)(floorA.Y - level.YMap1), floorA.SpriteX, floorA.SpriteY, SpriteA.SPRITEA_WIDTH, SpriteA.SPRITEA_HEIGHT); } hardware.DrawSprite(SpriteItemsA.ItemsSheetA, (short)(level.ExitLevel.X - level.XMap1), (short)(level.ExitLevel.Y - level.YMap1), level.ExitLevel.SpriteX, level.ExitLevel.SpriteY, SpriteItemsA.SPRITEIA_WIDTH, SpriteItemsA.SPRITEIA_HEIGHT); foreach (Items i in level.items) { hardware.DrawSprite(SpriteItemsA.ItemsSheetA, (short)(i.X - level.XMap1), (short)(i.Y - level.YMap1), i.SpriteX, i.SpriteY, SpriteItemsA.SPRITEIA_WIDTH, SpriteItemsA.SPRITEIA_HEIGHT); } } else if (level == new Level("levels/level2.txt")) { hardware.DrawSprite(level.BackgroundB, 0, 0, level.XMap2, level.YMap2, MainController.SCREEN_WIDTH, MainController.SCREEN_HEIGHT); foreach (WallA wallA in level.wallA) { hardware.DrawSprite(SpriteA.TilesSheetA, (short)(wallA.X - level.XMap2), (short)(wallA.Y - level.YMap2), wallA.SpriteX, wallA.SpriteY, SpriteA.SPRITEA_WIDTH, SpriteA.SPRITEA_HEIGHT); } foreach (WallB wallB in level.wallB) { hardware.DrawSprite(SpriteA.TilesSheetA, (short)(wallB.X - level.XMap2), (short)(wallB.Y - level.YMap2), wallB.SpriteX, wallB.SpriteY, SpriteA.SPRITEA_WIDTH, SpriteA.SPRITEA_HEIGHT); } hardware.DrawSprite(SpriteItemsA.ItemsSheetA, (short)(level.ExitLevel.X - level.XMap2), (short)(level.ExitLevel.Y - level.YMap2), level.ExitLevel.SpriteX, level.ExitLevel.SpriteY, SpriteItemsA.SPRITEIA_WIDTH, SpriteItemsA.SPRITEIA_HEIGHT); foreach (Items i in level.items) { hardware.DrawSprite(SpriteItemsA.ItemsSheetA, (short)(i.X - level.XMap2), (short)(i.Y - level.YMap2), i.SpriteX, i.SpriteY, SpriteItemsA.SPRITEIA_WIDTH, SpriteItemsA.SPRITEIA_HEIGHT); } foreach (FloorA floorA in level.floorA) { hardware.DrawSprite(SpriteA.TilesSheetA, (short)(floorA.X - level.XMap2), (short)(floorA.Y - level.YMap2), floorA.SpriteX, floorA.SpriteY, SpriteA.SPRITEA_WIDTH, SpriteA.SPRITEA_HEIGHT); } } else if (level == new Level("levels/level3.txt")) { hardware.DrawSprite(level.BackgroundB, 0, 0, level.XMap3, level.YMap3, MainController.SCREEN_WIDTH, MainController.SCREEN_HEIGHT); foreach (WallA wallA in level.wallA) { hardware.DrawSprite(SpriteA.TilesSheetA, (short)(wallA.X - level.XMap3), (short)(wallA.Y - level.YMap3), wallA.SpriteX, wallA.SpriteY, SpriteA.SPRITEA_WIDTH, SpriteA.SPRITEA_HEIGHT); } foreach (WallB wallB in level.wallB) { hardware.DrawSprite(SpriteA.TilesSheetA, (short)(wallB.X - level.XMap3), (short)(wallB.Y - level.YMap3), wallB.SpriteX, wallB.SpriteY, SpriteA.SPRITEA_WIDTH, SpriteA.SPRITEA_HEIGHT); } hardware.DrawSprite(SpriteItemsA.ItemsSheetA, (short)(level.ExitLevel.X - level.XMap3), (short)(level.ExitLevel.Y - level.YMap3), level.ExitLevel.SpriteX, level.ExitLevel.SpriteY, SpriteItemsA.SPRITEIA_WIDTH, SpriteItemsA.SPRITEIA_HEIGHT); foreach (Items i in level.items) { hardware.DrawSprite(SpriteItemsA.ItemsSheetA, (short)(i.X - level.XMap3), (short)(i.Y - level.YMap3), i.SpriteX, i.SpriteY, SpriteItemsA.SPRITEIA_WIDTH, SpriteItemsA.SPRITEIA_HEIGHT); } foreach (FloorA floorA in level.floorA) { hardware.DrawSprite(SpriteA.TilesSheetA, (short)(floorA.X - level.XMap3), (short)(floorA.Y - level.YMap3), floorA.SpriteX, floorA.SpriteY, SpriteA.SPRITEA_WIDTH, SpriteA.SPRITEA_HEIGHT); } } else if (level == new Level("levels/level4.txt")) { hardware.DrawSprite(level.BackgroundC, 0, 0, level.XMap4, level.YMap4, MainController.SCREEN_WIDTH, MainController.SCREEN_HEIGHT); foreach (WallA wallA in level.wallA) { hardware.DrawSprite(SpriteA.TilesSheetA, (short)(wallA.X - level.XMap4), (short)(wallA.Y - level.YMap4), wallA.SpriteX, wallA.SpriteY, SpriteA.SPRITEA_WIDTH, SpriteA.SPRITEA_HEIGHT); } foreach (WallB wallB in level.wallB) { hardware.DrawSprite(SpriteA.TilesSheetA, (short)(wallB.X - level.XMap4), (short)(wallB.Y - level.YMap4), wallB.SpriteX, wallB.SpriteY, SpriteA.SPRITEA_WIDTH, SpriteA.SPRITEA_HEIGHT); } hardware.DrawSprite(SpriteItemsA.ItemsSheetA, (short)(level.ExitLevel.X - level.XMap4), (short)(level.ExitLevel.Y - level.YMap4), level.ExitLevel.SpriteX, level.ExitLevel.SpriteY, SpriteItemsA.SPRITEIA_WIDTH, SpriteItemsA.SPRITEIA_HEIGHT); foreach (Items i in level.items) { hardware.DrawSprite(SpriteItemsA.ItemsSheetA, (short)(i.X - level.XMap4), (short)(i.Y - level.YMap4), i.SpriteX, i.SpriteY, SpriteItemsA.SPRITEIA_WIDTH, SpriteItemsA.SPRITEIA_HEIGHT); } foreach (FloorA floorA in level.floorA) { hardware.DrawSprite(SpriteA.TilesSheetA, (short)(floorA.X - level.XMap4), (short)(floorA.Y - level.YMap4), floorA.SpriteX, floorA.SpriteY, SpriteA.SPRITEA_WIDTH, SpriteA.SPRITEA_HEIGHT); } } else if (level == new Level("levels/level5.txt")) { hardware.DrawSprite(level.BackgroundE, 0, 0, level.XMap5, level.YMap5, MainController.SCREEN_WIDTH, MainController.SCREEN_HEIGHT); foreach (WallA wallA in level.wallA) { hardware.DrawSprite(SpriteA.TilesSheetA, (short)(wallA.X - level.XMap5), (short)(wallA.Y - level.YMap5), wallA.SpriteX, wallA.SpriteY, SpriteA.SPRITEA_WIDTH, SpriteA.SPRITEA_HEIGHT); } foreach (WallB wallB in level.wallB) { hardware.DrawSprite(SpriteA.TilesSheetA, (short)(wallB.X - level.XMap5), (short)(wallB.Y - level.YMap5), wallB.SpriteX, wallB.SpriteY, SpriteA.SPRITEA_WIDTH, SpriteA.SPRITEA_HEIGHT); } hardware.DrawSprite(SpriteItemsB.ItemsSheetB, (short)(level.ExitLevel.X - level.XMap5), (short)(level.ExitLevel.Y - level.YMap5), level.ExitLevel.SpriteX, level.ExitLevel.SpriteY, SpriteItemsB.SPRITEIB_WIDTH, SpriteItemsB.SPRITEIB_HEIGHT); foreach (Items i in level.items) { hardware.DrawSprite(SpriteItemsA.ItemsSheetA, (short)(i.X - level.XMap5), (short)(i.Y - level.YMap5), i.SpriteX, i.SpriteY, SpriteItemsA.SPRITEIA_WIDTH, SpriteItemsA.SPRITEIA_HEIGHT); } foreach (FloorA floorA in level.floorA) { hardware.DrawSprite(SpriteA.TilesSheetA, (short)(floorA.X - level.XMap5), (short)(floorA.Y - level.YMap5), floorA.SpriteX, floorA.SpriteY, SpriteA.SPRITEA_WIDTH, SpriteA.SPRITEA_HEIGHT); } } else if (level == new Level("levels/tolast.txt")) { hardware.DrawSprite(level.BackgroundE, 0, 0, level.XMap5, level.YMap5, MainController.SCREEN_WIDTH, MainController.SCREEN_HEIGHT); foreach (WallA wallA in level.wallA) { hardware.DrawSprite(SpriteA.TilesSheetA, (short)(wallA.X - level.XMap5), (short)(wallA.Y - level.YMap5), wallA.SpriteX, wallA.SpriteY, SpriteA.SPRITEA_WIDTH, SpriteA.SPRITEA_HEIGHT); } foreach (WallB wallB in level.wallB) { hardware.DrawSprite(SpriteA.TilesSheetA, (short)(wallB.X - level.XMap5), (short)(wallB.Y - level.YMap5), wallB.SpriteX, wallB.SpriteY, SpriteA.SPRITEA_WIDTH, SpriteA.SPRITEA_HEIGHT); } hardware.DrawSprite(SpriteItemsA.ItemsSheetA, (short)(level.ExitLevel.X - level.XMap5), (short)(level.ExitLevel.Y - level.YMap5), level.ExitLevel.SpriteX, level.ExitLevel.SpriteY, SpriteItemsA.SPRITEIA_WIDTH, SpriteItemsA.SPRITEIA_HEIGHT); foreach (Items i in level.items) { hardware.DrawSprite(SpriteItemsA.ItemsSheetA, (short)(i.X - level.XMap5), (short)(i.Y - level.YMap5), i.SpriteX, i.SpriteY, SpriteItemsA.SPRITEIA_WIDTH, SpriteItemsA.SPRITEIA_HEIGHT); } foreach (FloorA floorA in level.floorA) { hardware.DrawSprite(SpriteA.TilesSheetA, (short)(floorA.X - level.XMap5), (short)(floorA.Y - level.YMap5), floorA.SpriteX, floorA.SpriteY, SpriteA.SPRITEA_WIDTH, SpriteA.SPRITEA_HEIGHT); } } else if (level == new Level("levels/levelend.txt")) { hardware.DrawSprite(level.BackgroundD, 0, 0, level.XMap6, level.YMap6, MainController.SCREEN_WIDTH, MainController.SCREEN_HEIGHT); foreach (WallA wallA in level.wallA) { hardware.DrawSprite(SpriteA.TilesSheetA, (short)(wallA.X - level.XMap6), (short)(wallA.Y - level.YMap6), wallA.SpriteX, wallA.SpriteY, SpriteA.SPRITEA_WIDTH, SpriteA.SPRITEA_HEIGHT); } foreach (WallB wallB in level.wallB) { hardware.DrawSprite(SpriteA.TilesSheetA, (short)(wallB.X - level.XMap6), (short)(wallB.Y - level.YMap6), wallB.SpriteX, wallB.SpriteY, SpriteA.SPRITEA_WIDTH, SpriteA.SPRITEA_HEIGHT); } hardware.DrawSprite(SpriteItemsA.ItemsSheetA, (short)(level.ExitLevel.X - level.XMap6), (short)(level.ExitLevel.Y - level.YMap6), level.ExitLevel.SpriteX, level.ExitLevel.SpriteY, SpriteItemsA.SPRITEIA_WIDTH, SpriteItemsA.SPRITEIA_HEIGHT); foreach (Items i in level.items) { hardware.DrawSprite(SpriteItemsA.ItemsSheetA, (short)(i.X - level.XMap6), (short)(i.Y - level.YMap6), i.SpriteX, i.SpriteY, SpriteItemsA.SPRITEIA_WIDTH, SpriteItemsA.SPRITEIA_HEIGHT); } foreach (FloorA floorA in level.floorA) { hardware.DrawSprite(SpriteA.TilesSheetA, (short)(floorA.X - level.XMap6), (short)(floorA.Y - level.YMap6), floorA.SpriteX, floorA.SpriteY, SpriteA.SPRITEA_WIDTH, SpriteA.SPRITEA_HEIGHT); } foreach (FloorB floorB in level.floorB) { hardware.DrawSprite(SpriteB.TilesSheetB, (short)(floorB.X - level.XMap6), (short)(floorB.Y - level.YMap6), floorB.SpriteX, floorB.SpriteY, SpriteB.SPRITEB_WIDTH, SpriteB.SPRITEB_HEIGHT); } foreach (FloorC floorC in level.floorC) { hardware.DrawSprite(SpriteC.TilesSheetC, (short)(floorC.X - level.XMap6), (short)(floorC.Y - level.YMap6), floorC.SpriteX, floorC.SpriteY, SpriteC.SPRITEC_WIDTH, SpriteC.SPRITEC_HEIGHT); } foreach (FloorD floorD in level.floorD) { hardware.DrawSprite(SpriteD.TilesSheetD, (short)(floorD.X - level.XMap6), (short)(floorD.Y - level.YMap6), floorD.SpriteX, floorD.SpriteY, SpriteD.SPRITED_WIDTH, SpriteD.SPRITED_HEIGHT); } foreach (FloorE floorE in level.floorE) { hardware.DrawSprite(SpriteE.TilesSheetE, (short)(floorE.X - level.XMap6), (short)(floorE.Y - level.YMap6), floorE.SpriteX, floorE.SpriteY, SpriteE.SPRITEE_WIDTH, SpriteE.SPRITEE_HEIGHT); } foreach (FloorF floorF in level.floorF) { hardware.DrawSprite(SpriteF.TilesSheetF, (short)(floorF.X - level.XMap6), (short)(floorF.Y - level.YMap6), floorF.SpriteX, floorF.SpriteY, SpriteF.SPRITEF_WIDTH, SpriteF.SPRITEF_HEIGHT); } foreach (FloorG floorG in level.floorG) { hardware.DrawSprite(SpriteG.TilesSheetG, (short)(floorG.X - level.XMap6), (short)(floorG.Y - level.YMap6), floorG.SpriteX, floorG.SpriteY, SpriteG.SPRITEG_WIDTH, SpriteG.SPRITEG_HEIGHT); } } if (chosenPlayer == 1) { oldX = characterA.X; oldY = characterA.Y; } else if (chosenPlayer == 2) { oldX = characterB.X; oldY = characterB.Y; } //Level One Map if (level == new Level("levels/level1.txt")) { oldXMap = level.XMap1; oldYMap = level.YMap1; } //Level Two Map else if (level == new Level("levels/level2.txt")) { oldXMap = level.XMap2; oldYMap = level.YMap2; } //Level Three Map else if (level == new Level("levels/level3.txt")) { oldXMap = level.XMap3; oldYMap = level.YMap3; } //Level Four Map else if (level == new Level("levels/level4.txt")) { oldXMap = level.XMap4; oldYMap = level.YMap4; } //Level Five Map else if (level == new Level("levels/level5.txt")) { oldXMap = level.XMap5; oldYMap = level.YMap5; } else if (level == new Level("levels/tolast.txt")) { oldXMap = level.XMap5; oldYMap = level.YMap5; } //Final Level Map else if (level == new Level("levels/levelend.txt")) { oldXMap = level.XMap6; oldYMap = level.YMap6; } //Pause Menu First Version if (hardware.IsKPressed(Hardware.KEY_P)) { Timer storet = timer; timer.Dispose(); audio.StopMusic(); hardware.ClearScreen(); Sdl.SDL_Color white = new Sdl.SDL_Color(0, 0, 0); textPause = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), "PAUSE", white); textPause = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), "Continue [C]", white); textPause = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), "Quit [Q]", white); char pause = Convert.ToChar(Console.ReadLine().ToLower()); switch (pause) { case 'c': timer = storet; break; //Nothing because game continues case 'q': intro.GetExit(); break; //Call GetExit } } }while (!gameOver); audio.StopMusic(); timer.Dispose(); }
public void Start() { //Here will be the controller code to move //"between screens with images" and the game Hardware hardware = new Hardware(1366, 698, 24, false); IntroScreen intro = new IntroScreen(hardware); CreditsScreen credits = new CreditsScreen(hardware); HelpScreen help = new HelpScreen(hardware); ChooseCharacterScreen chooseCharacter = new ChooseCharacterScreen(hardware); GameScreen game = new GameScreen(hardware); do { intro = new IntroScreen(hardware); hardware.ClearScreen(); intro.Show(); if (!intro.GetExit()) { if (intro.ChoseMenu == 1) { Console.WriteLine("Received input: " + intro.ChoseMenu); chooseCharacter.Show(); game = new GameScreen(hardware); game.ChosenPlayer = chooseCharacter.GetChosenPlayer(); hardware.ClearScreen(); game.Show(); hardware.ClearScreen(); } else if (intro.ChoseMenu == 2) { Console.WriteLine("Received input: " + intro.ChoseMenu); hardware.ClearScreen(); help = new HelpScreen(hardware); help.Show(); } else if (intro.ChoseMenu == 3) { Console.WriteLine("Received input: " + intro.ChoseMenu); hardware.ClearScreen(); credits = new CreditsScreen(hardware); credits.Show(); } else if (intro.ChoseMenu == 4) { Console.WriteLine("Received input: " + intro.ChoseMenu); hardware.ClearScreen(); intro.GetExit(); } if (intro.ChoseMenu == 5) { Console.WriteLine("Received input: " + intro.ChoseMenu); chooseCharacter.Show(); game = new GameScreen(hardware); game.ChosenPlayer = chooseCharacter.GetChosenPlayer(); hardware.ClearScreen(); game.Show(); hardware.ClearScreen(); } else if (intro.ChoseMenu == 6) { Console.WriteLine("Received input: " + intro.ChoseMenu); hardware.ClearScreen(); help = new HelpScreen(hardware); help.Show(); } else if (intro.ChoseMenu == 7) { Console.WriteLine("Received input: " + intro.ChoseMenu); hardware.ClearScreen(); credits = new CreditsScreen(hardware); credits.Show(); } else if (intro.ChoseMenu == 8) { Console.WriteLine("Received input: " + intro.ChoseMenu); hardware.ClearScreen(); intro.GetExit(); } } Thread.Sleep(5000); }while (intro.GetExit() == true); }