Tutorial 1 Part 1

Right, we'll start with the basics. In this tutorial we will create a project which will put a sprite on the screen. Very simple!

Start by downloading this zip file (21kb). Create a new directory on your hard drive and extract the two files into this directory.

Start up DXC and select "New project workspace" from the file menu. Create the project in the same directory as the one you created above. You will now have a new project with a blank editor and empty banks window.

Right-click on the banks window and select Create New -> Image (BMP).

Right-click on the banks window

Select "background.bmp" and click "Open". The background image will now be added to the banks window. You should see a thumbnail and some information about the image.

Open an image

Right-click on the banks window again and create another new image. Select "walking man.bmp". The sprite sheet should be added to the banks window.

Right-click on the banks window and this time select Create New -> Sequence (SEQ). The Sequence editor will appear which we will use to create an animation sequence. Click on the sprite sheet on the left and enter these numbers into the fields on the right: Sprite X = 64 (the width of each frame), Sprite Y = 64 (the height of each frame), Sprite Count = 30 (there are 30 frames in total), X Count = 10 (there are 10 frames on each line in the sprite sheet). Select "Test" to see the animation.

Create an animation sequence

You should now have 3 banks in your program. Now enter the code below or copy and paste this text file into the editor. The best way to do this is to right-click on this link, select "Save Target As", download the text file and then open it in Notepad.


//TUTORIAL 1 PART 1

//DEFINE VARIABLES 1

Global KEYPRESS$

//DEFINE PROCEDURES
DefProc INIT_DISPLAY()
DefProc CREATE_SPRITES()

//---- START MAIN CODE ----

//CALL THE PROCEDURE TO CREATE THE SCREEN

INIT_DISPLAY() 2

//CALL THE PROCEDURE TO CREATE THE SPRITES
CREATE_SPRITES()

//START LOOP - THIS LOOP WILL REPEAT UNTIL A KEY IS PRESSED
Repeat 3

    KEYPRESS$ = Inkey$()
    Update Display
Until KEYPRESS$ > ""

//THE INIT_DISPLAY PROCEDURE CREATES A SCREEN AND A PLANE
Procedure INIT_DISPLAY() 4

    Create Map 640,480,1,1 In Bank 50 //CREATE A MAP IN BANK 50
    Set Tile 0,0,1 Using Bank 50 //CREATE A TILE USING A BACKGROUND IMAGE IN BANK 1
    Create Plane 1 Using Bank 50 //CREATE PLANE 1 USING THE MAP IN BANK 50
    //SET WHITE TO BE TRANSPARENT INSTEAD OF DEFAULT BLACK AS OUR SPRITE CONTAINS BLACK PIXELS
    Set Bitmap 2 Transparency To 255,255,255
EndProc

//THIS PROCEDURE WILL CREATE THE SPRITE
Procedure CREATE_SPRITES() 5

    Create Sprite 1,288,208 Using Bank 3 //CREATE SPRITE #1 AT 288,208 USING THE SEQUENCE IN BANK 3
    Sprite On 1 //ENABLE THE SPRITE
    Sprites On //NOW TURN ON THE SPRITE SYSTEM
EndProc

EndProg


1   The first section of the code declares all variables and procedures.

2   Next the code calls up the INIT_DISPLAY and CREATE_SPRITES procedures. Using procedures helps to keep the program tidy and allows you to use the same code as many times as you like without needing to repeat it over and over.

3   This is the start of the main program loop. It will repeat continuously, looking for input and refreshing the display, until a key is pressed. It is looking for any key press greater than nothing and it will then quit.

4  This procedure creates the screen and plane. You must create a screen and plane at the start of the program or else you will not be able to see anything.

5  This procedure creates the walking man sprite. The sprite is given a ID number of 1, placed in the middle of the screen and told that the sequence of images for the sprite is held in bank 3. You need to enable the sprite (sprite on 1) and then turn on the sprite system (sprites on). Both of these commands are needed or the sprite will not appear.

These two procedures may be placed anywhere after they are declared and called up but it is best that they are placed at the end of the program for tidyness. The code inside the procedures is not executed unless the procedure is called up in the program.



You should now be able to run this project. Click on the Run icon The run icon and click Start on the Run Time Debug Center. You should see a man walking in the middle of the screen.

You should see this man walking in the middle of your screen

Next Page