User Tools

Site Tools


hpl1:tutorials:tutorial_2_-_level_creation

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
hpl1:tutorials:tutorial_2_-_level_creation [2010/11/04 07:05]
jens
hpl1:tutorials:tutorial_2_-_level_creation [2012/05/02 16:05] (current)
jato4 [TUTORIAL 2.5 – Linking two levels together.]
Line 108: Line 108:
  
 ===== TUTORIAL 2.5 – Linking two levels together. ===== ===== TUTORIAL 2.5 – Linking two levels together. =====
-The last tutorial for level creation is how to link to levels together using the _start and _area_link boxes. To make this work you will need a script file for your level, there is an empty script file in tutorials/​tutorial2 called “tut_level.hps”. Copy this file to your mystuff folder. 
-Rename the file “mystuff_level.hps” and open it in a text editor. As you can see it's quite empty, it contains the different foundation parts that you use for different things when writing scripts for a level. For the scripts we are going to do now you will use this part: 
  
-<code c++> 
-void OnStart() 
-{ 
  
 +The last tutorial for level creation is how to link to levels together using the _start and _area_link boxes. To make this work you will need a script file for your level, there is an empty script file in tutorials/​tutorial2 called “tut_level.hps”. Copy this file to your mystuff folder. Rename the file “mystuff_level.hps” and open it in a text editor. As you can see it's quite empty, it contains the different foundation parts that you use for different things when writing scripts for a level. For the scripts we are going to do now you will use this part:
 +
 +
 +<code c++>void OnStart()
 +{
 +   TROLL THE TONI MADNESS... TONI VALLTOITTAA KAIKEN JOS HÄN HALUAA NIIN! (Ota tää pois jos haluut kopsata tän void OnStart() jutun) ​
 } }
 </​code>​ </​code>​
 +
  
 As you can see this area already has some script in it: As you can see this area already has some script in it:
 +
 +
 <code c++> <code c++>
  //SET UP LINKS  //SET UP LINKS
Line 127: Line 131:
  0.5f , 0.5f);//​Fade out and in time (seconds).  0.5f , 0.5f);//​Fade out and in time (seconds).
 </​code>​ </​code>​
 +
  
 Link name, this is the area that the player can interact with to initate the loading of a new level. New map, the name of the new level and location1 is the area where the player will start when entering that new level. If you so far have named you level ”mystuff_level.dae” and added a location1 _start to it the script is ready to be used with only a slight modification. Link name, this is the area that the player can interact with to initate the loading of a new level. New map, the name of the new level and location1 is the area where the player will start when entering that new level. If you so far have named you level ”mystuff_level.dae” and added a location1 _start to it the script is ready to be used with only a slight modification.
 +
  
 Links can also be used to travel between different locations in a single level. To try this out we are going to use the ”mystuff_level.dae” we already have and add a new area to it. Links can also be used to travel between different locations in a single level. To try this out we are going to use the ”mystuff_level.dae” we already have and add a new area to it.
  
-Open the project in your 3D editor, create a new cube that is about 1m*1m*1m in size and place it in an location on the opposite side of the room from your ”_start_location1” cube.  Rename this new cube to ”_area_link_warp”. This will create an area in the game that will bring up the door icon when you are close, if you click with the left mouse button you will activate the area and be transportaed to location1 in the map ”mystuff_level.dae”. Since this is the map you are already in you will simply be warped back to your starting location.+ 
 +Open the project in your 3D editor, create a new cube that is about 1m%%*%%1m%%*%%1m in size and place it in an location on the opposite side of the room from your ”_start_location1” cube.  Rename this new cube to ”_area_link_warp”. This will create an area in the game that will bring up the door icon when you are close, if you click with the left mouse button you will activate the area and be transportaed to location1 in the map ”mystuff_level.dae”. Since this is the map you are already in you will simply be warped back to your starting location. 
  
 To make it easier finding the ”_area_link_warp” cube, lets add a point light where the area is. Make it bright green and set the X scale to 2, making the radius of the light 2 meters. To make it easier finding the ”_area_link_warp” cube, lets add a point light where the area is. Make it bright green and set the X scale to 2, making the radius of the light 2 meters.
 +
  
 Export your level and overwrite the old ”mystuff_level.dae”. Make sure that you have copied the script file to the same location and that you have neamed it ”mystuff_level.hps” as we said in the beggining of this chapter. Now launch Penumbra and start a new game, you should see a green light and if you walk over to it and interact you should be transported back to the start. Export your level and overwrite the old ”mystuff_level.dae”. Make sure that you have copied the script file to the same location and that you have neamed it ”mystuff_level.hps” as we said in the beggining of this chapter. Now launch Penumbra and start a new game, you should see a green light and if you walk over to it and interact you should be transported back to the start.
  
-Lets do the same but use two different levels. First go back to your current project in the 3D editor and create another cube that you place in another location and rename it ”_area_link_travel”. Do the same here that you add a light to make it easier finding the location, this time make it bright blue. Export this level and overwrite the previous ”mystuff_level.dae”. ​ 
  
