Share Your Code

Tilt Monster

Posted by jonathanbeebe, Posted on May 26, 2011, Last updated October 18, 2011

GitHub URL: 
https://github.com/jonbeebe/Tilt-Monster

Tilt Monster (formerly known in the App Store as Doodle Dash!) was the FIRST project of Jonathan Beebe, and was one of (if not THE) first Corona SDK game to reach over 100,000 sales in the App Store!

(Special thanks to Biffy Beebe for the artwork/graphics assets, and her ideas and inspiration throughout the development process--this is the project that did it for us!)

Now YOU have access to the complete source code of the game, for you to learn from and/or use it as a framework for your own projects.

Tilt Monster is still live in the App Store right now (free), so if you use this game's source code, you should definitely swap the graphics out with your own (and of course, change the name!).

View in the App Store

The source code was released so you can see a COMPLETE game--not just Sample Code--that was live and selling in the App Store, so you have a **proven** project to learn from when creating your own games.

---

Note from Jonathan:

This was my very first Corona project, and it has served as an EXTREMELY valuable learning tool. I hope you find as much value in this project as I have, and I look forward to your contributions via GitHub. Enjoy!

---

See the game in action:

http://youtu.be/yWu04VuOaJs


Replies

Boydy
User offline. Last seen 18 hours 37 min ago. Offline
Joined: 18 Jan 2011

Keep up the great work mate!

inas
User offline. Last seen 23 weeks 6 days ago. Offline
Joined: 25 Feb 2011

Wow, you are awesome!

thankyou :)

ChrisSlee
User offline. Last seen 7 weeks 4 days ago. Offline
Joined: 11 Feb 2011

That is really a great help to the community. You're the best!

ChunkyApps
User offline. Last seen 2 weeks 4 days ago. Offline
Joined: 19 Jan 2011

Let me just say Thank You so much for this. I am at the finish line of my own game and I was actually hoping for something like this. While it is great to see all of this code out here, the value of a finished game that is in the app store is tremendous.

The big thing I wanted to see is how you take care of memory management.
This is one of the most important things and sadly one of the least covered on this site. I would love if someone with experience on this topic could make a detailed tutorial all about memory management. (Many people talk about their memory leaks. I am almost finished with my game and I STILL don't know how to check for leaks. My game tests fine on my iPhone 4 so I am hoping I'm good)

Anyway, thanks again!

tomchristman24447
User offline. Last seen 20 weeks 3 days ago. Offline
Joined: 21 Jan 2011

Thanks Jon & Biffy for your generous sharing.

jonathanbeebe
User offline. Last seen 1 year 29 weeks ago. Offline
Alumni
Joined: 12 Apr 2011

Thank you all for your comments so far.

@noahm26: have you seen the following page? It might help you out some. If you need more info, can you describe exactly in what area and I can write up an article on the topic (if needed); however, it might be enough:

http://developer.anscamobile.com/content/performance-and-optimization

ChunkyApps
User offline. Last seen 2 weeks 4 days ago. Offline
Joined: 19 Jan 2011

@jonathanbeebe: Maybe I am worried about this more than I should be. I have actually adapted your clean function from ghost vs. monsters along with director class. My code is working nice and quick on my iPhone 4 but I haven't tested on an earlier device.

However, I have seen many people write on the forums that they are seeing memory leaks in their games. How do they know this? How do you check for a memory leak?

I know how to find errors using Terminal but not how to check memory leaks. Any info on that would be quite useful.

carlos m. icaza
User offline. Last seen 2 years 1 week ago. Offline
Alumni
Joined: 22 Jun 2009

Thank you Jonathan for your generosity

Carlos

kbane
User offline. Last seen 1 year 27 weeks ago. Offline
Joined: 28 Mar 2011

This is really great, thank you for sharing this.

I did find an issue that I have a question about. When I load the app for the first time, the music plays for the first game, but if I die and start the game again the music does not play. Does anyone know how to fix this issue?

Thanks for any help, and again thanks for sharing Jonathan!

Kevin

jonathanbeebe
User offline. Last seen 1 year 29 weeks ago. Offline
Alumni
Joined: 12 Apr 2011

@noahm26: I just posted a new article to my blog that covers memory management, and how to track memory leaks:

http://jonbeebe.net/corona-sdk-memory-management-101-tag-memory-m

Also, as of the last stable Corona release, you no longer need that cleanGroups script I provided in the past. There have been changes to the Corona core that cleans up child objects from groups automatically when you call display.remove() and removeSelf().

Hope that helps!

ChunkyApps
User offline. Last seen 2 weeks 4 days ago. Offline
Joined: 19 Jan 2011

@ jonathanbeebe:
And there it is.
That is exactly what I was looking for. Ansca should make that article the front page on their docs section. Great job explaining everything.
You are truly a unique person for being so helpful and generous with your knowledge and time. It is very much appreciated!
Thanks!

