Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by programlocura

Hi everybody,

I've bought the impactJs framework and let me say that it is better than expected :) I'm very happy with the results.
I'm currently developing a game with some friends and I need to do a runner style game, and i'm having problems with the screen scrolling.

I need that the screen scrolls at same velocity (and acceleration) that the player run, but if the player collides with a wall, the screen still with the same velocity (The player lose when he's out of the screen).

I'm currently following the character, but if the character stops, the screen stops.

Can you give me an idea how to do this?

Thank you :)

1 decade ago by Arantor

Well, how are you handling the screen scrolling exactly?

I'm guessing that you're tying the game's screen.x to the player's pos.x? Instead of doing that, set the position from the game rather than the player's entity and thus it's updated in spite of what the player does or does not do.

1 decade ago by programlocura

Thanks for the quickly answer Arantor.

Yeah, i'm currently updating the screen.x position with the player's pos.x right in the middle of the screen.
I was trying to do your way, but, i've setted that the character bounce against the enemy a couple of times until the character kill him and it seems that there is trouble with that, my partial code is this:

[code]
var player = this.getEntitiesByType( EntityPlayer )[0];

player.pos.x = this.screen.x + (ig.system.width /2) - player.size.x;
this.screen.x += 1;
[/code]

I'm obviously doing something wrong.

Thanks for help!

1 decade ago by mimik

update: function() {		
		this.parent();
		// screen follows the player
		var player = this.getEntitiesByType( EntityPlayer )[0];
		if( player ) {
			this.screen.x = player.pos.x-ig.system.width/2;
			this.screen.y = player.pos.y-ig.system.height/2;
		}
	}

this make the screen follow the player

on both Y and X.

if you just want the screen to move all the time just make a

this.screen.x += 1; ?

1 decade ago by programlocura

Hi!
I don't know why it is, but it isn't working. I'm currently doing exactly what mimik say, but the player remains stopped in the middle of the screen.

Aren't there any examples of a runner games like "Canabalt" or something like that?

Thanks!
Page 1 of 1
« first « previous next › last »