Friday 30 December 2011 1 comments

Time for reflection

Since I started this project back in October there have certainly been some challenges both related to this and those of my day to day life.

However, as I explained in my initial project kick off there is a goal to all this and setting myself a target of at least 3 hours a day for 6 days a week has certainly given me the impetus to ensure this keeps ticking along.

The more I get involved with Corona SDK by Ansca the more I feel I have made the right decision. Of course I would say that but the more I dig, the support of the community and the 3rd party applications has made this a voyage of discovery.

What I haven't mentioned to date is that I am a reasonably experienced developer having spent some 15 years within the IT industry but probably the last 8 or so have been in management so getting back to my first love of coding and being creative while solving problems is my expertise and this has certainly set me up well on this project.

Reading the game design book The Art of Game Design: A book of lenses was again a better decision than I knew at the time. This taught me to be iterative and thoughtful and not get carried away by shiny new toys as well as consider my audience / customers. That coupled with my over ambition to achieve the next AAA game or Angry Birds rival on first attempt has seen me move from game idea to a simpler game idea a few times to one I am happy to proceed with.

The real proof of this came when I handed my wife the first alpha release of my game (copious amounts of bugs) of which she continually played it over and over for some 20 minutes. The feeling of satisfaction to not only get to grips with the Corona SDK to actually produce something that worked but so a completed non gamer (casual gamer if you like) and interact in how you intended with little instructions is the motivator for the next 200 hours, 1000 hours, hell why not the whole 10000.

The turning point was certainly this week. I was struggling. I had spent an inordinate amount of time getting pretty much no where. I had been using the Corona SDK trial version which is some builds behind the indie license and of course the daily builds. I upgraded to the stable paid version and this was when the light bulb moment happened.

I had been struggling with device performance issues. Like the XCode simulator the Corona one doesn't bottleneck performance relative to a device but instead is happy to consume most of my Mac Book Pro's power to make me think all was well. Compiling to the device pretty much rendered it useless.

I had been using the Director Class by Ricardo Rauber to control scenes while within the trial and while excellent Ansca had released their own supported version called Storyboard. Once I had paid for the indie license the layout of Storyboard just seemed to open my eyes up to how it should all hang together. As a result I have completed rewritten my game with 48 hours, achieving 55 to 60 fps and half way to integrating open feint into the game.

I also found an excellent tool called Physics Editor by Code 'n' Web which has greatly improved my collision detection mapping. A tool that only costs $20, allows you to import your images and then hit auto trace. Output to Corona and you have the physics data you need to provide accurate collision mapping. This alone has saved me hours but given a far greater polish to the experience.

So in summary feeling pretty confident about getting the game out into the app store and android market and the benefit that Corona SDK gives me is that I can target iPad, iPhone, iPod, Android devices, Nook and Amazon Fire with very little to worry about. Also with a greatly improved advertising network which on first sight looks far better than iAd (click rates to be verified) a multi device app should be available early 2012.

And this is good as it brings me back on schedule for releasing 3 games within the first year as part of my project.

It should be a happy new year and I wish you the same
Monday 19 December 2011 0 comments

Catmull Splines: Object follows path

Following on from my introductory blog on catmull splines I have applied and worked on an example simplifying the excellent Flight Path sample template which can be found here for the Corona SDK framework.

What I was trying to do is understand the equation I put forward an started making it a little more useful to mine (and hopefully your needs)

Right lets look at some code. Only two files here and have tried commenting as much as possible

main.lua
-- This line makes the physics engine features available under the “physics” namespace
require( "physics" )
-- A further file to create a smooth curve when drawing
require( "smoothCurve")

-- ither instantiates or resumes the world. IMPORTANT: it must be called before any of the other functions in this section.
physics.start()
-- ets the x,y components of the global gravity vector, in units of m/s2. The default is ( 0, 9.8 ) to simulate standard
-- Earth gravity, pointing downwards on the y-axis.
physics.setGravity(0,0) 

-- Creates a group in which you can add and remove child display objects. Initially, there are no children in a group. 
-- The local origin is at the parent’s origin; the reference point is initialized to this local origin
local mainGroup = display.newGroup()
local lineGroup = display.newGroup()  mainGroup:insert(lineGroup)
local objectGroup = display.newGroup()  mainGroup:insert(objectGroup)

-- Calculation interval of drawing between the dotted lines
local lineDrawInterval = 50

