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 tenix

Hey guys two questions. I'm sure I could figure this out with time, but I'll ask here first in case someone has done it already and has some pointers. I'm looking to add collision to the outside border of the map on every single map. This would be a great 1.21 feature check box :). I know I could make a 1 pixel collision box and place it all around but that becomes tedious and there must be an easy way.

Also, I'm wondering if there's an easy way to stop the camera from moving and seeing black screen when you reach the map bounds.

Great community. Thanks

1 decade ago by StuartTresadern

Use a couple of marker entities to mark the bottomLeft and TopRight which you can then place in the level with the editor. You can then use these to set the Max and Min values for your camera when you load the level. Are you using a separate camera class ?.

1 decade ago by tenix

Got the camera working with something basically like this

if(this.screen.x >= ig.game.collisionMap.pxWidth - player.pos.x){
				this.screen.x = ig.game.collisionMap.pxWidth - ig.system.width;
			}

Now I need to figure out how to add collision on all sides

1 decade ago by tenix

Nevermind, I'm dumb that doesn't work

1 decade ago by StuartTresadern

Take a look at this thread http://impactjs.com/forums/help/screen-scrolling Dominic shows the camera class code and explains how to use it. I use the same code but add a couple of entities for my limits but you could base the limits on any of the map layers.

1 decade ago by tenix

Got it thanks. Not sure if this is the "right" way, but it works all around on all sizes of maps for me.

			if(this.screen.x <= 0){
				this.screen.x = 0;
			}
			if(this.screen.y <= 0){
				this.screen.y = 0;
			}
			if(this.screen.x >= this.collisionMap.width * this.collisionMap.tilesize - ig.system.width){
				this.screen.x = this.collisionMap.width * this.collisionMap.tilesize - ig.system.width;
			}

			if(this.screen.y >= this.collisionMap.height * this.collisionMap.tilesize - ig.system.height){
				this.screen.y = this.collisionMap.height * this.collisionMap.tilesize - ig.system.height;
			}

1 decade ago by tenix

Now back to the collision on outer edge :)

9 years ago by SirPereira

@tenix for this to work, you always need to specify a collision map, right?

You did specify it around the map, right?
Page 1 of 1
« first « previous next › last »