Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Fake Text Mode, or Text Mode Simulator. I wanted some text mode like functions for originally learning programming.
- // Haxe already has some console style functions in Sys, but then I realized I wanted to also do it on all platforms that
- // haxe targets, whether or not they had an actual text console. So I chose to use Haxeflixel and arrange the characters
- // as a set of sprites (originally tiles but I couldn't set the individual tile colors). The background colors are setup
- // in a tilemap with 16 different colored tiles set to the default cga/ega 16 colors. The result here is a small set of
- // functions from which I hope to build a text console (like ms-dos, or dosbox), and can do things like make roguelike
- // games for phones. Or old fashioned text adventures with ascii pictures, or what have you.
- package;
- import flixel.FlxG;
- import flixel.FlxSprite;
- import flixel.FlxState;
- import flixel.math.FlxPoint;
- import flixel.util.FlxTimer;
- import haxe.ds.Vector;
- import flixel.text.FlxText;
- import flixel.tile.FlxTilemap;
- import flixel.ui.FlxButton;
- import flixel.math.FlxMath;
- import haxe.Utf8;
- import TextSim;
- class PlayState extends FlxState
- {
- var ts : TextSim;
- override public function create():Void
- {
- // so to create a new 'textsim' we supply console width and height (in characters)
- // glyph(character) width and height in pixels, and the asset paths to the character sets
- ts = new TextSim( 80, 25, 8, 16, AssetPaths.sixteen_color_glyphs__png, AssetPaths.TextBack__png );
- add( ts );
- ts.ClrScr();
- ts.PutChar( " ", 24, 12, null, "blue" );
- ts.PutChar( "░", 25, 12, "cyan", "blue" );
- ts.PutChar( "▒", 26, 12, "cyan", "blue" );
- ts.PutChar( "▓", 27, 12, "cyan", "blue" );
- ts.PutChar( "█", 28, 12, "cyan", "blue" );
- ts.PutChar( "░", 29, 12, "white", "cyan" );
- ts.PutChar( "▒", 30, 12, "white", "cyan" );
- ts.PutChar( "▓", 31, 12, "white", "cyan" );
- ts.PutChar( "█", 32, 12, "white", "cyan" );
- ts.PutChar( "▌", 33, 12, "dkgray", "blue" );
- ts.PutStr( "Hello World!", 34, 12, "ltyellow", "blue", true );
- ts.PutChar( "▐", 46, 12, "dkgray", "blue" );
- ts.PutChar( "█", 47, 12, "white", "cyan" );
- ts.PutChar( "▓", 48, 12, "white", "cyan" );
- ts.PutChar( "▒", 49, 12, "white", "cyan" );
- ts.PutChar( "░", 50, 12, "white", "cyan" );
- ts.PutChar( "█", 51, 12, "cyan", "blue" );
- ts.PutChar( "▓", 52, 12, "cyan", "blue" );
- ts.PutChar( "▒", 53, 12, "cyan", "blue" );
- ts.PutChar( "░", 54, 12, "cyan", "blue" );
- ts.PutChar( " ", 55, 12, null, "blue" );
- super.create();
- }
- override public function update(elapsed:Float):Void
- {
- super.update(elapsed);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement