Hi,
I am starting work on a new game and I have run into a problem very quickly. The problem is that when I run the code, the sprites appear to load correctly but most of them are not displayed. The code I use to prepare the game is shown below:
function InitialiseGame()
REM *** Set Display Settings ***
set display mode 640,480,16
set window on
maximize window
set window layout 1,1,1
set window title "Hnefatafl - The Viking Game"
color backdrop rgb(102,0,0)
backdrop on
REM *** Load Sprites ***
create animated sprite 1,"GraphicsMenu Background.png",1,1,1 ` Backgrounds
create animated sprite 2,"GraphicsBook Background.png",1,1,2
create animated sprite 3,"GraphicsScroll Background.png",1,1,3
create animated sprite 4,"GraphicsttlCredits.png",1,1,4 ` Page Titles
create animated sprite 5,"GraphicsttlHistory.png",1,1,5
create animated sprite 6,"GraphicsttlRules.png",1,1,6
create animated sprite 7,"GraphicsttlAccountCreation.png",1,1,7
create animated sprite 8,"GraphicsttlAccountRecovery.png",1,1,8
create animated sprite 9,"GraphicsttlHighscores.png",1,1,9
create animated sprite 10,"GraphicscmdHistory.png",1,1,10 ` Command Buttons
create animated sprite 11,"GraphicscmdCreateAccount.png",1,1,11
create animated sprite 12,"GraphicscmdRules.png",1,1,12
create animated sprite 13,"GraphicscmdPlayGame.png",1,1,13
create animated sprite 14,"GraphicscmdCredits.png",1,1,14
create animated sprite 15,"GraphicscmdAccountRecovery.png",1,1,15
create animated sprite 16,"GraphicscmdHighscores.png",1,1,16
create animated sprite 17,"GraphicscmdExit.png",1,1,17
create animated sprite 18,"GraphicscmdEnter.png",1,1,18
create animated sprite 19,"GraphicscmdBack.png",1,1,19
create animated sprite 20,"GraphicstxtEnterUserName.png",1,1,20 ` Text
create animated sprite 21,"GraphicstxtP1UserName.png",1,1,21
create animated sprite 22,"GraphicstxtP2UserName.png",1,1,22
create animated sprite 23,"GraphicstxtPassword.png",1,1,23
create animated sprite 24,"GraphicstxtPlzEnterAnswerToQ.png",1,1,24
create animated sprite 25,"GraphicstxtPlzEnterPassword.png",1,1,25
create animated sprite 26,"GraphicstxtPlzEnterRecoveryQ.png",1,1,26
create animated sprite 27,"GraphicstxtPlzEnterUserName.png",1,1,27
create animated sprite 28,"GraphicstxtUserName.png",1,1,28
create animated sprite 29,"GraphicsTextBox.png",1,1,29 ` GUI
REM *** Set Sprite Priorities ***
for c = 1 TO 3
set sprite priority c,0 ` Put backgrounds to the back
next c
for c = 4 TO 29
set sprite priority c,1 ` Put everything else in front of the backgrounds
next c
REM *** Set Sprite Frames ***
for c = 1 TO 29
set sprite frame c,1
next c
REM *** Offset Sprites ***
for c = 1 TO 9
offset sprite c,sprite x(c) / 2,sprite y(c) / 2 ` Focus images on their center
next c
for c = 10 TO 17
offset sprite c,sprite x(c) / 2,0 ` Focus command buttons at the top so they can be easily placed one after another
next c
for c = 18 TO 29
offset sprite c,sprite x(c) / 2,sprite y(c) / 2 ` Focus images on their center
next c
REM *** Size Sprites ***
REM *** Place Sprites ***
sprite 1,screen width() / 2,screen height() / 2,1 ` Menu background
sprite 2,screen width() / 2,screen height() / 2,2 ` Book background
sprite 3,screen width() / 2,screen height() / 2,3 ` Scroll background
sprite 4,screen width() / 2,screen height() / 5,4 ` Credits (on scroll background)
sprite 5,screen width() / 4,screen height() / 5,5 ` History (on book background)
sprite 6,screen width() / 4,screen height() / 5,6 ` Rules (on book background)
sprite 7,screen width() / 2,screen height() / 5,7 ` Account Creation (on scroll background)
sprite 8,screen width() / 2,screen height() / 5,8 ` Account Recovery (on scroll background)
sprite 9,screen width() / 2,screen height() / 5,9 ` Highscores (on scroll background)
nY = screen height() / 5 ` This hold the Y co-ordinate of the next stripe
for c = 10 TO 17 ` These are the command button's on the main menu
sprite c,screen width() / 2,nY,c ` This places the command button stripes one after another
nY = nY + sprite height(c) ` This adds the width of the last sprite to the Y co-ordinate
next c
sprite 18,(screen height() / 6) * 5,(screen height() / 6) * 5,17 ` Enter command button
sprite 19,screen height() / 6,(screen height() / 6) * 5,19 ` Back command button
sprite 20,20,screen height() / 4,20 ` Text: "Enter User Name :"
sprite 21,20,screen height() / 4,21 ` Text: "Player One User Name :"
sprite 22,20,screen height() / 2,22 ` Text: "Player Two User Name :"
sprite 23,(sprite x(20) + (sprite width(20) / 2)) - image width(22) / 2,(screen height() / 8) * 3,23 ` Text: "Password :" / places it in line with the end of player one
clone sprite 23,123 ` Creates new Text: "Password :"
sprite 123,(sprite x(21) + (sprite width(21) / 2)) - image width(22) / 2,(screen height() / 8) * 5,23 ` Text: "Password :" / places it in line with the end of player two
clone sprite 23,223 ` Creates new Text: "Password :"
sprite 223,screen width() / 2 - (image width(222) / 2),(screen height() / 2) + 100,23 ` Text: "Password :"
sprite 24,screen width() / 2 - (image width(23) / 2),screen height() / 2,24 ` Text: "Please enter the answer to the question :"
sprite 25,screen width() / 2 - (image width(24) / 2),(screen height() / 2) + 25,25 ` Text: "Please enter your password :"
clone sprite 25,125 ` Creates a second Text: "Please enter your password :"
sprite 125,screen width() / 2 - (image width(24) / 2),(screen height() / 2) + 50,25 ` Text: "Please enter your password :"
sprite 26,screen width() / 2 - (image width(25) / 2),(screen height() / 2) + 75,26 ` Text: "Please enter a recovery question :"
sprite 27,screen width() / 2 - (image width(26) / 2),screen height() / 4,27 ` Text: "Please enter your desired user name :"
sprite 28,screen width() / 2 - (image width(27) / 2),screen height() / 4,28 ` Text: "User Name :"
sprite 29,0,0,29 ` Create the original for the text box clones
nSpriteToTrack = 20 ` This stores which text box is assigned to which input
for c = 520 TO 529
clone sprite 29,c ` Create enough text boxes
sprite c,(sprite x(nSpriteToTrack) + (sprite width(nSpriteToTrack) / 2)) + 50,sprite y(nSpriteToTrack),29 ` GUI Text Box linked to "Enter User Name"
nSpriteToTrack = nSpriteToTrack + 1 ` Moves the counter to the next text input
next c
sprite 501,(sprite x(123) + (sprite width(123) / 2)) + 50,sprite y(123),29 ` These three are assigned to cloned text
sprite 502,(sprite x(125) + (sprite width(125) / 2)) + 50,sprite y(125),29
sprite 503,(sprite x(223) + (sprite width(223) / 2)) + 50,sprite y(223),29
REM *** Load Objects ***
for c = 101 TO 124
load object "GraphicsAttackBoardSquare.x",c ` Load all attacker board squares
next c
for c = 201 TO 212
load object "GraphicsDefenderBoardSquare.x",c ` Load all defender board squares
next c
for c = 301 TO 305
load object "GraphicsKingBoardSquare.x",c ` Load all king board squares
next c
for c = 401 TO 480
load object "GraphicsPlainBoardSquare.x",c ` Load all plain board squares
next c
for c = 501 TO 524
load object "GraphicsAttackerPiece.x",c ` Load all attacker pieces
next c
for c = 601 TO 612
load object "GraphicsDefenderPiece.x",c `Load all defender pieces
next c
load object "GraphicsKing.x",1
load object "GraphicsHouse.x",2
load object "GraphicsTable.x",3
REM *** Size Objects ***
for c = 101 TO 124
scale object c,object size x(3) / 14,object size y(3) / 14,object size z(c) / 2 ` Sizes board squares on the basis on the table
next c
for c = 201 TO 212
scale object c,object size x(3) / 14,object size y(3) / 14,object size z(c) / 2
next c
for c = 301 TO 305
scale object c,object size x(3) / 14,object size y(3) / 14,object size z(c) / 2
next c
for c = 401 TO 480
scale object c,object size x(3) / 14,object size y(3) / 14,object size z(c) / 2
next c
for c = 501 TO 524
scale object c,(object size x(101) / 4) * 3,(object size y(c) / 14) * 3,(object size z(101) / 4) * 3 ` Sizes pieces on the basis of the squares
next c
for c = 601 TO 612
scale object c,(object size x(101) / 4) * 3,(object size y(c) / 14) * 3,(object size z(101) / 4) * 3
next c
REM *** Place Objects ***
position object 2,0,0,0 ` Place the House in the center of the map
position object 3,0,-20,-50 ` Place the table in the middle of the room
DrawBoard() ` This draws all of the squares into the board
nPieceNumber = 501 ` This keeps track of which piece is being placed over the square
for c = 101 TO 124
position object nPieceNumber,object position x(c),object position y(c) + (object size y(nPieceNumber) / 2),object position z(c) ` This places attacking pieces over attaker squares
nPieceNumber = nPieceNumber + 1
next c
nPieceNumber = 601
for c = 201 TO 212
position object nPieceNumber,object position x(c),object position y(c) + (object size y(nPieceNumber) / 2),object position z(c) ` This places defending pieces over defeder squares
nPieceNumber = nPieceNumber + 1
next c
position object 1,object position x(301),object position y(301) + (object size y(1) / 2),object position z(301) ` This places the king on his starting square
REM *** Load Sound ***
REM *** Hide All ***
hide all sprites
HideAllObjects()
endfunction
Can anyone see why the sprites might not display. No error occurs with loading them yet they cannot be seen. Strangely, the text boxes (sprites 520 - 529) seem to show up OK. From this, I can tell that the other sprites are there as when I click on where they should be, the text boxes appear and then disappear when I click where back should be.
Any help would be greatly appreciated,
Lucas