Share Your Code

Game Logic

Sort by: Latest Additions | Most Viewed | Recently Updated | Top Rated

The latest additions of sample code and code libraries shared by developers for Corona SDK.

0 votes
Lua Class System - Object Oriented Library For Your Projects

I am sharing a small work of my own, a clean and light-weight class system I have been working on. Lua Class System (LCS) is a library for (pseudo) object oriented mechanisms. It aims to be something clean, simple to use, minimalistic so that it would easily fit in every project where object-oriented concepts might be needed. Hope some might find it useful. I am still maintaining it so small changes could occur in... More...

Posted by roland.yonaba, Posted on 20 May 2012, Last updated 20 May 2012 | 0 comments

1 vote
Invert, Horizontal Flip and Vertical Flip Physics Shapes

I recently discovered that is was very easy way to invert images, e.g: myObject.xScale = -1, will horizontally flip a display object. This works well but it will not flip any custom physics shapes assigned to the object so in order for the objects to have the correct physics the shapes need to be flipped also. Here is a function I created which will output a new list of flipped or inverted shapes coordinates from... More...

Posted by Beloudest, Posted on 7 May 2012, Last updated 7 May 2012 | 0 comments

0 votes
Simple Polygon Triangulation

I've been looking for a way to break a simple polygon into component polygons for a while. I won't tell you why because I'm using it in a game, but I just had to share this solution. It takes any clockwise winding polygon (entered by tapping the screen in sequence) and breaks it into it's interior triangles - literally "triangulation." I can't take credit for the math, which was the only complete and understandable... More...

Posted by horacebury, Posted on 4 May 2012, Last updated 4 May 2012 | 1 comments

3 votes
OWL (Objects with Lua)

OWL is a single-module library that provides an easy way to incorporate object-oriented programming concepts into Corona SDK projects. Supports classes that produce display objects (as well as classes that produce non-display objects), and can even be used with non-Corona Lua scripts as well. Features include: More...

Posted by jonathanbeebe, Posted on 25 Apr 2012, Last updated 25 Apr 2012 | 2 comments

0 votes
Jump without the physics engine

well i started looking for a way to create a game without using the physics engine and letting the player jump and i used the hit test that was provided from one of the users in the website now the logic is that you need to play with the player y value to be able to control the jump and the falling down have fun with the code i hope you like it in the get hub you need to go to the download to get the file More...

Posted by mtayyar, Posted on 24 Apr 2012, Last updated 24 Apr 2012 | 4 comments

0 votes
Line intersection

Another little demo with sample code to calculate the intersection point between two lines. As always from me, you'll need the mathlib.lua here (because it has the key function): https://developer.anscamobile.com/code/maths-library main.lua: 1 2 3 4 5 6 7 8 9 10 11 12 -- line intersection require("mathlib")   -- http://local.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/   -- turn off... More...

Posted by horacebury, Posted on 8 Apr 2012, Last updated 8 Apr 2012 | 0 comments

0 votes
Polygon fill and Point in Polygon detection

Source of my inspiration: http://alienryderflex.com/tutorials.shtml local widthheight, isclosed, isperpixel = 1, false, false local widthheight, isclosed, isperpixel = 10, true, true NOTE: The functions in this demo are provided in the mathlib.lua found here: More...

Posted by horacebury, Posted on 5 Apr 2012, Last updated 5 Apr 2012 | 2 comments

1 vote
Simple Lua Table Save & Load

Hi, I'm not sure if anyone is going to use it, but I wanted to share this little piece of code. Currently it is designed to work with Corona XML Parser. What this code does is simply store lua table into an xml file and load it afterwards. More...

Posted by krystian6, Posted on 4 Apr 2012, Last updated 4 Apr 2012 | 0 comments

5 votes
Quick Bubble Popper

Another common forum request. This will show some spawning, touch handling with table listener and object removal. Also shows some forward declarations for the "cart-before-the-horse" issue. Added some collision bounds and EndGame removal mechanics. Added some Group usage examples and proper reverse-removal of objects. Also note use of .alive to prevent "double-taps". Split into module to show ONE WAY this can be... More...

Posted by TheRealTonyK, Posted on 1 Apr 2012, Last updated 1 Apr 2012 | 12 comments

4 votes
Cool Linear Velocity Chaser

A forum post that needed some "chaser" type functionality drove me to throw this together. It shows how to use timers and Linear Velocity to make objects smoothly and kind of "organically" chase another object Hope you have fun with it, I know I did! 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 local physics = require("physics")   physics.start()   Random = math.random   local... More...

Posted by TheRealTonyK, Posted on 31 Mar 2012, Last updated 31 Mar 2012 | 1 comments

3 votes
Cat-mull-rom open and closed

So, got back into the old bezier stuff again and figured it might be fun to try and get the curve passing straight through the control points. Makes it more useful for plotting courses for game characters, because players are not going to be drawing lines and placing control points - they'll just drag out a path or whatever and the character should traverse it, etc... More...

Posted by horacebury, Posted on 25 Mar 2012, Last updated 25 Mar 2012 | 0 comments

7 votes
Collisionator - Filter Generator

