RequireSystemScript('print.js');


function game(){

	ApplyColorMask(CreateColor(20,20,200)); // Blue background

	print(0,1, "This is printed\non the topleft in bold and italics\n", 'BI');  // end with \n, so the next text is on the next line.
	print("This line is just below the first one and has a shadow.", 'S'); // does not end with \n, so ...
	print(" This is the continuation of the second line", 'S'); // our text continues on the same line.
	print(GetScreenWidth()>>1,GetScreenHeight(), "This is plain text centered at the bottom (press any key to continue)", undefined, 0, 1);
	print(GetScreenWidth(), 0, "This is text is right-justified at the top", undefined, 1, -1);

	// A little show of html and super/subscript:
	print.ml(1, 70, "<s>For <b>a</b> = <b><i>1</i></b> and <b>b</b> = <b><i>4</i></b> calculate</s>");
	print.ml("<_5>a</_>"); // 'a' subscript 5
	print.setZoom(1, 4)( String.fromCharCode(131), print.fx.ZOOMY , -1,0); // Zoomed, Y-centered print
	print.ml("<^7>b</^>"); // 'b' superscript 7
	print ("e")
	print ("x", print.fx.ITALIC, -1, 0);
	print.ml ("dx &lt; x");

	FlipScreen();
	PressAnyKey();

	ApplyColorMask(CreateColor(20,20,200)); // Blue background

	print.ln(25, 25,  "Outlined + shadow", 'OS');
	print.ln("Only Outlined ", 'O');
	print.ln("Shadow + Outlined + Bold", 'SOB');
	print.setAngle(Math.PI/8);
	print.ln("Rotated + Bold", 'RB');
	print.ln("Rotated + Bold + Shadow", 'RBS');
	print.ln("Rotated + Bold + Shadow + Outlined", 'RBSO');
	print.ln("underlined", "U")
	print.ln(); // Empty line!
	print.setSkew(-8, 32);
	print.ln("Skewed Text X", "X")
	print.ln("Skewed Text Y Bold Underlined", "YUB")

	FlipScreen();
	PressAnyKey();

	ApplyColorMask(CreateColor(20,20,200)); // Blue background

	// The following 3 lines can be written as: print.setZoom(2, 2)(10,10, "Extra wide\n", 'W');
	print.setZoom(2, 2);
	print(10,10); // Set the cursor at (10,10)!
	print("Extra wide\n", 'W');  

	print("Extra wide + Bold\n", 'WB')
	print("Extra wide + Outlined\n", 'WO')
	print("Extra high + Outlined\n", 'HO')
	print(GetScreenWidth()>>1,GetScreenHeight()>>1, "Extra high + wide + Outlined, centered\n", 'HWO', 0,0)
	print.setZoom(0.75);
	print(GetScreenWidth()>>1,GetScreenHeight(), "Compressed Bold (press any key to continue)", print.fx.ZOOMX + print.fx.BOLD, 0, 1);

	FlipScreen();
	PressAnyKey();

	while(AreKeysLeft()) { GetKey(); }

	print.addFont('mistress9.rfn', "small"); // Load and Register the font as 'small'
//	print.addFont('/mike.rfn', "small");


	// Now for the finale: simple html!
	SetFrameRate(13);
	while (!AreKeysLeft()) {
		ApplyColorMask(CreateColor(20,20,200)); // Blue background
		print.ml(GetScreenWidth(),8,"THE <b>right</b> justification not working yet", undefined, 1);

		// All different type of 'A'
		print.ml(0,1,"A<->A</->A<B>A<U>A<I>A</I></U>A</B><S>A</S><p>");

		// For Neologix:
		print.ml("This <i>is</i> <h>markup <b>language</b></h>. <=>double-<s>strikethough</s></=>, <-><b>single</b> <U>strike<#FF0000>through</#></U></->"
			+"<#FF00FF>B<#FF33FF>u<#FF66FF><u>n</u><#FF99FF>n<#FFBBFF><i>y<#FFEEFF>-<u>R</u></i></#>a</#>b</#>b</#>i</#>t</#>." );
		print.ml(0,40,"_<B>_</B><->_</->_<I>_</I><S>_</S>"); // not perfect yet

		// A complex bit of html (includes <n> == print.fx.NERVOUS, moving text... ):
		print.ml(0,50,"<h1>Header</h1>This is our<b>body</b>,<br />and<br/>next line<h2>header2</h2>some text<h3>header3</h3>and more text: E=mc<^2>2</^>.<h4>Header4 </h4>"
			+"<p>Ipsum <n>lo</n><n>r</n><n>em</n></p>");
		print.ml(150,100,"<h2>A list</h2><li>item1</li><li>Item2</li>End of the list"); // numbered lists not implemented :(

		// The mistress9.rfn must be subscripted one pixel to look ok between the systemfont.
		print.ml(150,280,"Embedding<@small><_1> a <#FFFF00>different</#> </_></@>font. <@small><_1>For best effect use fonts with the same height.</_></@>");
		
		FlipScreen();
	}

	SetFrameRate(0); // Unthrottle

	ApplyColorMask(CreateColor(20,20,200)); // Blue background

	// Define our cursor position at 0,0, then print 'hello', then set the other font and print 'user'. Switch back to default font.
	print(0,0)("Goodbye ").setFont('small').ml("<_1>game programmer!</_>").setFont()(" Thanks for watching the print demo!");

	FlipScreen();
	PressAnyKey();

}

function PressAnyKey(){
	// clear Keyboard Buffer
	while(AreKeysLeft()) { GetKey(); }
	while (IsMouseButtonPressed(MOUSE_LEFT)) {}
	// Wait until a key is pressed
	while (!AreKeysLeft() && !IsMouseButtonPressed(MOUSE_LEFT)) {}
}
