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 Imran

Hey again all, I've been able to start modifying level geometry on the fly to create a "treadmill" type effect as seen here:

LevelTest.layer[1].data[8].shift();
LevelTest.layer[0].data[8].shift();
LevelTest.layer[1].data[8].push(2);
LevelTest.layer[0].data[8].push(1);

The big issue I've been having with this is that I can't seem to add to the end of a an array for a level row without removing another entry of the array (effectively locking the horizontal size of the level to 10 pixels in a stage), since my character is moving from left to right, I need to basically have the level "generate under his feet" and I can't do this if I'm locked to those 10 pixels.

Any suggestions, guys?

1 decade ago by dominic

I'm not sure I understand what you want to do. Did you have a look at the source code for Drop? This game generates the level dynamically. It removes the first row, adds one at the end and moves all entities up by 8px (the tilesize).

If you don&039;t want to remove the first row of the array, but really want the level to grow, you can just append your new rows *and* adjust the map's #.height to account for the new row.

1 decade ago by Imran

Ah, I think that was the piece I was missing Dominic, the idea of moving ALL entities back by one tile unit.

Also, thank you for referring to the height for me, I forgot that I need to adjust it to make the map grow.

Thanks again for the help!

Imran

1 decade ago by Imran

Hi Dominic, since I'm doing a horizontal platformer I'm adjusting the width of the map instead of the height. However, even though I'm adjusting the width and adding to it, it's not showing up (I only see changes when I delete a piece of the map first).

Any ideas? I'm basically trying to do a platformer like Biolab and have levels generate procedurally like Drop.

Thanks,
Imran

1 decade ago by dominic

It should work the way you describe it.

Do you maybe use the Camera Class from Biolab? Maybe it should doesn't scroll far enough, because it's still bound by the initial width you gave it?

Upload your game somewhere and I'll have a look.

1 decade ago by Imran

Hi Dominic, I am in fact using the jumpNrun demo as a base, so if that uses the same camera class from biolab, then that's the one we're working with!

Here's the code from my main.js - I'm just trying to test popping blocks in and out using this command:
if(ig.input.pressed('pop')){
	console.log("popping!")
//	console.log(LevelTest.layer[1].data[9])
	console.log(LevelTest.layer[1].width)
	LevelTest.layer[1].width++
	LevelTest.layer[1].data[9].push(2);
	LevelTest.layer[0].data[8].push(0);
}

However, while it does change the width of said array, it doesn't actually add any blocks to it. Hopefully knowing that I'm using JumpNRun as a base for this can provide some more answers.

Thanks,

Imran

1 decade ago by dominic

Oh, it seems you&039;re changing the width of the LevelData - the JSON object containing the "raw" level information _before_ it is loaded. If you call #.loadLevel() it will take that level data and create a bunch of BackgroundMap, a CollisionMap and all the entities.

Modifying this level data after it has been loaded, won&039;t have any effect. You have to change the #.width on the ig.game.collisionMap and the BackgroundMaps in the ig.game.backgroundMaps array.

1 decade ago by Imran

Dominic - I did not know that!

Thanks for the tip, sir - I hope you had a good time at onGameStart!
Page 1 of 1
« first « previous next › last »