I've created a tool to generate collision filters quickly for use in apps & games: http://labs.zanuka.com/collisionator3000XL/index.html * UPDATE: New version uploaded April 2, 2012. This version automatically selects the reciprocal object collision so you no longer have to tick both manually. For example if you want object 2 to collide with object 1, just select one collision in the grid and the other will be... More...

Posted by ZANUKA, Posted on 22 Mar 2012, Last updated 1 Apr 2012 | 11 comments

4 votes
(Not-) Verlet Rope

Just playing about with some of Carlos' code and thought to myself, "Doesn't the bezier line look like a rope?"... So I made the control points physics objects, joined them with distance joints and fixed the first one in place. While the following code has major performance issues, I'm sure, it could probably serve as the basis for some interesting effects. I have commented in CAPITALS everywhere I've changed the... More...

Posted by horacebury, Posted on 15 Mar 2012, Last updated 15 Mar 2012 | 2 comments

2 votes
Transition Manager 1.0

Transition Manager 1.0 Syntax: instance.Start(object, time, xValues, yValues) Example: 1 2 3 local transman = require "transman" local square = display.newRect(50, 50, 0, 0) transman.Start(square, 500, {50, 100, 150, 200, 250}, {50, 100, 150, 200, 250}) Parameters: - object: A display object that will be the target of the transition. - time: A number that specifies the... More...

Posted by joelwe, Posted on 11 Mar 2012, Last updated 14 Mar 2012 | 0 comments

12 votes
Texturemapped Raycasting Engine

As a follow up to my original code share of the Corona port I did of my 2D raycasting engine, texture mapped walls have been added. This was achieved using sprite sheets. The downside of this is the frame rate takes quite a hit compared with the flat filled walls shown in the original sample. I know I can optimise how I use sprites in this demo, but I still think more needs to be done to get the frame rate up -... More...

Posted by Jesder, Posted on 10 Mar 2012, Last updated 10 Mar 2012 | 17 comments

0 votes
Stopwatch Timing Class

Current Version: 1.2 Stopwatch is an easy way to create and manage timers (not the performWithDelay kind!), clocks, and any other timekeeping your app might require. Count down to from any number to 0, count up to infinity, pause and resume, and more! 0. Require stopwatch Simply add stopwatch.lua to your project folder, and require it into the files you need it like so: 1 local stopwatch = require "stopwatch... More...

Posted by Revaerie, Posted on 9 Mar 2012, Last updated 9 Apr 2012 | 19 comments

2 votes
Conway's Game of Life for Corona SDK

A quick code share to create Life within Corona. This is great learning example to master 2D arrays and to soak up some game logic roots! The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970. Check out the full story on my blog at Conway's Game of Life for Corona SDK More...

Posted by croisened, Posted on 9 Mar 2012, Last updated 9 Mar 2012 | 0 comments

0 votes
Basic ladder control for sprite

I have been trying to figure out how to do this and finally put all the pieces together (sort of). I saw a several questions about this in the forum, and never really found a solid answer, so I thought I would share the code I worked up. The basic answer is "When player collides with ladder, turn gravity off". But your 'up' button needs to track what state the gravity is in or the player movement can get wonky.... More...

Posted by sds65805, Posted on 9 Mar 2012, Last updated 9 Mar 2012 | 0 comments

1 vote
Pauseable Transitions, unified timer and transition module, can replace built-in

Here is yet-another pausable transition library. I call it "ctrans", short for "custom transitions". It is different in that it keeps track of all transitions internally, rather than just tag on data to tween objects. This keeps the size of the tween objects small and allows you to perform actions on a large set of transitions with a simple command. More...

Posted by kenneth34, Posted on 4 Mar 2012, Last updated 10 Apr 2012 | 4 comments

3 votes
Asteroids

I got hit with the urge to write the Atari classic Asteroids using the physics engine and a "no button" touch controls. So, here's the source code. It's really messy, not object oriented but it shouldn't throw too many errors and I've tried to handle the object removal etc reasonably well. There are some principles which n00bs could learn from and some which you should avoid, but all in all if you were to take the... More...

Posted by horacebury, Posted on 27 Feb 2012, Last updated 28 Feb 2012 | 10 comments

0 votes
Ultra Simple Parallax Scrolling

So this is a parallax scrolling module that will handle up to 5 "layers" of parallax. This is made for landscape orientation, but you should be able to just flip a few things in the file and make it work for vertical as well. You can insert as many images as you want within each layer (minimum of 3, I don't think it'll work properly with only 2). Also, all images within each layer will need to be the exact same size... More...

Posted by 003naveen, Posted on 26 Feb 2012, Last updated 26 Feb 2012 | 1 comments

7 votes
Maths Library

NOTE: I have commented out the line at the top, so you now only need to require the mathlib in your main.lua and Disclaimer: I am not a mathematician and never will be. The library I've posted here has been developed to help me do things I don't really understand. I have derived all the code here either from first principles or translated it from other code posted to forums and which I can rely on working. It is... More...

Posted by horacebury, Posted on 15 Feb 2012, Last updated 11 May 2012 | 8 comments

13 votes
Raycasting Engine

Back in 1997, I wrote a raycasting engine in Turbo Pascal. It had a number of features and was heading towards being turned into a fully fledged game engine. That never happened. But since then, as I move between development platforms, I like to port a cutdown version of it to help make me familiar with the syntax and API on the new platform. Here is a basic raycasting engine written in LUA with the Corona SDK. More...

