How do I Resizing on Collision, Comparing size of 2 objects.

0 favourites
  • 3 posts
From the Asset Store
220 Food Sprites in 16x16 pixel size. Perfect for items for a retro style game.
  • Hello guys, I am totally new to programming its self, however I understand it fairly well, however I got some issues with finding certain ways / expressions to what I want to achieve. Hopefully I will get some help here.

    So, what I want to do:

    A) If player collides with another object, it should check wether the player is bigger or smaller than that object ( in actual pixel count )

    B) If the player is bigger than the object, than the player should change size by 10% of the object size that it has collided with.

    C) If the player is smaller that the object, than the player should decrease in size by 10% of the object size that it has collided with.

    * The thing is, that my player will collide with lots of different shapes, and I really do not want to take just width / height in the account, I would like to take in the account the actual size of the object, I think that something like pixel counting ( after eliminating transparency ) would be best solution, if at all possible.

    Thank you very much & please accept my apologies for my rather bad English.

  • What are you going to base the 10% on ? the number of pixels in your player vs the number in the other object? If so how will you alter it's size if not by using the height & width.

    Counting pixels will be a relatively slow process if there are lots of objects or the game is fast moving. If you really want to do it you could check out the canvas plugin. This will give you a way of calculating the actual number of pixels which are anything other than transparent.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanx for a hint.

    Could you please be little more descriptive about "a way of calculating the actual number of pixels", I am poking around,but I cant find the way :/

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)