Differences

This shows you the differences between the selected revision and the current
version of the page.


wmebook:ch8 2007/12/09 12:06 wmebook:ch8 2008/01/10 13:57 current
Line 9: Line 9:
**Story:** **Story:**
-Game starts in a dream. Molly appears in a huge hall and suddenly she splits in two. The other Molly tells her, that she is her image from the alternate universe. In this dialogue is Molly being told about a house in an old German town which contains a secret book called WME book. This house serves as a portal to different realm where Molly could find an answer to all human questions. Upon reading the WME book in the room, the door will transport Molly to that realm.+Game starts in a dream. Molly appears in a huge hall and suddenly she splits in two. The other Molly tells her, that she is her image from the alternate universe. In this dialogue is Molly being told about a house in an old German town which contains a secret book called WME book. This house serves as a portal to a different realm where Molly could find an answer to all human questions. Upon reading the WME book in the room, the door will transport Molly to that realm.
Molly travels to the town and finds a house door locked. She has to improvise a lock pick to lock pick that door and enter the house. Then Molly has to search the room to find a hidden button which opens the drawer where the secret book is being kept. This button is hidden in the image and there’s a little hint of the eye flash upon entering the room. Molly travels to the town and finds a house door locked. She has to improvise a lock pick to lock pick that door and enter the house. Then Molly has to search the room to find a hidden button which opens the drawer where the secret book is being kept. This button is hidden in the image and there’s a little hint of the eye flash upon entering the room.
Line 15: Line 15:
But it’s behind the glass, so molly has to pick up a rock outside and break the glass with the rock. Then she can press the button to reveal the WME book. But it’s behind the glass, so molly has to pick up a rock outside and break the glass with the rock. Then she can press the button to reveal the WME book.
-By reading WME book in the room, she is transported to the pillar with a skeleton. Skeleton tells her that she is there to save him from his eternal slavery by replacing him on his position. Molly wants to protest but with a flash of light she is the skeleton in the middle of the circle waiting for another soul to free her.+By reading WME book in the room, she is transported to the pillar with a skeleton. Skeleton tells her that she is there to save him from his eternal slavery by replacing him on his position. Molly wants to protest but with a flash of light she becomes the skeleton in the middle of the circle waiting for another soul to free her.
Camera goes to the image with circle far away and Molly curses her fate. Camera goes to the image with circle far away and Molly curses her fate.
Line 52: Line 52:
{{wmebook:storyboard.jpg|}} {{wmebook:storyboard.jpg|}}
-Ok. We know enough about our game to start the development. Again we will build upon the knowledge gained in the previous chapters so for you – cheaters- out there will come hard times.+Ok. We know enough about our game to start the development. Again we will build upon the knowledge gained in the previous chapters so for you – cheaters - out there will come hard times.
Let’s get our hands dirty and fire up the Project Manager and right off the bat create 4 800x600 scenes by right click -> Add scene. Name them **Dream**, **Circle**, **Desk** and **Street**. Let’s get our hands dirty and fire up the Project Manager and right off the bat create 4 800x600 scenes by right click -> Add scene. Name them **Dream**, **Circle**, **Desk** and **Street**.
Line 75: Line 75:
{{wmebook:ch8_1.jpg|}} {{wmebook:ch8_1.jpg|}}
-This doesn’t affect the compiled game. We’ve already stated that to affect the real game we’d need to change game.script file, but we’ll use this convenient feature for now to speed up our work.+This doesn’t affect the compiled game. We’ve already stated that to affect the real game we’d need to change game.script file, but we’ll use this convenient feature for now to speed up our work. Also note, that
Open the **scene_init.script** file of the Room scene and erase the lines referencing sally: Open the **scene_init.script** file of the Room scene and erase the lines referencing sally:
Line 85: Line 85:
</code> </code>
-Let’s add some sort of noninteractive sequence when Molly first enters the screen. Now I’ll do for this particular game a bit unnecessary thing as Molly will never return to this scene, but I want to demonstrate on this principle how would you handle the events which are triggered on the very first enter to the scene.+Let’s add some sort of noninteractive sequence when Molly first enters the screen. I’ll do for this particular game a bit unnecessary thing as Molly will never return to this scene, but I want to demonstrate on this principle how would you handle the events which are triggered on the very first enter to the scene.
Locate this line of code: Locate this line of code:
Line 104: Line 104:
</code> </code>
-StateDream is a global variable as seen above and this way the whole game knows about it. Now WME template uses two-state approach. First you check if this variable was ever set and if not, we assign its Visited attribute to false (indicating that the scene was never visited) By this assignment StateDream is no longer null but it’s [object] instead.+StateDream is a global variable as seen above and this way the whole game knows about it. Default WME template uses two-state approach. First it checks if this variable was ever set and if not, we assign its Visited attribute to false (indicating that the scene was never visited) By this assignment StateDream is no longer null but it’s [object] instead.
-Next you check out the Visited attribute and set it to true (if it was false) to indicate, that you’ve already been in the scene and this way the whole mechanism provide that lines of code in the second condition get called only if you enter the scene for the very first time. +Next the Visited attribute is checked and set to true (if it was false) to indicate, that you’ve already been in the scene and this way the whole mechanism provide that lines of code in the second condition get called only if you enter the scene for the very first time. 
-We’re going to build upon this script a bit. First there’s a pitfall. At the beginning of the scene_init.script we let Molly walk around. But we don’t want player to interrupt this walk by left clicking. So we’re going to set the whole scene_init.script into non interactive mode so we know, that player won’t interfere with our game by canceling events.+ 
 +We’re going to build upon this script a bit and solve one possible pitfall. At the beginning of the scene_init.script we let Molly walk around. But we don’t want player to interrupt this walk by left clicking. So we’re going to set the whole scene_init.script into non interactive mode so we know, that player won’t interfere with our game by canceling events.
