Flik: Sphere Central!
Docs!
Sphere Docs
Intro --- how to make a...
This is how to make an intro for your game...
Were going to draw an image and put some text on it...
A simple example is:-
[Note: The following code goes into your game.js file...]

EvaluateSystemScript("time.js");

function IntroScreen()
{
GetSystemFont().drawTextBox(0,0,GetScreenWidth(), GetScreenHeight(), 0, "lots of text here...");
FlipScreen(); // show the text
Delay(5000);
}

But if you have lots of text to show, that example is rubbish.
So here is a much better IntroScreen function that you might actually learn something from...
[Note: The following code goes into your game.js file replacing the code from above...]

EvaluateSystemScript("time.js");

function IntroScreen()
{
var x = 0;
var y = GetScreenHeight() + 10; // start at the bottom of the screen
var h = 50; // the height of the text box
var w = GetScreenWidth();
var txt = "Once upon a time in a land far away... There was a guy called heh, heh, blah, good luck!";
var background = LoadImage("intro.jpg");
while(y > -h) // force the txt to go up the screen
{
background.blit(0,0);
GetSystemFont().drawTextBox(x,y, w, h, 0, txt);
FlipScreen();
Delay(75)
y -= 1;
}
}

Yeah, now you have an IntroScreen function, that you can call upon by using:-

IntroScreen();

So for example your game function may look like:-

function game()
{
IntroScreen(); // call upon the intro
}

The intro function essentially works by...
Decreasing the y value of the call to font.drawTextBox(x,y,w,h, offset, txt)...
By decreasing this y value in a loop, the text vertically rises.

Now, the while(y > -h) means while y is greater than minus h.
So while y is greater than -50 in this case.

Also, it blit's a background image at (0,0) each time...
This image could be a picture of some stars, to fully achieve a stars wars type intro.

Once the txt is drawn, it calls FlipScreen() which copies the drawing that we've done from the backbuffer to the screen.
If we wanted to add some music to this intro we could do so like so:-

var song = LoadSound("blah.mp3");
song.play(true); // repeat the song forever
IntroScreen(); // call upon the intro
song.stop();

So for example your game function may look like:-

function game()
{
var song = LoadSound("blah.mp3");
song.play(true); // repeat the song forever
IntroScreen(); // call upon the intro
song.stop();
}

This isn't actually changing the IntroScreen function at all.
Its just wrapping music around it.

Thats its folks, soon, I will cover arrays..

Made By Flik!