Daniel W.
User offline. Last seen 6 days 1 hour ago. Offline
Joined: 13 Jan 2011

@jonathanbeebe: You truly are a gem in this community. I learned so much from Ghosts vs. Monsters and your blog (if you haven't read it, go read it right now - http://jonbeebe.net/) that I cannot wait to go through the sample code.

MobiDojo
User offline. Last seen 13 weeks 4 hours ago. Offline
Joined: 19 Jan 2011

Thank you very much!!! All of the available source code you guys have provided has helped me learn more about the Lua programming language and enable me to put my own twist in the apps I'm developing. I've learned so much in such a short amount of time. :D

alanfalcon
User offline. Last seen 1 year 1 week ago. Offline
Joined: 16 Jan 2011

Tilt Monster was the game that convinced me to go with Corona in the first place. Thanks so much for sharing, Jonathan (and Biffy!)

IJRuiz@Hotmail.com
User offline. Last seen 2 years 34 weeks ago. Offline
Joined: 17 Dec 2010

Thank you Jonathan fro being very generous. This is an inspiration and assist for those new to this field. To have a complete source code of a full working app is so incredible! Thanks again!

sewfew2000
User offline. Last seen 2 years 3 weeks ago. Offline
Joined: 28 May 2011

It's so great that You give to all of us a new "step forward" to learn more with this fantastic "developer tool" from Ansca Mobile.Thank you ,Thank you,Thank youJonathan!!!

lemsim
User offline. Last seen 1 year 16 weeks ago. Offline
Joined: 30 Mar 2011

@jonathanbeebe: THANK YOU! I have learned SO much from your code! I have to admit, I could not believe it when I first saw that you were release your code. But I am so glad you did. So again thank you so much.

After looking at your code for a long time, I am just curious about one thing. The clean() function. It seems that you clean mostly Runtime events but not display objects like background images and so on? Your apps works great on both Android and iPad so you must be doing something right (LOL) So I am wondering if I am not doing something wrong!

Right now each of my modules (menuScreen, optionsScreen, gameScreen and so on) have a clean() where I not only cancel Runtime events but also try to delete display objects using your method (from you site) which display.remove()

My question: Is is necessary to explicitly remove display objects when exiting each module? Your code seems to say no but I just wanted to make sure. by the way I am using Director 1.2 right now.

In any event, let me again says THANKS for not only the code but also your willingness to help this community. You are of course an asset!

Mo.

ps: anybody can comment on this issue of course.

jonathanbeebe
User offline. Last seen 1 year 29 weeks ago. Offline
Alumni
Joined: 12 Apr 2011

@lemsim: I'm glad you are getting a lot of value out of the code!

The reason I don't remove display objects with the clean function, is because when a screen is transitioned, it removes the display group, which actually removes all of the children objects within that group.

So for future reference, if you have a group, and you add objects to that group, when you call removeSelf() (or display.remove()) on the group, all the children objects will be removed as well.

Runtime event listeners, however, do not get removed automatically (ever), so that's why I do it manually in the clean function.

Thanks again for your comments.

lemsim
User offline. Last seen 1 year 16 weeks ago. Offline
Joined: 30 Mar 2011

Hey. You are really welcome!

Just to make sure (i m sorry if I am dense today!) Do I still need to use display.remove() in my clean()? You seems to say that display.remove() on a group will remove all the children objects BUT do I need to actual use that if I am using Director 1.2? my feeling is no and that Director removes all groups and objects at screen switching (but not Runtime listeners and transitions for instance)

Am I correct to think that?

Thanks for your super fast answer by the way!

Mo

jonathanbeebe
User offline. Last seen 1 year 29 weeks ago. Offline
Alumni
Joined: 12 Apr 2011

Yup, you've got it. Director will remove all objects, as long as you added those objects to the screenGroup (or localGroup I think is the default for director screens).

Remember though, if you have any runtime listeners, such as enterframe listeners or runtime touch listeners, you need to manually remove those.

Basically, anytime you have this in your code:

Runtime:addEventListener...

You need to have:

Runtime:removeEventListener...

Somewhere else or you're risking some major crashes. Display objects and their attached non-runtime listeners will get removed when you remove their parent group though :-)

Hope that helps!

lemsim
User offline. Last seen 1 year 16 weeks ago. Offline
Joined: 30 Mar 2011

ABSOLUTELY it helped! Thank you so much for getting back to me so rapidly. I appreciated it very much. It all make sense now.

THANKS.

Mo.

admin6
User offline. Last seen 4 weeks 3 days ago. Offline
Joined: 13 Mar 2011

How can i add more life to the game?

And did someone fix audio bug when hit play again button background music stop?

Thanks

Konradzik
User offline. Last seen 6 weeks 1 day ago. Offline
Joined: 19 Jan 2011

Thank you for Tilt Monster code Jonathan someday I will buy a beer for that. Now my lua learning process increased twice.

tomprice
User offline. Last seen 1 year 12 weeks ago. Offline
Joined: 6 Jun 2011

Thanks very much for this Jonathan

davidcraigster
User offline. Last seen 2 years 40 weeks ago. Offline
Joined: 16 Jun 2011

Is there a way to control this game on an emulator?

iain0
User offline. Last seen 2 years 42 weeks ago. Offline
Joined: 25 Jun 2011

Hi

I must be missing something.

I downloaded the files and all I get are images.

What have I done wrong ?

Iain

eng.tareqali
User offline. Last seen 2 years 6 weeks ago. Offline
Joined: 23 Dec 2010

can I use the code for making my game, with changing images and some properties of the game ??

THank u to much for the code, very helpful

jonathanbeebe
User offline. Last seen 1 year 29 weeks ago. Offline
Alumni
Joined: 12 Apr 2011

You are free to do what you want with the code/images, etc. :-)

