R0J0hound's Forum Posts

  • Oh sure. It takes the file and uses the tokenat expression to look at it a line at a time.

    One event sees if the line starts with #recipe, if it does it uses the rest of that line as the name of a new recipe.

    The other event handles either blank lines or lines that have a number followed by an ingredient name.

    Left() gets the left side of some text

    Mid() gets the middle

    Trim() removes any leading and trailing spaces in the text.

    Finally it keeps track of the uid of the last recipe created. That is just so we can pick it again when adding ingredients to it.

  • You set the variables from the bullet behavior right after so it nulls any changes you do before. Move the gravity action down to fix that.

    It’s probably not what you’re after though. Curved motion for pool balls is caused by friction between the ball and the table as the ball spins around in 3D. The physics model as is doesn’t account for that.

  • It’s converting binary to decimal. So instead of a three digit binary number like 101 it turns it into a number 0 to 7.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You could take event 5 and delete all its sub events and actions.

    Then add this one action:

    b: set value at a.curx to int(mid(“11100001”, 4*a.at(a.curx-1)+2*a.at(a.curx)+a.at(a.curx+1), 1))

    No idea if it’s faster but it’s more compact.

  • Here's an old topic with an example to find out if an object is inside a polygon that may be helpful.

    It's rather old so there may be ways to simplify/clean it up to be simpler.

    As far as coloring the shape you'd probably want to look at the canvas object. Not quite sure what it can do since i don't use c3.

    Edit: oops forgot the link

    construct.net/en/forum/construct-2/how-do-i-18/drawing-loop-around-bubbles-71853

    Edit2:

    updated example:

    dropbox.com/s/rpi4nzhd763b4l6/pointInPoly.capx

  • Thought I'd have a go at this.

    The events simplify nicely by having a dictionary for the inventory and an instance of a recipe dictionary for each recipe.

    dropbox.com/s/cw1xuiiymjqq6oq/crafting_test2.capx

    JSON and XML are a pain to write imo. With the above example you can just create the recipes with events fairly cleanly, or just load and parse a plain text file to populate it.

    #recipe Blinding Flash Potion
    2 wormwood
    5 sulfer
    
    #recipe Potion of Sweet and Savory
    5 salt
    5 sugar

    I could get behind writing recipes like that all day long. No quotes or matching brackets.

  • My pleasure. Glad it was useful!

    -cheers

  • It‘a all connected so a path can be found between any two points.

    You could start the generating from one end or the other, or simultaneously generate from both ends and the somehow connect the two mazes later. Maybe utilize the astar algorithm on an empty weighted grid to find a meandering path between the points, and then fill in the rest with more random maze.

    Ultimately I don’t think it improves the maze generated over just a random one.

    It can be made to highlight the path between two points though.

  • Some more fiddling with things. It can be made more like prims algo by pulling from a random point on the stack instead of the first. Also can be made to fill a shape with the maze.

    dropbox.com/s/ejadw6go33j4b0i/mazegen2.capx

  • It's this one:

    en.wikipedia.org/wiki/Maze_generation_algorithm

    I did a bit of a twist with the part about neighbors to make the events look cleaner.

    I went for visualizing the maze but depending on how the maze would be represented things can change up.

  • Here's another attempt with another algorithm.

    dropbox.com/s/6ux3pv6bvaofuo0/mazegen1.capx

  • You're not setting the bullet speed and angle of motion after the events. The result is it just pushes the other balls aside.

    Anyways here's a revision with damping. If you want to use the bullet behavior there are some comments of what to modify and where.

    dropbox.com/s/0figv3qlg6wdtv0/collision_responce_2.capx

  • Updated the links in that old post. I found some older maze generators but it used a third party plugin i no longer have.

    -cheers

  • If you want to use the bullet behavior, the simplest solution would be to set vx,vy in an event above the events I gave, and then setting the bullet angleOfMotion and speed in an event after.

    Vx = speed*cos(angleOfMotion)

    Vy = speed*sin(angleOfMotion)

    Speed = distance(0,0,vx,vy)

    AngleOfMotion = angle(0,0,vx,vy)

    The other equation you gave was for figuring out the initial speed to stop in a specified distance. From your description you don’t need that. You just need to slow it down.

    Global number speed=0

    Global number dir=0

    For each ball

    — set dir to angle(0,0,ball.vx,ball.vy)

    — set speed to max(0, distance(0,0,ball.vx,ball.vy)-200*dt)

    — ball: set vx to speed*cos(dir)

    — ball: set vy to speed*sin(dir)

  • I guess the issue is there is an infinite loop when two balls collide in your events.

    Anyways here's a better approach.

    When a ball hits a wall the ball is moved out in the closest direction from the wall and a bounce calculation is done with that direction.

    In a similar fashion when two balls collide they are moved apart and a bounce calculation is done.

    All balls are assumed to have the same mass and all the walls are not rotated.

    In events i used 16 and 32. That's the radius of the balls and 2*radius.

    dropbox.com/s/2apd1uwsnsylzpu/collision_responce.capx

    Damping can be done by multiplying the velocity by 0.995 or something. Angular damping doesn't make sense unless we are doing angular velocity too.

    If you want different masses or different levels of elasticity you can change up the bounce code with:

    en.wikipedia.org/wiki/Collision_response