Posted by Jesder, Posted on 14 Feb 2012, Last updated 14 Feb 2012 | 13 comments

4 votes
Particle Candy Effects Creator

This is a simple helper project to ease the creation of Particle Candy effects. I've been looking for a decent GUI to help me invent particle candy effects and couldn't find anything working, so I decided to go ahead and create my own GUI. For now it allows to adjust only Particle Type properties [and without fancy FX or fields or anything like that], but if you would like to get more, please let me know. More...

Posted by krystian6, Posted on 5 Feb 2012, Last updated 17 May 2012 | 30 comments

2 votes
Accurate tempo/BPM-based timing in your animations and music apps

Accurate tempo/BPM-based timing in your animations and general beat-sequenced stuff. I am using this logic in a spiffy metronome that I am porting over to iOS using Corona. I've used this rock-solid tempo pulse logic in my music apps for various platforms since 1998 and it has never done me wrong. More...

Posted by Gary Duke, Posted on 2 Feb 2012, Last updated 2 Feb 2012 | 5 comments

0 votes
Radio Like Buttons

I was originally making this for an odesk project, but now that I realized how long it will take to perfect it, I will just update it as I go for everyone to use. It is like a check box. Here is how to use it so far: 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 local control = require("control")    newBox = control.newControl(      ... More...

Posted by Gigabook, Posted on 27 Jan 2012, Last updated 27 Jan 2012 | 0 comments

1 vote
Get Sprite by Name in a Sprite Sheet

Are you upset with the order of you sprite sheets? I am :) It's easy, for me, to sort sprite by name, example : "ship_1,ship_2", and to get the index of the first frame. Use the Basic layout in Zwoptex, then choose to order by name/Ascending. Here is a short snippet to get a sprite picture index in a sprite sheet. pSheetData is the sprite sheet used by sprite.newSpriteSheetFromData. pName is the picture name,... More...

Posted by dmekersa, Posted on 27 Jan 2012, Last updated 31 Jan 2012 | 1 comments

0 votes
Running Clock

This code will create a variable running timer for your game/app. Please see below for what to set it up. Functions: clock.cancelTimers(): This will cancel or pause your timers clock.resumeTimers(): This will resume your timers from a clock.cancelTimer call First you have to require the clock by writing: 1 local clock = require("clock") Then to set up a clock you have to follow this: 1 2 3 4 5 6 7... More...

Posted by jeremyapplebaum12, Posted on 22 Jan 2012, Last updated 22 Jan 2012 | 2 comments

5 votes
Follow (and avoid) Object

I ported this nice AS2 follow-object script by Philip Radvan see the original post here http://www.freeactionscript.com/2009/04/enemy-behavior-run-away-follow-player/ fin.lua 1 2 3 4 5 6 7 8 9 10 11 12 local fin = {} local radians = 180/math.pi  --> precalculate radians   fin.distanceBetween = function ( pos1, pos2 )          local sqrt = math.sqrt  ... More...

Posted by canupa.com, Posted on 18 Jan 2012, Last updated 29 Apr 2012 | 12 comments

1 vote
Point to Point Dragable Travel Objects

I decided to create a reusable function to easily declare any number of objects to travel from point A to point B at designated speed. Was planning on using it in future games... you know, creating cool features before I need them. The idea was later built upon to allow dragging around of the starting and ending points with the objects spacing out in proportion accordingly. Have fun tweaking the code :) main.lua: 1... More...

Posted by TimeSpaceMagic, Posted on 12 Jan 2012, Last updated 13 Jan 2012 | 2 comments

1 vote
Calculating area of an object

I have wanted to calculate the mass of an object for use in my previously submitted sample code (trajectory plotting.) The following code does that - calculates the area of an object, where it's points are clockwise in order and do not overlap. The limitation of 8 points maximum is not present. Using files produced from PhysicsEditor (that of a table of tables to represent more than 8 points) is left as an exercise... More...

Posted by horacebury, Posted on 7 Jan 2012, Last updated 7 Jan 2012 | 0 comments

2 votes
Simple XML Parser

Story I've used XML Parser created by Jonathan Beebe ( http://blog.anscamobile.com/2011/07/how-to-use-xml-files-in-corona/ ) to read small and simple XML files. However for one of my projects I do have a large XMLs to parse which are generated automatically for me. As you know, automatically may mean - random. Using a list of nodes and looping through it was out of the question. This is why I've created this little... More...

Posted by krystian6, Posted on 27 Dec 2011, Last updated 13 Feb 2012 | 6 comments

1 vote
oop - no metas, no module()

Introduction I've build a Class - with actually just one function - for easy and very basic OOP in Lua. After some tryings I've decided to go without metatables and without module(...). This is my own approach and of course ain't the best out there, but as far as I've tested it, it does its job very well for me, so may it do for you too. My first approach was using metas, as everywhere suggested. And this... More...

Posted by jack0088, Posted on 16 Dec 2011, Last updated 19 Dec 2011 | 2 comments

4 votes
Calculating Trajectory

