Id like some advice on a logic issue

● ARCHIVED · READ-ONLY
Started by Monkey BizNiz 3 posts View original ↗
  1. Hey guys,

    Im looking for some advice and hopefully an example on what would be a very fast method to have the game check if a bunch of events are on the same tile.

    Lets say I place 20 different events on the map, who all do random movement and can move on eachother, id like to have a function that would quickly keep checking how many and which events are collided with eachother.

    I could make a loop that would check literally every tile on the whole map and see which one has multiple events on it, but since there are only 20 events, i feel like that it could get checked way faster.

    I also had this idea to somehow have a loop only check on each of the coordinates that currently contain an event, but I dont know how to make that.

    Please ask if I havent been clear enough

    Thanks in advance,
  2. you can do it with a hitChecker

    start take a look with this
    PHP:
        function hitCheck(a, b){ // colision
            var ab = a._boundsRect;
            var bb = b._boundsRect;
            return ab.x + ab.width > bb.x && ab.x < bb.x + bb.width && ab.y + ab.height > bb.y && ab.y < bb.y + bb.height;
        };

    also take a look in bounds
    http://pixijs.download/dev/docs/core_display_Bounds.js.html#line13

    If you use rmmv system, you can use this but you need create your own bounds obj with the event x,y.
    If you use pure pixijs for your event, you only need to use getBounds
  3. @Jonforum I probably shouldve mentioned it was intended for rpg maker mv. Also I dont really understand what those a and b should be filled in with; the event Ids? Also if thats the case what is _boundsRect supposed to be? As far as i know events dont have the width and height attributes... I know a bit about the javascript basics, but not a whole lot more than that. Im a bit lost