Collisions / images

philippe68

  • Posts: 7
Hi,
I follow the tutorial "Working wtih images" but the part with the " get pixel"was not clear enought for me
I don't understand how it works.
I would like to delete a part of an image et make actors go through it but I do not understand how I can give collision to my image and how collision will act while I'm deleting th image
thanks for your help
Phil

Luyren

  • *
  • Posts: 2646
l'd use an actor for your terrain with a sensor collision. Whenever your player or other actors collide with it, you'll have to loop through that actor's collision edges, and if it finds a non-transparent pixel in your terrain, stop its movement in that direction. That would be my first idea.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter

philippe68

  • Posts: 7
Thanks a lot
I 'll try this evening......but to be clear I would like to delete part of my image not all of it
In fact How can I handle the terrain like Bazooka boy ?

Luyren

  • *
  • Posts: 2646
but to be clear I would like to delete part of my image not all of it
You'll use the clear image block for that, as described in the Stencylpedia article, by using the image of another actor as the mask.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter

philippe68

  • Posts: 7
Yes I Understand that and it works pretty well, but then how manage the collisions of the new shape of my image
First my actor is stuck by the image then when something delete it , the actor can move throught it.  How can I handle those collisions?
Thanks for your patience and sorry for my bad english

Luyren

  • *
  • Posts: 2646
This is more complex than just saying "do this", and requires some thinking outside the box. Unless you are currently working on a game with these features, it is ok to work on something else simpler first, get more experience and then go back to this.

That said the collision detection is what I described in a previous reply. You player, upon a sensor collision with your terrain actor, will compare a point in its position (for instance the point corresponding to its feet on the ground), and look for non-transparent pixels in the image of the terrain actor, using the "get pixel" block. The get pixel block as number returns 0 if there is no pixel in the given position, for the record. If your actor finds a non transparent pixel, you run the code to make it grounded and prevent it from falling through.

You'll need to manage the image of the terrain that can be destroyed as well, so there are a bunch of moving pieces in this system, but this is the genral idea. Anything more specific than that will require you to post the code you made so far so we can comment on it.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter

philippe68

  • Posts: 7
Ok fine I'll work on it and come back later
thank you Luyren