Differences

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


wmebook:ch4 2007/12/06 13:38 wmebook:ch4 2008/01/10 11:56 current
Line 3: Line 3:
So far we’ve been experimenting with prebuilt demo, but now it’s the time to go back to the roots and create a completely new project of our liking. Start the project manager and press Ctrl+N (alternatively click on the new project icon or choose new project from the File menu). Name your project as you wish and let WME create it. So far we’ve been experimenting with prebuilt demo, but now it’s the time to go back to the roots and create a completely new project of our liking. Start the project manager and press Ctrl+N (alternatively click on the new project icon or choose new project from the File menu). Name your project as you wish and let WME create it.
-Now you can see that WME creates a new project with putting there some preset material and the starting of our new game can’t be easier as we can immediately run this minimalistic project and it works. What we’re going to do though is to turn our focus to the point where the game actually begins. This point is a simple file called **game.script**.+You can see that WME creates a new project with putting there some preset material and the starting of our new game can’t be easier as we can immediately run this minimalistic project and it works. What we’re going to do though is to turn our focus to the point where the game actually begins. This point is a simple file called **game.script** //(located in data->scripts)//.
You can easily check in your Project Manager, that the game has one script attached to it and it won’t be surprise for you, that this attached script is ... game.script. So simply said the very first thing WME does after initializing all windows system stuff is to execute this file. I am speaking about it so broadly, because I want you to fully understand how versatile WME is. At this point nothing is decided, how the game will look, how the game will play etc. You can easily check in your Project Manager, that the game has one script attached to it and it won’t be surprise for you, that this attached script is ... game.script. So simply said the very first thing WME does after initializing all windows system stuff is to execute this file. I am speaking about it so broadly, because I want you to fully understand how versatile WME is. At this point nothing is decided, how the game will look, how the game will play etc.
Line 14: Line 14:
</code> </code>
-First we include the file base.inc, which contains 3 global variables actor, Scene and Keyboard. This way we don’t have in every single script declare global Scene; before calling for example Scene.GetNode(); Base.inc in turn includes another file called const.inc which contains constants for actor directions and text alignment. In course of our game creation we will add global variables and constants in these files to keep our game tidy. We can also separate our includes into more files if we’re so inclined. Second file contains definition to keyboard codes so we don’t have to guess numbers and simply type their textual representation like VK_ESCAPE instead of 27 if we want to test for Esc key.+First we include the file base.inc, which contains 3 global variables - actor, Scene and Keyboard. This way we don’t have in every single script declare global Scene; before calling for example Scene.GetNode(); Base.inc in turn includes another file called const.inc which contains constants for actor directions and text alignment. In course of our game creation we will add global variables and constants in these files to keep our game tidy. We can also separate our includes into more files if we’re so inclined. Second file contains definition to keyboard codes so we don’t have to guess numbers and simply type their textual representation like VK_ESCAPE instead of 27 if we want to test for Esc key.
<code script> <code script>
Line 38: Line 38:
By default you have the preset behavior that if you right click on a hotspot, little menu appears where you can choose from three actions. **Now do me a favor and delete those two lines.** We’ll try to go barebones. By default you have the preset behavior that if you right click on a hotspot, little menu appears where you can choose from three actions. **Now do me a favor and delete those two lines.** We’ll try to go barebones.
-But you may ask, what is a window? Window is a collection of graphical items (buttons, images, edit fields for textual input) which is very practical for forming GUI (graphical user interface). The big advantage is that it’s Scene independent so you can have it on screen for every scene without explicitly forming the elements every time. We’ll look on the windows building later, so let’s focus for now what those two lines mean. First loads a window file (which contains a definition of the graphical window) and second set it invisible. The window is attached to the Game object so scene changing can’t affect it. Note that windows are an exception. Entities use //Active//, Windows use //Visible//.+You may ask, what is a window? Window is a collection of graphical items (buttons, images, edit fields for textual input) which is very practical for forming GUI (graphical user interface). The big advantage is that it’s Scene independent so you can have it on screen for every scene without explicitly forming the elements every time. We’ll look on the windows building later, so let’s focus for now what those two lines mean. First line loads a window file (which contains a definition of the graphical window) and second sets it invisible. The window is attached to the Game object so scene changing can’t affect it. Note that windows are an exception. Entities use //Active//, Windows use //Visible//.
<code script> <code script>
Line 65: Line 65:
Now those are important lines. Variable “actor” is a global variable defined in base.inc which will now be filled with the definition of our .actor file. Again later on we’ll look how the actor files are constructed. For now let’s live with the fact that we have molly and she can do whatever we want. Now those are important lines. Variable “actor” is a global variable defined in base.inc which will now be filled with the definition of our .actor file. Again later on we’ll look how the actor files are constructed. For now let’s live with the fact that we have molly and she can do whatever we want.
-Also as a side note, we can use second function **Scene.LoadActor(actor);** which loads the actor but attaches it to the current scene and so the actor is destroyed when you leave the scene.+Also as a side note, we can use second function **Scene.LoadActor(actor);** which loads the actor but attaches it to the current scene and cthe actor is destroyed when you leave the scene.
Last we set up the attribute **MainObject** to our freshly loaded actor, which does the only thing – when actor moves and the scene is supposed to scroll, the scrolling is oriented to this actor. In case there were more switchable actors (like for example in Day of the Tentacle) this attribute will provide correct scrolling for selected character. You can set also null to this attribute. Last we set up the attribute **MainObject** to our freshly loaded actor, which does the only thing – when actor moves and the scene is supposed to scroll, the scrolling is oriented to this actor. In case there were more switchable actors (like for example in Day of the Tentacle) this attribute will provide correct scrolling for selected character. You can set also null to this attribute.
Line 214: Line 214:
</code> </code>
-Now test the game and you’ll see that it’s still running although we made quite some changes to it. And as we want to continue boiling our example game down to the necessary minimum, we need to look at the **game_loop.script** as well.+Now test the game and you’ll see that it’s still running although we made quite some changes to it. And as we want to continue boiling our example game down to the necessary minimum, we need to look at the **game_loop.script** (formerly named game_daemon.script) as well.
<code script> <code script>
 
wmebook/ch4.1196944687.txt.gz · Last modified: 2007/12/06 13:38 by metamorphium
Recent changes RSS feed Creative Commons License Driven by DokuWiki