Uhfgood

Hello World with blinking

Mar 30th, 2017
526
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Fake Text Mode, or Text Mode Simulator.  I wanted some text mode like functions for originally learning programming.
  2. // Haxe already has some console style functions in Sys, but then I realized I wanted to also do it on all platforms that
  3. // haxe targets, whether or not they had an actual text console.  So I chose to use Haxeflixel and arrange the characters
  4. // as a set of sprites (originally tiles but I couldn't set the individual tile colors).  The background colors are setup
  5. // in a tilemap with 16 different colored tiles set to the default cga/ega 16 colors.  The result here is a small set of
  6. // functions from which I hope to build a text console (like ms-dos, or dosbox), and can do things like make roguelike
  7. // games for phones.  Or old fashioned text adventures with ascii pictures, or what have you.
  8. package;
  9.  
  10. import flixel.FlxG;
  11. import flixel.FlxSprite;
  12. import flixel.FlxState;
  13. import flixel.math.FlxPoint;
  14. import flixel.util.FlxTimer;
  15. import haxe.ds.Vector;
  16.  
  17. import flixel.text.FlxText;
  18. import flixel.tile.FlxTilemap;
  19. import flixel.ui.FlxButton;
  20. import flixel.math.FlxMath;
  21.  
  22. import haxe.Utf8;
  23.  
  24. import TextSim;
  25.  
  26. class PlayState extends FlxState
  27. {
  28.     var ts : TextSim;
  29.    
  30.     override public function create():Void
  31.     {
  32.         // so to create a new 'textsim' we supply console width and height (in characters)
  33.         // glyph(character) width and height in pixels, and the asset paths to the character sets
  34.         ts = new TextSim( 80, 25, 8, 16, AssetPaths.sixteen_color_glyphs__png, AssetPaths.TextBack__png );
  35.         add( ts );
  36.  
  37.         ts.ClrScr();
  38.        
  39.         ts.PutChar( " ", 24, 12, null, "blue" );
  40.         ts.PutChar( "░", 25, 12, "cyan", "blue" );
  41.         ts.PutChar( "▒", 26, 12, "cyan", "blue" );
  42.         ts.PutChar( "▓", 27, 12, "cyan", "blue" );
  43.         ts.PutChar( "█", 28, 12, "cyan", "blue" );
  44.         ts.PutChar( "░", 29, 12, "white", "cyan" );
  45.         ts.PutChar( "▒", 30, 12, "white", "cyan" );
  46.         ts.PutChar( "▓", 31, 12, "white", "cyan" );
  47.         ts.PutChar( "█", 32, 12, "white", "cyan" );
  48.         ts.PutChar( "▌", 33, 12, "dkgray", "blue" );
  49.         ts.PutStr( "Hello World!", 34, 12, "ltyellow", "blue", true );
  50.         ts.PutChar( "▐", 46, 12, "dkgray", "blue" );
  51.         ts.PutChar( "█", 47, 12, "white", "cyan" );
  52.         ts.PutChar( "▓", 48, 12, "white", "cyan" );
  53.         ts.PutChar( "▒", 49, 12, "white", "cyan" );
  54.         ts.PutChar( "░", 50, 12, "white", "cyan" );
  55.         ts.PutChar( "█", 51, 12, "cyan", "blue" );
  56.         ts.PutChar( "▓", 52, 12, "cyan", "blue" );
  57.         ts.PutChar( "▒", 53, 12, "cyan", "blue" );
  58.         ts.PutChar( "░", 54, 12, "cyan", "blue" );
  59.         ts.PutChar( " ", 55, 12, null, "blue" );
  60.         super.create();
  61.     }
  62.  
  63.     override public function update(elapsed:Float):Void
  64.     {
  65.         super.update(elapsed);
  66.     }
  67.    
  68. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×