This code calculates every point (to the granularity you want) of an object travelling along a trajectory, starting with a given angle and velocity. I wanted to provide some very simply functions developers can call and have the most simple demonstration code - because that's all I can deal with. I have to say that I did not work this stuff out myself, but just went looking for a really good tutorial, which I found... More...

Posted by horacebury, Posted on 5 Dec 2011, Last updated 5 Dec 2011 | 6 comments

1 vote
Pausable Transitions - A very simple method

Yeah I know there are a lot of transition managers.. Still never hurts to share code.. So here goes. USAGE : 1 2 3 transition.to(object,params} transition.pause(object)     transition.resume(object) I am not sure about the efficiency of this module. So if anyone has any modifications or if anyone finds any bug, please comment below. And I haven't tested this completely, but till... More...

Posted by Satheesh, Posted on 26 Nov 2011, Last updated 27 Nov 2011 | 5 comments

3 votes
RagDoll example

Code: https://files.me.com/horacebury/dzd1ev Swf Video: https://files.me.com/horacebury/cctx6z I've been wondering about the issue surrounding Ragdoll physics in Corona and had always wanted to produce a direct comparison to illustrate the differences various developers are seeing, myself included. Recently, I found some JavaScript ports of the Box2D Flash engine and thought that I would attempt a rag doll scenario... More...

Posted by horacebury, Posted on 22 Nov 2011, Last updated 22 Nov 2011 | 20 comments

0 votes
Move Camera

