Tilt Monster - Open Source

Tilt Monster - Disabling the Rating Option Request

Written by Paul Allan Harrington

Take a look at the startGame function in main.lua at line 90. Jonathan did a nice job commenting the code so it should be fairly easily to determine which lines of code to remark out and/or delete.

If I'm correct, I believe you could remark out and/or delete lines 91 - 133.

I did some lite testing and the above worked out successfully.

If you have the Corona Simulator "Show Project Sandbox" (File | Show Project Sandbox), you'll be able to look at the rating.data file that is created to track the number of times the app is opened. Jonathan has the app set to request a rating on the 4th attempt. Deleting or remarking out lines 91 - 133 will no longer create and modify the rating.data file, so deleting it (rating.data) and making your code changes will help you determine if your on track. The file should not reappear if you make the correct modifications.

Side-Note: The Corona Simulator's "Show Project Sandbox" feature is such a great tool to utilize during development and testing. It opens the application's sandbox folder where the Corona Simulator stores data saved by your application.

 

Tilt Monster - Disabling the Themes Option

Written by Paul Allan Harrington

In optionsScreen.lua just after optionsGroup:insert( themeSelector ) at original Line: 292, add the following:

themeSelector.isVisible = false

You will also need to modify the following graphics:

optionsBackground.png

This e-mail address is being protected from spambots. You need JavaScript enabled to view it

themes-btn-over.png

This e-mail address is being protected from spambots. You need JavaScript enabled to view it

themes-btn.png

This e-mail address is being protected from spambots. You need JavaScript enabled to view it

   

Tilt Monster - App Development and Open Source Generosity

Written by Paul Allan Harrington

