Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ig.module(
- 'game.entities.Player'
- )
- .requires(
- 'impact.entity',
- 'game.entities.BulletPlayer'
- )
- .defines(function() {
- EntityPlayer = ig.Entity.extend({
- size: {x: 25, y: 32},
- collides: ig.Entity.COLLIDES.PASSIVE,
- animSheet: new ig.AnimationSheet('media/player.png', 25, 32),
- init: function(x, y, settings) {
- this.parent(x, y, settings);
- this.addAnim('anim', 0.1, [2, 3]);
- this.addAnim('left', 0.1, [0, 1]);
- this.addAnim('right', 0.1, [4, 5]);
- },
- update: function() {
- this.vel.x = 0;
- this.vel.y = 0;
- if (ig.input.state('down')) {
- this.vel.y = 200;
- this.currentAnim = this.anims.anim;
- }
- if (ig.input.state('up')) {
- this.currentAnim = this.anims.anim;
- this.vel.y = -200;
- }
- if (ig.input.state('right')) {
- this.currentAnim = this.anims.right;
- this.vel.x = 200;
- }
- if (ig.input.state('left')) {
- this.currentAnim = this.anims.left;
- this.vel.x = -200;
- }
- if(ig.input.state('fire')){
- var bullet = new EntityBulletPlayer();
- ig.game.spawnEntity(EntityBullet,this.pos.x, this.pos.y);
- }
- this.parent();
- }
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement