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 ShawnSwander

I've tried some things but its not working.

My game is like a board game with an overhead view players move up to 3 tiles per turn. When the player moves over a water tile I want to stop his movement for that turn. When he moves over sand I want it to reduce the number of tiles he can move from 3 to 2. I also would like to play sound files when the player moves on a water tile. How do I implement special behaviors when a player moves on a specific tile. Nothing I've tried works well.

1 decade ago by jswart

Could you make a new ' empty ' entity. One that renders in Weltmeister but not in-game. Then check for player collision with this new 'environment tile (entity)' and then check it's type.

// pseudo-code

    if ( player.isColliding( environmentEntity ) ) {

        switch ( environmentEntity.type ) {
             case 'sand': //do stuff
                 break;
              //...
        }
}

Basically do a trigger entity like dominic did in the tutorial video, but add the additional features you need.

1 decade ago by der_r

Another way is to use the getTile() function of the corresponding Map object. It takes a pixel-position as parameters and gives the tile number.

1 decade ago by ShawnSwander

@der_r yeah I finally was able to do it with getTile() there wasn't any examples of this in the documentation. Here is a snippet for anyone who wants to do the same thing.
switch(ig.game.backgroundMaps[0].getTile(this.pos.x,this.pos.y)){
										case 18:
											impedance_message="Your motion is slowed by the sand."
											movelimit=2;
										break;
										case 22:
											movelimit=1;
										break;
										}
Page 1 of 1
« first « previous next › last »