public override void Show() { bool escPressed = false; do { hardware.ClearScreen(); hardware.DrawImage(imgCredits); fontTexts = SdlTtf.TTF_RenderText_Solid(font32.GetFontType(), credits[0], green); hardware.WriteText(fontTexts, 330, 10); yText = 40; for (int i = 1; i < credits.Length; i++) { fontTexts = SdlTtf.TTF_RenderText_Solid(font24.GetFontType(), credits[i], red); hardware.WriteText(fontTexts, 250, (short)(startY + yText)); yText += 20; } hardware.UpdateScreen(); int keyPressed = hardware.KeyPressed(); hardware.Pause(20); if (keyPressed == Hardware.KEY_ESC) { startY = 720; escPressed = true; exit = true; } if (startY > 100) { startY -= 2; } } while (!escPressed || !exit); }
//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); }
private void initialiceLevelTexts() { if (Directory.Exists("./levels")) { string[] fileList = Directory.GetFiles("./levels"); foreach (string file in fileList) { if (file.StartsWith("./levels\\level")) { levelPaths.Add(file); int amount = file.LastIndexOf('.') - 1 - file.LastIndexOf('\\'); levelsTextRed.Add(SdlTtf.TTF_RenderText_Solid( font.GetFontType(), file.Substring( file.LastIndexOf('\\') + 1, amount), hardware.Red)); levelsTextWhite.Add(SdlTtf.TTF_RenderText_Solid( font.GetFontType(), file.Substring( file.LastIndexOf('\\') + 1, amount), hardware.White)); } } } pressEnterEnglish = SdlTtf.TTF_RenderText_Solid( new Font("fonts/PermanentMarker-Regular.ttf", 20).GetFontType(), "PRESS ENTER TO SELECT A LEVEL", hardware.White); pressEnterEnglish = SdlTtf.TTF_RenderText_Solid( new Font("fonts/PermanentMarker-Regular.ttf", 20).GetFontType(), "PULSA ENTER PARA SELECCIONAR UN NIVEL", hardware.White); }
private void initialiceTexts() { enterName = SdlTtf.TTF_RenderText_Solid( new Font("fonts/Creepster-Regular.ttf", 30).GetFontType(), "ENTER PLAYER NAME: ", hardware.Red); }
////////////////////////////////////////////////////////////// // RUDIMENTARY DRAW FUNCTIONS ////////////////////////////////////////////////////////////// //Draws text to the screen public void drawText(string text, int x, int y, Handle font, Color color, int ptSize = 12) { // Get the font handle at the desired point size IntPtr handle; try { handle = font.getResource <Font>().getFontHandle(ptSize); } catch (Exception e) { Trace.WriteLine("GraphicsComponent.drawText(string,Font,Color,int): Could not draw font: " + e.Message); return; } // Render the text to a SDL surface IntPtr surf = SdlTtf.TTF_RenderUNICODE_Blended(handle, text, color.sdlColor); if (surf == IntPtr.Zero) { Trace.WriteLine("GraphicsComponent.drawText(string,Font,Color,int): Could not render font: " + SdlTtf.TTF_GetError()); } // Draw the Texture2D Texture2D tempTex = new Texture2D(surf); drawTex(tempTex, x, y, Color.WHITE); Sdl.SDL_FreeSurface(surf); }
//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); }
/// <summary> /// Initialize Font subsystem. /// </summary> private static void InitializeFontSystem() { if (SdlTtf.TTF_Init() != (int)SdlFlag.Success) { FontException.Generate(); } }
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); } } }
private void initialiceTexts() { helpTextEnglish = SdlTtf.TTF_RenderText_Solid( new Font("fonts/Creepster-Regular.ttf", 20).GetFontType(), "Press TAB to show help", hardware.Red); finishTextEnglish = SdlTtf.TTF_RenderText_Solid( new Font("fonts/Creepster-Regular.ttf", 18).GetFontType(), "Press ESC to finish", hardware.Red); helpTextSpanish = SdlTtf.TTF_RenderText_Solid( new Font("fonts/Creepster-Regular.ttf", 20).GetFontType(), "Pulsa TABULADOR para mostrar la ayuda", hardware.Red); finishTextSpanish = SdlTtf.TTF_RenderText_Solid( new Font("fonts/Creepster-Regular.ttf", 18).GetFontType(), "Pulsa ESC para finalizar", hardware.Red); for (int i = 1; i <= nums.Length; i++) { nums[i - 1] = SdlTtf.TTF_RenderText_Solid( new Font("fonts/Creepster-Regular.ttf", 40).GetFontType(), i.ToString(), hardware.Red); } }
static short startX, startY; // For Scroll public static void Init(short w, short h, int colors, bool fullScreen) { width = w; height = h; int flags = Sdl.SDL_HWSURFACE | Sdl.SDL_DOUBLEBUF | Sdl.SDL_ANYFORMAT; if (fullScreen) flags |= Sdl.SDL_FULLSCREEN; Sdl.SDL_Init(Sdl.SDL_INIT_EVERYTHING); hiddenScreen = Sdl.SDL_SetVideoMode( width, height, colors, flags); Sdl.SDL_Rect rect2 = new Sdl.SDL_Rect(0, 0, (short)width, (short)height); Sdl.SDL_SetClipRect(hiddenScreen, ref rect2); SdlTtf.TTF_Init(); // Joystick initialization isThereJoystick = true; if (Sdl.SDL_NumJoysticks() < 1) isThereJoystick = false; if (isThereJoystick) { joystick = Sdl.SDL_JoystickOpen(0); if (joystick == IntPtr.Zero) isThereJoystick = false; } }
public int SizeText(string text) { int w, h; SdlTtf.TTF_SizeUNICODE(font, text, out w, out h); return(w); }
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); }
private void initialiceOptions() { string[] optionsSpanish = { "Empezar nueva partida", "Continuar partida", "Seleccionar mapa", "Ver puntuaciones", "Editor de mapas", "Cambiar idioma", "Salir" }; renderOptionsSpanish(optionsSpanish); pressEnterSpanish = SdlTtf.TTF_RenderText_Solid( new Font("fonts/PermanentMarker-Regular.ttf", 28).GetFontType(), "PULSA ENTER PARA ELEGIR UNA OPCIÓN", hardware.White); string[] optionsEnglish = { "Start a new game", "Continue game", "Select map", "See highscores", "Map editor", "Switch language", "Quit the game" }; renderOptionsEnglish(optionsEnglish); pressEnterEnglish = SdlTtf.TTF_RenderText_Solid( new Font("fonts/PermanentMarker-Regular.ttf", 30).GetFontType(), "PRESS ENTER TO SELECT AN OPTION", hardware.White); amountOfOptions = optionsEnglish.Length; }
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 GlyphMetrics() { this.Quit(); this.Init(); IntPtr fontPtr = SdlTtf.TTF_OpenFont("../../FreeSans.ttf", 12); int minx; int miny; int maxx; int maxy; int advance; SdlTtf.TTF_GlyphMetrics(fontPtr, 1, out minx, out maxx, out miny, out maxy, out advance); Assert.AreEqual(-1, minx); Assert.AreEqual(4, maxx); Assert.AreEqual(0, miny); Assert.AreEqual(8, maxy); Assert.AreEqual(5, advance); // Console.WriteLine("minx: " + minx.ToString()); // Console.WriteLine("maxx: " + maxx.ToString()); // Console.WriteLine("miny: " + miny.ToString()); // Console.WriteLine("maxy: " + maxy.ToString()); // Console.WriteLine("advance: " + advance.ToString()); this.Quit(); }
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); }
public void DrawOption() { hardware.DrawImage(imgSupr); string[] tmp = map[count].Split('.'); fontMap = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), tmp[0], white); hardware.WriteText(fontMap, 360, 250); }
public Font(string fileName, int fontSize) { fontType = SdlTtf.TTF_OpenFont(fileName, fontSize); if (fontType == IntPtr.Zero) { Console.WriteLine("Font type not found"); } }
public void Load(string fileName, short sizePoints) { internalPointer = SdlTtf.TTF_OpenFont(fileName, sizePoints); if (internalPointer == IntPtr.Zero) { SdlHardware.FatalError("Font not found: " + fileName); } }
//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); }
/// <summary> /// Gets the size of the given text in the current font. /// </summary> /// <param name="textItem">String to display</param> /// <returns>The size of the text in pixels.</returns> public Size SizeText(string textItem) { int width; int height; SdlTtf.TTF_SizeUNICODE(this.Handle, textItem, out width, out height); GC.KeepAlive(this); return(new Size(width, height)); }
public Font(string fileName, int fontSize) { fontType = SdlTtf.TTF_OpenFont(fileName, fontSize); if (fontType == IntPtr.Zero) { Console.WriteLine("Font type not found: " + fileName + " " + fontSize); Environment.Exit(2); } }
public void OpenFontIndex() { this.Quit(); this.Init(); IntPtr fontPtr = SdlTtf.TTF_OpenFontIndex("../../FreeSans.ttf", 10, 0); Assert.IsFalse(fontPtr == IntPtr.Zero); this.Quit(); }
public void OpenFontIndexRW() { this.Quit(); this.Init(); IntPtr fontPtr = SdlTtf.TTF_OpenFontIndexRW(Sdl.SDL_RWFromFile("../../FreeSans.ttf", "rb"), 1, 12, 0); Assert.IsFalse(fontPtr == IntPtr.Zero); this.Quit(); }
public void CloseFont() { this.Quit(); this.Init(); IntPtr fontPtr = SdlTtf.TTF_OpenFontIndexRW(Sdl.SDL_RWFromFile("../../FreeSans.ttf", "rb"), 1, 12, 0); SdlTtf.TTF_CloseFont(fontPtr); this.Quit(); }
public void FontHeight() { this.Quit(); this.Init(); IntPtr fontPtr = SdlTtf.TTF_OpenFont("../../FreeSans.ttf", 9); Assert.AreEqual(SdlTtf.TTF_FontHeight(fontPtr), 12); this.Quit(); }
public void LinkedVersion() { Sdl.SDL_version version = SdlTtf.TTF_Linked_Version(); //Console.WriteLine("Ttf version: " + version.ToString()); Assert.AreEqual("2.0.7", version.major.ToString() + "." + version.minor.ToString() + "." + version.patch.ToString()); this.Quit(); }
public override void Show() { Credits[] remakers = new Credits[SIZE]; remakers[0].remaker = "Raul Gogna"; remakers[1].remaker = "Guillermo Pastor"; remakers[2].remaker = "Pepito Grillo"; bool escPressed = false; do { hardware.ClearScreen(); hardware.DrawImage(imgCredits); fontTexts = SdlTtf.TTF_RenderText_Solid(font32.GetFontType(), textfixed[0], green); hardware.WriteText(fontTexts, 330, 10); yText = 40; for (int i = 1; i < textfixed.Length; i++) { fontTexts = SdlTtf.TTF_RenderText_Solid(font24.GetFontType(), textfixed[i], black); hardware.WriteText(fontTexts, 250, (short)(startY + yText)); fontTexts = SdlTtf.TTF_RenderText_Solid(font24.GetFontType(), textfixed[i], red); hardware.WriteText(fontTexts, 248, (short)(startY + yText)); if (i == 12) { for (int j = 0; j < remakers.Length; j++) { fontRemakers = SdlTtf.TTF_RenderText_Solid(font24.GetFontType(), remakers[j].remaker, black); hardware.WriteText(fontRemakers, 250, (short)(startY + yText)); fontRemakers = SdlTtf.TTF_RenderText_Solid(font24.GetFontType(), remakers[j].remaker, red); hardware.WriteText(fontRemakers, 248, (short)(startY + yText)); yText += 20; } } yText += 20; } hardware.UpdateScreen(); int keyPressed = hardware.KeyPressed(); hardware.Pause(20); if (keyPressed == Hardware.KEY_ESC) { startY = 720; escPressed = true; exit = true; } if (startY > 100) { startY -= 5; } } while (!escPressed || !exit); }
public void FontFaceStyleName() { this.Quit(); this.Init(); IntPtr fontPtr = SdlTtf.TTF_OpenFont("../../FreeSans.ttf", 10); //Console.WriteLine("FontFaceStyleName:" + SdlTtf.TTF_FontFaceStyleName(fontPtr).ToString()); Assert.AreEqual(SdlTtf.TTF_FontFaceStyleName(fontPtr).ToString(), "Roman"); this.Quit(); }
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); }