00Rez's Forum Posts

  • It seems the .capx still uses a collision box?

    EDIT: I removed all the code that checks for collision. It runs perfectly and at 59fps when there are many squares to check. So it seems OK.

    Next step. What happens when I have multiple instances of the object which checks as well?

    Don't know what happened with the link DropBox didn't update the file properly I think it *should* be the new version now...

    Is this what you mean?

  • Don't use invisible collision objects! It could make it run much slower than the loop I described using events only.

    Remember the way condition works already has a built-in 'for each'. So an event reading 'A overlaps B' means 'For each A: test if overlaps B, and remember both instances if so'. Therefore, using an object to test overlap of nearby objects still tests every single instance in the game. Worse, collision checks can be much slower than just measuring the distance. So I would strongly recommend you do not use a big overlapping sprite - just use something based on the events I posted, it's the fastest and simplest way.

    Whoops sorry about that! Thanks for that Ashley. A forgot to think about how the collision works :/ I've updated the links to take out the collision square! Just uses your method now... <img src="smileys/smiley5.gif" border="0" align="middle" />

  • A .capx would be nice... they are always very informative!

    You're lucky I managed to do this at work! It's here. Hope this helps you and anyone else!

    The block points itself to the nearest purple enemy. You can see the collision box!

    Edit: Here's an exported version if you just want to see it in action!

    Edit2: Updated links to take out the collision test. Now they only use Ashley's method!

  • No, the range is relatively small.

    However, this UID and looping is part of what is confusing to me about construct. SO what am I to do? A large invisible circle around the object? I am still a bit confused.

    Every object has unique ID (UID) in Construct and is used to select a specific object (no two objects have the same UID). Of all the ways to do it you will still have to loop through all objects you want to test the distance to. To optimise this and make it faster you would need to make sure you do the bare minimum with events to each object only focusing on the objects that matter. So:

    Use paint or whatever to draw a square say 320x320 pixels in size (or whatever the largest distance is you want to check) fill it pink or whatever (doesn't matter), set this as a new object call it rangeCollisionBox or whatever, set opacity to 80 just so you can see whats through it. Set this objects visibility to "invisible" you don't want to see it when you run the program. Setup the events so that every "tick" the rangeCollisionBox is positioned at the players position or do this every time you want to check the nearest object.

    Next, do a "for each" on every object you're checking the distance to then add a sub event underneath this which checks whether the objects are overlapping the rangeCollisionBox. If they are then perform Ashley's algorithm on each of these.

    I'm not 100% sure this is right and 100% sure it makes sense as I can't test at the moment. I hope it helps <img src="smileys/smiley5.gif" border="0" align="middle" /> I'll see if I can knock up a capx tonight.

    Edit: If Ashley made the nearest function and it used his method you could still use a collision box to filter the objects.

  • love the improvements rez,

    hope you don't lose the 'retro' graphic opacity zones of the first test. that has dungeon crawl written all over it...lol.

    love the smoothness of the latest tests as well.

    my half-orc 'grogan t. blackblade' awaits your progress.

    <img src="smileys/smiley1.gif" border="0" align="middle" /> If I can find a quicker way of rendering shadows then this would be easy just a play on opacity. Another way is to limit the range so when you render the light it only uses a few objects for lit squares but I still need to find a quick/good way of doing this. Then you would have a dark layer over everything then use light objects to cut out the dark layer like the way the light works in my demos, hopefully that would speed things up! Then there's making it as easy as possible for everyone... <img src="smileys/smiley5.gif" border="0" align="middle" />

  • A couple of subevents makes it fairly easy. You don't need an array - just two values for 'closest so far' and 'closest UID'. Local variables would be good for those. The algorithm works like this:

    1. Set 'closest so far' to a large number e.g. 999999, and 'closest UID' to -1.

    2. For each object:

    ---a) if the distance to this object is less than 'closest so far':

    -----> set 'closest so far' to the distance to this object

    -----> set 'closest UID' to this object's UID

    3. Pick object with UID = 'closest UID'

    ---> do something with this instance - it's the closest

    Combine this with jayjay's idea of having a large invisible square/circle object (collision mask) so you pick only the objects within it/overlapping it, then you wouldn't have to worry about having lots of objects to iterate through. Unless you needed the range to be really big then this would be pointless as you would have to iterate through all objects anyway.

  • > It's probably still not been updated for r51:

    >

    >

    > > "cr.plugins" has been renamed to "cr.plugins_" (trailing underscore) for better name mangling./QUOTE]

    >

    > Thanks Ashley.

    When exported the functions don't work. <img src="smileys/smiley19.gif" border="0" align="middle" />

  • Another update! Just a few more tests. See first post.

  • It's probably still not been updated for r51:

    > "cr.plugins" has been renamed to "cr.plugins_" (trailing underscore) for better name mangling./QUOTE]

    Thanks Ashley.

  • Bump, fixed things. Hooray for the holidays. I'm working on some new plugins now!

    EDIT: I've made a function plugin, you can download it here. If anyone could please test and I'll fix any bugs with it before I add it to the main post.

    Hey, the function plugin seems to work great but when I add and use the plugin and preview it shows:

    <img src="http://dl.dropbox.com/u/19078872/assert.gif" border="0">

    After clicking OK everything is fine. Unless this is something I've done? I just unzipped the contents to the plugin folder inside a folder named "function".

  • Picking the nearest object would slow down games a lot - instead of taking the first picked (which seems to you to be random), it would have to check every single instance measuring its distance. If you have 100 object instances, that's 100 times as much work, and it affects every single condition!

    You can add a for-each loop yourself to test each individual instance's distance. I'll see if I can add a 'pick closest' for the next build.

    Damn iterations!! An idea I might use is to have some kind of list/array of all specified objects and an associated distance to whatever target then use min(a,b,c...) to find the the smallest distance or max(a,b,c...) to find the largest distance or maybe an array/list which sorts itself as objects are added from smallest to highest then you can pick the first for nearest and last for furthest. Each has its pros and cons but there's a few ways to do it whilst trying to keep away from the iterations... <img src="smileys/smiley5.gif" border="0" align="middle" />

    I tend to think of the most complicated way of doing something so there's probably simpler methods.

  • Your plugin is fine, don't worry. Good work :)

    It's my poor understanding of JavaScript that's the problem. I'm endeavoring to rectify my failing :)

    Definitely worth learning zenox!!

  • I agree, that would be a very useful function. Seems strange that it's not already available, got used to that in Game Maker <img src="smileys/smiley17.gif" border="0" align="middle" /> quite easy to implement as a plugin but would be better to be in the main built-in System object.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Families!! <img src="smileys/smiley20.gif" border="0" align="middle" />

  • Now averages around 57 FPS - much better :)

    That's great! Still more to do...