Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / How to load a title screen before the game loads

Author
Message
Ashley Leppington
12
Years of Service
User Offline
Joined: 1st Mar 2014
Location:
Posted: 1st Mar 2014 18:46
Hello everybody

I am trying load a title screen before the game loads.



load image "media\backdrops\Starting_Screen copy.png", 11
do
if stage = 0
paste image 11, 1024, 768, 32

if spacekey()
stage = 1
endif

endif
if stage=1

Function Init_game()
endif()

This is the code above but I keep getting an error message saying
"FUNCTION FunctionName (Function Parameters)" The highlighted code which has the error is the second last line of code in the code snippet above.

I do not know how to fix this error message. Please can somebody help me out. Many Thanks.
CSL
17
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: USA
Posted: 1st Mar 2014 22:00 Edited at: 1st Mar 2014 22:24
First off, the "do" has a missing "loop".

endif() should be endif with no parentheses.

Your functions must be separated from the main program.
Function Init_game() shouldn't be placed where it is, it's also missing an endfunction.
If your intention was to call the InitGame() function, then you should call it by using InitGame(), not Function InitGame()

There are also some logic errors, specifically with your if spacekey() statement. If the intention is to wait for the user to press the space key to continue, then you should add a condition for this. As it is, the program will not give a chance to press the space bar and it will continue until it crashes when it finds function in the middle of the code.

I made some updates to get you on the right track.



CSL
wattywatts
17
Years of Service
User Offline
Joined: 25th May 2009
Location: Michigan
Posted: 2nd Mar 2014 00:38
Generally, you want to call sync after displaying something and before loading something else. As CSL stated, there are some issues with your code, and simply loading an image won't display it, just load it into memory.

New sig coming soon..
ShellfishGames
13
Years of Service
User Offline
Joined: 6th Feb 2013
Location:
Posted: 2nd Mar 2014 02:24
And note that paste image does not take ID, width, height, depth as parameters as you seemed to assume in your code, but ID, x, y [, transparency flag]. Your IDE probably tells you what parameters a command expects at the bottom of the window, right below the code.

tiffer
20
Years of Service
User Offline
Joined: 6th Apr 2006
Location: Scotland
Posted: 2nd Mar 2014 17:39 Edited at: 2nd Mar 2014 20:30


Try this.

Cwatson
tiffer
20
Years of Service
User Offline
Joined: 6th Apr 2006
Location: Scotland
Posted: 2nd Mar 2014 18:00
Ps. the error message you're getting telling you that the program thread has ran into the function declaration at the bottom. This is because you haven't closed the loop.

Cwatson
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 2nd Mar 2014 20:37
Quote: "There are also some logic errors, specifically with your if spacekey() "


There's nothing wrong with that.

The following snippet works perfectly for me:






Powered by Free Banners
tiffer
20
Years of Service
User Offline
Joined: 6th Apr 2006
Location: Scotland
Posted: 3rd Mar 2014 19:12
Gandalf is right. spacekey() returns a boolean value(on/off) so 'if spacekey()' is logically correct.

Cwatson
timer help
12
Years of Service
User Offline
Joined: 14th Jan 2014
Location:
Posted: 10th Mar 2014 18:13
please use code tags
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 10th Mar 2014 23:31
More to the point, please respond to the help you've been given.



Powered by Free Banners
Ashley Leppington
12
Years of Service
User Offline
Joined: 1st Mar 2014
Location:
Posted: 11th Mar 2014 09:50
In my main loop of the game, I already have a init_game function. Will I have to get rid of this init_game function? Also does the code below need to go in the main game loop?


[/code]
load image "media\backdrops\Starting_Screen copy.png", 11

if stage = 0
paste image 11, 100, 100,1
repeat : until spacekey()
stage = 1
endif

if stage=1
`Function Init_game()
Init_game()
endif

end ` End Program

Function Init_game()
` Function code
ENDFUNCTION[code]

Login to post a reply

Server time is: 2026-07-06 19:40:43
Your offset time is: 2026-07-06 19:40:43