This is a very very very very simple module, just for those people who are just beginning, I remember when i was having struggles with moving the camera with objects outside of the screen. Go to sites.google.com/site/myplace2go2/corona-sdk and download the attachment camera.lua How to use: 1 2 3 4 5 6 7 8 9 10 --------------------- -- require camera --------------------- local camera = require("camera... More...

Posted by Gigabook, Posted on 10 Nov 2011, Last updated 10 Nov 2011 | 3 comments

7 votes
Director Slim - Stripped down Director Class

I've managed to strip it down to only 15 lines of code! That's right. Plus 6 lines for the header. Works faster, with lower overhead - hence higher performance. UPDATE 2011-11-05: Reduced to 15 lines. Fully working example added to GitHub. I didn't like director 1.3 when it came out, so I decided to stick with version 1.2a - the one with improved group cleaning function. I was fine with it thanks to Ricardo and... More...

Posted by Lerg, Posted on 29 Oct 2011, Last updated 4 Nov 2011 | 37 comments

1 vote
Soft physics body

I thought soft bodies looked cool and thought of a way to make one myself. This is probably not a good way to do it. Crashes corona if the body starts spinning too wildly. This requires http://developer.anscamobile.com/code/make-outside-edge-walls-module if you can't be bothered to get that module, delete: "walls = require("walls") walls.make() " from the code. 1 2 3 4 5 6 7 8 9 10 11 display.setStatusBar(... More...

Posted by mightE, Posted on 28 Oct 2011, Last updated 28 Oct 2011 | 0 comments

1 vote
Sequence.lua - Transition Execution order

Hello everybody! I am a bit new to Corona but i am working on a game template. Below you can find the class i wrote to handle sequential animations (function calls). It's really easy but i think it will be helpful for somebody here. My idea is to integrate it with TransitionManager somehow, but still havent stated with that, if somebody has any ideas about it i will be glad to here them. PS: I think methods like... More...

Posted by calledpaul, Posted on 17 Oct 2011, Last updated 17 Oct 2011 | 0 comments

0 votes
we will miss you steve jobs by dsrawat4u@gmail.com

This tutorial is build for a tribute to "Steve Jobs:The man behind apple" From me(Deepak Singh Rawat) using a better way to understand movieclip action with buttons!! For more information check my blog :- www.anscacorona.blogspot.com or My youtube channel :- www.youtube.com/user/iphonemaclover thank you Have fun with corona SDK File included:- main.lua mainmenu.lua loadmainmenu.lua More...

Posted by Deepak Singh Rawat, Posted on 13 Oct 2011, Last updated 5 Dec 2011 | 3 comments

2 votes
Simple graphical timed score

Hi for this example you need a 25x29 transparent png for every number from 0 to 9, named n#.png. This example is for a 6 digits score. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 display.setStatusBar (display.HiddenStatusBar)   --Define variables local imatgesScore= {} local scoredigit={} local scoreResta=0 score=0   --Initialize scoredigits to Zero for m=0,5,1 do  ... More...

Posted by josua, Posted on 12 Oct 2011, Last updated 12 Oct 2011 | 1 comments

4 votes
Water Buoyancy Example

I am currently working on a game (my first in fact) which unexpectedly has led me down this long, but productive, detour of a road in trying to implement a buoyancy effect that makes physics objects float realistically when dropped into a body of liquid. More...

Posted by iNSERT.CODE, Posted on 10 Oct 2011, Last updated 10 Oct 2011 | 10 comments

1 vote
Orbital Rotation

Showing how to set up an orbital rotation for your corona sdk project. In this example the moon orbits the earth. Download Source: http://www.sims3tinkers.com/orbitalrotationcoronasdk.zip 1 2 3 4 5 6 7 8 9 10 11 12 -- -- Orbital Rotation - Moon around Earth -- Demonstrates one method for orbiting objects -- By Wintermuteai1 - http://www.sims3tinkers.com -- Version: 1.0 -- -- Sample code is MIT licensed, see http... More...

Posted by wintermuteai1, Posted on 30 Sep 2011, Last updated 30 Sep 2011 | 6 comments

1 vote
Ghost vs Monsters - OOP

This is Ghost vs Monsters re-written in an object-oriented style of programming. It's intended as a example of how one might separate functionality within the application. Many thanks to everyone at Beebe Games and Ansca for making the code publicly available! More...

Posted by dmccuskey, Posted on 29 Sep 2011, Last updated 18 Oct 2011 | 4 comments

0 votes
Throwback Football

Here's the code for "Throwback Football" that we did at the Corona Hackathon It's an example of what can be done with the Corona SDK in 8 hours and shows some key features like global variables, director usage, physics, timers, transitions, basic AI, etc. Read the blog here Enjoy, Croisened More...

Posted by croisened, Posted on 26 Sep 2011, Last updated 26 Sep 2011 | 0 comments

0 votes
Updating gravity

:D I found a way, I don't think it has been posted (if it is I look stupid :L ) This code will update the gravity on every enterFrame (should probably change that to a timer every second) to the variable grav. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 grav = 1 function gravi() print(grav) grav = 10 print(grav) end timer.performWithDelay(5000,gravi)        --]]... More...

Posted by mightE, Posted on 19 Sep 2011, Last updated 19 Sep 2011 | 1 comments

1 vote
abc alphabet learner Tutorial using table View in ansca corona

This tutorial is build using list view of corona sample. For more information check my blog :- www.anscacorona.blogspot.com or My youtube channel :- www.youtube.com/user/iphonemaclover thank you Have fun with corona SDK --xxxxxxxxxxxxxxx main.lua file xxxxxxxxxxxx 1 2 3 4 5 6 7 8 9 10 --import the table view library local tableView = require("tableView")   --import the button events library... More...

Posted by Deepak Singh Rawat, Posted on 19 Sep 2011, Last updated 5 Dec 2011 | 20 comments

0 votes
making an object point at a touch event

It isn't a major thing, but I find it can be useful. I have not yet thought of a way to do it without physics. How I do it: The code will make an object called "arr" (I don't know why I called it that) which is attached to the player. The players rotation is found by finding the angle between the player and the arr object. This will run on its own: 1 2 3 4 5 6 7 8 9 10 11 physics = require( "physics... More...

Posted by mightE, Posted on 17 Sep 2011, Last updated 17 Sep 2011 | 4 comments

1 vote
DMC Lib - Drag and Drop

dmc_dragdrop is a module which coordinates drag and drop operations in an application. It can be used to implement things like draggable shopping carts or even a vehicle configurator (e.g., engine, weapons, tires, etc). The module's functionality is based on that of the Adobe Flex Drag Manager, so if you've used that before, then the operation of dmc_dragdrop will be very familiar. Though the module is fully object-... More...

Posted by dmccuskey, Posted on 15 Sep 2011, Last updated 15 Sep 2011 | 7 comments

4 votes
Improved Interactive Line Drawing to Physics Body

A proof of concept on how to draw a line and have it act as a physical body. I owe MichaelAssadi a huge debt of gratitude for posting his example, it was what got me started. More...

Posted by gander, Posted on 3 Sep 2011, Last updated 3 Sep 2011 | 6 comments

2 votes
DMC Corona Library

The DMC Corona Library is a collection of classes and utilities that I have created while developing apps using Corona SDK. I thought it might be useful to others so I decided to polish it to make it into a re-usable framework. Right now there are three core files (more coming): dmc_objects - for object-oriented programming dmc_buttons - to create buttons and button groups dmc_utils - collection of useful functions... More...

Posted by dmccuskey, Posted on 1 Sep 2011, Last updated 1 Sep 2011 | 9 comments

6 votes
A* Pathfinding Demo

This tutorial utilizes the great A* pathfinding code uploaded by Lerg which is found here: http://developer.anscamobile.com/code/pathfinding-module More...

Posted by codepunk_schmidt, Posted on 29 Aug 2011, Last updated 29 Aug 2011 | 14 comments

3 votes
A* pathfinding module

This is a Lua implementation of the A* search algorithm based on using heaps. I took a python implementation and rewrote it in Lua. This module can work with 4 directions maps and 8 directions maps (basically any number of directions from 1 to 8). Demo app can be found here (thanks to Codepunk): http://developer.anscamobile.com/code/pathfinding-demo Here is the Lua pathfinder module. pathfinder.lua-- A* pathfinding... More...

Posted by Lerg, Posted on 25 Aug 2011, Last updated 16 Sep 2011 | 5 comments

4 votes
Dynamic Module Loading

“Dynamic Module Loading”. Sounds fancy but in fact it really isn’t. Whenever I start a new project and am in the design phase, I look for areas of the design that can benefit from being data driven and a way to support an extensible plugin model. The code I’m about to show you here does just that. Again, not rocket science but I think you’ll see that it can help you quite a bit. The whole concept behind this lies... More...

Posted by codepunk_schmidt, Posted on 17 Aug 2011, Last updated 17 Aug 2011 | 2 comments

1 vote
Adding Image and dynamic function from array

Simple code to load image and function to be associated to its event from a table. I hope you will find it useful. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 --array with image name and function to be called on click event local circles = {{"image1","fn1"}, {"image1","fn2"}, {"image1","fn3"}}   local x... More...

Posted by renvis@technowand, Posted on 16 Aug 2011, Last updated 16 Aug 2011 | 3 comments

2 votes
Object drag direction

The below code shows the direction in which an object is tragged. The directions shown are - UP - UP LEFT - UP RIGHT - LEFT - RIGHT - DOWN - DOWN LEFT - DOWN RIGHT This is useful in cases where you need to change the image based on the direction of object or if you need to code a joystick. 1 2 3 4 5 6 7 8 9 10 --to store previous position of x and y local prevx = 0 local prevy = 0   local circle = display.... More...

Posted by renvis@technowand, Posted on 1 Aug 2011, Last updated 1 Aug 2011 | 1 comments

0 votes
Keeping score aligned

Hey, i don't know if someone has posted something similar to this, but I couldn't find one, so I wrote my own. If it's already out there somewhere, then sorry -- I just thought this could help the community. Basically, it is an external module that you require in to your code called length.lua. length.lua 1 2 3 4 5 6 7 8 9 10 11 12 13 module(..., package.seeall)   function width(y,t)  ... More...

Posted by mdcapps, Posted on 29 Jul 2011, Last updated 29 Jul 2011 | 7 comments

2 votes
PuzzleApp

This sample code is a demonstration of how you could implement a simple jigsaw puzzle concept using the Corona SDK's bitmap masking functionality. I created this a long time ago and it was just sitting on my harddrive, so I thought I'd put it to good use and share it with the developer community. It is optimized for Galaxy Tab/Nook dimensions, but could of course be tweaked to match any dimensions. It's the logic... More...

Posted by jonathanbeebe, Posted on 26 Jul 2011, Last updated 26 Jul 2011 | 5 comments

9 votes
Rotate object with finger

I have been trying to figure out how to rotate an object with my finger by moving it in clockwise or counter-clockwise position. After much Math searching and confusion, I think I got it. Here it is: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 local function rotateObj(event)         local t = event.target         local phase = event.phase        ... More...

Posted by ChunkyApps, Posted on 14 Jul 2011, Last updated 14 Jul 2011 | 13 comments

1 vote
Very simple scoring method

This is a very simple way of updating a user's score and then saving it to be called again when the app is restarted, basically saving the score indefinitely. There is only really one file to this, and thanks to peach pellen for providing some of the code snippets in her wonderful tutorials -- really guys check it out www.techority.com anyway, here is the main.lua file 1 2 3 4 5 6 --[[ SCORING SAMPLE CODE BY MAX... More...

Posted by mdcapps, Posted on 14 Jul 2011, Last updated 14 Jul 2011 | 2 comments

2 votes
Arrow Basics

I needed an arrow for my game but quickly found out that it doesn't move properly (arrow head wouldn't point down with gravity) so I came up with this. This is the basics of how an arrow should work in Corona. I figured out how to do this with the help of peach pellen and the forum user canupa.com. Also the magnet code was taken from the gravity sample code written by horacebury. Coded by Nick Homme More...

