SpriteControlHelp.txt171010644640102025055660580802526820360556verdana 10Times_New_Roman 12Times_New_Roman 12 underscoreTimes_New_Roman 10HelpCloseJust Basic Game Creator v4.3Produced by D.J.Sellings. November 2010

This application will help all you budding developers to quickly build your program graphics and see them move and interact.

A major part of producing graphics is the volume of coding and calculations for placing and moving, this application does this for you!

Once you understand the approach and naming of routines, you will be able to create coding to form the basis of any game.

To get the best from this application you will need to have a basic understanding of Just Basic to be able to pick up and develop your creations fully.


                                    Have fun.Display Screen LayoutThere are seven sections in the screen display:

1) Top level Drop Down Menu Controls

2) A Header that displays the current loaded Workfile, drive and folder path

3) A List box showing all loaded sprites, backgrounds and any copied sprites
Note: All loaded bmps are saved to memory, copied sprites are not, these are copies of existing sprites.

4) Main Graphics display (640pixels x 480pixels)

5) Example picture of previously created games using this program

6) A secondary graphics control panel were functions can be selected using the mouse. All controls can also be accessed via the drop down menus

7) A button (Create Code) to access the code creation screenFunction Reference 1Load bmp(s)
Loads sprite bmps into memory and displays their names in the Sprite List for use in your program. You can use the 'Unload a bmp' function to delete and clear memory.

Unload bmp
Before unloading a bmp from memory ensure you have removed any sprites showing in the screen display, then select the 'Unload bmp' option and click on the sprite name in the list box you want to remove.

Add Sprite
Adds your loaded sprites to the display at top left position. You can use the Position Sprite function to place anywhere on the display.

Add Sprite List
This function loads the sprite images as a list to enable animation. Click your first sprite and then you will be asked if you want to add another. Continue adding until complete and then click 'no' to finish. You will only see the first image until you start your animation cycle or select an individual image to display.

Remove Sprite
Will remove selected sprite from the display screen but will still be available in the Sprite List to add again if required.

Position Sprite
Using this function you can select and move any of your sprites in the display. Click on the sprite in the screen, use your mouse to position and then release the left mouse button to finalise. You can use the x, y, coordinates at the bottom of the screen to help.Function Reference 2Set Sprite Path
You can select a sprite and using the mouse move the sprite to different positions creating a path for the sprite to follow. In the Options you can set the 'Run Path' to on and enter a sprite name and that sprite will follow the set route.

Copy Sprites
Useful when you need to creat walls, platforms, etc. You can create as many copies as needed from a loaded sprite with each copy having their own number as a suffix to the original name.

Scale Sprite
Option to change the size of an sprite. In the input box enter the % size requred. 100 is the current size so 50 will be half size and 200 will double the sprite size.

Redraw Sprites
When opening another window over this application window or after minimising, there will be instances that it does not refresh. Just click this option to redraw the display screen.

Sprite Visible / Invisible
You can set the visibility of a sprite to on or off, select which option and click on the sprite name in the list box..

Sprite Coordinates
Click on the sprite name in the list box and it will display its x, y coordinates within the screen display.

Set Sprite Direction
Click sprite name in list box and type in direction. Options are; Normal, Mirror, Flip and Rotate 180.Function Reference 3Find a sprite.
A unique facility for finding a sprite by name when you have multiple sprites on screen. When selected you use the mouse and click a sprite on the screen and using the collision function it highlights the name of sprite selected.

Set Active Sprite
You can input the name to be treated as the current player 1. This can also be done in the Options box.

Options
Options function opens a window to the control variables. Here you can set and test everything from jump height, to turning on sprite animation. You will need to practise what affects changing values has but that is part of the fun of this package.

Additional Options
More control variables for lives and scores

Set Background
Uses a loaded bmp and sets it as your display background. Do not use sprites as backgrounds as it will distort the picture. Backgrounds are standard pictures and do not use the sprite shading. To set a background just click the name in the list box. You can set another background anytime in your program by overwriting existing.Function Reference 4Set Key Controls
You can select a key and link it to a routine. i.e. select the left arrow key and then select the 'move sprite left' routine. When you run your program the player1sprite left movement will be controlled by this key. When you click this option a message will ask you to press a key. When a key is pressed a window will display the key pressed and you then select a routine from the combo box to be linked to this key. Pressing the 'ESC' key will end the key routine.Options 1Sprite Height
Height in pixels of the main player. It is important that this is added as it is used to determine the sprites y position in the games.

