1 decade ago by ArcadeHype
Just wondering if someone could give me some ideas on how i can properly position my bullets so they project from the tip of my spaceship. Currently the bullets are being projected from the center of my ship. They are firing in the correct direction based on the angle of my ship but i cant seem to position them correctly as i want.
Not sure if i am being clear enough but you should get a better idea after seeing the demo: http://www.html5gameblogs.com/games/asteroids/
Here is the code i am using to create the bullets:
Any help is appreciated, thanks.
Not sure if i am being clear enough but you should get a better idea after seeing the demo: http://www.html5gameblogs.com/games/asteroids/
Here is the code i am using to create the bullets:
if( ig.input.pressed('shoot') ) { ig.game.spawnEntity(EntityBullet, this.pos.x, this.pos.y); }
EntityBullet = ig.Entity.extend({ //bullet properties size: {x: 18, y: 29}, animSheet: new ig.AnimationSheet( 'media/bullet.png', 18, 29 ), maxVel: {x: 800, y: 800}, bulletOffSet: 55, //collision types type: ig.Entity.TYPE.NONE, checkAgainst: ig.Entity.TYPE.B, collides: ig.Entity.COLLIDES.PASSIVE, init: function( x, y, settings ) { this.parent( x, y, settings ); this.vel.x = this.accel.x = Math.cos((ig.game.player.angle*Math.PI/180) + this.bulletOffSet) * this.maxVel.x; this.vel.y = this.accel.y = Math.sin((ig.game.player.angle*Math.PI/180) + this.bulletOffSet) * this.maxVel.y; this.addAnim( 'idle', 0.2, [0] ); //rotate the angle of the animation sprite this.currentAnim.angle = ig.game.player.angle*(Math.PI/180); }, });
Any help is appreciated, thanks.