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 Braxton

I have been banging my head against the wall to figure this out, any help added is extremely welcome! So essentially the user can blast a hole through the CPU player using a laser. Once that hole is in the CPU other entities that can fit in the hole can pass through the CPU. So I was thinking to simulate the a hole, I would use clearRec to clear a line of the CPU on the size of the laser. something like this:
ig.system.context.clearRect(this.pos.x,this.size.x,laser.pos.y,laser.size.y);
but this doesn't work just clears the canvas and not the entity.

From there I was thinking using something like this to make the entity pass through the hole created:
http://impactjs.com/forums/help/passing-through-entity-from-only-one-direction

Anybody have any idea on how to help me?

1 decade ago by Graphikos

This is just visual right? Why not just change the animation sheet to something with a hole in it? Using clearRect() is always going to clear anything and everything in the context.

1 decade ago by Braxton

Let me rephrase, I need to be able to have the part of the collision on an entity removed. Maybe this img might help!
/>			</div>
		</div>
			<div class=

1 decade ago by Graphikos

How large is this entity? If you can break it up into multiple entities/tiles you'd be better off. Either way... sounds like quite the challenge.

1 decade ago by der_r

you could create an entity for each hole and then use logic

if collides_with_main_entity and not collides_with_any_hole_entities then overall_collision=true;

1 decade ago by StuartTresadern

If the entity does not need to move and only requires simple animation I would look at using a map layer with tiles and remove the collision and tiles as required (as Graphikos said). If it has to be an entity then maybe look at detecting the collision spawn two new entities using the collision info for size / position and kill the current entity sort of a split InTwo Entity.

1 decade ago by Braxton

so lets say its 120px, do you think its possible to have 120 entities moving in unison? Or would this be too much?

1 decade ago by StuartTresadern

Its possible but I suspect not playable !!!. Can you explain in more detail how this large breakable entity needs to move etc.

1 decade ago by Braxton

that red rectangle in the picture is similar to a pong paddle, it would move maybe within 600px on the up and down on the y-axis? The more I explain the less I think this is do-able! lol

1 decade ago by beardedbuddha

How about doing it something like this:

Make the enemy entity collide so things can pass through it (COLLIDES.PASSIVE)
You will still be able to detect collisions though and handle them with some logic.
So when you shoot the hole in him, you set a property on him, indicating that
the player can pass through)

Then you handle the collisions something like this:

If player collides and hole==false, set player x vel to 0 (or maybe throw him away) and apply damage.

If player collides and hole == true, get the collision coordinates.
If the coordinates are between two values (that correspond with the hole in the sprite) then let him pass through (don't alter his velocity)

This was written on a phone on a bus without looking anything up. Sorry if this is horribly impossible..

1 decade ago by beardedbuddha

Of course you would need to control the y pos and .standing properties of the player while he is "inside" the enemy entity..

1 decade ago by beardedbuddha

Another approach could be to solve the problem with semantics instead of code.
You could make it so that the enemy entity could technically always be passed through, but until you shoot the hole, the player is destroyed if he gets too close ;)

Not sure how well this would work in your game world, but it sure would be easier to code..!

1 decade ago by paulh

check against the pixels?

http://impactjs.com/forums/code/per-pixel-collision-detection-plugin
Page 1 of 1
« first « previous next › last »