new file: Files/flashplayer_32_sa.exe new file: favicon.ico new file: globe.gif new file: imgs/download.png new file: imgs/zuck.jpg new file: index.html new file: other.ico new file: script.js new file: site.webmanifest new file: sitemap.html new file: styles/backround.css new file: styles/border.css new file: styles/fonts/Titillium_Web/OFL.txt new file: styles/fonts/Titillium_Web/TitilliumWeb-Black.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-Bold.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-BoldItalic.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-ExtraLight.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-ExtraLightItalic.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-Italic.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-Light.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-LightItalic.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-Regular.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-SemiBold.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-SemiBoldItalic.ttf new file: styles/fonts/webfontkit-20221027-163353/generator_config.txt new file: styles/fonts/webfontkit-20221027-163353/specimen_files/grid_12-825-55-15.css new file: styles/fonts/webfontkit-20221027-163353/specimen_files/specimen_stylesheet.css new file: styles/fonts/webfontkit-20221027-163353/stylesheet.css new file: styles/fonts/webfontkit-20221027-163353/titilliumweb-extralight-demo.html new file: styles/fonts/webfontkit-20221027-163353/titilliumweb-extralight-webfont.woff new file: styles/fonts/webfontkit-20221027-163353/titilliumweb-extralight-webfont.woff2 new file: styles/fonts/webfontkit-20221027-165950/generator_config.txt new file: styles/fonts/webfontkit-20221027-165950/specimen_files/grid_12-825-55-15.css new file: styles/fonts/webfontkit-20221027-165950/specimen_files/specimen_stylesheet.css new file: styles/fonts/webfontkit-20221027-165950/stylesheet.css new file: styles/fonts/webfontkit-20221027-165950/titilliumweb-bold-demo.html new file: styles/fonts/webfontkit-20221027-165950/titilliumweb-bold-webfont.woff new file: styles/fonts/webfontkit-20221027-165950/titilliumweb-bold-webfont.woff2 new file: styles/style.css new file: tools/2048/.gitignore new file: tools/2048/.jshintrc new file: tools/2048/CONTRIBUTING.md new file: tools/2048/LICENSE.txt new file: tools/2048/README.md new file: tools/2048/Rakefile new file: tools/2048/favicon.ico new file: tools/2048/index.html new file: tools/2048/js/animframe_polyfill.js new file: tools/2048/js/application.js new file: tools/2048/js/bind_polyfill.js new file: tools/2048/js/classlist_polyfill.js new file: tools/2048/js/game_manager.js new file: tools/2048/js/grid.js new file: tools/2048/js/html_actuator.js new file: tools/2048/js/keyboard_input_manager.js new file: tools/2048/js/local_storage_manager.js new file: tools/2048/js/tile.js new file: tools/2048/meta/apple-touch-icon.png new file: tools/webretro/cores/neocd_libretro.js new file: tools/webretro/cores/neocd_libretro.wasm new file: tools/webretro/cores/nestopia_libretro.js new file: tools/webretro/cores/nestopia_libretro.wasm new file: tools/webretro/cores/o2em_libretro.js new file: tools/webretro/cores/o2em_libretro.wasm new file: tools/webretro/cores/opera_libretro.js new file: tools/webretro/cores/opera_libretro.wasm
154 lines
4.8 KiB
JavaScript
154 lines
4.8 KiB
JavaScript
/**
|
|
* Created by stryker on 2014.03.05..
|
|
*/
|
|
define(['module/HUD'],function(HUD){
|
|
|
|
//Private variables
|
|
var _game = null;
|
|
//var _alienGroups = [];
|
|
var _playerShip = null;
|
|
|
|
//Private class
|
|
//This is a wrapper for the aliengroup
|
|
//Instead of extending Phaser group, i wrap it up in a class
|
|
var _Aliens = function(configuration){
|
|
var _alienGroup = _game.add.group(),
|
|
_cols = configuration.cols,
|
|
_rows = configuration.rows,
|
|
_scoreValue = configuration.scoreValue,
|
|
_firingTime = configuration.firingTime,
|
|
_bulletSpeed = configuration.bulletSpeed,
|
|
_health = configuration.health,
|
|
_easing = configuration.easing,
|
|
_alien = null,
|
|
_tween = null,
|
|
_bulletGroup = null,
|
|
_bullet = null,
|
|
_explosionGroup = null,
|
|
_explosion = null,
|
|
_livingAlien = [],
|
|
_randomAlienIndex = null,
|
|
_shooter = null,
|
|
_shootingEvent = null;
|
|
|
|
_alienGroup.enableBody = true;
|
|
_alienGroup.physicsBodyType = Phaser.Physics.ARCADE;
|
|
_createAllienGroup();
|
|
|
|
function _createAllienGroup(){
|
|
//making aliens
|
|
for(var i=0;i < _cols;i++){
|
|
for(var j=0; j < _rows;j++){
|
|
_alien = _alienGroup.create(i * 48, j * 50, 'invader');
|
|
|
|
//custome properties
|
|
_alien.health = _health;
|
|
_alien.myScore = _scoreValue;
|
|
|
|
_alien.anchor.setTo(0.5, 0.5);
|
|
_alien.animations.add('fly', [ 0, 1, 2, 3 ], 20, true);
|
|
_alien.play('fly');
|
|
_alien.body.moves = false;
|
|
}
|
|
}
|
|
|
|
|
|
//setting aliens postition
|
|
_alienGroup.x = 100;
|
|
_alienGroup.y = 50;
|
|
|
|
// All this does is basically start the invaders moving.
|
|
_tween = _game.add.tween(_alienGroup).to( { x: 200 }, 2000, _easing, true, 0, 1000, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
var _fireBullet = function(){
|
|
_bullet = _bulletGroup.getFirstExists(false);
|
|
|
|
_livingAlien = [];
|
|
|
|
_alienGroup.forEachAlive(function(alien){
|
|
_livingAlien.push(alien);
|
|
});
|
|
|
|
if(_bullet && _livingAlien.length > 0){
|
|
|
|
//_bullet.lifespan = _game.height / (_bulletSpeed/1000);
|
|
_bullet.checkWorldBounds = true;
|
|
|
|
_randomAlienIndex = _game.rnd.integerInRange(0,_livingAlien.length);
|
|
|
|
_shooter = _livingAlien[_randomAlienIndex];
|
|
|
|
if(_shooter){
|
|
_bullet.reset(_shooter.body.x,_shooter.body.y);
|
|
|
|
_game.physics.arcade.moveToObject(_bullet,_playerShip,_bulletSpeed);
|
|
}
|
|
//all alien died
|
|
}else if(_livingAlien.length == 0){
|
|
_game.state.start('End');
|
|
}
|
|
|
|
};
|
|
|
|
var _collisionHandler = function(bullet, alien){
|
|
|
|
alien.damage(bullet.bulletDamage);
|
|
bullet.kill();
|
|
|
|
if(alien.health == 0){
|
|
_explosion = _explosionGroup.getFirstExists(false);
|
|
_explosion.reset(alien.body.x,alien.body.y);
|
|
_explosion.play('kaboom',30,false,true);
|
|
}
|
|
|
|
HUD.updateScoreText(alien.myScore);
|
|
};
|
|
|
|
//Public functions
|
|
return{
|
|
setBulletGroup: function(bullets){
|
|
_bulletGroup = bullets.getBulletGroup();
|
|
},
|
|
getBulletGroup: function(){
|
|
return _bulletGroup;
|
|
},
|
|
setExplosionGroup: function(explosions){
|
|
_explosionGroup = explosions.getExplosionGroup();
|
|
},
|
|
startShooting: function(){
|
|
_shootingEvent = _game.time.events.loop(_firingTime,_fireBullet,this);
|
|
},
|
|
stopShooting: function(){
|
|
_game.time.events.remove(_shootingEvent);
|
|
},
|
|
createOverLap: function(bulletGroup){
|
|
_game.physics.arcade.overlap(bulletGroup, _alienGroup, _collisionHandler, null, this);
|
|
},
|
|
getAlienGroup: function(){
|
|
return _alienGroup;
|
|
}
|
|
|
|
}
|
|
|
|
};//End of _Aliens
|
|
|
|
//Public functions
|
|
return{
|
|
init: function(game){
|
|
_game = game;
|
|
},
|
|
preload: function(){
|
|
_game.load.spritesheet('invader', 'assets/img/invader32x32x4.png', 32, 32);
|
|
},
|
|
create: function(configuration){
|
|
return( new _Aliens(configuration) );
|
|
},
|
|
setPlayerShip: function(playerShip){
|
|
_playerShip = playerShip;
|
|
}
|
|
}
|
|
}); |