Condensing Collision Detection Into Less Events/Sprite Spawning

0 favourites
  • 6 posts
From the Asset Store
Very simple code without excess options (15 events for server and 11 events for client)
  • I've been trying to keep myself within the bounds of the 50 free events for my first endeavor into Construct 3, but with my collision events, that doesn't seem possible. I know eventually I'll get the license for more games now that I've had a good feel for the platform, but still, I may be doing something wrong here. My collision detection for the player sprite alone is nine events, and I haven't even added in the destroyer events for sprites going off screen (though I suppose I could just wrap that into destroy when off screen). Figured I'd ask here though and see if anyone knows of a cleaner/more simplistic way to handle collision detection where it doesn't chew up all my events.

    I've also got another issue around spawning things in my game. The game is an infinite runner, so the player has no left/right movement, just a jump action, and unfortunately using random(#) to spawn my obstacles isn't working. There are certain points where the spawns are just too far apart for a jump, or at just the right distance apart that they can't execute two jumps in succession fast enough, no matter the timing. What I'm wondering is if there's a way to tell the program of a sweet spot for tree spawning. Like "if last spawn is within x distance, you can trigger, otherwise, wait until it is x distance from spawner to send the next one." Seems complex and unlikely, but I thought I'd ask.

    I suppose I could keep playing with the random numbers and stagger them a bit to get the desired effect, but wanted to ask just in case.

    Thank you!

  • Since they are all trees you could just make them all one type and use different frames or animations to look like the various trees. That would save on events.

    For the random id go for something like this which would make each tree at closest 0.5 sec apart.

    Var next=0
    
    Next<time
    — set next to time+random(0.5,5)
    — spawn tree
    — tree: set frame to int(random(5))
  • R0J0hound -- It's stuff like this that reminds me how new I am not only to Construct, but just programming games in general. I don't know that I ever would have thought of that on my own, but it's a smart way to approach something like this. Thank you so much!

  • Weird that I cannot edit. Sorry for the double post, but I attempted to try the code and, well, I think we might have miscalculated here LOL. I'm going to play around a bit and see what I come up with, but thought I'd share what ended up happening because it made me laugh.

    Thanks again!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The variable is a local variable, so it resets every frame. You can edit it and make it static, that will make it remember it's value.

  • Ah; my globals had been setting static by default, so I was missing that it wasn't checked off for local variables. That worked by the way. It's still not *quite* the result I am looking for with my spawns, but it's a start. I think the spawning is honestly going to take up the majority of my time in figuring out because it needs to start out simplistic at first, and progressively get harder, and I'm not quite sure how to achieve that yet.

    As an update, I have now moved to the paid version, as after the core game (which could have probably made it within 50 events), the rest would not, so now I'm just hammering away adding in things that I want to see in this game. It's shaping up to be quite a starter project in C3, but I'm learning so much. The tree sprite trick was super slick though. You'd never know any other way that it wasn't eight separate sprites for the eight tree formations I have.

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