R0J0hound's Recent Forum Activity

  • Prominent

    I forget exactly where. Search for "poly" in the runtime.js for how I accessed it. It was basically mirroring what the built in physics behavior does. They both use some helper functions that are defined in commonjs.js. (I think that's the file, it's in the exporters/html5 folder).

    The functions allow you to get a list of the points that make up the collision polygon, but transformed to match layout coordinants. The sprite behavior may be another place to find the list of points.

  • Prominent

    The best way I can think of would be to create an object at each corner and use the "pick nearest" condition. You'll probably need to define the corners with imagepoints to do that.

  • In the simple case set a variable to the current time "on touch". Then you can get the duration of the touch from "is touching" with time-start_time.

  • One approach is to move the laser backwards until it's not overlapping the other object, then the end of the laser would be the collision point.

  • 1

    You can use random if you set it with events.

    2

    You can set the angle to the angle of motion by adding the action:

    Bullet: set angle to angle(0,0,self.vx,self.vy)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If you're setting the x every tick you're just overriding where the behavior moved the object. Behaviors are run before events.

  • For the first one you can do it with the bullet behavior and a negative gravity I think.

    The second one you'd have to use the custom movement behavior with a negative horizontal acceleration.

    Or you can do it with just events with and object "bullet" with instance variables vx and vy

    on space pressed

    --- player spawn bullet

    --- bullet: set vx to 100

    --- bullet: set vy to random(-20,20)

    every tick

    --- bullet: add -100*dt to vx

    --- bullet: set position to (self.x+self.vx*dt, self.y+self.vy*dt)

    ^-that's to do the second picture. Fiddle with it and you can make the bullets accelerate in the other directions.

  • This should do it I think.

    "energy" is the amount of energy to add

    "slot" is the selected weapon

    "num_full" is the number of weapons with full energy, so the loop knows when to stop. To make it work when you don't have some weapons just keep the weapons you don't have with full energy.

    variable slot=0
    variable energy=10
    variable num_full=0
    
    Array.At(slot) + energy <= 100
    ---> set array at slot to Array.At(slot) + energy
    ---> set energy to 0
    else
    ---> array: set at slot to 100
    ---> set energy to Array.At(slot) + energy -100
    ---> set num_full to 1
    
    while
    num_full<9
    energy>0
    ------> set num_full to 0
    --- array: for each x
    ------ array.curValue < 100
    ------ energy > 0
    ---------> set array at array.curX to Array.At(array.curX) + 1
    ---------> subtract 1 from energy
    ------ array.curValue = 100
    ---------> add 1 to num_full[/code:2dhud75g]
  • ghost As you probably have found the replace function in the event editor doesn't let you do that. The objects need to be the same type to do for it to work.

  • Sorry, I don't know what's amiss. Assuming my example is correct then yours should work if there is no typos.

  • pcfernandesjr

    Doesn't the original example do that too? Like alextro said it just positions the eggs where the player was a certain time in the past, so if the player stops they will all stack on him.

    I don't have a solution to keeping the eggs from stacking. I've tried stopping time advancement when the player doesn't move, but then the eggs are just frozen in space.

    One idea could be to think of the eggs as a chain attached to the player. So maybe leveraging the pin behavior to link them together and drop them with gravity and bounce them a bit.

  • I meant how the behavior actually moves the object. The two ways I can think of off hand would be either it calculates a distance and angle an repeatedly moves and decreases the distance, or it continuously moves toward a point at a constant speed. It doesn't matter either way since it just moves to a stationary point. It can't handle a moving point.

    One way you possibly could use the behavior would be to use the move to behavior to advance to the next node and then every tick manually rotate the square and use that equation to rotate the object with the square.

R0J0hound's avatar

R0J0hound

Member since 15 Jun, 2009

Twitter
R0J0hound has 157 followers

Connect with R0J0hound