Level Loading

Posted By: Valdsator

Level Loading - 10/22/10 17:11

My game now has a menu and a working "New Game" button. When this button is pressed, the game loads my test level, but it creates some weird problems. First of all, the lighting is a bit messed up. My map's lighting is supposed to be dark blue, but when I load this level through the menu, the blue is a lot lighter. Also, some weird, giant, red block appears at the start of the level.

Here's the code for loading the level:
Code:
vec_set(sky_color,vector(180,130,40));
level_load("testlevel.wmb");
skybox = ent_createlayer("cityskylinebig.tga", SKY|CUBE|SHOW, 0);
snd_stop(musichandle);
SOUND* music = "SONG2.wav";
musichandle = snd_loop(music,80,0);
menu = 0;
gamemenu = 1;
game_save("restart",1,SV_ALL);


It's basically the same way the menu level is loaded, but the there's code that changes the music, switches some variables, and saves the game, so restarting the level is possible (although, I'm guessing this is inefficient :P).

Anyone know what's causing the level loading to mess up?
Posted By: Roy

Re: Level Loading - 10/23/10 14:42

The lightning may be brighter, because you have the sun or ambiance set. This affects the overall level lightning. You can check if these are set (they are by default) in File/Map Properties under the tab 'Sun'.

Is your lightning different when you load the level with script, than without script?

The giant red block is probably not created because of this section of your script. It might be created elsewhere or it is already in the level.

To check if it is already in the level, look in the project tab (left in WED) and make sure there are no blocks that are 'off' (right click->mode; mostly, they look different in the project tab) If 'off' is set, you can see the block ingame, but not in WED.

Posted By: Valdsator

Re: Level Loading - 10/23/10 22:33

When I load the "testlevel" in the main function though, the lighting is perfect and there is no red block. But, if I load the "menu" level, and then press New Game, the lighting messes up and the red block appears.

Is it because my script is interrupting the level loading, and causing it to mess up?
Posted By: Pappenheimer

Re: Level Loading - 10/24/10 12:22

Some questions:
- why do you set the skycolor, when you create a skycube anyway?
- why do you use game_save, when the level is just loaded?
- What happens, when you don't set a skycolor, and don't create a skycube?
Posted By: Valdsator

Re: Level Loading - 10/27/10 23:36

Originally Posted By: Pappenheimer
Some questions:
- why do you set the skycolor, when you create a skycube anyway?
- why do you use game_save, when the level is just loaded?
- What happens, when you don't set a skycolor, and don't create a skycube?

Sorry for the late reply! D:

1. Good question... tongue
2. I use game_load to restart the level when Restart Level is pressed. I'll probably change this to loading the level properly, but for now I haven't set up a variable to tell the game what level it should be at.
3. Taking out the skybox, and sky color did not seem to affect anything, but, I tried taking out the skybox from the function main, and from the level loading code, and the huge red block disappeared (which I noticed has some other colored parts, and might be my character's model). The lighting continued to stay messed up though.
Posted By: MrGuest

Re: Level Loading - 10/27/10 23:58

i always had problems with ent_createlayer
before calling level_load, remove ent view entities (those created by ent_createlayer) and hopefully will solve your problem.
Code:
ent_remove(skybox);
level_load("testlevel.wmb");


Posted By: Valdsator

Re: Level Loading - 10/28/10 02:38

Awesome! That gets rid of the big block, but the messed up lighting remains. The lighting might be just not changing, because it does look kind of like the lighting in the menu (the menu and first level are very similar, but lighting is a bit different). Is there anything I should do to tell the program to relight the level?
Posted By: Valdsator

Re: Level Loading - 10/31/10 03:08

Bump. Still need help with the lighting problem!

Edit: I think I should give a bit more information about this problem. Here's a picture of how it looks after loading the level from the menu, how it should look (achieved by loading the level from the script), and what the menu lighting looks like, which is basically the same as how the 1st level's lighting should be.


Edit 2: Alright, after doing some testing that I should have done earlier, I've realized that the second level is taking the first level's light settings, and then mixing it's own light settings. I'm guessing I simply need to reset the light at the start of the level, somehow. But, I don't know how to do this. Help?
Posted By: Valdsator

Re: Level Loading - 11/04/10 21:37

Bump? D:
© 2024 lite-C Forums