R0J0hound's Recent Forum Activity

  • 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.

  • Decompilers that produce source to recompile the original file don't really exist.

    I used a hex editor to change some text in the csx file. So basically I just tweaked some data in it. Anything more like changing the logic isn't really feasible, even for small things. Basically it would require using assembly language to deal with the lowest level stuff. A big change like like making it work with animations isn't possible. You'd be better off making another plugin I suppose.

  • pcfernandesjr

    In that example just adding another egg works fine to add it to the end. If you want the eggs to be ordered in the way you collect them you could do something like this to assign a number to the eggs you collect:

    global index=0
    
    on player collided with egg
    egg is not collected
    for each egg
    --- egg: set collected to true
    --- egg: set num to index
    --- add 1 to index[/code:1pc1953s]
    
    Then change the "for each" in the example to
    
    egg is collected
    for each egg ordered by egg.num ascending
  • Yeah, my solution is very incomplete. I don't know exactly how the the moveto behavior operates to make a recommendation. Personally I'd opt to do the motion with just events instead of working around the behaviors, but it's likely not useful since it would be incompatible with what you may had.

    [quote:ycvgommh]The problem is I can't think of the formula I need to use to adjust the object's position based on the rotation of the square. Any help?

    If you want the math to rotate an object around a point here's a post with the math for that:

  • You could just move around the unrotated nodes, but keep the circle invisible. Then have another visible sprite that you set:

    sprite: set position to square

    sprite: move circle.x-square.x pixels at square.angle

    sprite: move circle.y-square.y pixels at square.angle+90