var HeroBullet = Container.expand(function() { var self = Container.call(this); //{0} var bulletGraphics = XS.getAsset('heroBullet', 'Hero Bullet Graphics', 0.5, 0.5); self.addChild(bulletGraphics); //{1} //{2} self.speed = 10; //{3} self.move = function() { //{4} self.y -= self.speed; }; //{5} }); //{6} //{7} var EnemyBullet = Container.expand(function() { var self = Container.call(this); //{8} var bulletGraphics = XS.getAsset('enemyBullet', 'Enemy Bullet Graphics', 0.5, 0.5); self.addChild(bulletGraphics); //{9} //{10} self.speed = 5; //{11} self.move = function() { //{12} self.y += self.speed; //{13} }; //{14} }); //{15} //{16} var Hero = Container.expand(function() { var self = Container.call(this); //{17} var heroGraphics = XS.getAsset('hero', 'Hero Spaceship', 0.5, 0.5); self.addChild(heroGraphics); }); //{18} //{19} var Enemy = Container.expand(function() { var self = Container.call(this); //{20} var enemyGraphics = XS.getAsset('enemy', 'Enemy Spaceship', 0.5, 0.5); self.addChild(enemyGraphics); //{21} self.speed = 3; //{22} self.move = function() { //{23} self.y += self.speed; //{24} }; //{25} }); //{26} //{27} var Game = Container.expand(function() { var self = Container.call(this); //{28} //{29} var hero = self.addChild(new Hero()); hero.x = 1024; hero.y = 2400; //{30} var enemies = []; var heroBullets = []; var enemyBullets = []; var score = 0; //{31} var scoreText = new Text2('0', { size: 100, font: "'GillSans-Bold',Impact,'Arial Black',Tahoma", fill: "#ffffff" }); //{32} scoreText.anchor.set(0.5, 0); XS.gui.topCenter.addChild(scoreText); //{33} function spawnEnemy() { var enemy = new Enemy(); enemy.x = Math.random() * 2048; enemy.y = -100; enemies.push(enemy); self.addChild(enemy); } //{34} //{35} function fireHeroBullet() { var bullet = new HeroBullet(); bullet.x = hero.x; bullet.y = hero.y - 50; heroBullets.push(bullet); self.addChild(bullet); //{36} } //{37} //{38} function fireEnemyBullet(enemy) { var bullet = new EnemyBullet(); bullet.x = enemy.x; bullet.y = enemy.y + 50; enemyBullets.push(bullet); self.addChild(bullet); //{39} } //{40} //{41} function updateGameObjects() { enemies.forEach(function(enemy, index) { enemy.move(); if (enemy.y > 2732) { enemy.destroy(); //{42} enemies.splice(index, 1); } //{43} }); //{44} //{45} heroBullets.forEach(function(bullet, index) { bullet.move(); //{46} if (bullet.y < 0) { bullet.destroy(); //{47} heroBullets.splice(index, 1); } //{48} }); //{49} //{50} enemyBullets.forEach(function(bullet, index) { bullet.move(); //{51} if (bullet.y > 2732) { bullet.destroy(); //{52} enemyBullets.splice(index, 1); //{53} } //{54} }); //{55} } //{56} //{57} function checkCollisions() { // Check collisions between hero bullets and enemies heroBullets.forEach(function(heroBullet, hIndex) { enemies.forEach(function(enemy, eIndex) { if (heroBullet.intersects(enemy)) { heroBullet.destroy(); heroBullets.splice(hIndex, 1); enemy.destroy(); //{58} enemies.splice(eIndex, 1); score += 100; scoreText.setText(score); } //{59} }); //{60} }); //{61} //{62} // Check collisions between enemy bullets and hero enemyBullets.forEach(function(enemyBullet, index) { if (enemyBullet.intersects(hero)) { enemyBullet.destroy(); enemyBullets.splice(index, 1); //{63} XS.showGameOver(); // Handle hero hit by enemy bullet } //{64} }); //{65} } //{66} //{67} function handleTick() { updateGameObjects(); checkCollisions(); //{68} if (XS.ticks % 60 === 0) { spawnEnemy(); } //{69} //{70} if (XS.ticks % 30 === 0) { fireHeroBullet(); } //{71} //{72} enemies.forEach(function(enemy) { if (XS.ticks % 90 === 0) { fireEnemyBullet(enemy); } //{73} }); //{74} } //{75} //{76} XS.on('tick', handleTick); //{77} stage.on('down', function(obj) { var pos = obj.event.getLocalPosition(self); //{78} hero.x = pos.x; //{79} hero.y = pos.y; //{80} }); //{81} //{82} stage.on('move', function(obj) { var pos = obj.event.getLocalPosition(self); //{83} hero.x = pos.x; //{84} hero.y = pos.y; //{85} }); //{86} }); //{87}
var HeroBullet = Container.expand(function() {
var self = Container.call(this); //{0}
var bulletGraphics = XS.getAsset('heroBullet', 'Hero Bullet Graphics', 0.5, 0.5);
self.addChild(bulletGraphics); //{1}
//{2}
self.speed = 10;
//{3}
self.move = function() { //{4}
self.y -= self.speed;
}; //{5}
}); //{6}
//{7}
var EnemyBullet = Container.expand(function() {
var self = Container.call(this); //{8}
var bulletGraphics = XS.getAsset('enemyBullet', 'Enemy Bullet Graphics', 0.5, 0.5);
self.addChild(bulletGraphics); //{9}
//{10}
self.speed = 5;
//{11}
self.move = function() { //{12}
self.y += self.speed; //{13}
}; //{14}
}); //{15}
//{16}
var Hero = Container.expand(function() {
var self = Container.call(this); //{17}
var heroGraphics = XS.getAsset('hero', 'Hero Spaceship', 0.5, 0.5);
self.addChild(heroGraphics);
}); //{18}
//{19}
var Enemy = Container.expand(function() {
var self = Container.call(this); //{20}
var enemyGraphics = XS.getAsset('enemy', 'Enemy Spaceship', 0.5, 0.5);
self.addChild(enemyGraphics);
//{21}
self.speed = 3;
//{22}
self.move = function() { //{23}
self.y += self.speed; //{24}
}; //{25}
}); //{26}
//{27}
var Game = Container.expand(function() {
var self = Container.call(this); //{28}
//{29}
var hero = self.addChild(new Hero());
hero.x = 1024;
hero.y = 2400;
//{30}
var enemies = [];
var heroBullets = [];
var enemyBullets = [];
var score = 0;
//{31}
var scoreText = new Text2('0', {
size: 100,
font: "'GillSans-Bold',Impact,'Arial Black',Tahoma",
fill: "#ffffff"
}); //{32}
scoreText.anchor.set(0.5, 0);
XS.gui.topCenter.addChild(scoreText);
//{33}
function spawnEnemy() {
var enemy = new Enemy();
enemy.x = Math.random() * 2048;
enemy.y = -100;
enemies.push(enemy);
self.addChild(enemy);
} //{34}
//{35}
function fireHeroBullet() {
var bullet = new HeroBullet();
bullet.x = hero.x;
bullet.y = hero.y - 50;
heroBullets.push(bullet);
self.addChild(bullet); //{36}
} //{37}
//{38}
function fireEnemyBullet(enemy) {
var bullet = new EnemyBullet();
bullet.x = enemy.x;
bullet.y = enemy.y + 50;
enemyBullets.push(bullet);
self.addChild(bullet); //{39}
} //{40}
//{41}
function updateGameObjects() {
enemies.forEach(function(enemy, index) {
enemy.move();
if (enemy.y > 2732) {
enemy.destroy(); //{42}
enemies.splice(index, 1);
} //{43}
}); //{44}
//{45}
heroBullets.forEach(function(bullet, index) {
bullet.move(); //{46}
if (bullet.y < 0) {
bullet.destroy(); //{47}
heroBullets.splice(index, 1);
} //{48}
}); //{49}
//{50}
enemyBullets.forEach(function(bullet, index) {
bullet.move(); //{51}
if (bullet.y > 2732) {
bullet.destroy(); //{52}
enemyBullets.splice(index, 1); //{53}
} //{54}
}); //{55}
} //{56}
//{57}
function checkCollisions() {
// Check collisions between hero bullets and enemies
heroBullets.forEach(function(heroBullet, hIndex) {
enemies.forEach(function(enemy, eIndex) {
if (heroBullet.intersects(enemy)) {
heroBullet.destroy();
heroBullets.splice(hIndex, 1);
enemy.destroy(); //{58}
enemies.splice(eIndex, 1);
score += 100;
scoreText.setText(score);
} //{59}
}); //{60}
}); //{61}
//{62}
// Check collisions between enemy bullets and hero
enemyBullets.forEach(function(enemyBullet, index) {
if (enemyBullet.intersects(hero)) {
enemyBullet.destroy();
enemyBullets.splice(index, 1); //{63}
XS.showGameOver();
// Handle hero hit by enemy bullet
} //{64}
}); //{65}
} //{66}
//{67}
function handleTick() {
updateGameObjects();
checkCollisions();
//{68}
if (XS.ticks % 60 === 0) {
spawnEnemy();
} //{69}
//{70}
if (XS.ticks % 30 === 0) {
fireHeroBullet();
} //{71}
//{72}
enemies.forEach(function(enemy) {
if (XS.ticks % 90 === 0) {
fireEnemyBullet(enemy);
} //{73}
}); //{74}
} //{75}
//{76}
XS.on('tick', handleTick);
//{77}
stage.on('down', function(obj) {
var pos = obj.event.getLocalPosition(self); //{78}
hero.x = pos.x; //{79}
hero.y = pos.y; //{80}
}); //{81}
//{82}
stage.on('move', function(obj) {
var pos = obj.event.getLocalPosition(self); //{83}
hero.x = pos.x; //{84}
hero.y = pos.y; //{85}
}); //{86}
}); //{87}
Round powerup. Shield icon Single Game Texture. In-Game asset. 2d. Pixelart. White background. Blank background. Low detail. High contrast.
Extra missile powerup circle. Missile and plus sign. Single Game Texture. In-Game asset. 2d. Pixelart. White background. Blank background. Low detail. High contrast.
Single space torpedo flying upwards Game Texture. In-Game asset. 2d. Pixelart. White background. Blank background. Low detail. High contrast.
Background galaxy nebulas and galaxies Single Game Texture. In-Game asset. 2d. Pixelart. White background. Blank background. Low detail. High contrast. --ar 1:10
Round powerup. Green health icon Single Game Texture. In-Game asset. 2d. Pixelart. White background. Blank background. Low detail. High contrast.
Blue glowing powerup circle with s in center Single Game Texture. In-Game asset. 2d. Pixelart. White background. Blank background. Low detail. High contrast.
Round powerup. Lightning icon pointing up. Single Game Texture. In-Game asset. 2d. Pixelart. White background. Blank background. Low detail. High contrast.
Stylish hero spaceship facing upwards, with a single cannon in the center. Single Game Texture. In-Game asset. 2d. Pixelart. White background. Blank background. Low detail. High contrast.
single alien enemy spaceship facing down, looking like space alien adopted to living in space. Game Texture. In-Game asset. 2d. Pixelart. White background. Blank background. Low detail. High contrast.
Single enemy slime bullet, seen from above facing upwards. Single Game Texture. In-Game asset. 2d. Pixelart. White background. Blank background. Low detail. High contrast.
Round powerup icon with bullseye Single Game Texture. In-Game asset. 2d. Pixelart. White background. Blank background. Low detail. High contrast.
Clean plasma bubble Single Game Texture. In-Game asset. 2d. Pixelart. White background. Blank background. Low detail. High contrast.