DimensioneX Change language Step 9


Home
Features
Play Online
Download
Forum
Tutorial
Documentation
Wiki
Support
Resources
Members
Gadgets
Contacts
Links






free screen-saver
Fantasy Screensavers and Desktop Backgrounds

 


DimensioneX on SourceForge.net

 

Further interactivity

To have the scissors, the player gives a key to the surfer (his ID is surfer). When you do this, the onReceive event triggers. So, using SmallBasic  it goes like this (insert code in the EVENTS section:)

EVENT surfer.onReceiveItem
ACTIONS
    If $TARGET.type="key"
	Speak "Oh dear, thank you!"
	Move scissors,$AGENT
    Else
    	Return false
    End_If

Here is a simple explanation of the above:

  • According to the event model, when the surfer receives an item, the player acts like the events' AGENT. The given item is the events' TARGET, instead.

  • First we check that the given item is a key. Please note the use of the OR logical operator.

  • If the surfer receives a key, then, the block following the keyword ACTIONS is executed.

  • The surfer speaks to the AGENT (the player) - this is the default behaviour of the Speak action.

  • Then the scissors are moved from their current position to the players' (AGENT) pockets.

Opening the box

Here is another event for making the scissors capable of un-sealing the box

 
EVENT scissors.onUseWith
ACTIONS
If $TARGET=box
    box.open=0
    box.description="The seal has been removed"
    PlaySound "sndBlip.wav"
Else
    Return false
End_If

Here is a simple explanation of the above:

  • According to the event model, when a player uses the scissors on an item, this item is the events' TARGET.

  • First we check that the scissors are being used on the box. 

  • In that case, the box open attribute is set to false. This means that a box is not open, but it becomes implicitly openable.

  • The description of the box is changed. As soon as you look at it, you will see it's changed.

  • A sound is played on the player's browser

Before testing, you have to download the sound file. The method to be used is similar to the one you have learned for grabbing images. Just right-click on the following link 

sndBlip.wav

and choose "Save object as..." to save the file in your game's media folder, testland.

Note: Sound/music files can be in one of the following formats: WAV, MID. Also .AU and MP3. can be used in some cases (compatibility depends on your users' installed plug-ins, actually). 

Winning the game

Finally, we insert an event for winning the game:

 
EVENT box.onOpen
ACTIONS
    PlayBackground $WORLD,"sndJ0074200.mid"
    Goal

Please download and save the music file from here: sndJ0074200.mid . Same method used above.

Here is a simple explanation of the above:

  • In that case, we send a background music to all the players with the PlayBackground statement. 

  • The Goal statement terminates the game and broadcasts a "Game finished" messages to all the players. Please note that any game finish is recorded in the Hall of Fame (accessible at the game's front page) automatically.

Done!! It wasn't that difficult, was it?

Previous Next

Suggestion: In your game set the WORLD's VERSION tag and increment it as you add features. It will be useful for users to understand if something's changed with respect to their last visit. See the Developer's Reference, section about WORLD definition. See also the WORLD's SAVEGAME_PERSISTENCE tag for setting the persistence of saved games.