public AnimatedImage(string path, IntVector2 imageSize, int frames) { _imageSheet = new TCODImage(path); ImageSize = imageSize; Frames = frames; ImageIndex = 0F; Reverse = false; }
// Set up and display the main menu public void DisplayMainMenu() { // Setup the logo image TCODImage titleLogoImage = new TCODImage("titlelogo.bmp"); // Blit the image to the background titleLogoImage.blit2x(rootConsole, 0, -1); topOfMenu = 18; PrintMainMenu(); topOfMenu = 25; }
public SplashscreenScene(Game game) : base(game) { splashscreens = Directory.GetFiles("Assets/Splashscreens") .Select(fileName => new TCODImage(fileName)).ToArray(); if (splashscreens.Length == 0) { Game.ChangeScene(new MainMenuScene(Game)); return; } currentDelay = delayPerScreen; currentSplashscreenIndex = 0; currentSplashscreen = splashscreens[currentSplashscreenIndex]; }
private static void Initialize() { NoiseManager.GeneratePerlinImage(imageSize).Save("heightmap.png",System.Drawing.Imaging.ImageFormat.Png); img = new TCODImage("heightmap.png"); TCODConsole.initRoot(80, 80, "MapGen", false, TCODRendererType.OpenGL); root = TCODConsole.root; TCODConsole.setCustomFont("Data/terminal12x12_gs_ro.png", (int)TCODFontFlags.LayoutAsciiInRow,16,16); TCODSystem.setFps(60); random = new Random(); stopwatch = new Stopwatch(); stopwatch.Start(); }
public static TCODImage ImageToTCODImage(Image img) { TCODImage toReturn = new TCODImage(img.Width, img.Height); Bitmap imageToProcess = new Bitmap(img); //Console.WriteLine(imageToProcess.Width + "|" + imageToProcess.Height); for (int i = 0; i < imageToProcess.Width; i++) { for (int j = 0; j < imageToProcess.Height; j++) { Color c = imageToProcess.GetPixel(i,j); toReturn.putPixel(i, j, new TCODColor(c.R, c.G, c.B)); } } return toReturn; }
// Display the intro public void DisplayIntro() { int XLoc = 1; foreach (string s in Intro) { DisplayText(s, 1, ++XLoc, TCODColor.white, TCODColor.black, -1); } DisplayText("Press any key to start...", -1, 30, TCODColor.grey, TCODColor.black, -1); // Setup the logo image TCODImage rightMenuImage = new TCODImage("icicle.bmp"); // Blit the image to the background rightMenuImage.blit2x(rootConsole, 63, 2); }
public override void Update(float deltaTime) { currentDelay -= deltaTime; if (currentDelay <= 0.0f) { currentSplashscreenIndex += 1; currentDelay += delayPerScreen; if (currentSplashscreenIndex >= splashscreens.Length) { Array.ForEach(splashscreens, s => s.Dispose()); currentSplashscreen = null; // To keep render from breaking. Game.ChangeScene(new MainMenuScene(Game)); } else { currentSplashscreen = splashscreens[currentSplashscreenIndex]; } } }
// Set up the title screen public void DisplayTitleScreen() { // Setup the logo image TCODImage titleLogoImage = new TCODImage("titlelogo.bmp"); // Blit the image to the background titleLogoImage.blit2x(rootConsole, 0, -1); // Set up the title text# int yloc = 25; DisplayText("by & (c) Dave Moore ([email protected])", -1, yloc++, TCODColor.white, TCODColor.black, -1); DisplayText("(Version " + Application.ProductVersion.ToString() + ")", -1, yloc++, TCODColor.grey, TCODColor.black, -1); yloc++; DisplayText("for the 2011 7-Day Roguelike Challenge (7DRL) (http://7drl.org)", -1, yloc++, TCODColor.silver, TCODColor.black, -1); yloc++; DisplayText("Released under the GNU Public License (GPL) v2", -1, yloc++, TCODColor.grey, TCODColor.black, -1); DisplayText("Powered by Libtcod 1.5", -1, yloc++, TCODColor.grey, TCODColor.black, -1); yloc++; DisplayText("Press any key to continue...", -1, yloc, TCODColor.white, TCODColor.black, -1); }
public TitleModel() { TitleScreen = new TCODImage("content/images/logo.png"); }
private static void Update() { TCODKey key = TCODConsole.waitForKeypress(false); double move = 0.1; switch (key.KeyCode) { case TCODKeyCode.Left: { NoiseManager.XLower -= move; img = Helper.ImageToTCODImage(NoiseManager.GeneratePerlinImage(imageSize)); break; } case TCODKeyCode.Right: { NoiseManager.XLower += move; img = Helper.ImageToTCODImage(NoiseManager.GeneratePerlinImage(imageSize)); break; } case TCODKeyCode.Up: { NoiseManager.YLower -= move; img = Helper.ImageToTCODImage(NoiseManager.GeneratePerlinImage(imageSize)); break; } case TCODKeyCode.Down: { NoiseManager.YLower += move; img = Helper.ImageToTCODImage(NoiseManager.GeneratePerlinImage(imageSize)); break; } } TCODConsole.setWindowTitle(stopwatch.ElapsedMilliseconds.ToString()); /* if (stopwatch.ElapsedMilliseconds >100) { img = Helper.ImageToTCODImage(NoiseManager.GeneratePerlinImage(imageSize)); stopwatch.Restart(); } */ }
void render_image(bool first, TCODKey key) { sampleConsole.clear(); if (img == null) { img = new TCODImage("skull.png"); circle = new TCODImage("circle.png"); } if (first) TCODSystem.setFps(30); /* limited to 30 fps */ sampleConsole.setBackgroundColor(TCODColor.black); sampleConsole.clear(); float x = SAMPLE_SCREEN_WIDTH / 2 + (float)Math.Cos(TCODSystem.getElapsedSeconds()) * 10.0f; float y = (float)(SAMPLE_SCREEN_HEIGHT / 2); float scalex = 0.2f + 1.8f * (1.0f + (float)Math.Cos(TCODSystem.getElapsedSeconds() / 2)) / 2.0f; float scaley = scalex; float angle = TCODSystem.getElapsedSeconds(); uint elapsed = TCODSystem.getElapsedMilli() / 2000; if (elapsed > lastSwitch) { lastSwitch = elapsed; swap = !swap; } if (swap) { /* split the color channels of circle.png */ /* the red channel */ sampleConsole.setBackgroundColor(TCODColor.red); sampleConsole.rect(0, 3, 15, 15, false, TCODBackgroundFlag.Set); circle.blitRect(sampleConsole, 0, 3, -1, -1, TCODBackgroundFlag.Multiply); /* the green channel */ sampleConsole.setBackgroundColor(green); sampleConsole.rect(15, 3, 15, 15, false, TCODBackgroundFlag.Set); circle.blitRect(sampleConsole, 15, 3, -1, -1, TCODBackgroundFlag.Multiply); /* the blue channel */ sampleConsole.setBackgroundColor(blue); sampleConsole.rect(30, 3, 15, 15, false, TCODBackgroundFlag.Set); circle.blitRect(sampleConsole, 30, 3, -1, -1, TCODBackgroundFlag.Multiply); } else { /* render circle.png with normal blitting */ circle.blitRect(sampleConsole, 0, 3, -1, -1, TCODBackgroundFlag.Set); circle.blitRect(sampleConsole, 15, 3, -1, -1, TCODBackgroundFlag.Set); circle.blitRect(sampleConsole, 30, 3, -1, -1, TCODBackgroundFlag.Set); } img.blit(sampleConsole, x, y, TCODCBackgroundHelpers.CreateAddAlphaBackground((float).6), scalex, scaley, angle); }
static void Main1(string[] args) { Console.WriteLine("Hello World!"); Console.WriteLine( "Seriously even!" ); Console.WriteLine("Commit by Alex Williams."); Console.WriteLine("I want you inside me."); Console.Beep(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); // Define constants for the size of the window so that window- //dependant things can be easily updated const int WINDOW_WIDTH = 100; const int WINDOW_HEIGHT = 80; // Display an initializing message to the console Console.WriteLine( "Initilizing game window..." ); // Create the new libtcod output window. This needs to be done only // once, but before anything else. The first value is the width in // cells the window is, the second is the height in cells, and the // third is the name of the window TCODConsole.initRoot( WINDOW_WIDTH , WINDOW_HEIGHT , "Hello World!" ); TCODRendererType renderer = TCODSystem.getRenderer(); // Print to the console what renderer your machine is using. GLSL // is "best", but supported by fewer machines. Then comes OpenGL, // then straight SDL Console.WriteLine("Renderer is: " + renderer.ToString()); // Load the "skull.png" image file from the exectuable directory TCODImage skullImage = new TCODImage( "skull.png" ); // Set the maximum graphical update speed. This is important to // massively reduce CPU use with unnecessary updates TCODSystem.setFps( 30 ); // Set the default background color of the root console with black TCODConsole.root.setBackgroundColor( TCODColor.black ); // Clear is a function that overwrites every cell in the window with // a plain, empty cell of the color dictated by setBackgroundColor() TCODConsole.root.clear(); // Flush writes the graphical data that is pending to the screen. // Any graphics updates are not shown to the screen until flush is // called. Try to minimize this call TCODConsole.flush(); // Create a key variable to capture keyboard input TCODKey Key = TCODConsole.checkForKeypress(); // These two variables will track the location of the player sprite int x = 0; int y = 0; // Boolean used to determine if the credits have been played yet, // and ensures it is only played once bool creditsDone = false; // While the user has not closed the window and while the user has // not pressed escape, do stuff while ( !TCODConsole.isWindowClosed() && Key.KeyCode != TCODKeyCode.Escape ) { // Set the default background color of the root console with // black. This is neccessary because the credits animation // changes the default background color for some reason if ( !creditsDone ) { TCODConsole.root.setBackgroundColor( TCODColor.black ); } // Make sure the screen is blank before writing on it again with // graphical updates TCODConsole.root.clear(); // Display the credits graphic for the libtcod library if ( !creditsDone && TCODConsole.renderCredits( 50 , 50 , false ) ) { creditsDone = true; } // Block until the user presses a key, then capture that key Key = TCODConsole.checkForKeypress( (int)TCODKeyStatus.KeyPressed); // If the key pressed is an arrow key, update the location that // the character sprite will be rendered at. However, ensure // that the location of the character never goes out of bounds // of the screen if ( Key.KeyCode == TCODKeyCode.Down ) { y = (y + 1 < WINDOW_HEIGHT ) ? y + 1 : y; } else if ( Key.KeyCode == TCODKeyCode.Up ) { y = ( y - 1 > -1 ) ? y - 1 : y; } else if ( Key.KeyCode == TCODKeyCode.Right ) { x = ( x + 1 < WINDOW_WIDTH ) ? x + 1 : x; } else if ( Key.KeyCode == TCODKeyCode.Left ) { x = ( x - 1 > -1 ) ? x - 1 : x; } // If the player is 30 cells in the x and y direction away from // the origin, display text in a window frame around the moving // player if ( x >= 30 && y >= 30 ) { // Print the frame, where the top left origin of the frame // is the length of the first string to the left of the // player, and up one cell from the player, and the box // extends to twice + 1 the length of the strings // (accomodating the players sprite), and three cells down TCODConsole.root.printFrame( x - 16 , y - 1 , 33 , 3 ); // Set the color to be used for the strings TCODConsole.root.setForegroundColor( TCODColor.magenta ); // Print the strings before and after the player, with the // proper alignement TCODConsole.root.printEx( x - 1 , y , TCODBackgroundFlag.Set , TCODAlignment.RightAlignment , "TROLOLOLOLOL XD" ); TCODConsole.root.printEx( x + 1 , y , TCODBackgroundFlag.Set , TCODAlignment.LeftAlignment , "DX TROLOLOLOLOL" ); // Revert the foreground color back to white for printing // everything else TCODConsole.root.setForegroundColor( TCODColor.white ); } // If the player sits inside cell (45,45), draw the skull to // the screen, where the center of the skull is at (20,20) if ( x == 45 && y == 45 ) { skullImage.blit( TCODConsole.root , 20f , 20f ); } // Print a helpful hint at the bottom left corner, with a left // alignment TCODConsole.root.printEx( 0 , WINDOW_HEIGHT - 1 , TCODBackgroundFlag.Set , TCODAlignment.LeftAlignment , "Go to (45,45)!" ); // Display the x and y coordinates in the bottom right // corner, each with a right alignment TCODConsole.root.printEx( 96 , 79 , TCODBackgroundFlag.Set , TCODAlignment.RightAlignment , "" + x ); TCODConsole.root.printEx( 99 , 79 , TCODBackgroundFlag.Set , TCODAlignment.RightAlignment , "" + y ); // Print the character sprite with a center alignment TCODConsole.root.printEx( x , y , TCODBackgroundFlag.Set , TCODAlignment.CenterAlignment , "@" ); // Flush the changes to the screen TCODConsole.flush(); } }
public void loadMapImg() { img.clear(TCODColor.black); img = new TCODImage("assets/levels/map" + (engine.gameState.curLevel + 1) + ".png"); }
public GUI(Engine engine) { this.engine = engine; this.con = new TCODConsole(Globals.WIDTH, Globals.PANEL); this.img = new TCODImage("assets/levels/map" + (engine.gameState.curLevel + 1) + ".png"); }
public MenuCode pick() { TCODImage img = new TCODImage("assets/menu_background.png"); int selected = 0; while (!TCODConsole.isWindowClosed()) { img.blit2x(TCODConsole.root, 0, 0); int current = 0; foreach (MenuItem item in items) { if (current == selected) { TCODConsole.root.setForegroundColor(TCODColor.lighterOrange); } else { TCODConsole.root.setForegroundColor(TCODColor.lightGrey); } TCODConsole.root.print(10, 10 + current * 3, item.label); current++; } TCODConsole.flush(); TCODKey key = TCODConsole.checkForKeypress(); switch (key.KeyCode) { case TCODKeyCode.Up: selected--; if (selected < 0) { selected = items.Count - 1; } break; case TCODKeyCode.Down: selected = (selected + 1) % items.Count; break; case TCODKeyCode.Enter: return items[selected].code; default: break; } } return 0; }