Multiple Overlapping Objects

0 favourites
  • 5 posts
From the Asset Store
Be quick and choose the right answer for the shown equation.
  • Hey guys, just need a little bit of help on a game I've been working on.

    The whole point of my game is to take pictures of a night sky, and you're basically rewarded for a picture that has the largest amount of things in it.

    So I have randomly spawning meteors, stars, and a moon that follows a path. It's up to the player to try and time their photo correctly, and score the most points on it.

    The screen is divided into 9 sections, and the arrow keys navigate around these sections. When spacebar is pressed, a photo is taken, and this is where I would want the score to be calculated.

    The problem I am having is figuring how many meteors and stars are within the currently selected section.

    I've looked at this thread, but there's one issue. My overlapping object is not circular. If I were to use this, I'd get a lot of false positives on if the selected screen is actually overlapping a meteor or star.

    So basically, what is the easiest way to count up how many objects are overlapped by a rectangular object?

    Here's the game if anyone is interested.

    Thanks in advance.

  • It's actually pretty easy if you stop to think about it.

    The guy is checking the distance from each object to a master object, therefore he gets a circle, since they're 300 pixels away from a point in every direction.

    Your case is even more straightforward: instead of checking for distance, check whether objects are within a set of X and Y coordinates.

    for instance, object's X position is greater than 0, less than 640, and it's Y position is greater than 0 and less than 480, you just covered a 640x480 rectangle in the top-left corner.

    Easy isn't it? Rectangles and circles are the easy part, it gets a lot more complex once your area is some weird concave irregular polygon, but it appears you won't be needing that.

  • You can check if the lens object is overlapping an object and then object.PickedCount will tell you how many it's overlapping.

    moonStarMeteorOverlapping.capx (r99)

  • That's even better than my method.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Well thanks for the help, I figured there would be some expression or something simple I was missing.

    Thanks Ramones and Fimbul, I really appreciate it.

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