#35028 - Mitch GBA - Sat Jan 29, 2005 3:47 pm
Another question :D
I want my game to have some credit and title screens before the actual game starts. How do I do this? I tried having like:
while(level ==1)
{
level 1;
}
while(level ==2)
{
level 2;
}
etc.. But it didn't work. What do I do?
#35030 - Fatnickc - Sat Jan 29, 2005 4:07 pm
Err, how about this (pseudocode, adapt to your usage):
Code: |
BackgroundData=background1;
if(key(keyStart))
BackgroundData=background2;
if(key(keyStart))
{
BackgroundData=background3;
mainGame();
} |
Obviously you won't be able to just 'use' that, but if you know what to do in the basics, you'll work it out ;).
#35035 - Fatnickc - Sat Jan 29, 2005 5:41 pm
Sorry for double post, but hey.
In your code snippet, are you ever changing the value of level?
I mean, say :
Code: |
if(goal==1)
level=2; |
Maybe that is the problem
#35057 - Mitch GBA - Sat Jan 29, 2005 11:05 pm
yeah.. well, I tested it out with:
Code: |
if(KEY_A) { level == 2 } |
that didn't work..
why?
#35067 - Cearn - Sun Jan 30, 2005 12:51 am
Just
Mitch GBA wrote: |
Code: | if(KEY_A) { level = 2 } |
|
or a full
Code: |
if(~REG_KEYS & KEY_A) { level = 2; } |
?
The distinction is important because the former only checks whether KEY_A (the constant in your head file) is non-zero, which it undoubtedly is. Only the latter actually checks the key-states.
EDITED. Reason: me being an idiot and confusing == with = operator.
Last edited by Cearn on Sun Jan 30, 2005 2:13 am; edited 1 time in total
#35068 - tepples - Sun Jan 30, 2005 1:36 am
In addition, the statement 'level == 2;' has no effect. In C, == is the comparison operator for numerical equality, and = is the assignment operator. Try this:
Code: |
if(~REG_KEYS & KEY_A) { level = 2; } |
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#35070 - Cearn - Sun Jan 30, 2005 2:11 am
D'oh! Thanks for setting me straight.
#35098 - Mitch GBA - Sun Jan 30, 2005 10:19 am
Yeah I did try that full code... I'll try again, maybe I oversaw something. Tahnks for the help :)
#35124 - jenswa - Sun Jan 30, 2005 10:11 pm
Perhaps the code can't get out of the while loop. Maybe your getinput function is missing in the while loop, so nothing happens when you press a button.
To add a start screen, i have another method.
In the main code, i first load all things for the start screen and have a function which waits until the start key is pressed and then the main code continues and loads the actual game.
_________________
It seems this wasn't lost after all.