You can download Santa.zip to see an example of the ideas described here.
== Printing Text ==Printing text is a bit more complicated than we expect.
Color 0,0,0
The number 40 in LoadFont tells
the SIZE of the font. |
|
The TEXT command is simple - the first two numbers tell the position, followed by the message. The following 1,1 numbers tell it to center the text (usually a good idea).
Don't forget to choose a sensible color. At the beginning, the default color is black and the screen is black, so if you print a message at the beginning, you won't see it.
If you have a rounded image, you may see an ugly square surrounding background. To get rid of this, use Paint Shop Pro to fill the surrounding area with black (color 0,0,0) and save the pictures as a Windows Bitmap (.bmp). If your image has some black parts in it, you need to fill these with a slightly different color, e.g. color 4,4,4. This still looks black to the viewer, but BlitzBasic will not make that part transparent. For example:
If Santa looks like this
, then it will look like this in BlitzBasic :
Remember to save as a Windows Bitmap (.bmp).
You might want your "player" to changing directions - e.g. face
to the right when he is moving right, but face left when he is moving left.
You can do this by loading a different image. For example, instead
of just changing x = x - 3, you also change the image: santa
= santaLeft.
Then you
need to do 2 extra LoadImage commands at the beginning of the program -
one for santaLeft and
one for santaRight
Moving only |
Moving and Changing the Image |
... at the beginning .... .... inside the game loop ... If KeyDown(32) Then x = x + 3 ....... later ..... DrawImage santa, x , y |
... at the beginning .... santa = LoadImage("santaleft.bmp") If KeyDown(30) Then If KeyDown(32) Then .... later .... DrawImage santa, x , y |
Of course, you will need to use Paint Shop Pro to make two different santa pictures before using them in the program. You might also want an upSanta and a downSanta if he moves in those directions.
== Music ==
You can play music in the background. It only takes one command at the beginning of the program:
PlayMusic( "jbrock.mp3" )
Blitz Basic seems to play most normal music file formats: .wav,
.mid, .mp3
You won't be able to download mp3 files at school (they
are blocked),
but .wav and .mid files are okay. Try the following sites
(if you can't find something better):
http://www.wavplanet.com/ http://www.indianchild.com/Songs/funny_songs.htm
You can also play sound-effects when something happens. Put
the PlayMusic command
after an if ImagesOverlap... command.
You can get some sound effects from:
http://www.slinkycity.com/audio/
You won't want to use BOTH sound effects AND background music,
because
they will play at the same time.
You can restart your program (after winning) by doing the following:
To make levels, you just write one program following another.
(But don't
copy everything - see details below)
Then start
each new level with a label:
.Level1 at
the beginning
.Level2 before
the second level
.Level3 before
the third level
Now to start the second level, use the command:
GoTo
Level2
It might be a good idea to write each level as a separate program, fix all
the errors,
and then copy the various levels together into one program. It
is very difficult to find
and fix errors in a really big program.
** Don't Copy the Following **
Don't copy functions.
Don't copy the global command.
Don't
copy the type command(s).
If you run the program and it says "Duplicate identifier", then you have copied something that you shouldn't. You will need to delete the copy. Get help from the teacher if you can't get this to work.