Add **Game.Interactive = false;** just below the include line and **Game.Interactive = true;** to the end of the file. Phew. We’re safe. Add **Game.Interactive = false;** just below the include line and **Game.Interactive = true;** to the end of the file. Phew. We’re safe.
Line 237: Line 238:
Function basic is the dialogue itself. It’s pretty simple but we’ve used the object logic to check up if all options are depleted. For this we’ve set up an object depleted which has assigned three attributes – Who, Where and Why. Function basic is the dialogue itself. It’s pretty simple but we’ve used the object logic to check up if all options are depleted. For this we’ve set up an object depleted which has assigned three attributes – Who, Where and Why.
-In the course of dialogue we assign individual attributes, which sets: depleted.Who, depleted.Why or depleted.Where to true respectively. To save our time, we’ve written a little function checkDepleted(depleted) which returns true if all dialogue branches has been chosen. This function is called in this condition +In the course of dialogue we assign individual attributes, which sets: depleted.Who, depleted.Why or depleted.Where to true respectively. To save our time, we’ve written a little function checkDepleted(depleted) which returns true if all dialogue branches has been chosen. This function is called in the following condition:
<code script> <code script>
-if checkDepleted(depleted)) Game.AddResponse(3,options[3]);+if (checkDepleted(depleted)) Game.AddResponse(3,options[3]);
</code> </code>
-This way our exit response is added only after all other options have been chosen. At the exit branch we let our alternate molly disappear and we change scene to street.scene which is our next stop.+This way our exit response is added only after all other options have been chosen. At the exit branch we let our Alternate Molly disappear and we change scene to street.scene which is our next stop.
-In scene edit open the Street scene and first shape the floor and adjust scale level to look like this:+In the Scene Editor open the Street.scene and your first step is to shape the floor and adjust scale levels to look like this:
{{wmebook:ch8_2.jpg|}} {{wmebook:ch8_2.jpg|}}
-We have to adjust the scale level so our actor standing next to the door looks like she can pass through them. +Reason for adjusting the scale level is that our actor standing next to the door looks like she can pass through them.
Now create a region entities for Car, sign and door and attach scripts to them. Don’t forget to fill in captions for them. Also copy the file rock_scene.png to your street folder and add it as a sprite entity (don’t forget to fill the name and caption) and in the Item column fill Rock. Now create a region entities for Car, sign and door and attach scripts to them. Don’t forget to fill in captions for them. Also copy the file rock_scene.png to your street folder and add it as a sprite entity (don’t forget to fill the name and caption) and in the Item column fill Rock.
Line 284: Line 285:
</code> </code>
-We have our item ready to use so let’s put it in the scene. Open the **car.script** in our street scr folder and place in there the following:+We have our item ready to use so let’s put it in the scene. Open the **car.script** in our street scr folder and write there the following:
<code script> <code script>
Line 300: Line 301:
</code> </code>
-We know that upon second examination we find a wire. Copy the wire_item.png to the items folder and create all files as with the pliers. Of course add a new block to the items.items file.+We know that upon second examination of the car we find a wire. Copy the wire_item.png to the items folder and create all files as with the pliers. Of course add a new block to the items.items file.
<code script> <code script>
Line 358: Line 359:
</code> </code>
-As you can surely see with each left click we increase the number in the global variable carExamination. This in turn is checked in the switch clause and actor takes according item or refuses to steal a steering wheel. Again note that I am paranoid and set Interactivity to false for all longer actions which could break a game if player accidentally clicked at the wrong time.+As you can surely see with each left click we increase the number in the global variable carExamination. This in turn is checked in the **switch** clause and actor takes according item or refuses to steal a steering wheel. Again note that I am paranoid and set Interactivity to false for all longer actions which could break a game if player accidentally clicked at the wrong time.
-Our next time item is a lockpick. Again we do our homework with creating a new items.items block and copying lockpick_item.png to the items folder. For sake of saving space I’m not going to include this block as it’s identical to what we’ve done twice already. You can however find in the resources package all modified files from the chapter 8. +Our next item is a lockpick. Again we do our homework with creating a new items.items block and copying lockpick_item.png to the items folder. For sake of saving space I’m not going to include this block as it’s identical to what we’ve done twice already. You can however find in the resources package all modified files from the chapter 8.
Open the file **pliers.script** and add the lockpick creating event: Open the file **pliers.script** and add the lockpick creating event:
Line 390: Line 391:
</code> </code>
-Note that deleting the item the script belongs to must be executed as the last step because by deleting the item, the script terminates its execution and this way all lines after deletion would never get executed.+**Note that deleting the item - the script belongs to - must be executed as the last step because by deleting the item, the script terminates its execution and this way all lines after deletion would never get executed.**
The **Lockpick** itself must be defined as well in **items.items**. The **Lockpick** itself must be defined as well in **items.items**.
Line 418: Line 419:
</code> </code>
-Speaking of items in this scene we also have a rock which is pickable.+Speaking of items, in this scene we also have a rock which is pickable.
-Go through the routine of copying rock_item into the items folder, creating its sprite etc. (It's getting routine, isn't it?)+Go through the routine of copying rock_item into the items folder, creating its sprite etc. (It's a routine now, isn't it?)
<code script> <code script>
Line 633: Line 634:
{{wmebook:ch8_r2.jpg|}} {{wmebook:ch8_r2.jpg|}}
-Also note that I've again hilighted the Exit region which will bring us back to the Room scene. If we test the game we'd see that actor is too small, we have to raise the scale value to 100% and lift it a bit higher.+Also note that I've again hilighted the Exit region which will bring us back to the Room scene. If we tested the game, we'd see that the actor is too small so we have to raise the scale value to 100% and lift it a bit higher.
Scripts for this scene are: Scripts for this scene are:
Line 685: Line 686:
{{wmebook:ch8_r3.jpg|}} {{wmebook:ch8_r3.jpg|}}
 +
 +**ERRATA:** In the upcoming images there is a duplicity of node Drawer. Please create the sprite entity (the yellow one) as SpriteDrawer instead of Drawer.
