===================================================================
--- original.js
+++ change.js
@@ -1,81 +1,89 @@
-/****
+/****
* Classes
****/
var Hero = Container.expand(function () {
- var self = Container.call(this);
- var heroGraphics = self.attachAsset('hero', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.speed = 5;
- self.move = function (direction) {
- if (direction === 'left') self.x -= self.speed;
- if (direction === 'right') self.x += self.speed;
- if (direction === 'up') self.y -= self.speed;
- if (direction === 'down') self.y += self.speed;
- };
- self.shoot = function () {
- var bullet = new Bullet();
- bullet.x = self.x;
- bullet.y = self.y;
- game.addChild(bullet);
- return bullet;
- };
+ var self = Container.call(this);
+ var heroGraphics = self.attachAsset('hero', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 5;
+ self.move = function (direction) {
+ if (direction === 'left') {
+ self.x -= self.speed;
+ }
+ if (direction === 'right') {
+ self.x += self.speed;
+ }
+ if (direction === 'up') {
+ self.y -= self.speed;
+ }
+ if (direction === 'down') {
+ self.y += self.speed;
+ }
+ };
+ self.shoot = function () {
+ var bullet = new Bullet();
+ bullet.x = self.x;
+ bullet.y = self.y;
+ game.addChild(bullet);
+ return bullet;
+ };
});
var Monster = Container.expand(function () {
- var self = Container.call(this);
- var monsterGraphics = self.attachAsset('monster', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.speed = 2;
- self.moveTowards = function (targetX, targetY) {
- var dx = targetX - self.x;
- var dy = targetY - self.y;
- var angle = Math.atan2(dy, dx);
- self.x += Math.cos(angle) * self.speed;
- self.y += Math.sin(angle) * self.speed;
- };
+ var self = Container.call(this);
+ var monsterGraphics = self.attachAsset('monster', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 2;
+ self.moveTowards = function (targetX, targetY) {
+ var dx = targetX - self.x;
+ var dy = targetY - self.y;
+ var angle = Math.atan2(dy, dx);
+ self.x += Math.cos(angle) * self.speed;
+ self.y += Math.sin(angle) * self.speed;
+ };
});
var Bullet = Container.expand(function () {
- var self = Container.call(this);
- var bulletGraphics = self.attachAsset('bullet', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.speed = 10;
- self.move = function () {
- self.y -= self.speed;
- };
+ var self = Container.call(this);
+ var bulletGraphics = self.attachAsset('bullet', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 10;
+ self.move = function () {
+ self.y -= self.speed;
+ };
});
var Shop = Container.expand(function () {
- var self = Container.call(this);
- var shopGraphics = self.attachAsset('shop', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.x = 2048 / 2;
- self.y = 2732 - 128;
+ var self = Container.call(this);
+ var shopGraphics = self.attachAsset('shop', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.x = 2048 / 2;
+ self.y = 2732 - 128;
});
var Door = Container.expand(function () {
- var self = Container.call(this);
- var doorGraphics = self.attachAsset('door', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.x = 2048 / 2;
- self.y = 128;
+ var self = Container.call(this);
+ var doorGraphics = self.attachAsset('door', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.x = 2048 / 2;
+ self.y = 128;
});
-/****
+/****
* Initialize Game
****/
var game = new LK.Game({
- backgroundColor: 0x000000
+ backgroundColor: 0x000000
});
-/****
+/****
* Game Code
****/
var hero = game.addChild(new Hero());
hero.x = 2048 / 2;
@@ -83,49 +91,61 @@
var shop = game.addChild(new Shop());
var door = game.addChild(new Door());
var monsters = [];
var bullets = [];
-game.on('down', function (obj) {
- var touchPos = obj.event.getLocalPosition(game);
- if (touchPos.x < 1024) {
- hero.move('left');
- } else {
- hero.move('right');
- }
+window.addEventListener('keydown', function (event) {
+ switch (event.keyCode) {
+ case 37:
+ // left arrow
+ hero.move('left');
+ break;
+ case 39:
+ // right arrow
+ hero.move('right');
+ break;
+ case 38:
+ // up arrow
+ hero.move('up');
+ break;
+ case 40:
+ // down arrow
+ hero.move('down');
+ break;
+ }
});
game.on('up', function (obj) {
- bullets.push(hero.shoot());
+ bullets.push(hero.shoot());
});
LK.on('tick', function () {
- if (LK.ticks % 120 === 0) {
- // Spawn a monster every 2 seconds
- var monster = new Monster();
- monster.x = door.x;
- monster.y = door.y;
- monsters.push(monster);
- game.addChild(monster);
- }
- monsters.forEach(function (monster, index) {
- monster.moveTowards(hero.x, hero.y);
- if (monster.intersects(hero)) {
- LK.effects.flashScreen(0xff0000, 1000);
- LK.showGameOver();
- }
- });
- bullets.forEach(function (bullet, index) {
- bullet.move();
- if (bullet.y < 0) {
- bullet.destroy();
- bullets.splice(index, 1);
- } else {
- monsters.forEach(function (monster, mIndex) {
- if (bullet.intersects(monster)) {
- monster.destroy();
- monsters.splice(mIndex, 1);
- bullet.destroy();
- bullets.splice(index, 1);
- LK.setScore(LK.getScore() + 1);
- }
- });
- }
- });
+ if (LK.ticks % 120 === 0) {
+ // Spawn a monster every 2 seconds
+ var monster = new Monster();
+ monster.x = door.x;
+ monster.y = door.y;
+ monsters.push(monster);
+ game.addChild(monster);
+ }
+ monsters.forEach(function (monster, index) {
+ monster.moveTowards(hero.x, hero.y);
+ if (monster.intersects(hero)) {
+ LK.effects.flashScreen(0xff0000, 1000);
+ LK.showGameOver();
+ }
+ });
+ bullets.forEach(function (bullet, index) {
+ bullet.move();
+ if (bullet.y < 0) {
+ bullet.destroy();
+ bullets.splice(index, 1);
+ } else {
+ monsters.forEach(function (monster, mIndex) {
+ if (bullet.intersects(monster)) {
+ monster.destroy();
+ monsters.splice(mIndex, 1);
+ bullet.destroy();
+ bullets.splice(index, 1);
+ LK.setScore(LK.getScore() + 1);
+ }
+ });
+ }
+ });
});
\ No newline at end of file
wooden door thats round at the top 8 bit. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
wisard 8 bit from the top down. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
tentacle monster 8 bit. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
8 bit tentacle monster. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
8 bit stone brick dungeon floor with a tiny amount of moss with tinny little bricks and very low contrast make it darker to. Single Game Texture. In-Game asset. 2d. Blank background.. No shadows.
8 bit fireball with a flame trail that goes down. Single Game Texture. In-Game asset. 2d. Blank background.. No shadows.
just move the tentacles a tinny litle bit
make the monster move
green button 8 bit. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.