Browse Source

First check-in of "FishTutorialBase" template which will be used for
the behavior tutorial. Note that it duplicates some resources from
"AquariumToy" but the total size is small and I would like the beginner
to use this template as is, and not have to import things.

Charles Patterson 12 years ago
parent
commit
e1982f3
56 changed files with 1013 additions and 8 deletions
  1. 6 8
      templates/baseProject/README - setup.txt
  2. 62 0
      templates/fishTutorialBase/.gitignore
  3. 5 0
      templates/fishTutorialBase/README.txt
  4. 1 0
      templates/fishTutorialBase/cleandso.bat
  5. 34 0
      templates/fishTutorialBase/fishTutorial.torsion
  6. 35 0
      templates/fishTutorialBase/main.cs
  7. 4 0
      templates/fishTutorialBase/modules/AppCore/1/fonts/.gitignore
  8. 54 0
      templates/fishTutorialBase/modules/AppCore/1/main.cs
  9. 7 0
      templates/fishTutorialBase/modules/AppCore/1/module.taml
  10. 133 0
      templates/fishTutorialBase/modules/AppCore/1/scripts/canvas.cs
  11. 51 0
      templates/fishTutorialBase/modules/AppCore/1/scripts/constants.cs
  12. 68 0
      templates/fishTutorialBase/modules/AppCore/1/scripts/defaultPreferences.cs
  13. 64 0
      templates/fishTutorialBase/modules/AppCore/1/scripts/openal.cs
  14. 5 0
      templates/fishTutorialBase/modules/TropicalAssets/1/assets/animations/angelfish1Anim.asset.taml
  15. 5 0
      templates/fishTutorialBase/modules/TropicalAssets/1/assets/animations/angelfish2Anim.asset.taml
  16. 5 0
      templates/fishTutorialBase/modules/TropicalAssets/1/assets/animations/butterflyfishAnim.asset.taml
  17. 5 0
      templates/fishTutorialBase/modules/TropicalAssets/1/assets/animations/eelAnim.asset.taml
  18. 5 0
      templates/fishTutorialBase/modules/TropicalAssets/1/assets/animations/pufferfishAnim.asset.taml
  19. 5 0
      templates/fishTutorialBase/modules/TropicalAssets/1/assets/animations/rockfishAnim.asset.taml
  20. 5 0
      templates/fishTutorialBase/modules/TropicalAssets/1/assets/animations/seahorseAnim.asset.taml
  21. 5 0
      templates/fishTutorialBase/modules/TropicalAssets/1/assets/animations/triggerfish1Anim.asset.taml
  22. 5 0
      templates/fishTutorialBase/modules/TropicalAssets/1/assets/animations/triggerfish2Anim.asset.taml
  23. 7 0
      templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/angelfish1.asset.taml
  24. BIN
      templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/angelfish1.png
  25. 7 0
      templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/angelfish2.asset.taml
  26. BIN
      templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/angelfish2.png
  27. 3 0
      templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/background.asset.taml
  28. BIN
      templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/background.jpg
  29. 3 0
      templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/beam.asset.taml
  30. BIN
      templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/beam.png
  31. 3 0
      templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/bubble.asset.taml
  32. BIN
      templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/bubble.png
  33. 7 0
      templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/butterflyfish.asset.taml
  34. BIN
      templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/butterflyfish.png
  35. 7 0
      templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/eel.asset.taml
  36. BIN
      templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/eel.png
  37. 9 0
      templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/font.asset.taml
  38. BIN
      templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/font.png
  39. 7 0
      templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/pufferfish.asset.taml
  40. BIN
      templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/pufferfish.png
  41. 7 0
      templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/rockfish.asset.taml
  42. BIN
      templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/rockfish.png
  43. 3 0
      templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/rocksfar.asset.taml
  44. BIN
      templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/rocksfar.png
  45. 3 0
      templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/rocksnear.asset.taml
  46. BIN
      templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/rocksnear.png
  47. 7 0
      templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/seahorse.asset.taml
  48. BIN
      templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/seahorse.png
  49. 7 0
      templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/triggerfish1.asset.taml
  50. BIN
      templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/triggerfish1.png
  51. 3 0
      templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/wave.asset.taml
  52. BIN
      templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/wave.png
  53. 33 0
      templates/fishTutorialBase/modules/TropicalAssets/1/assets/particles/caustics.asset.taml
  54. 91 0
      templates/fishTutorialBase/modules/TropicalAssets/1/main.cs
  55. 13 0
      templates/fishTutorialBase/modules/TropicalAssets/1/module.taml
  56. 224 0
      templates/fishTutorialBase/modules/TropicalAssets/1/scripts/aquarium.cs

+ 6 - 8
templates/baseProject/README - setup.txt

@@ -1,12 +1,10 @@
 baseProject is a template for starting a Torque2D game from scratch.
 