And define it in the following steps: And define it in the following steps:
Line 710: Line 713:
  layer.Active = true;   layer.Active = true;
} }
-<code>+</code>
**ExitCloseup.script** **ExitCloseup.script**
Line 723: Line 726:
</code> </code>
 +As we can see, now the Closeup properly activates (making actor disappear) and upon clicking Exit it again disappears making actor appear.
 +
 +**Drawer.script** first has to check if the button in the painting has been pressed and if yes, it opens the drawer uncovering the book and hides itself.
 +
 +<code script>
 +#include "scripts\base.inc"
 +
 +on "LeftClick"
 +{
 +  global DrawerOpened;
 + 
 +  if (DrawerOpened)
 +  {
 +    var ent = Scene.GetNode("SpriteDrawer");
 +    ent.Active = true;
 +    ent = Scene.GetNode("Book");
 +    ent.Active = true;
 +    this.Active = false;
 +  }
 +  else
 +  actor.Talk("Hmm! It's locked");
 +}
 +</code>
 +
 +We just take a book upon left click:
 +
 +Add the book to **items.items**:
 +
 +<code script>
 +ITEM
 +{
 +  CURSOR_COMBINED = TRUE
 +  CAPTION = "WME User's Guide"
 +  NAME = "Book"
 +  SPRITE = "items\book.sprite"
 +  CURSOR = "items\book.sprite"
 +  CURSOR_HOVER = "items\book.sprite"
 +  SCRIPT = "items\book.script"
 +}
 +</code>
 +
 +create the sprite file for the book and to the **book.script** in the scene write the following:
 +
 +<code script>
 +#include "scripts\base.inc"
 +
 +on "LeftClick"
 +{
 +  actor.TakeItem("Book");
 +}
 +</code>
 +
 +and to the **book.script** in the items folder write this:
 +
 +<code script>
 +#include "scripts\base.inc"
 +
 +on "LeftClick"
 +{
 +  global BookRead = true;
 +  actor.Talk("Blablabla, this is a magical formula which tells you the secret of the ancient passage.");
 +}
 +</code>
 +
 +See, we have another global variable this time indicating if our actor read the secret book or not. We'll then extend our door passage a bit to enter the stone circle after you've read the book.
 +
 +Modify **scenes\Room\scr\door.script** to read the following:
 +
 +<code script>
 +#include "scripts\base.inc"
 +
 +on "LeftClick"
 +{
 +  global BookRead;
 + 
 +  if (BookRead)
 +    Game.ChangeScene("scenes\circle\circle.scene");
 +  else
 +    Game.ChangeScene("scenes\street\street.scene");
 +}
 +</code>
 +
 +Last scene in our game is the **circle**. You know the drill. Here's the basic layout:
 +
 +{{wmebook:ch8_7.jpg|}}
 +
 +The **Ending** is a sprite entity which has its Interactive turned off.
 +
 +{{wmebook:ch8_9.jpg|}}
 +
 +Now turn again off the //Active// check box for Ending entity so it's again invisible.
 +
 +Here're the scripts:
 +
 +**scene_init.script**
 +
 +<code script>
 +#include "scripts\base.inc"
 +
 +// here comes the stuff which initializes the scene
 +
 +actor.SkipTo(507, 526);
 +actor.Direction = DI_DOWN;
 +actor.Active = true;
 +actor.GoTo(498,474);
 +
 +////////////////////////////////////////////////////////////////////////////////
 +// scene state
 +global StateCircle;
 +
 +
 +// default values
 +if(StateCircle==null)
 +{
 +  StateCircle.Visited = false;
 +  // add scene states here
 +}
 +
 +
 +
 +////////////////////////////////////////////////////////////////////////////////
 +// setup scene according to state variables
 +
 +
 +
 +////////////////////////////////////////////////////////////////////////////////
 +if(!StateCircle.Visited)
 +{
 +  StateCircle.Visited = true;
 +
 +  // this is our first visit in this scene...
 +}
 +</code>
 +
 +**Servant.script**
 +
 +<code script>
 +#include "scripts\base.inc"
 +
 +on "LeftClick"
 +{
 +  Game.Interactive = false;
 + this.Talk("Finally you arrived! I was waiting here for you for so long!");
 + actor.Talk("Who are you?");
 + this.Talk("I'm the servant of the WME circle and I have to serve here until someone changes a place with me.");
 + actor.Talk("But how could that be? Who was the one in the alternate universe?");
 + this.Talk("I have only very little power but one of my skills is to influence other's dreams. I tried this on many people but you're the one who caught up.");
 + actor.Talk("I don't believe you. You are supposed to tell me the secrets of everything.");
 + this.Talk("The secret is not to get your legs wooden. HAHAHA!");
 +
 + Scene.FadeOut(400,255,255,255,255);
 + actor.Active = false;
 + Sleep(1000);
 + Scene.FadeIn(400);
 +
 + this.Talk("NOOOOOOOOOOOOOOOOOOOOOOOOO!");
 +
 + var e = Scene.GetNode("Ending");
 + e.Active = true;
 +
 + this.Talk("It can't be like this!");
 + this.Talk("Please save me someone, anyone???? Hello???");
 + this.Talk("Wait what did he said? Influencing other people dreams?");
 +
 + Game.FadeOut(5000,0,0,0,255);
 + Game.QuitGame();
 +
 + Game.Interactive = true;
 +}
 +</code>
 +
 +And our game skeleton is ready. If you want, you can look in the chapter 8 resource folder where - in the folder finished chapter - you can find the working version.
 +Now go and play that game before we move on.
 
wmebook/ch8.1197198392.txt.gz · Last modified: 2007/12/09 12:06 by metamorphium
Recent changes RSS feed Creative Commons License Driven by DokuWiki