R0J0hound's Forum Posts

  • Using the expressions:

    Sprite.ImagePointX(point)

    Sprite.ImagePointY(point)

    Replace "point" with either the index of the of the image point like 0 for the origin, 1 for the first image point, 2 for the second,... and so on.

    ...or you can use the name of the image point.

  • It's true, events are run top to bottom. However triggers (they have a green arrow to the left) are only run when they are triggered, but if there is more than one of the same trigger they are run top to bottom. Basically you could move the triggers around and the game will run the same as long as they have the same order. "on collision" and the gampad triggers are the exceptions. They are not real triggers, and are run in order with everything else in the event sheet.

  • Braus

    Sure, why not? In the capx it calculates the initial speed so it rotates n degrees. It's done when the speed is >= to 0.

    So you'd either figure out the number of degrees from any position to any other, or find a formula that can do that.

  • One way to do that path exactly could be:

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

    It could be made to move at a constant speed by splitting the curve up into lots of lines and make the time to move on each line proportionate to it's length.

    There are other solutions too:

    search.php?keywords=follow+path&terms=all&author=&sc=1&sf=all&sr=posts&sk=t&sd=d&st=0&ch=300&t=0&submit=Search

  • Try it. The math will make it scale from (centerx, centery) regardless where the origin on the sprite is.

  • You probably just want the spinner to slow down and when it stops just check if the angle is close to one of those.

    For example here is an example if there are four values on the wheel:

    +-----------------+
    | mouse: on click | spinner: set speed to random(100, 400)
    +-----------------+
    
    +------------------+
    | spinner: speed>0 | spinner: subtract 100*dt from speed
    |                  | spinner: rotate self.speed*dt degrees clockwise
    +------------------+
    
    +------------------+
    | spinner: speed<0 | spinner: speed set speed to 0
    +------------------+
       +---------------------------------------+
       | spinner: angle is 45 degrees from 0   | add 10 to score
       +---------------------------------------+
       +---------------------------------------+
       | spinner: angle is 45 degrees from 90  | add 50 to score
       +---------------------------------------+
       +---------------------------------------+
       | spinner: angle is 45 degrees from 180 | add 1337 to score
       +---------------------------------------+
       +---------------------------------------+
       | spinner: angle is 45 degrees from 270 | add 123456789 to score
       +---------------------------------------+[/code:3y93chdi]
    
    So in other words it's not necessary to know where it will stop beforehand, you just check the angle when it stops.  There I checked the angle with the "is within angle" condition but the "is between angles" could be used too.
    
    And in relation to your questions about my capx above:
    To make it start with more speed just set the start speed higher in the click event.
    The spinner is stopped when the speed is less than or equal to 0.
    It's not zero because we can only calculate speed per frame, and seldom will the speed end on 0 at exactly the frame time, so it overshoots slightly.
  • #3

    This can already be done by making the object global.

  • I don't think any of those are an application of the genetic algorithm. Mercuryus's example tweaks the jump as it goes but it's not following the algorithm. Radulepy's are more like ai examples.

    I tried my hand at the algorithm and came up with this:

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

    It does this:

    1. simulates 100 objects moving with 5 seconds worth of random input

    2. scores them

    3. kills the lower 50

    4. creates 50 new objects by combining two of the survivors and adding some random mutation

    5. and finally repeat.

    It doesn't converge very fast but given enough time it will converge on the objects moving as far along the path as possible. I imagine the scoring could be improved to help it converge faster but I'm probably done with this.

  • It doesn't use a behavior at all. Here's a working example of the idea:

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

  • You could use the math here:

  • The algorithm itself looks pretty simple. The hard part would be coming up with how to design the creature so it can do something interesting. One way that seems useful to me is to make one creature and make it player controlled. If you can get it to kind of do what you want you can then take that and come up with a way to automate it.

    With the physics one it looks like torque is being applied at the joints. I'm guessing its properties are when to apply the torque and the amount of torque to apply. That is probably per joint.

    The initial values for the properties would be some reasonable random value. Like if it takes 1 second before the ball hits the creature then for the time to apply torque a value of random(0, 2) could be reasonable.

    There are probably more complex ways to model the creature. Some ideas that comes to mind could be to only start the timer when the obstacle gets close, or somehow take into account the orientation of the creature. Giving the creature some sensory cues could be useful too.

    I think it basically amounts to a bunch of tinkering and creativity.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Nothing is impossible. There isn't a built in way to change the collision shape at runtime though so that may be another issue to tackle. Even that isn't impossible. You could look at yann's polygon plugin or deal with a physics engine directly with JavaScript through the browser plugin. Although I admit the latter is hard to do.

  • Maybe give the loot some velocity too when it's spawned. To make an explosion just give an impulse in a random direction. Probably more satisfying would be to make the loot launch away from the player.

    I don't have access to C2 currently but probably something like this:

    Create loot

    Loot: apply impulse -3 toward position (player.x, player.y)

  • Here's one way. Give your spinner Sprite a variable and call it 'speed'.

    Then add this event:

    Speed>0

    --- add -50*dt to speed

    --- rotate self.speed*dt degrees clockwise

    That makes the spinner Sprite slow down. Now all that's left is to change the initial speed so it stops at a certain spot. The equation for that is:

    Speed=sqrt(2*decceleration*distance)

    In the event above deceleration is 50. So if you wanted the spinner to spin twice and land on 90 degrees you'd do this:

    Start of layout

    --- set speed to sqrt(2*50*(360*2+90))

    Or in the case of always landing on one of six positions you could do:

    On space pressed

    Speed <= 0

    --- set speed to sqrt(2*50*(360+int(random(6))*60))

  • You could run the contents of the editbox as JavaScript using the browser object's execjs action. That is the simplest but the feedback would basically just be a return value. I suppose you could add some functions that call c2 functions to provide more feedback. But arbitrarily running js is an issue since absolutely any js can be run, which can be an issue.

    You can look at the browser and function objects in the manual to see what I talk about above.

    A more advanced thing you could do is make your own parser that reads the editbox a character at a time to do your own coding language. This gives much more control or what can and can't be done by the user. This can be as complex or as simple as you like. Probably not easy if it's not something you've done before.

    I've done some expression parsers before that you can find on the forum, but reading outside sources may be more useful.

    I guess it depends on what you actually want the code to do specifically and look like specifically.