paulallanharrington
User offline. Last seen 7 weeks 5 days ago. Offline
Joined: 14 Jan 2011

For a variety of products we are working on at http://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).

In an effort to complement Jonathan and Biffy Beebe's amazing generosity; as we learn from their work 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/

Best wishes,

Paul Allan Harrington
Visuals Work: { visualswork.com }
Consulting Group: { pahgroup.com }

KeepTrying
User offline. Last seen 4 weeks 6 days ago. Offline
Joined: 2 Jan 2011

@Jonathan

First of all, thanks for that great sample of successful game.
Why i don`t see it or any other game of Beebe Games in App Store ? You are on a vacation ? XD or developing the next hit ?

carlos.varela.com
User offline. Last seen 1 year 9 weeks ago. Offline
Joined: 24 Aug 2010

Thanks man so much!!!

Any ideas on how to increase the number of lives?
I am really very bad playing this ; ))P
I will need a very-very-easy settings just for me!!

lol

bigteethmedia
User offline. Last seen 1 year 31 weeks ago. Offline
Joined: 5 Aug 2011

Somebody knows how to dont show the rating message?

Thanks.

paulallanharrington
User offline. Last seen 7 weeks 5 days ago. Offline
Joined: 14 Jan 2011

@omarcaleroherrera2

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.

Best wishes,

Paul Allan Harrington
Visuals Work: { visualswork.com }
Consulting Group: { pahgroup.com }

bigteethmedia
User offline. Last seen 1 year 31 weeks ago. Offline
Joined: 5 Aug 2011

Thank you Paul

carlos.varela.com
User offline. Last seen 1 year 9 weeks ago. Offline
Joined: 24 Aug 2010

After...

settings =
{
orientation =
{
default = "landscapeRight",
supported = { "landscapeRight", "lanscapeLeft" },
},

...

The game in general works well except the tilt that move in oposite way if "lanscapeLeft" : (((

Is there a way to control this?
@bebee, please HELP!! ; ))P

dabocharif
User offline. Last seen 43 weeks 11 hours ago. Offline
Joined: 7 Jul 2011

Thank you Jonathan an Biffy for this GREAT release!

Could someone please tell me how reverse the scrolling movement? Instead of everything going DOWN, I want everything going UP..

Thx

KeepTrying
User offline. Last seen 4 weeks 6 days ago. Offline
Joined: 2 Jan 2011

Why the in game music stop play when you restart the game, i mean retry the round ?
Edit: Never mind figured out my self.

info242
User offline. Last seen 2 years 19 weeks ago. Offline
Joined: 25 Sep 2011

@KeepTrying

Can you please share it? I have the same problem :(

Thanks!

KeepTrying
User offline. Last seen 4 weeks 6 days ago. Offline
Joined: 2 Jan 2011

Ok @info242 here we go, open maingame.lua and change runningSound by gameMusic3 on LINE 1317.
Everytime you start the game by default gameMusic3 is played, when you press TryAgain the runningSound is activated.

Many thanks for @jonathanbeebe because i'm not a programmer and that source code let me learn more and more everyday.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
        -- Setup "Try Again" Button
                local touchTryAgainBtn = function( event )
                        if event.phase == "release" and tryAgainBtn.isActive == true then
                                
                                tryAgainBtn.isActive = false
                                
                                -- Play Sound >>> play sound active search
                                local soundsOn = gameSettings[ "soundsOn" ]
                                
                                if soundsOn == true then
                                        local freeChan = audio.findFreeChannel()
                                        audio.play( tapSound, { channel=freeChan } )
                                        
                                        local freeChan2 = audio.findFreeChannel()
                -- LINE 1317                    audio.play( runningSound, { loops=-1, channel=freeChan2 } )
                                end
                                
                                recycleRound()
                        end
                end

info242
User offline. Last seen 2 years 19 weeks ago. Offline
Joined: 25 Sep 2011

Thanks KeepTrying! it is working...

mase
User offline. Last seen 3 weeks 4 days ago. Offline
Joined: 23 Jun 2011

BGM has not been played on my ipod touch after ios 5 update.

Does anybody have the same problem?

Alberto A
User offline. Last seen 1 week 6 days ago. Offline
Joined: 3 Feb 2011

Anyone figure out how to reverse the direction of all objects.

Thanks

bigteethmedia
User offline. Last seen 1 year 31 weeks ago. Offline
Joined: 5 Aug 2011

Hi everyone. I find the Martian Control code made by Jhonatan and Im trying to do the ships land in the planets without drawing a path, I mean, each planet be the goal of certain ships, so you have to touch them to destroy before they land. But I dont know how to do that. Any idea on how to do that?

Thanks

Rule The Page
User offline. Last seen 1 year 9 weeks ago. Offline
Joined: 19 Jan 2011

How Can I add more themes for use? I need to learn that for my new app...

rijil.ks
User offline. Last seen 3 days 17 hours ago. Offline
Joined: 31 Oct 2011

all I can say is Thank you..

ensilage
User offline. Last seen 1 year 26 weeks ago. Offline
Joined: 6 Oct 2011

hi i am new in corona as well as game development. i am influenced by this code and if i want to develop the same code with just a small modification like moving bottom to up of the objects. how do i do this.

Thanks & Regards

Rule The Page
User offline. Last seen 1 year 9 weeks ago. Offline
Joined: 19 Jan 2011

I had a question about the facebook part. For my app I wanted to have a post score to facebook but I had a problem: Failed to index global function "facebook" on last line and in function "on event"

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
local touchFBBtn = function( event )
                        if event.phase == "release" then
                                
                                -- BELOW IS AN EXAMPLE OF HOW TO GET FACEBOOK SCORE POSTING TO WORK:
                                
                                
                                -- Play Sound
                                local soundsOn = gameSettings[ "soundsOn" ]
                                
                                if soundsOn == true then
                                        local freeChan = audio.findFreeChannel()
                                        audio.play( tapSound, { channel=freeChan } )
                                end
                                
                                --
                                
                                local facebookListener = function( event )
                                        if ( "session" == event.type ) then
                                                -- upon successful login, update their status
                                                if ( "login" == event.phase ) then
                                                        
                                                        local gameScore = getScore()
                                                        gameScore = comma_value(gameScore)
                                                        
                                                        local theMessage
                                                        
                                                        if gameSettings[ "difficulty" ] == "easy" then
                                                                theMessage = "just scored a " .. gameScore .. " on Alien Falls (Easy Mode)."
                                                        
                                                        elseif gameSettings[ "difficulty" ] == "medium" then
                                                                theMessage = "just scored a " .. gameScore .. " on Alien Falls (Medium Difficulty)."
                                                        
                                                        elseif gameSettings[ "difficulty" ] == "hard" then
                                                                theMessage = "just scored a " .. gameScore .. " on Alien Falls (Hard Mode)."
                                                        
                                                        end
                                                        
                                                        facebook.request( "me/feed", "POST", {
                                                                message=theMessage,
                                                                name="Download Alien Falls to Compete with Me!",
                                                                caption="Think you can beat my score of " .. gameScore .. "? I dare you to try!",
                                                                link="http://itunes.apple.com/app/alien-falls/id506423125?mt=8",
                                                                picture="http://tiwwas.com/wp-content/themes/FBAPPICON.png" } )
                                                end
                                        end
                                end
                                
                                -- replace "---" below with your Facebook App ID
                                 facebook.login( "***************", listener, {"publish_stream"}  )
                        
                        end
                end
<code>
to clarify the issue is on line "########", listener.... any idea what i did wrong or how to fix it?

Arsalan
User offline. Last seen 7 weeks 5 days ago. Offline
Joined: 8 Sep 2012

hi, i am new to android game development. i have just started working in lua. I was curious to know that what are the changes that i'll have to make in this code or resources formats(if any) in order to develop for android market. Since this version of game is for iOS. thanks!

mbrown0
User offline. Last seen 1 year 27 weeks ago. Offline
Joined: 27 Sep 2012

I am new to Corona and checking out sample projects. Love this Tilt Monster project but it is crashing in the current version of Corona when the player "dies". Anyone know why? Anyone else experiencing this besides me?

Arsalan
User offline. Last seen 7 weeks 5 days ago. Offline
Joined: 8 Sep 2012

The console that opens along with the Corona sdk must have shown you the code line that is making the game crash once the player dies. May b i can help u out if u can paste that code here.