Sprite Width
Width in pixels of the main player. It is important that this is added as it is used to determine the sprites x position in the games.

Collision Check
Up to 10 names can be added and will be used when checking for collisons with main player.

Player Name
Name of main player, usually called 'player1' and can be changed in game play.

Animation on/off
Set animation routine to on or off and every loop through main play will run the animation routine. You can use the delay parameter to adjust the speed.

Turn Sprite on/off
Turns sprite to face way it is walking, aligned to which way the sprite direction is set.

Ground level x
Used to determine ground level if the Parachute option is on. x1 is current floor level, x2 will double the fall level.

Bounce Routine on/off
If set to on then the sprite will bounce off any obstacle it hits at a variable line away from the obstacleOptions 2Parachute on/off
If set to on then main player will continually fall if not in contact with an obstacle. Mainly used in platform games.

Free Movement on/off
Use if you want your sprite to move continually until an event ocurres or a key is pressed.

Ladders on/off
There is a specific routine to manage a sprite when on a ladder. If a sprite touches a ladder object then it can go up, down but cannot go left or right after rung 1.

Move All on/off
Used for scrolling. This routine scrolls all objects listed in the 'MoveAll' box in Options, left or right as a group, the other option is to scroll the background. Example of this way of scrolling can be found in the turtle game.

Run Path on/off
If you have created a set of path xy nodes then setting this option to on will start the path sprite following its path

Path Sprite Name
Name of the sprite you want to follow the path you have created.

Jump Height
If you have set your sprite to jump this is the height in pixels it will rise.

Jump Distance
If you have set your sprite to jump this is the distance in pixels it will travel in the direction set for your sprite.
.Options 3Gravity
Puts a delay on sprite movement. Play about with values to get optimum result.

Left Speed
Decreasing the value will speed up the sprite movement,

Right Speed
Increasing the value will speed up the sprite movement,

Up Speed
Decreasing the value will speed up the sprite movement,

Down Speed
Increasing the value will speed up the sprite movement,

Pause lenth
Another method for putting a delay in any movement routine. Play with values to get best results.

Top Point
You can set an y position a sprite will stop at.

Bottom Point
You can set an y position a sprite will stop at.

Left Point
You can set an x position a sprite will stop at.

Right Point
You can set an y position a sprite will stop at.Options 4Levels
Enter the number of levels you want the game to run before it comes to end of game. You must ensure each level file is suffixed with level number i.e platformgame1, platformgame2, etc.

Key Set
Displays the keys and their routines that have been created via the 'key control' function.Example  (save baby turtle)Step 1
From the files menu select 'Open workfile' and in the file dialog box select and open the file 'workfile_turtle_game_L1.txt' from the 'turtle_game' folder. You will see that when the file loads the sprite list has a number of sprites, sc1 is the background screen, plat1/plat3 are used for the walkways, box, stakes, babyturtle and player 1-5 are objects and players. Finally, there are copies of sprites. These are copies of loaded sprites and you can make as many copies as required.

This example is not a completed game or level but enough to show what can be achieved quite easily. Control Keys are the left arrow, right arrow, spacebar, Z key to push box and X key to pull box. Toggle Z and X with arrow keys to keep moving the box, touching the babys bubble releases baby turtle. Check the options box to see the key functions and how the options have been set. Click through the collision check list to see what collision names have been entered. The game aim is to find baby turtle and release him from the bubble that he is trapped in.

Step 2
Firstly, use the left and right arrow keys to check turtle movement and then press the spacebar to check jumping. Ok, before we try and break this example down, have a play. Try going right using the box to cross the hole with spikes and to jump onto the large block but not too far as to end up walking of the block. Then make your way left using the box until you find baby turtle and release him by touching the bubble.

Now you have had a play I hope you like what you see. This is by no means the best you can get your game play, this will depend on how patient you are with your graphics, animations and control activity but please bear in mind Just Basic cannot compete with the higher level programming packages.Lets create a game (Breakout)There is a completed game level version of breakout that comes with this application which you can load and play. The following instructions will show how it was designed.

Step 1
Ensure you have reset the application or have just started from new.

Step 2
First we will load all our bmp sprites and background into memory, do this by selecting 'Load Sprites' from the 'Sprite Functions list'. When file dialog box has opened then select the 'bmps' folder and select each sprite bmp file and click open, repeat this until all your sprites are loaded and then click 'cancel' to end.

Sprites to load are:
            breakout_background.bmp
            brickblue.bmp
            brickred.bmp
            brickgreen.bmp
            ball.bmp
            player1.bmp

