Skip to content

Instantly share code, notes, and snippets.

@CoronaSDK
CoronaSDK / line_intersection.lua
Created March 29, 2013 04:39
Intersection of 2 lines for a Corona SDK Application
function intersection(p11,p12,p21,p22)
local Z = (p12.y-p11.y)*(p21.x-p22.x)-(p21.y-p22.y)*(p12.x-p11.x);
local Ca = (p12.y-p11.y)*(p21.x-p11.x)-(p21.y-p11.y)*(p12.x-p11.x);
local Cb = (p21.y-p11.y)*(p21.x-p22.x)-(p21.y-p22.y)*(p21.x-p11.x);
if Z == 0 and Ca == 0 and Cb == 0 then return nil end
if Z == 0 then return nil end
-- show rating prompt
local function ratingPrompt()
local function ask()
local function answer(event)
if ("clicked" == event.action) then
if (event.index == 1) then
system.openURL("http://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=440754678")
data.rated = "yes"
writeData()
elseif (event.index == 2) then
-- iap results
function iapTransaction(event)
if (event.transaction.state == "purchased") or (event.transaction.state == "restored") then
if (event.transaction.productIdentifier == "playmaticBalloons") then
data.iap.iapBalloons = "yes"
iconBalloonsPrice.alpha = 0
end
writeData()
elseif (event.transaction.state == "cancelled") then
elseif (event.transaction.state == "failed") then
local targetDevice = ( system.getInfo( "model" ) )
local isTall = ( "iPhone" == system.getInfo( "model" ) ) and ( display.pixelHeight > 960 )
if isTall == false and targetDevice == "iPhone" then
application =
{
content =
{
width = 320,
height = 480,