Here is a little bit more
local screenW, screenH, halfW = display.contentWidth, display.contentHeight, display.contentWidth*0.5
local scoreTotal = 0
local scoreBoard
local highscore
local coin, mapleLeaf, diamond, C4
local coinTimer
local coins = {“coin”, “mapleLeaf”, “diamond”, “C4”}
local coinsScore = { 25, 50, 100, -1000 }
local genericCoin = coins
–local splitDiamond = {“DiamondB”, “DiamondT”}
math.randomseed( os.time() )
os.clock ()
local dubstep = audio.loadStream( “Ninja2.mp3” )
dubstep = audio.play( dubstep, { duration = 61500, onComplete = finished })
local coinsProp = {radius=20, density=1.0, friction=0.3, bounce=0.2, filter = {categoryBits = 2, maskBits = 1}}
local allCoins = {}
–[[
ego = require “ego”
saveFile = ego.saveFile
loadFile = ego.loadFile
–]]
local function splitCoin( name )
if name == “diamond” then
print(name)
--display.remove( diamond )
--display.newImage( “coin.png” )
elseif name == “coin” then
print(name)
elseif name == “mapleLeaf” then
print(name)
elseif name == “C4” then
print(name)
end
end
local function coinTouchHandler( event )
--if event.phase == “began” then
local sounds = audio.loadSound(“METALonMETAL.mp3”);
audio.play(sounds)
print("begin "…event.target.name)
--elseif event.phase == “ended” then
scoreTotal = scoreTotal + event.target.coinValue
scoreBoard.text = string.format("%d", scoreTotal )
print(scoreTotal)
--print(event.target)
splitCoin( event.target.name )
--end
end
local function createCoin( name, score )
local genericCoin
if name == “diamond” then
genericCoin = display.newImage( “Diamond.png”, 90, 90 )
elseif name == “coin” then
genericCoin = display.newImage( “Coin.png”, 90, 90 )
elseif name == “mapleLeaf” then
genericCoin = display.newImage( “MapleLeaf.png”, 90, 90 )
elseif name == “C4” then
genericCoin = display.newImage( “C4.png”, 90, 90 )
end
genericCoin.name = name
genericCoin.x, genericCoin.y = 140, 550
genericCoin.rotation = 100
genericCoin.height = 50
genericCoin.width = 50
genericCoin.coinValue = score
genericCoin:addEventListener( “touch”, coinTouchHandler )
return genericCoin
end
local function getRandomCoin()
local coinsProp = genericCoin[math.random(1, #genericCoin)]
local coins = display.newImage(coinsProp.whole)
end
local function shootObject(type)
– logic for random coin
local r = math.random( 1, 4 )
--print®
local object = createCoin(coins[r],coinsScore[r])
– How I make the coin fly
physics.addBody( object, { radius=20, density=1.5, friction=0.3, bounce=0.2, filter = {categoryBits = 2, maskBits = 1}} )
physics.addBody( object, “dynamic” )
--physics.setPreCollision = “passthru”
local v = math.random( 340, 560 )
local b = math.random( -65, 65 )
local c = math.random( 20, 60 )
object:setLinearVelocity( b, -v )
object:applyTorque( -c )
end