-- Method called when our object (blue box) is touched
function onObjectTouched(self, event)
--[[
  Touch events are a special kind of hit event. When a user's finger touches the screen, they are starting a sequence of touch events, each with different phases.

  event.name is the string "touch".
  event.x is the x-position in screen coordinates of the touch.
  event.y is the y-position in screen coordinates of the touch.
  event.xStart is the x-position of the touch from the "began" phase of the touch sequence.
  event.yStart is the y-position of the touch from the "began" phase of the touch sequence.
  event.phase is a string identifying where in the touch sequence the event occurred:
   "began" a finger touched the screen.
   "moved" a finger moved on the screen.
   "ended" a finger was lifted from the screen.
   "cancelled" the system cancelled tracking of the touch.

]]
 if(event.phase == "began") then
  -- Determine whether we are to draw a line
  self.allowLineDraw = true
  -- Determine the stype of line output
  self.lineType = "dotted"
  -- Instantiate our table to hold the points
  self.points = {}
  -- Insert our initial touch
  table.insert(self.points, {x = event.x, y = event.y})
  -- Returns a reference to the current stage object, which is the root group for all display objects and groups. 
  -- Currently, Corona has a single stage instance, so this function always returns a reference to the same object
  display.getCurrentStage():setFocus( self )
  -- Set the focus to our object (box)
  self.isFocus = true
 elseif (event.phase == "moved" and self.isFocus == true) then
  -- Make a check to see we have at least one point
  if(#self.points == 0) then
   -- Instantiate our table to hold the points
   self.points = {}
   -- Insert our current position
   table.insert(self.points, {x = self.x, y = self.y})
   table.insert(self.points, {x = event.x, y = event.y})
  end
  -- Determine the distance between our points
  -- math.sqrt: Returns the square root of a value.
  -- math.pow: Returns the result of raising a number to the power of another number.
  local distance = math.sqrt(math.pow(self.points[#self.points].x - event.x, 2) + math.pow(self.points[#self.points].y - event.y, 2))
  -- Insert our current position
  table.insert(self.points, {x = event.x, y = event.y})
  -- If we have set our object to draw a line first check
  if(self.allowLineDraw == true) then 
   -- Draw the line
   drawLine(self) 
   -- Now get our object to follow it 
   followPoints(self)   
   -- Since we have followed it and moved over our control point, remove the lone
   self.allowLineDraw = false
   -- Dependent on our line draw interval recall our method 
   timer.performWithDelay(lineDrawInterval, function(new) self.allowLineDraw = true end)
  end
 elseif(event.phase == "ended") then
  -- Now that we have lifted our touch determined the distance
  local distance = math.sqrt(math.pow(self.points[#self.points].x - event.x, 2) + math.pow(self.points[#self.points].y - event.y, 2))
  -- Returns a reference to the current stage object, which is the root group for all display objects and groups. 
  -- Currently, Corona has a single stage instance, so this function always returns a reference to the same object
  display.getCurrentStage():setFocus(nil)
  -- Remove the focus from our object now
  self.isFocus = false
  -- Follow to the end point
  followPoints(self)  
  -- Show on the stage the line to be solid
  self.lineType = "solid"
  -- Draw it solid rather than dotted
  drawLine(self)
 end
end

function drawLine(box)
 -- Do we have a line already
 if(box.lineGroup ~= nil) then
  -- Make sure we destory anything in memory 
  box.lineGroup:removeSelf()
  box.lineGroup = nil 
 end
 -- Retrieve our point (see other description) i.e. our catmull spline
 local smoothPoints = smoothCurve.getSmoothCurvePoints(box.points)
 -- If we don't have any points then exit now 
 if(smoothPoints == nil) then return end
 
 -- Lets create a new linegroup display object for our box 
 box.lineGroup = display.newGroup()
 --insert this into our linegroup display object on our stage 
 lineGroup:insert(box.lineGroup)

 -- Return modulus dependent on line type
 local modNumber = box.lineType == "dotted" and 2 or 1
 
 -- Iterate through our points
 for i = 0 ,#smoothPoints do
  if(i % modNumber == 0 and smoothPoints[i] ~= nil and smoothPoints[i + 1] ~= nil) then 
   local line = display.newLine(smoothPoints[i].x, smoothPoints[i].y, smoothPoints[i + 1].x, smoothPoints[i + 1].y)
   
   -- Determine line width dependent on modulus
   line.width = modNumber == 1 and 1 or 3
   -- Insert the line into our display object
   box.lineGroup:insert(line)
  end
 end
 -- Return the points now we have them all
 return smoothPoints
 
end 

function followPoints(box)
 -- Check to see if we have any points if not exit
 if(box.points == nil or #box.points == 0) then 
  return 
 end
 -- Get our point to follow
 point = box.points[1]
 -- Get the angle for our box to move
 local angle = math.atan2((box.y - point.y) , (box.x - point.x) ) * (180 / math.pi)
 -- Detemine the x and y velocity to move our object
 local velocityX = math.cos(math.rad(angle)) * 50 * -1
  local velocityY = math.sin(math.rad(angle)) * 50 * -1
 -- Now set the object (box) velocity
 box:setLinearVelocity( velocityX, velocityY)
 -- Initialise our method
 local enterFrameFunction = nil
 local checkForNextPoint
 checkForNextPoint = function(box)
  -- Do we have an object (box)
  if(box ~= nil) then
   -- Get our destination
   local dest = box.dest
   -- Return the velocity we have just set
   local velX, velY = box:getLinearVelocity()
   -- Cbeck a load of stuff
   if( (velX < 0 and box.x < dest.x and velY < 0 and box.y < dest.y) or  (velX > 0 and box.x > dest.x and velY < 0 and box.y < dest.y) or
    (velX > 0 and box.x > dest.x and velY > 0 and box.y > dest.y) or  (velX < 0 and box.x < dest.x and velY > 0 and box.y > dest.y) or #box.points == 0) then
    -- Remove our event listener
    Runtime:removeEventListener("enterFrame", enterFrameFunction)
    -- Remove the point as we have just got to it so not to keep drawing the same one over and over
    table.remove(box.points, 1)
    -- Now draw it
    drawLine(box)
    -- If we have at least another point left then repeat all this again
    if(#box.points > 0) then
     followPoints(box)
    else
     -- If we don't then stop the object (box) waiting for another touch
     box:setLinearVelocity( 0, 0)
    end

   end  
  else
   -- Nothing to do so remove our listener
   Runtime:removeEventListener("enterFrame", enterFrameFunction)
  end
 end
 
 -- Set the box destination to the current point
 box.dest = point
 -- Lets do it all again
 enterFrameFunction = function(event) checkForNextPoint(box) end
 -- Add another listener
 Runtime:addEventListener("enterFrame", enterFrameFunction)

end

-- Lets create our object which is a blue box
local box = display.newImage( "bluesquare.jpeg")
-- Position it roughly top left corner
box.x = 50
box.y = 50
-- Sets its calling method for when the object (box) is touched
box.touch = onObjectTouched
-- Add a listener so it will do something
box:addEventListener("touch", box)
-- Apply physics so that velocity etc will have some effect
physics.addBody(box, "dynamic",  {density = 100, isSensor = true, radius = 40})
-- Now add our local box to the main object display group
objectGroup:insert(box)

and the all important catmull splines magic

smoothCurve.lua
--[[
Creates a module. If there is a table in package.loaded[name], this table is the module. 
Otherwise, if there is a global table t with the given name, this table is the module. 
Otherwise creates a new table t and sets it as the value of the global name and the value of package.loaded[name]. 
This function also initializes t._NAME with the given name, t._M with the module (t itself), 
and t._PACKAGE with the package name (the full module name minus last component; see below). 
Finally, module sets t as the new environment of the current function and the new value of package.loaded[name], so that require returns t.

This function may receive optional options after the module name, where each option is a function to be applied over the module.
]]
module(..., package.seeall)

function getSmoothCurvePoints(points)

 -- Number of points must be at least 3 to calculate the catmull spline
 if(#points < 3) then return nil end
 -- Create our table to hold our points
 local smoothPoints = {}
    -- Steps Per Segment - The Higher The Number - The Smoother The Curve - The Longer It Takes To Calculate
    local curveSteps = 30
    -- First Segment (Remember the complication control points in the introduction blog)
    local firstSegement = drawCatmullSpline( points[1] , points[1] , points[2] , points[3] , curveSteps )
    -- Increment through control points and add it to our table
    for i = 1 , #firstSegement , 1 do
   table.insert(smoothPoints, {x = firstSegement[i].x, y = firstSegement[i].y})
    end
    -- Now increment through our segments inbetween
    for i = 2 , #points - 2 , 1 do
            local middleSegment = drawCatmullSpline( points[i-1] , points[i] , points[i+1] , points[i+2] , curveSteps )
            for i = 2 , #middleSegment , 1 do
               --Add our smoothpoints between our control points
      table.insert(smoothPoints, {x = middleSegment[i].x, y = middleSegment[i].y})
            end
    end
    
    -- Just to finish it all off apply our last segment
    local lastSegment = drawCatmullSpline( points[#points-2] , points[#points-1] , points[#points] , points[#points] , curveSteps )
    for i = 2 , #lastSegment , 1 do
   table.insert(smoothPoints, {x = lastSegment[i].x, y = lastSegment[i].y})
    end
 -- Now return our nice smooty curve
 return smoothPoints
end

function drawCatmullSpline( p0 , p1 , p2 , p3 , steps )
  -- Lets create a table for our points
    local points = {}
 
    for t = 0 , 1 , 1 / steps do
   -- Remember that complicated catmull spline equation in my blog.  Here we use it to work with our control points supplied
            local xPoint = 0.5 * ( ( 2 * p1.x ) + ( p2.x - p0.x ) * t + ( 2 * p0.x - 5 * p1.x + 4 * p2.x - p3.x ) * t * t + ( 3 * p1.x - p0.x - 3 * p2.x + p3.x ) * t * t * t )
            local yPoint = 0.5 * ( ( 2 * p1.y ) + ( p2.y - p0.y ) * t + ( 2 * p0.y - 5 * p1.y + 4 * p2.y - p3.y ) * t * t + ( 3 * p1.y - p0.y - 3 * p2.y + p3.y ) * t * t * t )
            
   -- Now insert these into the our table
            table.insert( points , { x = xPoint , y = yPoint } )
    end
    -- Finished with them all then return our points table
    return points
 
end
Right now we are cooking on gas what is this going to give us. Well here are a series of screenshots to give you a taster but why not give it a go to see what happens.

Now I have an object following a path what I want to implement is a chase and evade AI element to it. I'll post just as soon as I have worked it out.

Stay tuned ...
0 comments

Catmull Splines: An introduction

Those that had followed my project to date have known I have covered a few topics and provided commentary most notably on game design.

Having spent about three weeks on my first game concept I realised I had bitten off a little more than I could chew given my novice status in game design and development. That said which ever route I took there is a physics concept or mathematical gymnastics to perform and there was no getting away from it I was going to have to learn some stuff.

As you may also know I am currently working with the Corona SDK development framework and started looking at the excellent Flight Path sample template which can be viewed here. What I intend to do is write a mini series to document my learnings as well as hope this helps someone else in the future.

For those of you who aren't familiar with the concept of catmull splines (and don't worry I wasn't 72 hours ago), they can be described as splines which are a mathematical means of representing a curve, by specifying a series of points at intervals along the curve and defining a function that allows additional points within an interval to be calculated. There are various functions available to approximate a curve, but in this blog we will focus on a spline known as the catmull spline.

The points that define a spline are known as Control Points. One of the features of the catmull spline is that the specified curve will pass through all of the control points - this is not true of all types of splines.

To calculate a point on the curve, two points on either side of the desired point are required, as shown on the left. The point is specified by a value t that signifies the portion of the distance between the two nearest control points.

Given the control points P0, P1, P2, and P3, and the value t, the location of the point can be calculated as (assuming uniform spacing of control points):

q(t) = 0.5 *( (2 * P1) +
(-P0 + P2) * t +
(2*P0 - 5*P1 + 4*P2 - P3) * t2 +
(-P0 + 3*P1- 3*P2 + P3) * t3)

Ermmmm, don't know about you but this is gibberish to me!

While a spline segment is defined using four control points, a spline may have any number of additional control points. This results in a continuous chain of segments, each defined by the two control points that form the endpoints of the segments, plus an additional control point on either side of the endpoints. Thus for a given segment with endpoints Pn and Pn+1, the segment would be calculated using [Pn-1, Pn, Pn+1, Pn+2].

Because a segment requires control points to the outside of the segment endpoints, the segments at the extreme ends of the spline cannot be calculated. Thus, for a spline with control points 1 through N, the minimum segment that can be formulated is P1<->P2, and the maximum segment is PN-3<->PN-2. Thus, to define S segments, S+3 control points are required.

Now what does that all mean to us Corona SDK developers using lua. Well, again, if you have followed my blogs you would know I have hailed the efforts of Matthew Pringle and his Corona Remote app to aid rapid testing. Those who have used it know of the plotting of accelerometer points. Matthew very kindly posted some code on the ansca website which helps put the gibberish above into context. The code is as follows:

display.setStatusBar( display.HiddenStatusBar )
 
-- New Points Table
points = {}
 
-- New Line
local line
 
-- Add Points - Generated Randomly To Draw Jagged Line Across Screen
for i = 1, 11 , 1 do
        
        local xPoint = ( display.contentWidth / 10 ) * i - ( display.contentWidth / 10 )
        local yPoint = math.random( 50 , 250 )
        
        table.insert( points , 1 , { x = xPoint , y = yPoint } )
 
end
 
-- Draw Jagged Line
if ( #points > 2 ) then
        
        line = display.newLine( points[1].x , points[1].y , points[2].x , points[2].y )
        
        for i = 3 , #points , 1 do
        
                line:append( points[i].x , points[i].y )
        
        end 
                        
        line:setColor( 155 , 155 , 155 )
        line.width = 2
 
end
 
-- Catmull Spline Function
function drawCatmullSpline( p0 , p1 , p2 , p3 , steps )
 
        local points = {}
 
        for t = 0 , 1 , 1 / steps do
 
                local xPoint = 0.5 * ( ( 2 * p1.x ) + ( p2.x - p0.x ) * t + ( 2 * p0.x - 5 * p1.x + 4 * p2.x - p3.x ) * t * t + ( 3 * p1.x - p0.x - 3 * p2.x + p3.x ) * t * t * t )
                local yPoint = 0.5 * ( ( 2 * p1.y ) + ( p2.y - p0.y ) * t + ( 2 * p0.y - 5 * p1.y + 4 * p2.y - p3.y ) * t * t + ( 3 * p1.y - p0.y - 3 * p2.y + p3.y ) * t * t * t )
                
                table.insert( points , { x = xPoint , y = yPoint } )
                
                local dot = display.newCircle( xPoint , yPoint , 2 )
                dot:setFillColor( 255 , 0 , 0 )
 
        end
        
        return points
 
end
 
-- Draw Curve Using Catmull Spline Function
if ( #points > 2 ) then
 
        -- Steps Per Segment - The Higher The Number - The Smoother The Curve - The Longer It Takes To Calculate
        local curveSteps = 5
        
        -- First Segment
        local firstSegement = drawCatmullSpline( points[1] , points[1] , points[2] , points[3] , curveSteps )
        
        -- Draw First Segment
        local curve = display.newLine( firstSegement[1].x , firstSegement[1].y , firstSegement[2].x , firstSegement[2].y )
        for i = 3 , #firstSegement , 1 do
                curve:append( firstSegement[i].x , firstSegement[i].y )
        end
        
        -- Segments Inbetween
        for i = 2 , #points - 2 , 1 do
        
                local middleSegment = drawCatmullSpline( points[i-1] , points[i] , points[i+1] , points[i+2] , curveSteps )
                for i = 2 , #middleSegment , 1 do
                        curve:append( middleSegment[i].x , middleSegment[i].y )
                end
        
        end
        
        -- Last Segment
        local lastSegment = drawCatmullSpline( points[#points-2] , points[#points-1] , points[#points] , points[#points] , curveSteps )
        for i = 2 , #lastSegment , 1 do
                curve:append( lastSegment[i].x , lastSegment[i].y )
        end
        
        curve:setColor( 0 , 0 , 255 )
        curve.width = 2
 
end

The results of which put the equation above into something a little more tangible:


Wow that was a lot to take in but hopefully putting it all in one place has helped a little. As I mentioned I am a newbie on this so if anyone reading this thinks what the hell is he talking about this is completely wrong I am more than happy to be corrected just leave a comment.

The next in the series I will look into something more akin to a game and applying the Corona SDK template for novices. Stay tuned ...
Saturday 3 December 2011 0 comments

Game Design: Mockups

I have a little bit of artistic skill but not one that I have ever really been able to transfer to the computer, very much a pencil and paint man. I have a notebook that I put all my ideas into when I have a spark of inspiration and once I have dealt with the kids or finished my day job I can refer to.

All this is great but what I have been looking for is something that I can chuck a few transitions onto, or maybe the menu layer or the supporting website.

A tool which I have been using a lot recently is Balsamiq's mockup for wireframing some ideas. Now there are probably hundreds of tools like this but I really like the quirky wireframe designs and the inclusion of iphone templates.

What Balsamiq say about mockups:

"Mockups is zenware, meaning that it will help you get “in the zone”, and stay there. Our aim is for you to forget our software is there at all.

Mockups offers the same speed and rough feel as sketching with a pencil, but with the advantage of the digital medium: enlarging containers is just a drag operation, rearranging elements doesn’t require starting over, and your wireframes will be clear enough that you’ll be able to make sense of them tomorrow.

Mockups should make work fun."


Mockups can be bought for $79.

Saturday 26 November 2011 0 comments

Corona SDK development on a PC

If you had read my post on Mac development tools you will probably have a good idea of a way forward. For instance I went for TextMate with a really handy Corona Bundle to allow auto complete within the editor on my Mac.

I, like a lot of people, mix between Mac and PC. I have only been using a Mac for about two years and the rest of my career has been very much PC based. This is one of the beauties of Corona in that it can be installed and worked on on both devices. I tend to store my files on DropBox and switch between my machines therefore my work in progress is always to hand.

Unfortunately, TextMate isn't available for PC so instead I use Notepad++ and a very handy plugin which gives predictive autocomplete.

To setup the plugin obviously first install Notepad++ and download the plugin. Then just drop the file into: YOUR_NPP_DIR\plugins\APIs folder. If you haven't enabled auto complete in notepad, you can set those options in Settings>Preferences>Backup/Auto-Completion. Also make sure you have checked: Enable Auto-Completion on each input, function completion, and Function parameters hint on input. I had to restart Notepad++ for the changes to take effect.

However, once done you have a very handy and FREE Lua editor with Corona references.

Monday 21 November 2011 0 comments

The project - 100 hours completed

The first of my mini milestones has been achieved and that is hitting the 100 hour mark.

May not seem like much but my goal has been to mentally set mini goals to ensure I stick with it.

The first 100 hours have been tough. I probably haven't made it easy of myself but I started this project just a week after the birth of my second son so juggling this with a newborn has been tough. But of course that is also the motivation.

Those fragmented nights and early mornings have also been to the advantage of the project and being awake for some 20 hours in a day certainly helps. So much so that of my 936 hour target for the first year I am already about 20% ahead of schedule which is mostly due to working on it most days. Again little and often.

So what I have achieved in this first 100 hours:
  • Prototyped against GameSalad
  • Prototyped against Cocoa
  • Prototyped against Corona SDK
  • Chose to go with Corona
  • Worked my way through game design theories in The Art of Game Design: A book of lenses by Jesse Snell
  • Started working with Lua and Corona and found it very alien. Distinctly disliked the lack of integration in an IDE and to devices that XCode provides, for example. However, a couple of tools such as Corona Remote by Matthew Pringle as well as TextMate with the Corona plugin has made it a little more comforting
  • Started my first attempts at physic and game engine logic with some success but looking pretty ugly
  • Working on three game concepts and designs
  • Writing blog entires (1000 page view in first month)
  • Tweets (25 followers)

Phew!!! On paper, or blog, that looks quite impressive and after all that is the point of keeping a blog while on this journey to keep motivation and in the hard times see just how far I have come.

So on reflection things are going pretty well. I am ahead of schedule in terms of hours applied a day despite the new born baby and long working weeks in my 'day' job.

The focus over the coming hours, days and weeks is to apply the iterative prototyping approach that the lenses book recommended to the point I am comfortable with the tools, programming language and game concepts.
Thursday 17 November 2011 0 comments

Corona SDK Device Testing Tips

Having spent a couple of days working with Corona SDK my first challenge with it was how cumbersome it was to compile to a device. I admit at this point I am only on the free version but the concept of remote builds has never sat well with me, what happens if my internet connection goes down?

That aside, because I could pay to upgrade and get faster builds, the one thing which was proving a bind was the way to get the app onto the device to test. The steps to do this are:
  • Change to device build in the Corona Simulator
  • Wait for remote build to connect and build your solution and create compiled app
  • Connect device to machine
  • Open Organiser and drag app file to device and into Applications folder
  • Test
This becomes very laborious when its simple things you want to test regularly such as accelerometer and physics development.

Because I have done some work with XCode in the past I had become very used to plugging in my device and it all compiling nicely to device without any manual steps. I feared for my long turn future with Corona SDK if this was the development / testing cycle.

Thankfully tonight I came across a little gem. That little gem is Corona Remote by Matthew Pringle, an incredibly handy remote accelerometer app.

The premiss is that because the Corona simulator can't simulate the accelerometers data the app will do this for you by moving the device around as normal. The coronaremote app connects via your WIFI connection to your working machine's ip address and an open port of 8080 (check you firewall is open). All you then have to do is include the remote.lua file within your folder and add the following code within your app:

-- Load The Remote
local remote = require("remote")

-- Start The Remote On Port 8080
remote.startServer( "8080" )

-- Start The Compass ( if you want to use it )
remote.startCompass()

-- Get The Latest Accelerometer Values
local function updateAccelerometer()

    -- This Runtime Listener Is An Example Of How To
    -- Access The Remote You Can Query remote.xGravity
    -- Or Any Other Value From Anywhere In Your Application

    local xGravity = remote.xGravity
    local yGravity = remote.yGravity
    local zGravity = remote.zGravity
    local xInstant = remote.xInstant
    local yInstant = remote.yInstant
    local zInstant = remote.zInstant
    local isShake = remote.isShake
    -- Only Use If Compass Activated And Running v1.1 Or Later
    local magnetic = remote.magnetic

    -- Print xGravity To Terminal
    print( remote.xGravity )

end

-- Add Enter Frame Listener
Runtime:addEventListener( "enterFrame" , updateAccelerometer )

With a valid connection the simulator picks up the accelerometer data and reacts and simulates to your devices movements, magic!!

The app can be downloaded via App Store and worth every penny.
Sunday 13 November 2011 0 comments

Essential Mac apps for Corona development

Saw an excellent forum entry on Corona about apps to aid development. These are consolidated as:

Corona Project Manager - $74.99
Corona Project Manager is for anyone who develops mobile apps using Corona® SDK. Drag in a project folder, click Launch, and it's up and running in the simulator. It manages all the projects and assets (source code files, graphics, audio files, etc.) that go into your app so you can quickly switch from one to another, swap out assets, and just generally have a smoother workflow.

TextMate - $55
TextMate is my favorite text editor! BBEdit is good too, just a little pricey

Corona SDK bundle for TextMate - FREE
This TextMate bundle was recently released and makes development SO much quicker!

Pixelmator - $59
A great image editing alternative to Photoshop, with lots of filters, layer support, web export, and much more!

Sketch - $40
A vector drawing alternative to Adobe Illustrator. This developer (Pieter Omvlee) is awesome! He released a new version today 1.0.5 which had a few reported bugs. He released 1.0.6 within an hour that fixed them all!!! That's what I call amazing support! I highly recommend this app to anyone developing graphics, icons, splash screens, etc for apps - especially games. Most, if not all, of these apps have free trials.

Zwoptex - $24.95
Sprite sheet creator. This developer has been working very hard to make the app compatible with Corona Game Edition.

filewrangler - $15
This app is very helpful for renaming batches of files - which you'll be doing often if you create a Corona app with dynamic image resolution.

ImageOptim - FREE
This is a nice image compressor - works well on PNGs if you disable OptiPNG and AdvPNG. You can also use jonbeebe's "posterize" trick in Pixelmator or Photoshop.

iShowU HD - $29.95
iShowU HD is a very slick screencast app that can be used for making demo reels for your app or game.

ColorSchemer Studio 2 - $49.99
A nice app to build color combinations with a lot of tools to compare, compliment, and contrast colors. They even have a community driven color scheme gallery to download free color schemes into the app.

WireTap Studio - $69
Not the cheapest or the best audio editor but this one lets you select any input (even specific application audio) on your Mac to record audio. It also has a basic built-in editor.

gedit - FREE
A text editor

Daz Studio - $230+
Easy way to download 3D artwork and render it as 2D images for apps

Are there any others that you are using in your game development?
0 comments

Game Design - A Better Understanding

I've made a conscious effort to put the hours into the project the last few days. If you read my first post on the subject of game design, Game Design - a structured start, you would know I was working my through the The Art of Game Design: A book of lenses by Jesse Schell. What an eye opener!! Going into this project I didn't appreciate the complexities involved in game design and what I would need to consider. Having made it out the other side I am more inspired and focused than I was when I started the book.

For you reference here are the remaining topics / lenses that the book covered:
  • Lens #34: The Lens of Skill vs. Chance
  • Lens #35: The Lens if Head and Hands
  • Lens #36: The Lens of Competition
  • Lens #37: The Lens of Cooperation
  • Lens #38: The Lens of Competition vs. Cooperation
  • Lens #39: The Lens of Time
  • Lens #40: The Lens of Reward
  • Lens #41: The Lens of Punishment
  • Lens #42: The Lens of Simplicity/Complexity
  • Lens #43: The Lens of Elegance
  • Lens #44: The Lens of Character
  • Lens #45: The Lens of Imagination
  • Lens #46: The Lens of Economy
  • Lens #47: The Lens of Balance
  • Lens #48: The Lens of Accessibility
  • Lens #49: The Lens of Visible Progress
  • Lens #50: The Lens of Parallelism
  • Lens #51: The Lens of the Pyramid
  • Lens #52: The Lens of the Puzzle
  • Lens #53: The Lens of Control
  • Lens #54: The Lens of Physical Interface
  • Lens #55: The Lens of Virtual Interface
  • Lens #56: The Lens of Transparency
  • Lens #57: The Lens of Feedback
  • Lens #58: The Lens of Juiciness
  • Lens #59: The Lens of Channels and Dimensions
  • Lens #60: The Lens of Modes
  • Lens #61: The Lens of the Interest Curve
  • Lens #62: The Lens of Inherent Interest
  • Lens #63: The Lens of Beauty
  • Lens #64: The Lens of Projection
  • Lens #65: The Lens of the Story Machine
  • Lens #66: The Lens of the Obstacle
  • Lens #67: The Lens of Simplicity and Transcendence
  • Lens #68: The Lens of the Hero’s Journey
  • Lens #69: The Lens of the Weirdest Thing
  • Lens #70: The Lens of Story
  • Lens #71: The Lens of Freedom
  • Lens #72: The Lens of Indirect Control
  • Lens #73: The Lens of Collusion
  • Lens #74: The Lens of the World
  • Lens #75: The Lens of the Avatar
  • Lens #76: The Lens of Character Function
  • Lens #77: The Lens of Character Traits
  • Lens #78: The Lens of the Interpersonal Circumplex
  • Lens #79: The Lens of the Character Web
  • Lens #80: The Lens of Status
  • Lens #81: The Lens of Character Transformation
  • Lens #82: The Lens of Inner Contradiction
  • Lens #83: The Lens of The Nameless Quality
  • Lens #84: The Lens of Friendship
  • Lens #85: The Lens of Expression
  • Lens #86: The Lens of Community
  • Lens #87: The Lens of Griefing
  • Lens #88: The Lens of Love
  • Lens #89: The Lens of the Team
  • Lens #90:The Lens of Documentation
  • Lens #91: The Lens of Playtesting
  • Lens #92: The Lens of Technology
  • Lens #93:The Lens of the Crystal Ball
  • Lens #94: The Lens of the Client
  • Lens #95:The Lens of the Pitch
  • Lens #96:The Lens of Profit
  • Lens #97: The Lens of Transformation
  • Lens #98: The Lens of Responsibility
  • Lens #99: The Lens of the Raven
  • Lens #100: The Lens of Your Secret Purpose
This book has given me a real dip into a lot of areas that I may never had considered. That said it doesn't specifically tell you what you need to know but more question what you have done. Its not a book of ideas, you need to bring those but what it should do is cement those into something better.

Again, if you recall from the previous blog I mentioned I was to create a check list document to aid me and funny enough one of the topics of this book was that there isn't such a thing as a master document. My intention is to evolve my design document over the next couple of weeks and months as I start developing and prototyping. As the book drums home a lot the art of design and game development is one of the loop of iteration to ensure that issues or challenges are ironed out or overcome in small manageable packages.

Onwards and upawards!
Sunday 6 November 2011 1 comments

Corona SDK: Advantages and Disadvantages

Found a very good discussion on the advantages and disadvantages to the Corona SDK on Quora. Worth a read as there are some good external links on it also with further insight.

http://www.quora.com/iOS/What-are-the-drawbacks-of-the-Corona-SDK

Still think I have made the right decision.

Saturday 5 November 2011 0 comments

Game Design - A structured start

The lack of blogging this week has been due to child illness but mainly due to the fact I am a very slow reader!

The focus of my attention during this week has been to give myself a good grounding in the principles of game design rather than diving head first in to a few ideas that I have. Tempting as it is to just do this I feel I will be no better equipped than i have been in the past to succeed and stick with it without structure.

This very structure is what drew me to the book I am working my way through and that is the The Art of Game Design: A book of lenses by Jesse Schell.

I'll be honest, when I started this project I thought I had a lot of good ideas and that I just needed time to fulfill them. However, from having started to make my way through this book I realise just how involved game design is and those that succeed aren't purely luck.

What I have like about this book is the way that it is structured. As the title suggests its a book of lenses. What this mean is that using any of the lenses proposed in the book to view your idea and question its depths and values. Not all lenses are applicable, necessarily, to your game design but it can at least provide a check list to ensure you have considered most things.

Topics covered to date are subjects such as balance, rewards, demographics, cultures to name a few. To be more specific these are the lenses which I have read through so far within the book:
  • Lens #1: The Lens of Essential Experience
  • Lens #2: The Lens of Surprise
  • Lens #3: The Lens of Fun
  • Lens #4: The Lens of Curiosity
  • Lens #5: The Lens of Endogenous Value
  • Lens #6: The Lens of Problem Solving
  • Lens #7: The Lens of the Elemental Tetrad
  • Lens #8: The Lens of Holographic Design
  • Lens #9: The Lens of Unification
  • Lens #10: The Lens of Resonance
  • Lens #11:The Lens of Infinite Inspiration
  • Lens #12:The Lens of the Problem Statement
  • Lens #13:The Lens of the Eight Filters
  • Lens #14: The Lens of Risk Mitigation
  • Lens #15: The Lens of the Toy
  • Lens #16: The Lens of the Player
  • Lens #17: The Lens of Pleasure
  • Lens #18: The Lens of Flow
  • Lens #19: The Lens of Needs
  • Lens #20: The Lens of Judgment
  • Lens #21: The Lens of Functional Space
  • Lens #22: The Lens of Dynamic State
  • Lens #23: The Lens of Emergence
  • Lens #24: The Lens of Action
  • Lens #25: The Lens of Goals
  • Lens #26: The Lens of Rules
  • Lens #27: The Lens of Skill
  • Lens #28: The Lens of Expected Value
  • Lens #29: The Lens of Chance
  • Lens #30: Lens of Fairness
  • Lens #31: Lens of Challenge
  • Lens #32: Lens of Meaningful Choices
  • Lens #33: Lens of Triangularity
There are some 100 lenses so I have a while to go. I probably see this being the focus of my attention for the next couple of weeks as i'm not sure if you are like me but I dont retain information. For that reason once I have finished reading the book I plan to build a structured checklist document to use against all my future games on this project to ensure I have considered everything.
Saturday 29 October 2011 0 comments

Professional Advice: Matt Rix


Following in my series of seeking advice from those in the industry who have achieved success, Matt Rix of Trainyard fame has taken some time out to answer some questions.

Trainyard is an innovative and challenging puzzle mechanic with a smooth difficulty curve. There are a 100 main puzzles and 50 hard bonus puzzles with hundreds of ways to solve each puzzle.

The game has been engineered for low battery usage, developed with a color-blind mode. Includes full retina support and high-res graphics on iPad.

There are parallels with my project in that it took a year to make and was independently developed by Matt himself.

MyGamingProject: What do you foresee being my single biggest challenge?

Matt Rix: "Your biggest challenge is going to be sticking to it and staying motivated. It's easy to be motivated at the start of a project when everything is new and exciting, but later on, when you're dealing with painful bugs and doing marketing and all that, it'll be much harder."

MyGamingProject: What would you have done differently knowing what you know today?

Matt Rix: "I don't really have too many regrets. One thing I would say is "don't promise anything". It's fine for you to have goals and stick to them, but don't promise something to the world at large, or else there will be an even larger cost for switching plans."

MyGamingProject: What game development tools would you recommend?

Matt Rix: "It really depends on what your experience is, and what you want to do. If you're developing iOS games, Cocos2D is fantastic, and so is Unity. When it comes to art, I make most of my assets in Flash, but everyone has their own preferences for that. . A lot of people get caught up in using the "right" tools or methods, but at the end of the day, there are lots of different ways of doing everything, and they will all work. The hard part, as I said earlier, is actually sticking to it. If you do a few hours of work every day, no matter which tools you're using, you will finish your project."

MyGamingProject: How would you recommend marketing a game, techniques, channels, proposed budget etc?

Matt Rix: "This is a tough one. It's worth looking around to get a sense for other people's experiences with marketing, but really, the same thing rarely works twice. The key is to create a compelling marketing story. You need a reason for people to write about your game. It's also really important that your game has "moments of delight". These are the elements that make them say "wow", and these are the elements that make them share your game with their friends."

MyGamingProject: Any additional advice you feel would be of benefit
Matt Rix: "I honestly think that if you actually put this many hours into this, you will end up being successful. As cheesy as it sounds, if you don't give up, you can't fail."

Get Trainyard from iTunes for $0.99/£0.69.
Monday 24 October 2011 0 comments

Professional Advice: Zeptolab


I thought it beneficial to get some advice from those in the know. I have contacted a number of well known gaming companies to provide some tips as to what I should consider on my project.

The first to help in this series is Zeptolab.

For those of you who don't know Zeptolab created the highly successful Cut the rope and Cut the rope experiments.

They very kindly spared me some time after I explained my project and what it was I was trying to achieve.

Their first suggestion was to focus on quality. If you haven't read my entry on my chosen game environment this is why I want to focus on the game design and development rather than focusing on learning a programming language.

The second tip was not one that I had considered and that was to launch my title with an experienced and well-known publisher. I will certainly be investigating further to understand the benefits to following this route.

I'll bring you more in this series just as soon as I get more response but thanks again to Zeptolab for taking the time.
2 comments

The tools: a decision

Having given it much thought I have come to a decision about the gaming environment I am to start with. To summarise I will list my findings to date and then let you know which one I am to write my first game with.


GameSalad
This was the first for me and I enjoyed using it. it was pretty straightforward to use and would fit well with those coming into gaming that maybe come from a design background or used to using products such as Adobe Flash.
Key Facts
Programming Language: Not applicable
Supported Platforms: iOS (Mac, iPhone, iPad, Web)
Notable Games: Angry Anna, Bumps
Cost: $499 pe year


Cocos2D
While a steep learning curve at first it was very rewarding when getting things working. A knowledge of objective-c, XCode and Box2D is advantageous the excellent community and books available make almost any question, answerable.
Key Facts
Programming Language: Objective-c, C++
Supported Platforms: iOS (Mac, iPhone, iPad)
Notable Games: Feed me Oil, Tap Pet Hotel, Tap Zoo, Air Penguin, Zombie Farm, Trainyard
Cost: Free


Corona
Found this framework to be a half way house between GameSalad and Cocos2D. The new programming language took a little getting used to but the speed you could get things going as well as a decent community support meant I was up and running in no time. In built Box2D capabilities allowed me to achieve decent physic effects with a few lines of code.
Key Facts
Programming Language: Lua
Supported Platforms: iOS (Mac, iPhone, iPad), Android
Notable Games: Bubble Ball. Blast Monkeys, Globs, Float, Forgotten Places Lost Circus HD, Critter Quitters, Turtle and Rabbit Hare, ESP Guitar Experience
Cost: iOS: $199/year, Android $199/year, Both: $349/year


Unity 3D
I haven't really touched the surface of this and the power of the product is very clear. However, I was very mindful again of the words of Steffen Itterheim in Learn iPhone and iPad cocos2d Game Development, reiterating the need to focus on some achievable. With that in mind I have shelved this to at least year two when I have a game or two under my belt.
Key Facts
Programming Language: Javascript, C# and Boo
Supported Platforms: iOS (Mac, iPhone, iPad), Android, Web
Notable Games: Battleheart, Zombieville USA, Battle Bears
Cost: iOS: $400/$1500, Android $400/$1500


SIO2
This promised much from having read the website and gone through the forums. After downloading and registering I fired up the sample projects. Here started my problems!! Under the trial license you need to communicate with SIO2's licensing server but my license key wasn't recognised from their developer portal. A common problem from what I have read on forums and across google. I tried to then contact technical support but was told this wasn't available unless I upgraded. I also tried using iChat to get some assistance but was refused connection.
Key Facts
Programming Language: Lua
Supported Platforms: iOS (Mac, iPhone, iPad), Android, Web
Notable Games: Manic Marbles, Bowmaster
Cost: iOS: $399, Android $399


iTorque 2D
To be honest I didn't evaluate this one. But they describe themselves as follows:
"Making games for the iPhone, iPhone4, iPod touch, and iPad is now a fast, fun, and straightforward process using Torque's tools for game development. The unparalleled 2D editor has been extended to bring more iOS control and features to your fingertips with less coding required.

Students, designers, and indies can jump start their development with easy and powerful technology used by thousands of developers. Advanced developers can accelerate their development with this feature rich development environment.
Your iTorque 2D license provides the following features specific to the iPhone, iPhone 4, iPod touch, and iPad"
Key Facts
Programming Language: TorqueScript
Supported Platforms: iOS (Mac, iPhone, iPad)
Notable Games: Mass Effect Galaxy, Marble Blast Mobile
Cost: iOS: $149


Gideros Studio
Deniz Asli Soykurum Cetin, co-founder of Gideros, very kindly pointed out their game development framework. I have decided at this time not evaluate but that is not slight on their product but more a focus on those that have gone before them. They say:
"With Gideros Studio, now it’s possible to build a proof of concept demo of your application in a couple of hours. You can test your application idea in your desired platform by simply clicking play button, thanks to AS3-like functions in Gideros Studio. Even if you are an experienced mobile designer, fast testing your application concept on the real device will give you a important feedback about the user experience. You can use the accelerometer of iPhone for example, to see if your idea is fun enough."
Key Facts
Programming Language: Lua
Supported Platforms: iOS (Mac, iPhone, iPad), Android
Notable Games: Tim the Timber
Cost: Free/$139/$449


marmalade
Thank you to @_danyal for telling me about this product. Again, I have not tested as this seems pretty advanced for a newbie but offers good testimonials as well apps that have been created with it. In short, Marmalade is described as "the world’s most powerful SDK for the creation of richer apps and games on iOS, Android and other platforms. Marmalade’s unique technical architecture offers maximum performance through true native code."
Key Facts
Programming Language: C/C++
Supported Platforms: iOS, Android, Symbian, bada, webOS
Notable Games: Need for Speed Shift, Pro Evolution Soccer (PES) 2011, Backbreaker Football
Cost: Free/$149/$499/$3499


kobold2d
Steffen Itterheim who wrote the aforementioned Learn iPhone and iPad Cocos2D Game Development has also been busy extending the Cocos2D framework. Extending what is already an excellent language is obviously one to watch. Steffan writes: "Kobold2D is an extended and improved version of the popular Cocos2D game engine. Kobold2D is easier to get started with, more convenient to use, more powerful and flexible than Cocos2D. Use Kobold2D to develop iPhone, iPod touch, iPad and Mac OS X games for the Apple App Stores. Kobold2D is free and open source with additional premium content to support its development."
Key Facts
Programming Language: Objective-C
Supported Platforms: iOS (Mac, iPhone, iPad)
Notable Games: N/A
Cost: Free


Conclusion
So who have I gone for? Well I have really debated this but Steffan's words keep ringing in my head as well as a new member of my conscience, Jay Jennings. Jay Jennings for those of you who may or may not know wrote the excellent Corona Project Manager. He said something that has stuck in my head for days and that was: "I got into game development because I want to DEVELOP GAMES, not program". This was a really valid point that I had lost focus on. Given that the first two years of this project is to deliver quality successful games I have to be realistic and put my time into game design, polish and marketing to achieve results.

It is because of this I have decided to go with Corona. While the Lua language is at present a complete mystery to me I was able to get my prototype up and running very quickly and with the ability to relatively inexpensively distribute to both iOS and Android devices this had the final advantage over Cocos2D.

Wish me luck!
 
;