R0J0hound's Forum Posts

  • JackieChan

    Here's another idea for your list. Basically at the start of the layout the solid objects are duplicated to somewhere way off screen. That would be like a second collision layer where you can disable/enable the solids independent of what's on screen.

    So to use it here's the capx. Player1 is on the on screen solids and player2 is on the offscreen duplicate and a clone of player2 is positioned on-screen.

    https://dl.dropboxusercontent.com/u/542 ... sable.capx

  • Here's a list of ways:

  • It's the same key on the keyboard, so the keycode would be the same. I guess you could also check if shift held down.

    Here is a list of the keycodes reported by javascript, which C2 uses:

    http://www.cambiaresearch.com/articles/ ... -key-codes

    97 is Numpad 1 in that list.

    I think what you wanted was the charCode which could give you a 97 for "a", but the keyboard object doesn't provide that.

  • Ok, I had a look at the op and your capx since my previous post was about finding that setting. I don't see in what way the quality is bad. Are you referring to the art becoming slightly blurred because it's becoming bigger from everything scaling up so the canvas fills the screen? You could stop that by turning off fullscreen scaling by changing the project property "fullscreen in browser" from "letterbox scale" to "off".

  • [quote:1n1736en]- On ObjA collision with Marker + Pick instance of ObjB by UID stored in ObjA:

    • - If Marker.variable = 1: ObjA do thing 1; ObjB do thing 2
    • - If Marker.variable = 2: ObjA do thing 3; ObjB do thing 4

    As typed it should act exactly like your expected result. If it doesn't there must be some other events effecting it.

    Can you show an image of your event or maybe a capx.

    Edit:

    alextro

    Doesn't the on collision event pick both the ObjA and Marker? I guess I'd have to test it but I haven't had to do something like that as I recall.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • signaljacker

    I don't think you can use the action to do that, the recursion is unavoidable. The best you could do, I suppose, would be to every other frame hide the paster and then call that action the next frame and make it visible again.

    On another note, I wouldn't recommend using the "Load texture from canvas" action, as it doesn't work reliably and doesn't work at all on a lot of browsers.

    This link may be helpful though. It has an example that will paste all the objects of a layer with the correct zorder. It just requires all the object type you want to paste to be added in the events. At the very least it will help until I get ambitious enough to add layer pasting into the plugin.

  • This would do it. Note the tab means it's a sub-event.

    repeat distance(sprite.x,sprite.y,mouse.x,mouse.y) times
    --- sprite: move 1 pixel at angle(sprite.x,sprite.y,mouse.x,mouse.y) degrees
    	sprite: overlaps wall
    	--- stop loop
    	--- sprite: move -1 pixel at angle(sprite.x,sprite.y,mouse.x,mouse.y) degrees[/code:1l6cma2z]
    
    Edit:
    Opps, that will do it instantly
    
    You can make it move gradually, say 100 pixels per second, with the following:
    [code:1l6cma2z]repeat min(distance(sprite.x,sprite.y,mouse.x,mouse.y), 100*dt) times
    --- sprite: move 1 pixel at angle(sprite.x,sprite.y,mouse.x,mouse.y) degrees
    	sprite: overlaps wall
    	--- stop loop
    	--- sprite: move -1 pixel at angle(sprite.x,sprite.y,mouse.x,mouse.y) degrees[/code:1l6cma2z]
  • You could still use the bullet behavior. Just have it disabled until you want to bounce. Then when you want to use the bounce you enable it, set the speed and angle of motion from your variables, use the bonce action, then set your variables from the bullet's speed and such, and finally disable the behavior.

    If you want to do it with events, here's one way:

    1. when the object collides with a wall, move it backwards till it isn't with a loop.

    while

    object is overlapping wall

    --- object: move -1 pixel at angleOfMotion degrees

    2. Next we need to find the angle between the object an the wall. One way you can approximate this is with detectors sprites or checking if points around the object collide with walls.

    3. Then you can bounce by setting the angleOfMotion to 2*normal+180-angleOfMotion.

    https://dl.dropboxusercontent.com/u/542 ... ounce.capx

  • If you reuse the 512x512 sections more than once then separate objects or a tilemap would save you on vram usage. If each section is unique then you may as well use just one sprite.

  • Well, I was thinking of a complete event solution. I've done the astar algorithm many times before so it was pretty easy to get going with thin walls. It only works with one object and isn't setup to go as fast as possible so it may not be useful. In it the nodes collide with other nodes it's connected to.

    https://dl.dropboxusercontent.com/u/542 ... nwall.capx

  • Hmm...

    Are you using arrays to do this or is it just laying down sprites?

    If you're using an array to do this then you could loop over the array and create a wall where the floor isn't. Actually a tilemap would be better and done in the same way.

    If those are just sprites, then it may take a different approach. It's an interesting enough idea that I had a go at it:

    https://dl.dropboxusercontent.com/u/542 ... _edge.capx

  • I don't think a plugin could be made to understand a tilemap like that. Your image is vague but I guess the walls are on the edge of the tiles? No idea if you can do this with existing behaviors, but what you'd need to do is loop over all the tiles of the tilemap and build a mesh of movable area and then pass that to the behavior.

    Or if the existing plugins can't do that, it's possible to do it with events.

  • A bounce is basically done after a collision. Basically the steps are:

    1. check for collision

    2. resolve the collision by moving the object out of the other so it's just touching

    3. find the angle of the edge of the object where the object's touch. This is the collision normal.

    4. using the normal calculate the new velocities. This can be done with the angleOfMotion and the normal angle, or with the xy components and some vector math.

    2 and 3 are the more involved ones. The simplest for 2 would be to just move the object backwards till it's not colliding. Calculating the normal with 3 can either be done with detector sprites to get a good approximation or you can do some math with the object's geometry (typically polygon or circle) and calculate a exact normal. Another way to handle both is to use SAT (separating axis theorem).

  • I think you can make it a global layer.

  • This topic is probably relevant:

    Basically you'd need to use some kind of 3d to do it.