Posted by nick homme, Posted on 10 Jul 2011, Last updated 10 Jul 2011 | 2 comments

2 votes
Draw a line

Hey, This is a way to make a user draw a line with physics, this is also a good example for math.random. Try copy pasting this code into a main.lua document. It has a walk through on how to have the user draw a physics line, with a ball rolling down. Enjoy! :) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 --(Copy paste friendly)     -- Try swiping mouse over simulator to produce random colored lines   -- Starts... More...

Posted by MichaelAssadi, Posted on 29 Jun 2011, Last updated 1 Jul 2011 | 10 comments

3 votes
Angry Bird catapult like from simple pool example

****ENGLISH VERSION INCLUDED**** (Since I got some complaints from users asking me to translate my code in english, I've posted on my Github the revised code with english commentary ^^) This is an alternative code from the Hot Cross Bunny example that I would share with you guys... I took essentially the cueShot function from the simple pool example and I transformed it into a catapult, different from an angry bird... More...

Posted by rayman1900, Posted on 29 Jun 2011, Last updated 5 Aug 2011 | 9 comments

0 votes
Click to Spawn

Hello, this is my first snippet of code which I'll be using in my final game, but I thought I'd share it as I found it difficult to find on here on the site. Enter this is your main file, a level file or a seperate .lua file required by your normal file: 1 2 3 4 5 local function spawnObject(event)                 local object = display.newImage("images/object.... More...

Posted by george.fairs, Posted on 23 Jun 2011, Last updated 24 Jun 2011 | 7 comments

9 votes
Pauseable timers and transitions with speed adjustment

After searching for pausable timers for corona I found only several implementations. Beebe used enterFrame listener to implement his own timers and transitions. Transition manager has memory leaks and lacks some functionality. So I decided to wrap around existing corona timers and transitions into my own implementation. Remember to free the memory used by this module, I advice you you to call... More...

Posted by Lerg, Posted on 18 Jun 2011, Last updated 14 Apr 2012 | 37 comments

0 votes
Puzzle Piece Game Logic

1 2 3 4 5 6 7 8 9 10 11 12 ---by: James Timberlake ---Please use this for your own purposes. This is some code I found may be useful for everyone.Ti ---This is an example of creating pieces of the same image using sprite sheets --This can be used for more than game pieces, but that was the only way I knew of describing this. --Note: making pieces more than 400 will give a significant amount of time before loading... More...

Posted by jamestimberlakejr, Posted on 12 Jun 2011, Last updated 12 Jun 2011 | 13 comments

2 votes
Pinball Madness

Try this game out so you can see how you can see how easy it is to setup the Corona physics to create a pinball game. Sample code is MIT licensed and Open Source, so you can use the code at will and create your own game, edit it, add better looking scoring, how about adding a left and right paddle only, more lights, sounds. Show us what you can do. Carlos More...

Posted by carlos m. icaza, Posted on 3 Jun 2011, Last updated 18 Oct 2011 | 6 comments

4 votes
Flight Path

You are in charge. You are the Head Honcho at the new Nimitz class of nuclear powered aircraft carrier and your job is to make sure that every plane/helicopter lands safely. This sample project is provided for you learn a different type of game that can be developed using Corona. It is up to you now to implement sound, different planes, water movement, score, etc. The code is very simple to follow and as usual it... More...

Posted by carlos m. icaza, Posted on 2 Jun 2011, Last updated 18 Oct 2011 | 12 comments

16 votes
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!) More...

Posted by jonathanbeebe, Posted on 25 May 2011, Last updated 18 Oct 2011 | 47 comments

9 votes
How to make an Angry Birds catapult

Catapults like that found in Angry Birds and Hot Cross Bunnies are a staple weapon in the arsenal of any mobile gamer. We thought we'd share with you how to put together a slingshot catapult that looks great and feels authentic. More...

Posted by Fixdit, Posted on 18 May 2011, Last updated 25 Jan 2012 | 23 comments

2 votes
Angry Turtles

This is a version of our Ghosts vs Monsters re-done as Angry Turtles vs rabbits, or hares, up to you how you want to name it. Just shows you how easy it is to use the Ghosts VS Monsters template (or this one for that matter) and change a couple of assets and have a very different looking game. Enjoy and as always, this code, is Open Source. Feel free to edit, modify and do how ever you please. Carlos. More...

Posted by carlos m. icaza, Posted on 2 May 2011, Last updated 18 Oct 2011 | 1 comments

2 votes
LuaFSM

A design pattern for doing finite state machines (FSMs) in Lua Finite state machines can be used to force (at least parts of) your code into deterministic behaviour. I wrote this code to implement generic graphical objects where the presentation and behaviour of the objects can be specified by using state-transition tables. This resulted in less code (and less bugs), a higher modularity and above all a reduction of... More...

Posted by e.cornelisse, Posted on 27 Apr 2011, Last updated 27 Apr 2011 | 1 comments

5 votes
Air Hockey 2 Player Game

Air Hockey is a two player game designed to show off some of the physics engine properties of Corona SDK and how with a few lines of code you can write a very addictive game. First one to score five points wins. Works seamlessly across iOS and Android devices. Open sourced MIT Licensed. Feel free to use the code as you wish. If you decide you want to make changes or additions, feel free to do so and let us know to... More...

Posted by carlos m. icaza, Posted on 20 Apr 2011, Last updated 18 Oct 2011 | 10 comments

2 votes
Two Player Pool Table

This game template is an update to the sample pool game that ships with Corona SDK. This new version includes dual player support, sound, ability to change the felt on the pool table, plus other improvements as well. Feel free to do whatever you want with the game as the code as usual is open source. Now, up to you to learn how to spin and slow down the pool table balls, add more sound, etc. Feel free to share... More...

Posted by carlos m. icaza, Posted on 20 Apr 2011, Last updated 18 Oct 2011 | 4 comments

6 votes
Match The Letter

Match The Letter is a simple picture game for helping kids learn their letters. I posted the source to github. I built it both for my son to play with and to get more familiar with Corona, so any feedback is appreciated. https://github.com/johnpolacek/Match-The-Letter-Game The app is available for download on the iTunes App Store and Google Marketplace. For more info, go to http://johnpolacek.com/matchtheletter More...

Posted by johnpolacek, Posted on 9 Mar 2011, Last updated 18 Oct 2011 | 11 comments

7 votes
Billy Cart in Corona

For Corona users getting started with physics this project skeleton may be useful. Items of of interest: Wheel-powered vehicle Auto-generate physics landscapes Vector drawing Custom physics shapes Camera tracking Physics collision callbacks Get the code from github rather than here, as an additional config file is required. ----------------------------------------------------------------------- -- main.lua... More...

Posted by MarkHenryC, Posted on 10 Feb 2011, Last updated 23 Aug 2011 | 10 comments

12 votes
Object-Oriented Sample Game Framework

I put together a basic game framework to show novice programmers how to organize your code in a modular, object-oriented way. You can download the project from here: http://www.box.net/shared/uz5beg19h8 I wouldn't necessarily recommend starting here if you are totally new to programming, but if you have a little previous familiarity with object-oriented programming then this is a good head-start in using Corona. I... More...

Posted by jhocking, Posted on 20 Jan 2011, Last updated 11 May 2011 | 31 comments

12 votes
BeebeGames Class

*Requires Corona Build 243 at the very least. Download it here: beebegames1-8.zip VERSION 1.8 - Released January 16, 2011 What's new in this (and previous) version? 1.8 - Fixed major memory leak issues in regards to the destroy() function for objects and cancel() for timers. Also, randomTable functions have been deprecated because after extensive testing, localizing math.random actually works A LOT faster than using... More...

Posted by jonbeebe, Posted on 14 Dec 2010, Last updated 16 Jan 2011 | 70 comments

7 votes
Martian Control

Another example game very simliar to Flight Control done using Corona SDK. If you have played Flight Control, this is very simliar game. The code is now open source so you can see how easy it is to recreate using Corona. Once again, especial thanks to Jonathan and Biffy Beebe from Beebe Games for helping us showcase the power of Corona. This sample game took almost 30 hours to do, including imaging, sound, etc.... More...

Posted by carlos m. icaza, Posted on 13 Dec 2010, Last updated 18 Oct 2011 | 8 comments

16 votes
Ghosts vs. Monsters

A sample game very similar to Angry Birds. It is Ghosts vs. Monsters, done in Corona SDK. Two levels to play with and for you to see how easy it is do do a similar game using the Corona SDK. Sample took less than 36 hours to code, with music and graphics. Special thanks to Jonathan and Biffy Beebe for creating the game exclusively for us and for you to enjoy. Read more about it on our blog. More...

Posted by carlos m. icaza, Posted on 9 Dec 2010, Last updated 18 Oct 2011 | 41 comments

5 votes
SoundTextSync - Read-it-to-me Story Books and interactive text

Inspired by interactive story books for kids, like Broderbund's old Living Book titles from the 1990s. When the narrator reads the text, the words light up or are highlighted as they are spoken. After the narrator finishes reading, you can tap on any word and hear that word spoken. More...

Posted by DavidBFox, Posted on 22 Nov 2010, Last updated 22 Nov 2010 | 29 comments

1 vote
TweakScene

After hours of changing variables and building each time to balance my game. I decided to create a tweakscene. You can use this to change the values of some of your game variables while you play. This allows you to change them, play the game and take notes where they should be for perfect gameplay. More...

Posted by amigoni, Posted on 8 Nov 2010, Last updated 8 Nov 2010 | 0 comments

1 vote
Break Out Game

At a training seminar we setup once, we went through and build a break out game from scratch. Evan Kirchhoff, our sr. engineer put it together and we are uploading it for you to see how easy it is to do a full game in a few lines using Corona. Bricky There are six folders that build up to to the final game play. Carlos More...

Posted by carlos m. icaza, Posted on 15 Oct 2010, Last updated 15 Oct 2010 | 6 comments

2 votes
Samurai Kitchen

We were special guest at the 2009 Adobe Max Russel Brown's Photoshop Pre Conference-Conference and we wrote a game during the session where the attendees could swap in their images for the images in this game. I am uploading the zip file and hopefully it is self explanatory and you can see how easy it is to create games and do animations in just a few lines of code. Samurai Kitchen Carlos More...

Posted by carlos m. icaza, Posted on 15 Oct 2010, Last updated 18 Oct 2011 | 12 comments

1 vote
Corona Game Template by Ziray Studio Labs

The template includes example code for: Display groups Orientation and accelerometer Touch with buttons File reading Example level file for scripting game play The template separates functionality into modules for an object oriented approach. http://www.mikeziray.com/2010/06/27/corona-game-template-in-lua/ If you find the template useful, please consider buying a copy of our current application to support us. It’d... More...

Posted by Eric, Posted on 15 Oct 2010, Last updated 18 Oct 2011 | 1 comments

2 votes
Execution Order - An example to experience non-linear, sequential program flow

1 2 3 4 5 6 7 8 9 10 11 -- An example to experience non-linear, sequential program flow -- as event based, using transition onComplete statements -- and adding, listening for and removing Events -- -- In Corona, you may need to wait for some code to complete, -- in order for your program to flow in a prescribed sequence. -- Code with visuals such as transitions needs to send up a flare -- when its done, done here... More...

Posted by alangrus, Posted on 12 Oct 2010, Last updated 12 Oct 2010 | 0 comments

1 vote
2 Circling Balls - Corona physics example of body:applyForce()

The example uses the physics engine, sets gravity to 0, creates two balls separated in the x-direction, with initial speeds in opposite y-direction. More...

Posted by FrankS, Posted on 25 Sep 2010, Last updated 7 Oct 2010 | 1 comments

2 votes
Track Velocity

This code sample creates a circle that bounces off the edges of the screen. You can touch the circle and throw it around. It tracks velocity. When the user touches the circle and starts moving it, the change in distance over time is captured and given to the circle as it's new speed when the user lets go. More...

Posted by Gilbert, Posted on 3 Aug 2010, Last updated 7 Oct 2010 | 3 comments

4 votes
Another local score framework

A local score framework. More...

Posted by MikeHart, Posted on 15 May 2010, Last updated 7 Oct 2010 | 27 comments

1 vote
Simple local score framework

I wrote a simple and easy to use local high score system for some of my games and I thought I'd share. More...

Posted by Abica, Posted on 2 May 2010, Last updated 7 Oct 2010 | 4 comments