-Now, in your 3D editor delete the refernece for the wood box and also change the main lights in the room(the ones that are 5 meters) to any other bright colour you like. We do this simply to quickly make a level that looks different from the one we already have. +Lets do the same but use two different levels. First go back to your current project in the 3D editor and create another cube that you place in another location and rename it ”_area_link_travel”. Do the same here that you add a light to make it easier finding the location, this time make it bright blue. Export this level and overwrite the previous ”mystuff_level.dae”. 
 + 
 + 
 +Now, in your 3D editor delete the refernece for the wood box and also change the main lights in the room(the ones that are 5 meters) to any other bright colour you like. We do this simply to quickly make a level that looks different from the one we already have. 
  
 Continue on and rename you ”_start_location1” to ”_start_newmap” and change your ”_area_link_warp” to ”_area_link_travelback” we do this not because we have to but because you need to practice renaming and later editing the script. Last delte the ”_area_link_travel” cube and the light for it as well. Export this level to collada and name it ”mystuff_level2.dae”. Continue on and rename you ”_start_location1” to ”_start_newmap” and change your ”_area_link_warp” to ”_area_link_travelback” we do this not because we have to but because you need to practice renaming and later editing the script. Last delte the ”_area_link_travel” cube and the light for it as well. Export this level to collada and name it ”mystuff_level2.dae”.
 +
  
 You should now have to maps, mystuff_level1.dae and mystuff_level2.dae. You should now have to maps, mystuff_level1.dae and mystuff_level2.dae.
 +
  
 Go back to your ”mystuff_level.hps” script file and select the SET UP LINKS part and make a copy of it, your script file should then look like this: Go back to your ”mystuff_level.hps” script file and select the SET UP LINKS part and make a copy of it, your script file should then look like this:
  
-<code c++> 
-void OnStart() 
-{ 
  
 +<code c++>void OnStart()
 +{
 + 
  //SET UP LINKS  //SET UP LINKS
  SetupLink( "​warp",​ //Link name  SetupLink( "​warp",​ //Link name
Line 158: Line 172:
  "","",​ //Stop and end sound.  "","",​ //Stop and end sound.
  0.5f , 0.5f);//​Fade out and in time (seconds).  0.5f , 0.5f);//​Fade out and in time (seconds).
- +  
 + 
  //SET UP LINKS  //SET UP LINKS
  SetupLink( "​travel",​ //Link name  SetupLink( "​travel",​ //Link name
Line 169: Line 183:
 </​code>​ </​code>​
  
-Edit the second SET UP LINKS so that the link name is ”travel”,​ the new map is ”mystuff_level2.dae” and position changed to ”newmap”. Save the script file. + 
 +Edit the second SET UP LINKS so that the link name is ”travel”,​ the new map is ”mystuff_level2.dae” and position changed to ”newmap”. Save the script file. 
  
 You now have the script file ready for ”mystuff_level.dae” but you will also need one for your new ”mystuff_level2.dae”. Make a copy of the script file and rename it ” mystuff_level2.hps”. Open this new script file in a text editor and delete one of the SET UP LINKS so that you get a script file that looks like this: You now have the script file ready for ”mystuff_level.dae” but you will also need one for your new ”mystuff_level2.dae”. Make a copy of the script file and rename it ” mystuff_level2.hps”. Open this new script file in a text editor and delete one of the SET UP LINKS so that you get a script file that looks like this:
  
-<code c++> 
-void OnStart() 
-{ 
  
 +<code c++>void OnStart()
 +{
 + 
  //SET UP LINKS  //SET UP LINKS
  SetupLink( "​travelback",​ //Link name  SetupLink( "​travelback",​ //Link name
Line 185: Line 201:
 } }
 </​code>​ </​code>​
 +
  
 Rename the link, new map and position to be as they are above. ”travelback” is the name of the link in you new ”mystuff_level2.dae” level that will activate to take you back to your first map and make you start in ”location1”. Rename the link, new map and position to be as they are above. ”travelback” is the name of the link in you new ”mystuff_level2.dae” level that will activate to take you back to your first map and make you start in ”location1”.
 +
  
 Save this script file. You should now have two levels and two script files. To test if it works, launch Penumbra and start a new game. If you click the green area you should warp inside your first level, if you click the blue area you go to the new level with out a wooden box in it and if you click the green area in it you should go back to the first level again. Save this script file. You should now have two levels and two script files. To test if it works, launch Penumbra and start a new game. If you click the green area you should warp inside your first level, if you click the blue area you go to the new level with out a wooden box in it and if you click the green area in it you should go back to the first level again.
 +
  
 If it worked, a big congratulations. If not, try again! These two levels and their script files can be found in the ”tutorials/​tutorial2/​safety”. This directory is not added to the resource.cfg so you can't run the levels from there, I added them just incase you can't get it to work so that you would have something to look at and investigate to get it to work. If it worked, a big congratulations. If not, try again! These two levels and their script files can be found in the ”tutorials/​tutorial2/​safety”. This directory is not added to the resource.cfg so you can't run the levels from there, I added them just incase you can't get it to work so that you would have something to look at and investigate to get it to work.
 +
  
 Good going reading through this tutorial, it's the dullest and probably most difficult of them all. But now that it's over you should be able to create levels that have the right basic functions. In the three last tutorials we will look at material/​texture files, particle effects and in the final one do some basic scripting using everything we have learned so far. Good going reading through this tutorial, it's the dullest and probably most difficult of them all. But now that it's over you should be able to create levels that have the right basic functions. In the three last tutorials we will look at material/​texture files, particle effects and in the final one do some basic scripting using everything we have learned so far.
 +
hpl1/tutorials/tutorial_2_-_level_creation.txt · Last modified: 2012/05/02 16:05 by jato4