Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
});
bg.color(218/255, 214/255, 212/255);
bg.center = {x: middle.x, y: middle.y};
scene.add(bg);
// Paddle
paddle = platino.createSprite({image: "Paddle.png"});
paddle.anchorPoint = {x: 0.5, y: 0.5};
paddle.center = {
x: middle.x,
y: screenHeight - 100,
};
scene.add(paddle);
// Ball
ball = platino.createSprite({image: "Ball.png"});
ball.anchorPoint = {x: 0.5, y: 0.5};
ball.center = {
x: middle.x,
y: screenHeight - 90,
};
scene.add(ball);
// Bricks
var x,y,brick,top,left,w,h;
brick = platino.createSprite({image: "Brick.png"});
w = brick.width + brickPadding;
h = brick.height + brickPadding;
brick.dispose();
brick = null;
top = middle.y - (numOfRows * .5 * h);
left = middle.x - (numOfCols * .5 * w);
height: screenHeight * 2
});
bg2.color(208/255, 204/255, 202/255);
bg2.center = {x: middle.x, y: middle.y};
scene.add(bg2);
bg = platino.createSprite({
width: screenWidth,
height: screenHeight
});
bg.color(218/255, 214/255, 212/255);
bg.center = {x: middle.x, y: middle.y};
scene.add(bg);
// Logo
logo = platino.createSprite({image: "Logo.png"});
logo.anchorPoint = {x: 0.5, y: 0.5};
logo.center = {
x: middle.x,
y: middle.y - 200,
};
scene.add(logo);
// Logo label
logoLabel = platino.createTextSprite({
text: logoText,
fontSize: 220,
fontFamily: "Dolce Vita",
alpha: 0.5
});
size = logoLabel.sizeWithText(logoLabel.text);
logoLabel.center = {x: logo.center.x - size.width * .5, y: logo.center.y - size.height * .5};
height: screenHeight * 2
});
bg2.color(208/255, 204/255, 202/255);
bg2.center = {x: middle.x, y: middle.y};
scene.add(bg2);
bg = platino.createSprite({
width: screenWidth,
height: screenHeight
});
bg.color(218/255, 214/255, 212/255);
bg.center = {x: middle.x, y: middle.y};
scene.add(bg);
// Logo
logo = platino.createSprite({image: "Logo.png"});
logo.anchorPoint = {x: 0.5, y: 0.5};
logo.center = {
x: middle.x,
y: middle.y - 200,
};
scene.add(logo);
// Logo label
logoLabel = platino.createTextSprite({
text: logoText,
fontSize: 220,
fontFamily: "Dolce Vita",
alpha: 0.5
});
size = logoLabel.sizeWithText(logoLabel.text);
logoLabel.center = {x: logo.center.x - size.width * .5, y: logo.center.y - size.height * .5};
middle.y = game.STAGE_START.y + (screenHeight * 0.5);
// Determine state
if (typeof game.score === "undefined") {
logoText = "Arkazoid";
introSound.play();
} else if (game.lives === 0) {
logoText = "Game Over";
loseSound.play();
} else {
logoText = "You Won!";
winSound.play();
}
// Setup background
bg2 = platino.createSprite({
width: screenWidth * 2,
height: screenHeight * 2
});
bg2.color(208/255, 204/255, 202/255);
bg2.center = {x: middle.x, y: middle.y};
scene.add(bg2);
bg = platino.createSprite({
width: screenWidth,
height: screenHeight
});
bg.color(218/255, 214/255, 212/255);
bg.center = {x: middle.x, y: middle.y};
scene.add(bg);
// Logo
var onSceneActivated = function(e) {
Ti.API.info("GameScene has been activated.");
screenWidth = game.TARGET_SCREEN.width;
screenHeight = game.TARGET_SCREEN.height;
middle.x = game.STAGE_START.x + (screenWidth * 0.5);
middle.y = game.STAGE_START.y + (screenHeight * 0.5);
bounds.x1 = game.STAGE_START.x + wallThickness;
bounds.y1 = game.STAGE_START.y + wallThickness;
bounds.x2 = bounds.x1 + screenWidth - wallThickness * 2;
bounds.y2 = bounds.y1 + screenHeight - wallThickness;
game.score = 0;
game.lives = 3;
// Setup background
bg2 = platino.createSprite({
width: screenWidth * 2,
height: screenHeight * 2
});
bg2.color(208/255, 204/255, 202/255);
bg2.center = {x: middle.x, y: middle.y};
scene.add(bg2);
bg = platino.createSprite({
width: screenWidth,
height: screenHeight
});
bg.color(218/255, 214/255, 212/255);
bg.center = {x: middle.x, y: middle.y};
scene.add(bg);
// Paddle
height: screenHeight * 2
});
bg2.color(208/255, 204/255, 202/255);
bg2.center = {x: middle.x, y: middle.y};
scene.add(bg2);
bg = platino.createSprite({
width: screenWidth,
height: screenHeight
});
bg.color(218/255, 214/255, 212/255);
bg.center = {x: middle.x, y: middle.y};
scene.add(bg);
// Paddle
paddle = platino.createSprite({image: "Paddle.png"});
paddle.anchorPoint = {x: 0.5, y: 0.5};
paddle.center = {
x: middle.x,
y: screenHeight - 100,
};
scene.add(paddle);
// Ball
ball = platino.createSprite({image: "Ball.png"});
ball.anchorPoint = {x: 0.5, y: 0.5};
ball.center = {
x: middle.x,
y: screenHeight - 90,
};
scene.add(ball);
middle.y = game.STAGE_START.y + (screenHeight * 0.5);
// Determine state
logoText = "TwoScene";
introSound.play();
// Setup background
bg2 = platino.createSprite({
width: screenWidth * 2,
height: screenHeight * 2
});
bg2.color(208/255, 204/255, 202/255);
bg2.center = {x: middle.x, y: middle.y};
scene.add(bg2);
bg = platino.createSprite({
width: screenWidth,
height: screenHeight
});
bg.color(218/255, 214/255, 212/255);
bg.center = {x: middle.x, y: middle.y};
scene.add(bg);
// Logo
logo = platino.createSprite({image: "Logo.png"});
logo.anchorPoint = {x: 0.5, y: 0.5};
logo.center = {
x: middle.x,
y: middle.y - 200,
};
scene.add(logo);
scene.add(ball);
// Bricks
var x,y,brick,top,left,w,h;
brick = platino.createSprite({image: "Brick.png"});
w = brick.width + brickPadding;
h = brick.height + brickPadding;
brick.dispose();
brick = null;
top = middle.y - (numOfRows * .5 * h);
left = middle.x - (numOfCols * .5 * w);
brickCount = 0;
for (y = 0; y < numOfRows; y++) {
for (x = 0; x < numOfCols; x++) {
brick = platino.createSprite({image: "Brick.png"});
brick.center = {
x: left + (x + .5) * w,
y: top + (y + .5) * h,
};
brick.anchorPoint = {x: 0.5, y: 0.5};
scene.add(brick);
bricks.push(brick);
brickCount++;
}
}
// Labels
scoreLabel = platino.createTextSprite({
text: "Score: " + game.score,
fontSize: 36,
fontFamily: "Dolce Vita",
y: screenHeight - 100,
};
scene.add(paddle);
// Ball
ball = platino.createSprite({image: "Ball.png"});
ball.anchorPoint = {x: 0.5, y: 0.5};
ball.center = {
x: middle.x,
y: screenHeight - 90,
};
scene.add(ball);
// Bricks
var x,y,brick,top,left,w,h;
brick = platino.createSprite({image: "Brick.png"});
w = brick.width + brickPadding;
h = brick.height + brickPadding;
brick.dispose();
brick = null;
top = middle.y - (numOfRows * .5 * h);
left = middle.x - (numOfCols * .5 * w);
brickCount = 0;
for (y = 0; y < numOfRows; y++) {
for (x = 0; x < numOfCols; x++) {
brick = platino.createSprite({image: "Brick.png"});
brick.center = {
x: left + (x + .5) * w,
y: top + (y + .5) * h,
};
brick.anchorPoint = {x: 0.5, y: 0.5};
xMin = x-xRange,
xMax = x+xRange,
yMin = y-yRange,
yMax = y+yRange,
transform;
for (i = 0; i < count; i++) {
transform = platino.createTransform({
duration: rand(250, 500),
x: rand(xMin, xMax),
y: rand(yMin, yMax),
scaleX: 0.3,
scaleY: 0.3,
alpha: 0
});
transform.sprite = platino.createSprite({image: "Particle.png"});
transform.sprite.anchorPoint = {x: 0.5, y: 0.5};
transform.sprite.x = x;
transform.sprite.y = y;
scene.add(transform.sprite);
transform.addEventListener("complete", function(e){
e.source.sprite.hide();
e.source.sprite.dispose();
e.source.sprite = null;
});
transform.sprite.transform(transform);
transforms.push(transform);
}
};