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 Ant101

Hi,

Sorry for the barrage of questions recently - they've all been based around the same theme, but I wanted to rephrase what I'm asking:

I'm trying to create a 'trampoline' which will cause the player to 'jump' very high when he lands on it.

I had originally planned on doing this as a tile, with a custom collision type, which I would detect from handleMovementTrace(). However, I'm having problems with that approach (mainly related to reliable detection - see my thread: detecting-static-tile-y-collision-when-walking but maybe I'm doing that wrong.).

The other approach (which seems to be the more 'impact' way of doing things) is to have the trampoline 'tile' as an entity, and react to collisions using the entity-erntity collision detection mechanism.

What do others think? Are both approaches practical? Would you usually use one or the other?

Thanks

1 decade ago by alexandre

I would definitely create a plugin entity similar to, and possibly extending one of, the ones in the biolab entity pack (mover, trigger, etc).

1 decade ago by drailing

hi,

i used something like an trampoline in my WIP verison of portal imPortal - see 2nd level.

so here is my "accelerator" entity - you can configure it in every direction and to every power. if you set power_x = 0 you have a trampoline:


ig.module(
	'game.entities.accelerator'
)
.requires(
	'impact.entity'
)
.defines(function(){

EntityAccelerator = ig.Entity.extend({
	
    checkAgainst: ig.Entity.TYPE.A,
    gravityFactor: 0,
	
	size: {x: 8, y:5},
	offset: {x: 0, y:-1},
	animSheet: new ig.AnimationSheet( 'media/jumper.png', 8, 8 ),
	
	direction: "right",
	power_x: 100,
	power_y: 100,
	
	timer: new ig.Timer(),
	
    
    init: function( x, y, settings ) {
        this.parent( x, y, settings );
        
        this.power_y *= -1;
        
        this.addAnim( 'idle', 1, [0] );
		this.addAnim( 'jump', 1, [1] );
		
		this.currentAnim = this.anims.idle;
        
        if(this.direction == "left"){
        	this.power_x *= -1;
        	this.power_y *= -1;
        }
    },
    
    update: function(){
    	this.parent();
    	if(this.timer.delta() >= 0){
    		this.currentAnim = this.anims.idle;
    	}
    	
    },
    
    check: function(other){
    	other.maxVel.x = (this.power_x > other.maxVel.x)?this.power_x : other.maxVel.x;
    	other.vel.x = this.power_x;
    	other.vel.y = this.power_y;
    	this.currentAnim = this.anims.jump;
    	this.timer.set(1);
    }
    

});


});


note: you need to set the maxVel object back to normal values in one of the update method from the accelerator or your player entity.

and proudly presenting the handdrawn spritesheet!

1 decade ago by stahlmanDesign

An entity like drailing's accelerator is definitely the way to go.

@ drailing, I tried your plugin and it works great. In a race game, setting power_y to 0 is like a speed boost for going sideways.

1 decade ago by Ant101

Thanks both of you. So the consensus so far seems to be that entities are the way to go... So no one has used tiles for this?

1 decade ago by Ant101

(all three of you I mean!)
Page 1 of 1
« first « previous next › last »