Step 3
Set the game background using sprite 'breakout background' Do this by selecting 'Set Background' from the functions list, click 'ok' to the information notice widow and then click on the sprite name in the 'Sprite List'.Breakout continued 1Step 4
Now we need to do the boring bit, add the wall bricks. We will use copies of the three brick sprites we have previously loaded. Click the 'Copy Sprite' function, accept the info notice and then click one of the three coloured brick sprites. As you move your mouse around the screen you will see the mouse x, y coordinates at the bottom of the display screen. This will help to determine your placement coordinates and to line up your bricks.

I started my wall at coordinates 90x, 120y and each brick was placed 30 pixels apart going across and 16 pixels apart going down but you can position where you think best.

Once you have the brick in position, release the mouse button. You are now asked if you wish to make another copy, click yes and repeat the process until you have laid all your bricks. When finished then click 'no' to any more copies. You can do the same for the different coloured bricks.Breakout continued 2Step 5
We now need to add and position the bat and ball. For this we will use the main sprites and not copies. We could use copies but as we only need one of each and they are the main players in this game then let's keep them named individually rather than copies of.

Select the 'Add Sprite' from the functions list, accept the info notice and click on the player1 sprite, this is the bat. Using the mouse, position the bat (use the x, y coordinates) in the middle of the screen just up from the bottom, exact coordinates are not vital.

Repeat the above for the ball and position the ball in the middle of the screen above the bat and just below your wall.

Step 6
We now need to set the options to make this game come to life.

>   Set the Sprite Height to 12 and Sprite Width to 64 (bat height and width)
>    Set Collision Check 1 to 'copybrick'. This will ensure that the ball will check and find all collisions with any brick sprite. Set Collision Check 2 to 'player1', this will check for the ball hitting player1.
>   Set Top to 0, Bottom to 440, Right to 620  and Left to 0
>    Set Player Name to 'player1', this is the bat.
>    Set Bounce to 'on' and leave all other switch options to 'off'.
>    The only other parameters to set is the Gravity to (10 - 14) and the left and right speeds to (-2 and 2). These can be changed to speed up or slow down play.

To start your game you can click run under the Game drop down menu or click mouse on game screen and move bat to start.Creating CodeWhen the 'Create Code' button is pressed the Code window will open with blank editor screens. There are two editors, the Code Editor screen is used to show and edit the generated code for saving as a .bas file. The second General Editor allows the user to open other text files, Actions, Routines, other bits of coding etc, so the user can copy and past into the main code editor.

Options are:
Save files (.txt or .bas)
Open saved files
Clear editor screens (this clears both editor screens, use Select and Cut for individual editors)
Create program code
Run Code (opens another session of JustBasic and loads file for running)
Exit Code Screen and returns back to main program window

The code output is automatically generated from files, 'maincode.txt', 'workfile.txt', 'routines.txt' and current variables held in our Options parameters. All this is done automatically and once this has been generated then we can add any additional commands or actions to expand game playability. To assist this you can open a text file in the general editor and cut and paste code into your main code file.RoutinesWhen your code is created it includes the routines used whilst developing your game structure. If for any reason a routine has not been added then you can click the check box and run create code and the routine will be added. To remove the routine, uncheck the box and run create code again, this time the code is generated without the routine.

All routines are held in the file 'Routines.txt' and if you want to add new routines this is where they go along with the routine added to the SpriteControl .BAS file. Please follow the same structure by adding the next numbered title for the routine.User Q & A page1(Q) When I create the code from my game it does not contain all the routines needed.
(A) To ensure all routines are include in your code you need to play your game to ensure all routines are captured. This means moving your character left and right, jumping, etc. The program marks each routine used and then includes them in the coding. If any routine is not included you can copy from the routines.txt file and past into your codeing.

(Q) What is a routine?
(A) Routines are pre-defined actions, i.e move sprite left, jump sprite, push or pull an object. Using the Key Control function you can link a key to a routine. Once you have a good understanding of routines and how they work then feel free to add your own.

(Q) I sometimes get an error saying program cannot find a bmp file can you help?
(A) The most common cause is how and where you have set up your file and folders. I would advise you extract and install the SpriteControl folder (and sub folders) under your JustBasic folder. Within the program it uses the 'DefaultDir$' for identifying the Dir/path/file. If you create folders outside of the main 'SpriteControl' it may not find it.

(Q) When other windows open over my screen or if I minimise my window the graphics get overwritten!
(A) I have reduced the times this can happen but not all instances. If you lose your screen for whatever reason, just click on the 'pencil' icon to redraw your screen graphics.
