1 decade ago by TObe
Hi,
I'm new at Impact and I'm trying to make my first game with this awesome engine. I want to make a game like Galactic Plunder so, I was trying to make the scroll movement like in the game (camera x movement + ship constant velocity + when an arrow key is pressed the ship could move faster within the camera area).
I tryied to achieve this by first moving the camera at a constant "velocity":
Then I move the ship:
When I make this, I get an extrange behavior: when the ship shoots it goes up some distance with every shoot and also when no key is pressed the ship start to advance more some times and smooth others like if some kind of force where pushing it forward in some frames. Then I tryied to move the ship with something like:
And I get a nice behavior but no vertical collisions against the solid tiles :(
I'm new at Impact and I'm trying to make my first game with this awesome engine. I want to make a game like Galactic Plunder so, I was trying to make the scroll movement like in the game (camera x movement + ship constant velocity + when an arrow key is pressed the ship could move faster within the camera area).
I tryied to achieve this by first moving the camera at a constant "velocity":
update: function() { // screen follows the player var player = this.getEntitiesByType( EntityPlayer )[0]; if( player ) { this.screen.x = this.velScrollX; this.screen.y = player.pos.y - ig.system.height/2; } // Update all entities and BackgroundMaps this.parent(); this.velScrollX += 1; },
Then I move the ship:
update: function() { if( ig.input.state('left') ) { this.vel.x = -100; this.flip = true; } else if( ig.input.state('right') ) { this.vel.x = 100; this.flip = false; } else { //this.pos.x += 1; this.vel.x = 68; } // shoot if( ig.input.pressed('shoot') ) { ig.game.spawnEntity( EntitySlimeGrenade, this.pos.x, this.pos.y, {flip:this.flip} ); } this.currentAnim.flip.x = this.flip; // move! this.parent(); }
When I make this, I get an extrange behavior: when the ship shoots it goes up some distance with every shoot and also when no key is pressed the ship start to advance more some times and smooth others like if some kind of force where pushing it forward in some frames. Then I tryied to move the ship with something like:
this.pos.x += 1; // when no Arrow (right or left) key is pressed
And I get a nice behavior but no vertical collisions against the solid tiles :(