//Method to show the welcomeScreen, it will last until player press space. public void Show() { bool spacePressed = false, escPressed = false; font = new Font("font/fuenteproy.ttf", 20); Sdl.SDL_Color red = new Sdl.SDL_Color(255, 0, 0); Sdl.SDL_Color blue = new Sdl.SDL_Color(0, 0, 255); textSpace = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), "Press 'SPACE' to continue", red); myName = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), "Luis Selles", blue); hardware.DrawImage(imgWelcome); hardware.WriteText(textSpace, 325, 450); hardware.WriteText(myName, 480, 350); hardware.UpdateScreen(); do { int keyPressed = hardware.KeyPressed(); if (keyPressed == Hardware.KEY_ESC) { escPressed = true; exitGame = true; } else if (keyPressed == Hardware.KEY_SPACE) { spacePressed = true; exitGame = false; } }while (!escPressed && !spacePressed); }
public void ShowPSOnline(string lang) { bool exit = false; font = new Font("font/fuenteproy.ttf", 20); Sdl.SDL_Color red = new Sdl.SDL_Color(255, 0, 0); Sdl.SDL_Color black = new Sdl.SDL_Color(0, 0, 0); textPlayer1 = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), "Name player one: ", red); choosePlayer = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), "ENTER YOUR NAMES:", black); hardware.ClearScreen(); hardware.DrawImage(imgPlayerSelect); hardware.WriteText(textPlayer1, 200, 200); hardware.WriteText(choosePlayer, 370, 50); hardware.UpdateScreen(); do { if (hardware.KeyPressed() == Hardware.KEY_ESC) { exit = true; } } while (!exit); }
public Hardware(short width, short height, short depth, bool fullScreen) { screenWidth = width; screenHeight = height; colorDepth = depth; Red = new Sdl.SDL_Color(255, 0, 0); White = new Sdl.SDL_Color(255, 255, 255); TextNums = new IntPtr[10]; TextColon = new IntPtr(); TextComma = new IntPtr(); int flags = Sdl.SDL_HWSURFACE | Sdl.SDL_DOUBLEBUF | Sdl.SDL_ANYFORMAT; if (fullScreen) { flags = flags | Sdl.SDL_FULLSCREEN; } Sdl.SDL_Init(Sdl.SDL_INIT_EVERYTHING); screen = Sdl.SDL_SetVideoMode(screenWidth, screenHeight, colorDepth, flags); Sdl.SDL_Rect rect = new Sdl.SDL_Rect(0, 0, screenWidth, screenHeight); Sdl.SDL_SetClipRect(screen, ref rect); SdlTtf.TTF_Init(); }
public void InitText() { switch (num) { case 1: texts = textsIn; break; case 2: texts = textsEs; break; default: texts = textsIn; break; } Sdl.SDL_Color black = new Sdl.SDL_Color(255, 255, 0); for (int i = 0; i < textsPtr.Length; i++) { textsPtr[i] = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), texts[i], black); } for (int i = 0; i < 3; i++) { if (textsPtr[i] == IntPtr.Zero) { Environment.Exit(5); } } }
//This method lets the developer gets the roll he wants to //make tests. public int GetDevRoll() { number = 0; char addNumber = ' '; string rollValue = ""; Sdl.SDL_Color yellow = new Sdl.SDL_Color(255, 255, 0); do { addNumber = hardware.ReadNumber(); if (addNumber != '!' && addNumber != ' ' && addNumber != '?') { rollValue += addNumber; } txtRoll = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), rollValue, yellow); hardware.WriteText(txtRoll, 950, 330); hardware.UpdateScreen(); } while (addNumber != '!'); if (rollValue != "") { number = Convert.ToInt32(rollValue); } return(number); }
public static Image CreateImageFromText(string txt, byte r, byte g, byte b, Font f) { Sdl.SDL_Color color = new Sdl.SDL_Color(r, g, b); IntPtr textoComoImagen = SdlTtf.TTF_RenderText_Solid( f.GetPointer(), txt, color); return new Image(textoComoImagen); }
//Method to get the number of players that are going to play. public void ShownNumPlayerSelect(string lang) { char n; font = new Font("font/fuenteproy.ttf", 12); Sdl.SDL_Color black = new Sdl.SDL_Color(0, 0, 0); IntPtr txtNumPlayers, txtNum; if (lang == "spanish") { txtNumPlayers = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), "Inserta numero de jugadores entre 2 y 4: ", black); txtExit = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), "Presiona intro para salir", black); } else { txtNumPlayers = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), "Enter number of players between 2 and 4: ", black); txtExit = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), "Press enter to skip", black); } hardware.WriteText(txtNumPlayers, 150, 200); hardware.UpdateScreen(); do { n = hardware.ReadNumber(); if (n != '!' && n != '?') { if (n >= '2' && n <= '4') { num_players = Convert.ToInt32(Convert.ToString(n)); txtNum = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), Convert.ToString(num_players), black); hardware.WriteText(txtNum, 770, 200); hardware.WriteText(txtExit, 640, 430); hardware.UpdateScreen(); n = '!'; } } } while (n != '!'); do { } while (hardware.KeyPressed() != Hardware.KEY_ENTER); }
public CreditsScreen(Hardware hardware) : base(hardware) { exit = false; font24 = new Font("font/Joystix.ttf", 24); font32 = new Font("font/Joystix.ttf", 32); green = new Sdl.SDL_Color(0, 255, 0); red = new Sdl.SDL_Color(255, 20, 0); imgCredits = new Image("imgs/CreditsScreen.png", 840, 745); }
public void DecreaseEnergy(Object o) { if (character.Energy > 0) { character.Energy--; } Sdl.SDL_Color red = new Sdl.SDL_Color(255, 0, 0); textEnergy = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), "ENERGY: " + character.Energy, red); }
public ControllerScreen(Hardware hardware) : base(hardware) { exit = false; audio = new Audio(44100, 2, 4096); audio.AddWAV("music/reset.wav"); imgController = new Image("imgs/ControllerScreen.png", 840, 755); imgController.MoveTo(0, 0); font = new Font("font/Joystix.ttf", 10); yellow = new Sdl.SDL_Color(255, 255, 0); }
/// <summary> /// Blended Text /// </summary> /// <param name="textColor"></param> /// <param name="textItem"></param> /// <returns></returns> private Surface RenderTextBlended( string textItem, Color textColor) { Sdl.SDL_Color colorSdl = SdlColor.ConvertColor(textColor); if (textItem == null || textItem.Length == 0) { textItem = " "; } return(new Surface(SdlTtf.TTF_RenderUNICODE_Blended( this.Handle, textItem, colorSdl))); }
private void initTexts() { Sdl.SDL_Color red = new Sdl.SDL_Color(255, 0, 0); Sdl.SDL_Color green = new Sdl.SDL_Color(0, 255, 0); textEnergy = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), "ENERGY:", red); textPoints = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), "POINTS:", green); if (textEnergy == IntPtr.Zero || textPoints == IntPtr.Zero) { Environment.Exit(5); } }
private void initTexts() { Sdl.SDL_Color black = new Sdl.SDL_Color(255, 255, 255); Sdl.SDL_Color white = new Sdl.SDL_Color(0, 0, 0); textLives = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), "LIVES: ", white); textTimer = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), "TIMER: ", black); if (textLives == IntPtr.Zero || textTimer == IntPtr.Zero) { Environment.Exit(5); } }
public void ReadLimit(string lang) { char n; string num = ""; font = new Font("font/fuenteproy.ttf", 12); Sdl.SDL_Color black = new Sdl.SDL_Color(0, 0, 0); IntPtr txtNumPlayers, txtNum; if (lang == "spanish") { txtNumPlayers = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), "Inserta el limite de muertes: ", black); } else { txtNumPlayers = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), "Enter the limit of kills of the game: ", black); } hardware.ClearScreen(); hardware.DrawImage(imgPlayerSelect); hardware.WriteText(txtNumPlayers, 150, 200); hardware.UpdateScreen(); do { n = hardware.ReadNumber(); if (n != '!' && n != '?') { num += n; txtNum = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), Convert.ToString(num), black); hardware.WriteText(txtNum, 660, 200); hardware.UpdateScreen(); } } while (n != '!'); num_limit = Convert.ToInt32(Convert.ToString(num)); txtExit = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), "Press enter to skip", black); hardware.WriteText(txtExit, 640, 430); hardware.UpdateScreen(); do { } while (hardware.KeyPressed() != Hardware.KEY_ENTER); }
public void InitText() { switch (GameController.language) { case 1: tasks = tasksIn; agreements = agreementsIn; break; case 2: tasks = tasksEs; agreements = agreementsEs; break; default: tasks = tasksIn; break; } font = new Font("fonts/Nashville.ttf", 33); Sdl.SDL_Color gray = new Sdl.SDL_Color(125, 125, 125); Sdl.SDL_Color blue = new Sdl.SDL_Color(66, 125, 255); for (int i = 0; i < tasks.Length; i++) { taksPtr[i] = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), tasks[i], gray); namesPtr[i] = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), names[i], gray); } font = new Font("fonts/Nashville.ttf", 26); for (int i = 0; i < agreementsPtr.Length; i++) { agreementsPtr[i] = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), agreements[i], blue); } for (int i = 0; i < tasks.Length; i++) { if (taksPtr[i] == IntPtr.Zero || namesPtr[i] == IntPtr.Zero) { Environment.Exit(5); } } for (int i = 0; i < 3; i++) { if (agreementsPtr[i] == IntPtr.Zero) { Environment.Exit(5); } } }
//Add Timer public void DecreaseTime(Object o) { Sdl.SDL_Color black = new Sdl.SDL_Color(255, 255, 255); Sdl.SDL_Color white = new Sdl.SDL_Color(0, 0, 0); if (characterA.Lives > 0) { characterA.Time--; textTimer = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), "TIME: " + characterA.Time, black); } else if (characterB.Lives > 0) { characterB.Time--; textTimer = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), "TIME: " + characterB.Time, black); } else { string line; StreamReader input = File.OpenText("hiscore.dat"); line = input.ReadLine(); string[] info = line.Split(':'); addhiscore num = new addhiscore(); info = line.Split(':'); num.name = info[0]; num.points = int.Parse(info[1]); if (points > num.points) { top = true; input.Close(); } if (top == true) //Bool to activate/deactivate de HiScore Screen { HiScore(); while (hardware.KeyPress() != Hardware.KEY_SPC) { ; } } Image imgGameOver; imgGameOver = new Image("images/GameOverImage.png", 1200, 740); imgGameOver.MoveTo(0, 0); hardware.DrawImage(imgGameOver); hardware.UpdateScreen(); textSpace = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), "PRESS SPACE TO CONTINUE...", white); while (hardware.KeyPress() != Hardware.KEY_SPC) { ; } } }
public SelectLenguage(Hardware hardware) : base(hardware) { exit = false; audio = new Audio(44100, 2, 4096); audio.AddWAV("music/reset.wav"); imgWelcome = new Image("imgs/MenuPrincipal.png", 840, 755); imgChosenOption = new Image("imgs/BombMenu1.png", 50, 50); font = new Font("font/Joystix.ttf", 28); imgWelcome.MoveTo(0, 0); imgChosenOption.MoveTo(245, 420); yellow = new Sdl.SDL_Color(255, 255, 0); }
public void InitText() { Sdl.SDL_Color red = new Sdl.SDL_Color(255, 0, 0); string line; for (int i = 0; i < scorePtr.Length; i++) { line = text[ind, 0] + Convert.ToInt32(scoreList[i].num) + text[ind, 1] + Convert.ToInt32(scoreList[i].score) + text[ind, 2] + Convert.ToInt32(scoreList[i].jumps); scorePtr[i] = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), line, red); } }
//Show the multiple options of the menu. public void Show() { bool isSpacePressed = false; Sdl.SDL_Color red = new Sdl.SDL_Color(255, 0, 0); txtSpace = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), "Press 'SPACE' to continue", red); SelectLang(); imgArrow.MoveTo(270, 180); if (GetLang() == "spanish") { imgBack = new Image("img/menuscreenSpanish.jpg", 1152, 648); txtSpace = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), "Pulsa espacio para continuar", red); chosenGame = 1; } do { hardware.ClearScreen(); hardware.DrawImage(imgBack); hardware.WriteText(txtSpace, 200, 150); hardware.DrawImage(imgArrow); hardware.UpdateScreen(); //Moves the arrow throught the options of the menu int keyPress = hardware.KeyPressed(); if (keyPress == Hardware.KEY_UP && chosenGame > 1) { chosenGame--; imgArrow.MoveTo(250, (short)(imgArrow.Y - 52)); } else if (keyPress == Hardware.KEY_DOWN && chosenGame < 7) { chosenGame++; imgArrow.MoveTo(250, (short)(imgArrow.Y + 52)); } else if (keyPress == Hardware.KEY_SPACE) { isSpacePressed = true; } } while (!isSpacePressed); }
public void EscribirTexto(string texto, short x, short y, short size, byte r, byte g, byte b) { IntPtr tipoLetra = SdlTtf.TTF_OpenFont("SEGOEPRB.TTF", size); Sdl.SDL_Color color = new Sdl.SDL_Color(r, g, b); IntPtr textoComoImagen = SdlTtf.TTF_RenderText_Solid(tipoLetra, texto, color); if (textoComoImagen == IntPtr.Zero) { Environment.Exit(5); } Sdl.SDL_Rect origen = new Sdl.SDL_Rect(0, 0, ancho, alto); Sdl.SDL_Rect dest = new Sdl.SDL_Rect(x, y, ancho, alto); Sdl.SDL_BlitSurface(textoComoImagen, ref origen, pantalla, ref dest); }
public SettingScreen(Hardware hardware) : base(hardware) { exit = false; audio = new Audio(44100, 2, 4096); audio.AddWAV("music/reset.wav"); font = new Font("font/Joystix.ttf", 28); imgSetting = new Image("imgs/SettingsScreen.png", 840, 755); imgChosenOption = new Image("imgs/select.png", 40, 35); game = new GameScreen(hardware); imgSetting.MoveTo(0, 0); imgChosenOption.MoveTo(170, 240); white = new Sdl.SDL_Color(255, 255, 255); }
public IntroScreen(Hardware hardware) : base(hardware) { bakcGround = new Image("imgs/IntroScreen2.png", 1200, 720); audio = new Audio(44100, 2, 4096); audio.AddMusic("sound/IntroTheme.mid"); font = new Font("fonts/NexaRustSlab-BlackShadow01.otf", 35); bakcGround.MoveTo(0, 0); Sdl.SDL_Color white = new Sdl.SDL_Color(255, 255, 255); Englis = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), "Press space/A escape/B to continue", white); Castellano = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), "Espacio o A para Castellano", white); Englis = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), "Escape or B for English", white); }
public void SetPalette() { Sdl.SDL_Color[] colors = new Sdl.SDL_Color[255]; for (byte i = 0; i <= 254; i++) { colors[i].r = i; colors[i].g = i; colors[i].b = i; } IntPtr surfacePtr = VideoSetup(); int resultSetPalette = Sdl.SDL_SetPalette(surfacePtr, Sdl.SDL_LOGPAL | Sdl.SDL_PHYSPAL, colors, 0, 255); Assert.AreEqual(resultSetPalette, 0); Sdl.SDL_FreeSurface(surfacePtr); }
// Writes a text in the specified coordinates public void WriteText(string text, short x, short y, byte r, byte g, byte b, Font fontType) { Sdl.SDL_Color color = new Sdl.SDL_Color(r, g, b); IntPtr textAsImage = SdlTtf.TTF_RenderText_Solid(fontType.GetFontType(), text, color); if (textAsImage == IntPtr.Zero) { Environment.Exit(5); } Sdl.SDL_Rect src = new Sdl.SDL_Rect(0, 0, screenWidth, screenHeight); Sdl.SDL_Rect dest = new Sdl.SDL_Rect(x, y, screenWidth, screenHeight); Sdl.SDL_BlitSurface(textAsImage, ref src, screen, ref dest); }
public MapCreationScreen(Hardware hardware) : base(hardware) { font20 = new Font("font/Joystix.ttf", 20); imgMap = new Image("imgs/MapScreen.png", 840, 105); imgFloor = new Image("imgs/Floor.png", 840, 680); imgCursor = new Image("imgs/cursor.png", 40, 40); imgMap.MoveTo(0, 640); imgFloor.MoveTo(0, 0); imgCursor.MoveTo(40, 40); white = new Sdl.SDL_Color(255, 255, 255); Bricks = new List <Sprite>(); BricksDestroyable = new List <Sprite>(); font32 = new Font("font/Joystix.ttf", 32); font16 = new Font("font/Joystix.ttf", 16); yellow = new Sdl.SDL_Color(255, 255, 0); }
public static void WriteHiddenText(string txt, short x, short y, byte r, byte g, byte b, Font f) { Sdl.SDL_Color color = new Sdl.SDL_Color(r, g, b); IntPtr textoComoImagen = SdlTtf.TTF_RenderText_Solid( f.GetPointer(), txt, color); //if (textoComoImagen == IntPtr.Zero) // Environment.Exit(5); Sdl.SDL_Rect origen = new Sdl.SDL_Rect(0, 0, width, height); Sdl.SDL_Rect dest = new Sdl.SDL_Rect(x, y, width, height); Sdl.SDL_BlitSurface(textoComoImagen, ref origen, hiddenScreen, ref dest); }
public void Display(Font font) { Sdl.SDL_Color statementColor = new Sdl.SDL_Color(0xff, 0x00, 0x00); Sdl.SDL_Color answerColors = new Sdl.SDL_Color(0x00, 0xff, 0x00); IntPtr statementImg = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), Statement, statementColor); IntPtr[] answersImg = new IntPtr[4]; for (int i = 0; i < answersImg.Length; i++) { answersImg[i] = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), Answers[i], statementColor); } }
public void DrawText() { Sdl.SDL_Color red = new Sdl.SDL_Color(255, 0, 0); timeSpent = SdlTtf.TTF_RenderText_Solid (font.GetFontType(), time.ToString(), red); levelReached = SdlTtf.TTF_RenderText_Solid (font.GetFontType(), "1", red); score = SdlTtf.TTF_RenderText_Solid (font.GetFontType(), "1000", red); hardware.WriteText (timeSpent, 340, 486); hardware.WriteText (levelReached, 340, 513); hardware.WriteText (score, 340, 586); }
//Shows the second option of the menu. It tells the user to //enter a chip number to move. The player can only move 1 of his // 4 chips public int ShowSecondStep(string lang) { char addNumber = ' '; chipToMove = ""; nchip = 0; font = new Font("font/fuenteproy.ttf", 12); Sdl.SDL_Color red = new Sdl.SDL_Color(255, 0, 0); Sdl.SDL_Color yellow = new Sdl.SDL_Color(255, 255, 0); if (lang == "spanish") { txtMenu = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), "Inserta numero de ficha: ", red); } else { txtMenu = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), "Enter chip number to move: ", red); } hardware.WriteText(txtMenu, 640, 380); hardware.UpdateScreen(); do { addNumber = hardware.ReadNumber(); if (addNumber != '!' && addNumber != ' ' && addNumber != '?') { this.chipToMove += addNumber; } txtChip = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), chipToMove, yellow); hardware.WriteText(txtChip, 1050, 380); hardware.UpdateScreen(); } while (addNumber != '!'); if (chipToMove != "") { nchip = Convert.ToInt32(chipToMove); } return(nchip); }
public void ChosenOption() { Sdl.SDL_Color yellow = new Sdl.SDL_Color(255, 255, 0); switch (chosenOption) { case 2: case 5: textPtr[8] = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), menuTexts[chosenOption] + disp[GameController.language - 1], yellow); break; default: textPtr[8] = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), "", yellow); break; } }