R0J0hound's Recent Forum Activity

  • I mean ignoring hierarchy, waits and such to have the fireball shoot one way or another based on if the enemy is mirrored could be simple as:

    Every 1 seconds
    For each enemy
    — enemy: spawn fireball at imagepoint “mouth”
    — enemy: is mirrored
    — — fireball: apply impulse at angle -30
    — else
    — — fireball: apply impulse at angle 180+30

    Anyways, the relevant part is the “is mirrored” check. And generally if logic works for one enemy but not consistently with multiple then you can put that logic under a “for each enemy” event.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Maybe they are trying to make a merge game? And whatever they tried only works for one instance based on the “note”.

    We are missing information.

  • Couldn’t you just do “$”&TotalCash/100

  • Nope. The only vanilla plug-in way to do it is with mesh distort with some math. Beyond that you have to use 3rd party plugins. Reach out to the devs of the plugins on discord. They may very well be able to port it to v2 or the sdk.

  • I can never recall the name of the plugins.

    If you mean the 3d shape object that comes with construct then no, it only lets you rotate around the z axis.

    If you branch out to third party plugins such and “3d object” or third party behaviors such as “3d rotate” then you can rotate around more axis’ fairly easily.

    I haven’t really used them though since I’m more interested in exercising my mind to be more familiar with the math involved.

  • Since I made the example linked in the original post here it is tweaked to allow for tweening:

    dropbox.com/scl/fi/s234ich05y6bkli6uw6ws/card_flip3.c3p

    Hey! In Construct 3, since it's a 2D engine, simulating Z-axis movement usually means faking depth using scale, position, or layering.

    While it's true construct is primarily a 2d engine it indeed has real depth and a depth buffer if you want to utilize it. The original example and the updated example take advantage of it.

  • I mean at a glance it looks to be a long and complex solution. Probably can be simplified a lot. But that would require breaking it down to figure out exactly what it’s doing and why.

    But I guess I’m not a fan of llm ai code. Debugging, testing and cleaning up code is time consuming and I’d rather not do it if I can.

  • Whoa. Thats a lot of code. Hard to pick out the relevant parts. Well, as long as it works for your use case.

  • That example sets the zelevation so that probably overwrites a zelevation tween. So you could probably tween a value and add it the action that sets the zelevation.

  • What solution did you end up with?

    My first thought is you could mark all the squares horizontal, vertical from the start square and limit the end square to one of those.

    Pick cell by expression
    (Cell.x=start.x) | (cell.y=start.y) | (abs(cell.x-start.x)=abs(cell.y-start.y)
    Pick cell closest to touch.x,touch.y

    Alternately you could do some math to calculate the end tile on the closest 45 line.

    set ang to round(angle(start.x,start.y,touch.x,touch.y)/45)*45
    Set step to abs(ang)%45=0?cell.width:cell.width*sqrt(2)
    Set dist to round(((touch.x-start.x)*cos(ang)+(touch.y-start.y)*sin(ang))/step)*step
    
    Set endx to start.x+dist*cos(ang)
    Set ends to start.y+dist*sin(ang)

    Basically it finds the closest 45 degree line, then projects the touch position onto that, and rounds to the nearest cell.

    There may be a simpler solution too.

  • So it doesn't work because it can go vertical or horizontal sometimes? We can modify the formula further to only have angles at 45 degrees. Probably this:

    round(((sprite.bullet.angleOfMotion+45+360)%360)/90)*90-45

    For a single object you could also basically do the motion manually with two variables for the x and y velocity, then use overlapping at offset to see when to bounce. Logic would roughly be:

    start of layout
    -- sprite: set vx to 1
    -- sprite: set vy to 1
    
    sprite: overlaps wall at offset sprite.vx, 0
    -- sprite: set vx to -self.vx
    
    sprite: overlaps wall at offset 0, sprite.vy
    -- sprite: set vy to -self.vy
    
    every tick:
    -- sprite: set position to self.x+self.vx, self.y+self.vy

    However that doesn't work well if you have multiple moving objects that you want to bonce off each other.

    For a more deluxe and precise way you could move overlapping objects out of each other and calculate the collision normal at the same time to bounce off of. Construct doesn't have a built in way to do that so here is a way to do it between axis aligned boxes by utilizing an algorithm called the Separating Axis Theorem.

    dropbox.com/scl/fi/ac5ihr1qp0xpmoj7mtskh/perfect_bounce_w_sat_collision.capx

  • Change angle to sprite.angle or whatever name you gave the object.

    Or since you are using the bullet behavior with “set angle” to no, you’d want to use the action:

    “Bullet: set angle of motion” and use dop’s formula with

    round(((sprite.bullet.angleOfMotion+360)%360)/45)*45