Back in May of 2011 Jonathan and Biffy Beebe (http://beebegames.kodingen.com/) demonstrated amazing generosity when they open sourced their successful Tilt Monster app (http://developer.anscamobile.com/code/tilt-monster) which was one of (if not THE) first Corona SDK game to reach over 100,000 sales in the App Store!

Since that time I've exchanged several emails with Jonathan thanking he and Biffy for sharing their talents and keeping them informed about how we are adapting their work into various projects at VisualsWork.com.

In that same spirit of generosity and as we learn, I plan on providing examples and source code of various aspects of the game at: http://www.pahgroup.com/index.php/blog/7-tilt-monster-open-source/

 

Tilt Monster - Switching from Accelerometer to Touch based control

Written by Paul Allan Harrington

For a variety of products we are working on at VisualsWork.com we plan on incorporating many of the features and game play of Jonathan and Biffy Beebe's (http://beebegames.kodingen.com/) open sourced Tilt Monster app ( http://developer.anscamobile.com/code/tilt-monster). For much of our intended audience, our first course of action was to switch out the "Accelerometer" based player control for one that was "Touch" based.

For our initial testing, this is what we did:

Remarked out Runtime:addEventListener( "touch", touchPause ) on Line: 1185 in maingame.lua which also removes the "pause" feature as we just removed (remarked out) the "Event Listener" that was calling the "touchPause" function each time the screen was touched. We will likely want to create a button for the pause feature in future revisions and I'll share the code when we do. To remark out the code simply insert -- in before the appropriate code.

Example: --Runtime:addEventListener( "touch", touchPause )

For moving the player left or right depending on which side of the screen the user touched, we did the following:

Add a Runtime Event Listener to call a function we will create called "touchMove".

Example: Runtime:addEventListener( "touch", touchMove )

Add a local variable named "playerDirection" and function called "touchMove" for controlling the player direction:

-- Added to Switch from Accelerometer to Touch based control
local playerDirection -- used to control left and right player movement when playerObject.x = playerObject.x + playerDirection is added to the gameLoop function

local touchMove = function( event)

     -- Check to see if the screen is being "touched"
     if (event.phase == "began") then

          -- If the left side of the screen is being "touched" decrease playerDirection (makes the player move left)
          if event.x < display.contentWidth / 2 then

               playerDirection = -4

          end

          -- If the right side of the screen is being "touched" increase the playerDirection (makes the player move right)
          if event.x > display.contentWidth / 2 then

               playerDirection = 4

          end

     end

          -- Returns the playerDirection value to 0 (straight) when the screen is no longer being "touched"
          if (event.phase == "ended") then

               playerDirection = 0

          end

     return true

     end

Finally, I added the following line to the gameLoop function just above the call to moveTrees() around Line: 4242 :

playerObject.x = playerObject.x + playerDirection

Give it a try and feel free to contact me if you have questions, comments and suggestions.

*Update: When testing on iOS devices (not in the Corona Simulator), we learned that we forgot to disable the Accelerometer control when implementing our "Touch" based control. Initial testing also hinted at the need to "rethink" how we can provide a solution that isn't compromised when a user touches both the left and right side of the screen simultaneously. Stay tuned as we explore and post future revisons.

   

Tilt Monster - Adjusting the Games Level of Difficulty

Written by Paul Allan Harrington

This is my second post related to products we are working on at VisualsWork.com that will be incorporating many of the features and game play of Jonathan and Biffy Beebe's (http://beebegames.kodingen.com/) open sourced Tilt Monster app ( http://developer.anscamobile.com/code/tilt-monster).

For this installment we will be making adjustments to the games level of difficulty.

As we review the code Jonathan authored we see just how easy he has made it to modify the code that controls the games level of difficulty. Around line: 4862 in maingame.lua you'll notice Jonathan created a local function called "gameInit". Within that function we find the following code:

     if difficultySetting == "0" then
          -- Medium
          gameSettings[ "difficulty" ] = "medium"
          gameSettings["gameMoveSpeed"] = 7.7
          gameSettings["defaultMoveSpeed"] = 7.7

          print ( "Difficulty: Medium" )

     elseif difficultySetting == "1" then
          -- Easy
          gameSettings[ "difficulty" ] = "easy"
          gameSettings["gameMoveSpeed"] = 7.3
          gameSettings["defaultMoveSpeed"] = 7.3

          print ( "Difficulty: Easy" )

     elseif difficultySetting == "2" then
          -- Hard
          gameSettings[ "difficulty" ] = "hard"
          gameSettings["gameMoveSpeed"] = 8.1
          gameSettings["defaultMoveSpeed"] = 8.1

          print ( "Difficulty: Hard" )
     end

Jonathan has made it very easy for us. All we need to do is modify the appropriate "gameMoveSpeed" and defaultMoveSpeed" values for each of the 3 difficulty levels; "Medium", "Easy", and "Hard".

For our games intended audience we will be testing the following values: ("Medium" = 6, "Easy" = 3, "Hard" = 8

Example:

     if difficultySetting == "0" then
          -- Medium
          gameSettings[ "difficulty" ] = "medium"
          gameSettings["gameMoveSpeed"] = 6
          gameSettings["defaultMoveSpeed"] = 6

          print ( "Difficulty: Medium" )

     elseif difficultySetting == "1" then
          -- Easy
          gameSettings[ "difficulty" ] = "easy"
          gameSettings["gameMoveSpeed"] = 3
          gameSettings["defaultMoveSpeed"] = 3

          print ( "Difficulty: Easy" )

     elseif difficultySetting == "2" then
          -- Hard
          gameSettings[ "difficulty" ] = "hard"
          gameSettings["gameMoveSpeed"] = 8
          gameSettings["defaultMoveSpeed"] = 8

          print ( "Difficulty: Hard" )
     end

Also take a peek around Line: 212 at the local gameSettings table and notice:

     defaultMoveSpeed = 7.7, --> set to 3.7 for 60 fps; 7.7 for 30 fps
     gameMoveSpeed = 7.7,

You will likely what to change those values (currently 7.7) to the default of your choice. In our case, we will be testing a default value of 3.

Give it a try and feel free to contact me if you have questions, comments and suggestions.