Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ig.module(
- 'game.entities.Player'
- )
- .requires(
- 'impact.entity'
- )
- .defines(function() {
- EntityPlayer = ig.Entity.extend({
- size: {x: 16, y: 16},
- collides: ig.Entity.COLLIDES.FIXED,
- animSheet: new ig.AnimationSheet('media/player.png',16, 16),
- init: function(x, y, settings) {
- this.parent(x, y, settings);
- this.addAnim('anim', 0.1, [0]);
- },
- 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.anim;
- this.vel.x = 200;
- }
- if (ig.input.state('left')) {
- this.currentAnim = this.anims.anim;
- this.vel.x = -200;
- }
- this.parent();
- }
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment