Last active
December 20, 2015 18:58
-
-
Save eduresende/6179455 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Project: Attack of the Cuteness Game | |
-- http://MasteringCoronaSDK.com | |
-- Version: 1.0 | |
-- Copyright 2013 J. A. Whye. All Rights Reserved. | |
-- "Space Cute" art by Daniel Cook (Lostgarden.com) | |
-- housekeeping stuff | |
display.setStatusBar(display.HiddenStatusBar) | |
local centerX = display.contentCenterX | |
local centerY = display.contentCenterY | |
-- set up forward references | |
local spawnEnemy | |
local shipSmash | |
-- preload audio | |
-- create play screen | |
local function createPlayScreen() | |
local background = display.newImage("background.png") | |
background.y = 130 | |
background.alpha = 0 | |
background:addEventListener("tap", shipSmash) | |
local planet = display.newImage("planet.png") | |
planet.x = centerX | |
planet.y = display.contentHeight + 50 | |
planet.alpha = 0 | |
planet.xScale = 2 | |
planet.yScale = 2 | |
planet:addEventListener("tap", shipSmash) | |
transition.to( background, { time=2000, y=centerY, x=centerX, alpha=1 } ) | |
local function showTitle() | |
local gameTitle = display.newImage("gametitle.png") | |
gameTitle.alpha = 0 | |
gameTitle:scale(4, 4) | |
transition.to(gameTitle, {time=500, alpha=1, xScale=1, yScale=1}) | |
spawnEnemy() | |
end | |
transition.to( planet, { time=2000, y=centerY, alpha=1, xScale=1, yScale=1, onComplete=showTitle } ) | |
end | |
-- game functions | |
local function spawnEnemy() | |
local enemy = display.newImage("beetleship.png") | |
enemy.x = math.random(20, display.contentWidth-20) | |
enemy.y = math.random(20, display.contentHeight-20) | |
enemy:addEventListener("tap", shipSmash) | |
end | |
local function shipSmash(event) | |
local obj = event.target | |
display.remove(obj) | |
return true | |
end | |
local function startGame() | |
end | |
local function planetDamage() | |
end | |
local function hitPlanet(obj) | |
end | |
createPlayScreen() | |
startGame() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment