----------------- Part 5 ----------------- Code Sample 5.1 " function SceneWindow2D::onMouseMove(%this, %mod, %worldPosition) { moleHammer.setPosition(%worldPosition); } " Code Sample 5.2 " function startGame(%level) { //exec game scripts exec("./mole.cs"); exec("./respawnPoint.cs"); exec("./moleLevel.cs"); //exec our gui files exec("~/gui/endScreen.gui"); // Set The GUI. Canvas.setContent(mainScreenGui); Canvas.setCursor(DefaultCursor); // Hide the cursor Canvas.hideCursor(); moveMap.push(); sceneWindow2D.setUseObjectMouseEvents( true ); if( isFile( %level ) || isFile( %level @ ".dso")) { sceneWindow2D.loadLevel(%level); $levelForRestart = %level; } } " Code Sample 5.3 " function moleLevel::onUpdateScene(%this) { // Calculate how much time is left %timeLeft = $MOLE_LEVEL::timePerGame - %this.getSceneTime(); if( %timeLeft < 0 ) { %this.setScenePause( true ); Canvas.pushDialog( MoleEndScreenGui ); Canvas.showCursor(); } // Round it to full seconds %timeLeft = mFloor( %timeLeft + 0.5 ); // Update the GuiTextCtrl MoleGuiTimer.setText( %timeLeft ); } " Code Sample 5.4 " function endGame() { Canvas.showCursor(); sceneWindow2D.endLevel(); moveMap.pop(); } " Code Sample 5.5 " function mole::onMouseDown(%this, %modifier, %worldPosition, %mouseClicks) { if(%this.getAnimationName() $= ("animMoleComeOut" @ %this.moleColor) ) { %this.playAnimation( "animMoleWhacked" @ %this.moleColor ); //let the hammer strike, with animation auto-restore moleHammer.playAnimation( "animHammer", true ); } } "