-1. Copy this "baseProject" directory to wherever you want to create the project.
-2. copy the following files from your Torque2D original source to your copy of baseProject:
+1. Copy this "baseProject" directory to wherever you want to create the project.  This becomes the main project directory.
+2. If you are running Windows, copy the following files from your Torque2D original source to your copy of baseProject:
 	* OpenAL32.dll
 	* unicows.dll
-
-3a) copy the engine into "baseProject" as well.
-  To do this you may need to obtain or compile a copy.  Either
-	* copy the game engine Torque2D.exe (for Windows) or Torque2D.app (for Mac OSX). Or
-	* compile the original (or modified) Torque2D engine.  Then copy it.
-3b) alternatively you may want to copy the original (or modified) "engine" directory  to "baseProject" and build and modify your copy as part of this project.
+3. Copy the engine into "baseProject" as well.  To do this you may need to obtain or compile a copy.  Either
+	* compile the original Torque2D engine if you have not.
+	* Then copy it here.  It will be named Torque2D.exe (for Windows) or Torque2D.app (for Mac OSX).
+3b. Alternatively you may want to copy the original "engine" directory here, and then build and modify your copy as part of this project.

+ 62 - 0
templates/fishTutorialBase/.gitignore

@@ -0,0 +1,62 @@
+# Dev Files #
+###################
+*.xcworkspace
+*.xcuserdatad
+.LSOverride
+/tmp/*
+/preferences.cs
+*.dso
+*.edso
+*.user
+*.sdf
+*.suo
+*.dir
+*.opensdf
+*.idea
+*.dSYM
+*.res
+*.cache
+*.exports
+*.opt
+*.tmp
+Torque2D.app
+Torque2D_DEBUG.app
+Torque2D.exe
+Torque2D_DEBUG.exe
+Torque2DGame.app
+Torque2DGame_Debug.app
+linkmap.txt
+    
+# Compiled source #
+###################
+*.com
+*.class
+*.o
+*.a
+*.so
+*.obj
+*.lib
+*.idb
+*.pdb
+*.ilk
+*.ipch
+*.lastbuildstate
+*.unsuccessfulbuild
+*.manifest
+*.tlog
+
+# Logs and databases #
+######################
+*.log
+*.sql
+
+# OS generated files #
+######################
+.DS_Store
+.DS_Store?
+._*
+.Spotlight-V100
+.Trashes
+Icon?
+ehthumbs.db
+Thumbs.db

+ 5 - 0
templates/fishTutorialBase/README.txt

@@ -0,0 +1,5 @@
+fishTutorialBase is the starting point for the Fish Tutorial
+
+See the tutorial for how to begin with this template.  It is most likely located at https://github.com/GarageGames/Torque2D/wiki.
+
+

+ 1 - 0
templates/fishTutorialBase/cleandso.bat

@@ -0,0 +1 @@
+del /s *.dso

+ 34 - 0
templates/fishTutorialBase/fishTutorial.torsion

@@ -0,0 +1,34 @@
+<TorsionProject>
+<Name>fishTutorial</Name>
+<WorkingDir/>
+<EntryScript>main.cs</EntryScript>
+<DebugHook>dbgSetParameters( #port#, "#password#", true );</DebugHook>
+<Mods>
+<Folder>modules</Folder>
+</Mods>
+<ScannerExts>cs; gui</ScannerExts>
+<Configs>
+<Config>
+<Name>Release</Name>
+<Executable>Torque2D.exe</Executable>
+<Arguments/>
+<HasExports>true</HasExports>
+<Precompile>false</Precompile>
+<InjectDebugger>true</InjectDebugger>
+<UseSetModPaths>false</UseSetModPaths>
+</Config>
+<Config>
+<Name>Debug</Name>
+<Executable>Torque2D_DEBUG.exe</Executable>
+<Arguments/>
+<HasExports>false</HasExports>
+<Precompile>false</Precompile>
+<InjectDebugger>true</InjectDebugger>
+<UseSetModPaths>false</UseSetModPaths>
+</Config>
+</Configs>
+<SearchURL/>
+<SearchProduct>fishTutorial</SearchProduct>
+<SearchVersion>HEAD</SearchVersion>
+<ExecModifiedScripts>true</ExecModifiedScripts>
+</TorsionProject>

+ 35 - 0
templates/fishTutorialBase/main.cs

@@ -0,0 +1,35 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2013 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+setLogMode(6);
+$Scripts::ignoreDSOs = true;
+
+ModuleDatabase.scanModules( "modules" );
+ModuleDatabase.LoadExplicit( "TropicalAssets" );
+
+//-----------------------------------------------------------------------------
+
+function onExit()
+{
+    ModuleDatabase.unloadExplicit( "TropicalAssets" );
+}
+

+ 4 - 0
templates/fishTutorialBase/modules/AppCore/1/fonts/.gitignore

@@ -0,0 +1,4 @@
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore

+ 54 - 0
templates/fishTutorialBase/modules/AppCore/1/main.cs

@@ -0,0 +1,54 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2013 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+function AppCore::create( %this )
+{
+    // Load system scripts
+    exec("./scripts/constants.cs");
+    exec("./scripts/defaultPreferences.cs");
+    exec("./scripts/canvas.cs");
+    exec("./scripts/openal.cs");
+    
+    // Initialize the canvas
+    initializeCanvas("Torque 2D");
+    
+    // Set the canvas color
+    Canvas.BackgroundColor = "CornflowerBlue";
+    Canvas.UseBackgroundColor = true;
+    
+    // Initialize audio
+    initializeOpenAL();
+    
+    // This is one method of starting your game.
+    // Edit your "main" module(s) to have an attribute of Group="gameBase".
+    // Then uncomment the following line.
+    // Now the "AppCore" will go first and then start your game.
+    // ModuleDatabase.loadGroup("gameBase");
+}
+
+//-----------------------------------------------------------------------------
+
+function AppCore::destroy( %this )
+{
+
+}
+

+ 7 - 0
templates/fishTutorialBase/modules/AppCore/1/module.taml

@@ -0,0 +1,7 @@
+<ModuleDefinition
+	ModuleId="AppCore"
+	VersionId="1"
+	Description="Barebones startup module"
+	ScriptFile="main.cs"
+	CreateFunction="create"
+	DestroyFunction="destroy" />

+ 133 - 0
templates/fishTutorialBase/modules/AppCore/1/scripts/canvas.cs

@@ -0,0 +1,133 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2013 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+// initializeCanvas
+// Constructs and initializes the default canvas window.
+//------------------------------------------------------------------------------
+$canvasCreated = false;
+function initializeCanvas(%windowName)
+{
+    // Don't duplicate the canvas.
+    if($canvasCreated)
+    {
+        error("Cannot instantiate more than one canvas!");
+        return;
+    }
+
+    videoSetGammaCorrection($pref::OpenGL::gammaCorrection);
+
+    if ( !createCanvas(%windowName) )
+    {
+        error("Canvas creation failed. Shutting down.");
+        quit();
+    }
+
+    $pref::iOS::ScreenDepth = 32;
+
+    if ( $pref::iOS::DeviceType !$= "" )
+    {
+        %resolution = iOSResolutionFromSetting($pref::iOS::DeviceType, $pref::iOS::ScreenOrientation);
+    }
+    else
+    {
+        if ( $pref::Video::windowedRes !$= "" )
+            %resolution = $pref::Video::windowedRes;
+        else
+            %resolution = $pref::Video::defaultResolution;
+    }
+
+    if ($platform $= "windows" || $platform $= "macos")
+    {
+        setScreenMode( %resolution._0, %resolution._1, %resolution._2, $pref::Video::fullScreen );
+    }
+    else
+    {
+        setScreenMode( %resolution._0, %resolution._1, %resolution._2, false );
+    }
+
+    $canvasCreated = true;
+}
+
+//------------------------------------------------------------------------------
+// resetCanvas
+// Forces the canvas to redraw itself.
+//------------------------------------------------------------------------------
+function resetCanvas()
+{
+    if (isObject(Canvas))
+        Canvas.repaint();
+}
+
+//------------------------------------------------------------------------------
+// iOSResolutionFromSetting
+// Helper function that grabs resolution strings based on device type
+//------------------------------------------------------------------------------
+function iOSResolutionFromSetting( %deviceType, %deviceScreenOrientation )
+{
+    // A helper function to get a string based resolution from the settings given.
+    %x = 0;
+    %y = 0;
+    
+    %scaleFactor = $pref::iOS::RetinaEnabled ? 2 : 1;
+
+    switch(%deviceType)
+    {
+        case $iOS::constant::iPhone:
+            if(%deviceScreenOrientation == $iOS::constant::Landscape)
+            {
+                %x =  $iOS::constant::iPhoneWidth * %scaleFactor;
+                %y =  $iOS::constant::iPhoneHeight * %scaleFactor;
+            }
+            else
+            {
+                %x =  $iOS::constant::iPhoneHeight * %scaleFactor;
+                %y =  $iOS::constant::iPhoneWidth * %scaleFactor;
+            }
+
+        case $iOS::constant::iPad:
+            if(%deviceScreenOrientation == $iOS::constant::Landscape)
+            {
+                %x =  $iOS::constant::iPadWidth * %scaleFactor;
+                %y =  $iOS::constant::iPadHeight * %scaleFactor;
+            }
+            else
+            {
+                %x =  $iOS::constant::iPadHeight * %scaleFactor;
+                %y =  $iOS::constant::iPadWidth * %scaleFactor;
+            }
+
+        case $iOS::constant::iPhone5:
+            if(%deviceScreenOrientation == $iOS::constant::Landscape)
+            {
+                %x =  $iOS::constant::iPhone5Width;
+                %y =  $iOS::constant::iPhone5Height;
+            }
+            else
+            {
+                %x =  $iOS::constant::iPhone5Height;
+                %y =  $iOS::constant::iPhone5Width;
+            }
+    }
+   
+    return %x @ " " @ %y;
+}

+ 51 - 0
templates/fishTutorialBase/modules/AppCore/1/scripts/constants.cs

@@ -0,0 +1,51 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2013 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+$iOS::constant::iPhone = 0;
+$iOS::constant::iPad = 1;
+$iOS::constant::iPhone5 = 2;
+
+$iOS::constant::Landscape = 0;
+$iOS::constant::Portrait = 1;
+$iOS::constant::ResolutionFull = 0;
+$iOS::constant::ResolutionSmall = 1;
+
+$iOS::constant::iPhoneWidth = 480;
+$iOS::constant::iPhoneHeight = 320;
+
+$iOS::constant::iPhone4Width = 960;
+$iOS::constant::iPhone4Height = 640;
+
+$iOS::constant::iPadWidth = 1024;
+$iOS::constant::iPadHeight = 768;
+
+$iOS::constant::NewiPadWidth = 2048;
+$iOS::constant::NewiPadHeight = 1536;
+
+$iOS::constant::iPhone5Width = 1136;
+$iOS::constant::iPhone5Height = 640;
+
+$iOS::constant::OrientationUnknown = 0;
+$iOS::constant::OrientationLandscapeLeft = 1;
+$iOS::constant::OrientationLandscapeRight = 2;
+$iOS::constant::OrientationPortrait = 3;
+$iOS::constant::OrientationPortraitUpsideDown = 4;

+ 68 - 0
templates/fishTutorialBase/modules/AppCore/1/scripts/defaultPreferences.cs

@@ -0,0 +1,68 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2013 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+/// Game
+$Game::CompanyName              = "GarageGames LLC";
+$Game::ProductName              = "Torque 2D";
+
+/// iOS
+$pref::iOS::ScreenOrientation   = $iOS::constant::Landscape;
+$pref::iOS::ScreenDepth		    = 32;
+$pref::iOS::UseGameKit          = 0;
+$pref::iOS::UseMusic            = 0;
+$pref::iOS::UseMoviePlayer      = 0;
+$pref::iOS::UseAutoRotate       = 1;
+$pref::iOS::EnableOrientationRotation = 1;
+$pref::iOS::EnableOtherOrientationRotation = 1;   
+$pref::iOS::StatusBarType       = 0;
+
+/// Audio
+$pref::Audio::driver = "OpenAL";
+$pref::Audio::forceMaxDistanceUpdate = 0;
+$pref::Audio::environmentEnabled = 0;
+$pref::Audio::masterVolume   = 1.0;
+$pref::Audio::channelVolume1 = 1.0;
+$pref::Audio::channelVolume2 = 1.0;
+$pref::Audio::channelVolume3 = 1.0;
+$pref::Audio::sfxVolume = 1.0;
+$pref::Audio::musicVolume = 1.0;
+
+/// T2D
+$pref::T2D::ParticlePlayerEmissionRateScale = 1.0;
+$pref::T2D::ParticlePlayerSizeScale = 1.0;
+$pref::T2D::ParticlePlayerForceScale = 1.0;
+$pref::T2D::warnFileDeprecated = 1;
+$pref::T2D::warnSceneOccupancy = 1;
+$pref::T2D::imageAssetGlobalFilterMode = Bilinear;
+
+/// Video
+$pref::Video::appliedPref = 0;
+$pref::Video::disableVerticalSync = 1;
+$pref::Video::displayDevice = "OpenGL";
+$pref::Video::preferOpenGL = 1;
+$pref::Video::fullScreen = 0;
+$pref::Video::defaultResolution = "1024 768";
+$pref::Video::windowedRes = "1024 768 32";
+$pref::OpenGL::gammaCorrection = 0.5;
+
+/// Fonts.
+$Gui::fontCacheDirectory = expandPath( "^AppCore/fonts" );

+ 64 - 0
templates/fishTutorialBase/modules/AppCore/1/scripts/openal.cs

@@ -0,0 +1,64 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2013 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+// Audio channel descriptions.
+//------------------------------------------------------------------------------
+$musicAudioType = 1;
+$effectsAudioType = 2;
+
+//------------------------------------------------------------------------------
+// initializeOpenAL
+// Starts up the OpenAL driver.
+//------------------------------------------------------------------------------
+function initializeOpenAL()
+{
+    // Just in case it is already started.
+    shutdownOpenAL();
+
+    echo("OpenAL Driver Init");
+
+    if (!OpenALInitDriver())
+    {
+        echo("OpenALInitDriver() failed");
+        $Audio::initFailed = true;
+    }
+    else
+    {
+        // Set the master volume.
+        alxListenerf(AL_GAIN_LINEAR, $pref::Audio::masterVolume);
+
+        // Set the channel volumes.
+        for (%channel = 1; %channel <= 3; %channel++)
+            alxSetChannelVolume(%channel, $pref::Audio::channelVolume[%channel]);
+
+        echo("OpenAL Driver Init Success");
+    }
+}
+
+//------------------------------------------------------------------------------
+// shutdownOpenAL
+//------------------------------------------------------------------------------
+function shutdownOpenAL()
+{
+    OpenALShutdownDriver();
+}

+ 5 - 0
templates/fishTutorialBase/modules/TropicalAssets/1/assets/animations/angelfish1Anim.asset.taml

@@ -0,0 +1,5 @@
+<AnimationAsset
+    AssetName="angelfish1Anim"
+    Image="@asset=TropicalAssets:angelFishImage"
+    AnimationFrames="0 1 2 3 3 2 1 0"
+    AnimationTime="0.4" />

+ 5 - 0
templates/fishTutorialBase/modules/TropicalAssets/1/assets/animations/angelfish2Anim.asset.taml

@@ -0,0 +1,5 @@
+<AnimationAsset
+    AssetName="angelfish2Anim"
+    Image="@asset=TropicalAssets:angelfish2"
+    AnimationFrames="0 1 2 3 3 2 1 0"
+    AnimationTime="0.4" />

+ 5 - 0
templates/fishTutorialBase/modules/TropicalAssets/1/assets/animations/butterflyfishAnim.asset.taml

@@ -0,0 +1,5 @@
+<AnimationAsset
+    AssetName="butterflyfishAnim"
+    Image="@asset=TropicalAssets:butterflyfish"
+    AnimationFrames="0 1 2 3 3 2 1 0"
+    AnimationTime="0.4" />

+ 5 - 0
templates/fishTutorialBase/modules/TropicalAssets/1/assets/animations/eelAnim.asset.taml

@@ -0,0 +1,5 @@
+<AnimationAsset
+    AssetName="eelAnim"
+    Image="@asset=TropicalAssets:eel"
+    AnimationFrames="0 1 2 3 3 2 1 0"
+    AnimationTime="0.3" />

+ 5 - 0
templates/fishTutorialBase/modules/TropicalAssets/1/assets/animations/pufferfishAnim.asset.taml

@@ -0,0 +1,5 @@
+<AnimationAsset
+    AssetName="pufferfishAnim"
+    Image="@asset=TropicalAssets:pufferfish"
+    AnimationFrames="0 1 2 3 3 2 1 0"
+    AnimationTime="0.4" />

+ 5 - 0
templates/fishTutorialBase/modules/TropicalAssets/1/assets/animations/rockfishAnim.asset.taml

@@ -0,0 +1,5 @@
+<AnimationAsset
+    AssetName="rockfishAnim"
+    Image="@asset=TropicalAssets:rockfish"
+    AnimationFrames="0 1 2 3 3 2 1 0"
+    AnimationTime="0.4" />

+ 5 - 0
templates/fishTutorialBase/modules/TropicalAssets/1/assets/animations/seahorseAnim.asset.taml

@@ -0,0 +1,5 @@
+<AnimationAsset
+    AssetName="seahorseAnim"
+    Image="@asset=TropicalAssets:seahorse"
+    AnimationFrames="0 1 2 3 3 2 1 0"
+    AnimationTime="0.8" />

+ 5 - 0
templates/fishTutorialBase/modules/TropicalAssets/1/assets/animations/triggerfish1Anim.asset.taml

@@ -0,0 +1,5 @@
+<AnimationAsset
+    AssetName="triggerfish1Anim"
+    Image="@asset=TropicalAssets:triggerfish1"
+    AnimationFrames="0 1 2 3 3 2 1 0"
+    AnimationTime="0.4" />

+ 5 - 0
templates/fishTutorialBase/modules/TropicalAssets/1/assets/animations/triggerfish2Anim.asset.taml

@@ -0,0 +1,5 @@
+<AnimationAsset
+    AssetName="triggerfish2Anim"
+    Image="@asset=TropicalAssets:triggerfish2"
+    AnimationFrames="0 1 2 3 3 2 1 0"
+    AnimationTime="0.4" />

+ 7 - 0
templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/angelfish1.asset.taml

@@ -0,0 +1,7 @@
+<ImageAsset
+    AssetName="angelFishImage"
+    ImageFile="angelfish1.png"
+    CellCountX="2"
+    CellCountY="2"
+    CellWidth="256"
+    CellHeight="256" />

BIN
templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/angelfish1.png


+ 7 - 0
templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/angelfish2.asset.taml

@@ -0,0 +1,7 @@
+<ImageAsset
+    AssetName="angelfish2"
+    ImageFile="angelfish2.png"
+    CellCountX="2"
+    CellCountY="2"
+    CellWidth="256"
+    CellHeight="256" />

BIN
templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/angelfish2.png


+ 3 - 0
templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/background.asset.taml

@@ -0,0 +1,3 @@
+<ImageAsset
+    AssetName="background"
+    ImageFile="background.jpg" />

BIN
templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/background.jpg


+ 3 - 0
templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/beam.asset.taml

@@ -0,0 +1,3 @@
+<ImageAsset
+    AssetName="beam"
+    ImageFile="beam.png" />

BIN
templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/beam.png


+ 3 - 0
templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/bubble.asset.taml

@@ -0,0 +1,3 @@
+<ImageAsset
+    AssetName="bubble"
+    ImageFile="bubble.png" />

BIN
templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/bubble.png


+ 7 - 0
templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/butterflyfish.asset.taml

@@ -0,0 +1,7 @@
+<ImageAsset
+    AssetName="butterflyfish"
+    ImageFile="butterflyfish.png"
+    CellCountX="2"
+    CellCountY="2"
+    CellWidth="256"
+    CellHeight="256" />

BIN
templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/butterflyfish.png


+ 7 - 0
templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/eel.asset.taml

@@ -0,0 +1,7 @@
+<ImageAsset
+    AssetName="eel"
+    ImageFile="eel.png"
+    CellCountX="1"
+    CellCountY="4"
+    CellWidth="256"
+    CellHeight="64" />

BIN
templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/eel.png


+ 9 - 0
templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/font.asset.taml

@@ -0,0 +1,9 @@
+<ImageAsset
+    AssetName="font"
+    ImageFile="font.png"
+	CellOffsetY="1"
+	CellStrideY="16"
+    CellCountX="16"
+    CellCountY="6"
+    CellWidth="16"
+    CellHeight="14" />

BIN
templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/font.png


+ 7 - 0
templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/pufferfish.asset.taml

@@ -0,0 +1,7 @@
+<ImageAsset
+    AssetName="pufferfish"
+    ImageFile="pufferfish.png"
+    CellCountX="2"
+    CellCountY="2"
+    CellWidth="256"
+    CellHeight="256" />

BIN
templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/pufferfish.png


+ 7 - 0
templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/rockfish.asset.taml

@@ -0,0 +1,7 @@
+<ImageAsset
+    AssetName="rockfish"
+    ImageFile="rockfish.png"
+    CellCountX="2"
+    CellCountY="2"
+    CellWidth="256"
+    CellHeight="128" />

BIN
templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/rockfish.png


+ 3 - 0
templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/rocksfar.asset.taml

@@ -0,0 +1,3 @@
+<ImageAsset
+    AssetName="rocksfar"
+    ImageFile="rocksfar.png" />

BIN
templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/rocksfar.png


+ 3 - 0
templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/rocksnear.asset.taml

@@ -0,0 +1,3 @@
+<ImageAsset
+    AssetName="rocksnear"
+    ImageFile="rocksnear.png" />

BIN
templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/rocksnear.png


+ 7 - 0
templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/seahorse.asset.taml

@@ -0,0 +1,7 @@
+<ImageAsset
+    AssetName="seahorse"
+    ImageFile="seahorse.png"
+    CellCountX="4"
+    CellCountY="1"
+    CellWidth="128"
+    CellHeight="256" />

BIN
templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/seahorse.png


+ 7 - 0
templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/triggerfish1.asset.taml

@@ -0,0 +1,7 @@
+<ImageAsset
+    AssetName="triggerfish1"
+    ImageFile="triggerfish1.png"
+    CellCountX="2"
+    CellCountY="2"
+    CellWidth="256"
+    CellHeight="256" />

BIN
templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/triggerfish1.png


+ 3 - 0
templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/wave.asset.taml

@@ -0,0 +1,3 @@
+<ImageAsset
+    AssetName="wave"
+    ImageFile="wave.png" />

BIN
templates/fishTutorialBase/modules/TropicalAssets/1/assets/images/wave.png


+ 33 - 0
templates/fishTutorialBase/modules/TropicalAssets/1/assets/particles/caustics.asset.taml

@@ -0,0 +1,33 @@
+<ParticleAsset
+    AssetName="Caustics">
+    <ParticleAssetEmitter
+        EmitterName="caustics"
+		EmitterType="line"
+		EmitterSize="100 1"
+		FixedAspect="false"
+        OldestInFront="1"
+        Image="@asset=AquariumToy:Beam">
+        <ParticleAssetEmitter.Fields>
+            <Quantity
+                Keys="0 1" />
+            <QuantityVariation
+                Keys="0 1" />				
+            <Lifetime
+                Keys="0 4" />				
+            <LifetimeVariation
+                Keys="0 2" />
+            <Speed
+                Keys="0 0" />
+            <RandomMotion
+                Keys="0 45" />				
+            <SizeX
+                Keys="0 50" />				
+            <SizeXVariation
+                Keys="0 40" />
+            <SizeY
+                Keys="0 75" />								
+            <AlphaChannel
+                Keys="0 0 0.5 0.3 0.8 0.3 1 0" />
+        </ParticleAssetEmitter.Fields>
+    </ParticleAssetEmitter>
+</ParticleAsset>

+ 91 - 0
templates/fishTutorialBase/modules/TropicalAssets/1/main.cs

@@ -0,0 +1,91 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2013 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+function TropicalAssets::create( %this )
+{
+    // We need a main "Scene" we can use as our game world.  The place where sceneObjects play.
+    // Give it a global name "mainScene" since we may want to access it directly in our scripts.
+    new Scene(mainScene);
+
+    // Without a system window or "Canvas", we can't see or interact with our scene.
+    // AppCore initialized the Canvas already
+
+    // Now that we have a Canvas, we need a viewport into the scene.
+    // Give it a global name "mainWindow" since we may want to access it directly in our scripts.
+    new SceneWindow(mainWindow);
+    mainWindow.profile = new GuiControlProfile();
+    Canvas.setContent(mainWindow);
+
+    // Finally, connect our scene into the viewport (or sceneWindow).
+    // Note that a viewport comes with a camera built-in.
+    mainWindow.setScene(mainScene);
+    mainWindow.setCameraPosition( 0, 0 );
+    mainWindow.setCameraSize( 100, 75 );
+
+    // load some scripts and variables
+    // exec("./scripts/someScript.cs");
+
+
+    exec("./scripts/aquarium.cs");
+
+    buildAquarium();
+    createAquariumEffects();
+    TropicalAssets.spawnFish(10);
+}
+
+//-----------------------------------------------------------------------------
+
+function TropicalAssets::destroy( %this )
+{
+}
+
+//-----------------------------------------------------------------------------
+
+function TropicalAssets::spawnFish(%this, %amount)
+{
+    for (%i = 0; %i < %amount; %i++) {
+        %position = getRandom(-55, 55) SPC getRandom(-20, 20);
+        %index = getRandom(0, 5);
+        %anim = getUnit(getFishAnimationList(), %index, ",");
+        
+        %fishInfo = getFishSize(%anim);
+        
+        %fish = new Sprite()
+        {
+            Animation = %anim;
+            class = "FishClass";
+            position = %position;
+            size = %fishInfo;
+            SceneLayer = "2";
+            SceneGroup = "14";
+            minSpeed = "5";
+            maxSpeed = "15";
+            CollisionCallback = true;
+        };
+        
+        %fish.createPolygonBoxCollisionShape( 15, 15);
+        %fish.setCollisionGroups( 15 );
+        mainScene.add( %fish );        
+    }
+}
+
+//-----------------------------------------------------------------------------

+ 13 - 0
templates/fishTutorialBase/modules/TropicalAssets/1/module.taml

@@ -0,0 +1,13 @@
+<ModuleDefinition
+	ModuleId="TropicalAssets"
+	VersionId="1"
+	Description="Tropical Fish Assets."
+	Dependencies="AppCore=1"
+	ScriptFile="main.cs"
+	CreateFunction="create"
+	DestroyFunction="destroy">
+		<DeclaredAssets
+			Path="assets"
+			Extension="asset.taml"
+			Recurse="true"/>
+</ModuleDefinition>

+ 224 - 0
templates/fishTutorialBase/modules/TropicalAssets/1/scripts/aquarium.cs

@@ -0,0 +1,224 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2013 GarageGames, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//-----------------------------------------------------------------------------
+
+function getFishAnimationList()
+{
+   %list = "TropicalAssets:angelfish1Anim" @ "," @ "TropicalAssets:angelfish2Anim" @ "," @ "TropicalAssets:butterflyfishAnim";
+   %list = %list @ "," @ "TropicalAssets:pufferfishAnim" @ "," @ "TropicalAssets:rockfishAnim" @ "," @ "TropicalAssets:seahorseAnim";
+   %list = %list @ "," @ "TropicalAssets:triggerfish1Anim" @ "," @ "TropicalAssets:eelAnim";
+}
+
+//-----------------------------------------------------------------------------
+
+function getFishSize(%anim)
+{
+    switch$(%anim)
+    {
+        case "TropicalAssets:angelfish1Anim":
+        %fishInfo = "15 15";
+
+        case "TropicalAssets:angelfish2Anim":
+        %fishInfo = "15 15";
+        
+        case "TropicalAssets:butterflyfishAnim":
+        %fishInfo = "15 15";
+        
+        case "TropicalAssets:pufferfishAnim":
+        %fishInfo = "15 15";
+        
+        case "TropicalAssets:rockfishAnim":
+        %fishInfo = "15 7.5";
+        
+        case "TropicalAssets:seahorseAnim":
+        %fishInfo = "7.5 15";
+        
+        case "TropicalAssets:triggerfish1Anim":
+        %fishInfo = "15 15";
+
+        case "TropicalAssets:eelAnim":
+        %fishInfo = "7.5 3.75";
+    }
+
+    return %fishInfo;
+}
+
+//-----------------------------------------------------------------------------
+
+function buildAquarium()
+{
+    // Background
+    %background = new Sprite();
+    %background.setBodyType( "static" );
+    %background.setImage( "TropicalAssets:background" );
+    %background.setSize( 100, 75 );
+    %background.setCollisionSuppress();
+    %background.setAwake( false );
+    %background.setActive( false );
+    %background.setSceneLayer(5);
+    mainScene.add( %background );
+    
+    // Far rocks
+    %farRocks = new Sprite();
+    %farRocks.setBodyType( "static" );
+    %farRocks.setPosition( 0, -7.5 );
+    %farRocks.setImage( "TropicalAssets:rocksfar" );
+    %farRocks.setSize( 100, 75 );
+    %farRocks.setCollisionSuppress();
+    %farRocks.setAwake( false );
+    %farRocks.setActive( false );
+    %farRocks.setSceneLayer(4);
+    mainScene.add( %farRocks );
+    
+    // Near rocks
+    %nearRocks = new Sprite();
+    %nearRocks.setBodyType( "static" );
+    %nearRocks.setPosition( 0, -8.5 );
+    %nearRocks.setImage( "TropicalAssets:rocksnear" );
+    %nearRocks.setSize( 100, 75 );
+    %nearRocks.setCollisionSuppress();
+    %nearRocks.setAwake( false );
+    %nearRocks.setActive( false );
+    %nearRocks.setSceneLayer(3);
+    mainScene.add( %nearRocks );
+    
+    // Left trigger
+    %leftTrigger = new SceneObject() { class = "AquariumBoundary"; };
+    
+    %leftTrigger.side = "left";
+    %leftTrigger.setSize( 5, 400 );
+    %leftTrigger.setPosition( -85, 0);
+    %leftTrigger.setSceneLayer( 1 );
+    %leftTrigger.setSceneGroup( 15 );
+    %leftTrigger.setCollisionGroups( 14 );
+    %leftTrigger.createPolygonBoxCollisionShape( 5, 400);
+    %leftTrigger.setDefaultDensity( 1 );
+    %leftTrigger.setDefaultFriction( 1.0 );        
+    %leftTrigger.setAwake( true );
+    %leftTrigger.setActive( true );
+    %leftTrigger.setCollisionCallback(true);
+    %leftTrigger.setBodyType( "static" );
+    %leftTrigger.setCollisionShapeIsSensor(0, true);
+    mainScene.add( %leftTrigger );
+    
+    // Right trigger
+    %rightTrigger = new SceneObject() { class = "AquariumBoundary"; };
+    
+    %rightTrigger.setSize( 5, 400 );
+    %rightTrigger.side = "right";
+    %rightTrigger.setPosition( 85, 0);
+    %rightTrigger.setSceneLayer( 1 );
+    %rightTrigger.setSceneGroup( 15 );
+    %rightTrigger.setCollisionGroups( 14 );
+    %rightTrigger.createPolygonBoxCollisionShape( 5, 400);
+    %rightTrigger.setDefaultDensity( 1 );
+    %rightTrigger.setDefaultFriction( 1.0 );    
+    %rightTrigger.setAwake( true );
+    %rightTrigger.setActive( true );
+    %rightTrigger.setCollisionCallback(true);
+    %rightTrigger.setBodyType( "static" );
+    %rightTrigger.setCollisionShapeIsSensor(0, true);
+    mainScene.add( %rightTrigger );    
+}
+
+//-----------------------------------------------------------------------------
+
+function AquariumBoundary::onCollision(%this, %object, %collisionDetails)
+{
+    if (%object.class $= "FishClass")
+        %object.recycle(%this.side);
+}
+
+//-----------------------------------------------------------------------------
+
+function createAquariumEffects()
+{
+    %obj = new Scroller();
+    %obj.setBodyType( "static" );
+    %obj.setImage( "TropicalAssets:wave" );
+    %obj.setPosition( 0, 0 );
+    %obj.setScrollX(2);
+    %obj.setSize( 100, 75 );
+    %obj.setRepeatX( 0.2 );   
+    %obj.setSceneLayer( 0 );
+    %obj.setSceneGroup( 0 );
+    %obj.setCollisionSuppress();
+    %obj.setAwake( false );
+    %obj.setActive( false );
+    mainScene.add( %obj );
+    
+    // Add the caustics particle.
+    %caustics = new ParticlePlayer();
+    %caustics.Particle = "TropicalAssets:Caustics";
+    mainScene.add( %caustics ); 
+}
+
+//-----------------------------------------------------------------------------
+
+function FishClass::onAdd(%this)
+{
+    // Set a random speed for the fish
+    %this.setSpeed();
+   
+    if (getRandom(0, 10) > 5)
+    {
+        %this.setLinearVelocityX(%this.speed);
+        %this.setFlipX(false);
+    }
+    else
+    {
+        %this.setLinearVelocityX(-%this.speed);
+        %this.setFlipX(true);
+    }
+}
+
+//-----------------------------------------------------------------------------
+
+function FishClass::recycle(%this, %side)
+{
+    // Fish has turned around, so set a new random speed
+    %this.setSpeed();
+    %layer = getRandom(0, 5);
+    %this.setLinearVelocityY(getRandom(-3, 3));
+    %this.setPositionY(getRandom(-15, 15));
+    %this.setSceneLayer(%layer);
+
+    if (%side $= "left")
+    {
+        %this.setLinearVelocityX(%this.speed);
+        %this.setFlipX(false);
+    }
+    else if (%side $= "right")
+    {
+        %this.setLinearVelocityX(-%this.speed);
+        %this.setFlipX(true);
+    }
+}
+
+//-----------------------------------------------------------------------------
+
+function FishClass::setSpeed(%this)
+{
+   // Speed is a dynamic variable created when this function is first called
+   // Every other time after the first call will simply modify the variable
+   // .minSpeed and .maxSpeed are declared in the Dynamic Fields rollout of the editor
+   %this.speed = getRandom(%this.minSpeed, %this.maxSpeed);
+}