Yann's Recent Forum Activity

  • Ashley

    It's sad but there's no real equivalent to

    Sprite: [invert] pick by UID 

    anymore.

    I was actually using it a lot for connecting nodes (spliting games, node base system, etc)

    The basic pattern I was using was:

    // create a new edge and save the UID of first node
    + Mouse: on left click on node
       -> System: create object edge at node.X,node.Y
       -> edge: set new to true
       -> edge: set firstNode to node.UID
    
    // a new edge as been created
    + Edge: Is new
       // a close node other than the first Node -> we snap the edge to it
       + node: [invert] pick instance with UID edge.firstNode // so I pick every other
       + node: Pick nearest to (mouse.X, mouse.Y) // amongst every other node, the closest to the mouse
       + distance(mouse.X,mouse.Y,node.X,node.Y) < SNAP_RADIUS
          -> edge: Set angle toward(node.X, node.Y)
          -> edge: set width to distance(self.X,self.Y,node.X,node.Y)
          -> edge: set secondNode to node.UID
    
       // no close second node -> we follow the mouse
       + else
          -> edge: set secondNode to -1
          -> edge: set angle toward(Mouse.X,Mouse.Y)
          -> edge: set width to distance(self.X,self.Y,Mouse.X,Mouse.Y)
    ....

    Now, to be able to do the same I'll probably have to foreach through all the node, flag them with a boolean and then pick using this boolean, and to the nearest thing.

    That's kinda sad (:

    Also it seems that [invert] pick by UID does... the same as without inversion

    Test capx

  • Ashley

    There's a nice little trick

    + Foreach Family1:
       + SmallShip pick by UID Family.UID
          -> Fire Small bullet
       + LargeShip pick by UID Family.UID
          -> Fire Large bullet

    What I like to call C2's object type casting :D

  • JoyfulDreamer

    That was my first idea actually, but you have to constantly check that your next random step would still allow you to reach the goal. So you basically have to pathfind for each step.

    Unless you decide to just allo the snake to bit its tail.

    But than how much iteration until you'll really reach the goal?...

    I found that using a maze algo, it creates interesting looking random path and that you always end up with something valid.

  • Excal

    You have a mix of face palm error, object/project settings error and some arithmetical errors

    The face palm error is the fact that the GridTiles layer isn't transparent.

    So you don't see what is created on Layer 0.

    The object settings error is that you don't have the same Cell Size value in your finder in your ObjectDump and in your Gameplay Layouts. It does not necessarily cause the bug, but well... better safe than sorry (:

    The project setting error is that you have a layout width which is not a multiple of 64, so it doesn't look good

    The arithmetical ones are where you position your end point, and is a bit bound to the layout width error and some wrong calculation

    You try to place the end sprite at floor(WIDTH/cellSize)*cellSize which in fact put it out of the layout. The proper formula would be (floor(WIDTH/cellSize)-1)*cellSize

    Also since the origin is at the center of the sprite, you have to offset it to half cellSize.

    So the proper formula would be:

    X = (floor(WIDTH/cellSize) - 0.5) * cellSize

    Y = (floor(WIDTH/cellSize) - 0.5) * cellSize

    Oh and also I think you were generating the maze constantly... soooo

    Excal-RandomPath.capx

  • thehen

    Neat!

    Hmmm are you talking about that one? http://www.scirra.com/forum/plugin-polygon-update-20130423_topic62075_post381179.html#381179

    If you do, I did mentionned in this post that there were a scary error message when you start the preview, but it works anyway.

    The scary message comes from the fact that on start, since your polygon object is empty, it has no collision polygon. And Ash throw an assertion error for that. Because it seems, the physics behavior requires to be initialized with a valid collision polygon when the game start.

    Anyway, as scary as the message looks, assertion are disabled on export, and it doesn't look like it makes the physics behavior bugs.

    Sooooo...

  • You just have to project it back from canvas to the UI layer.

    crossLayerProjection.capx

  • thehen

    Super weird

    To be sure open runtime.js and check if there is a line with

    var MIN_SIZE = 1;[/code:3hc77qfi]
    
    If it's the case, you should have the last version (same as mine).
    
    I'm reposting the link here just in case 
    [url=https://app.box.com/s/hqn9vrttsuoesx2oolgk]polygon.zip[/url]
    
    If you have the same version, and if you still have the same bug hmmmmmmm
    ... trying on firefox.....
    hmmm working...
    
    Well at least double check, and if you still have the problem, I'll investigate since it would mean it's a plugin bug (:
  • bon4ire

    Nope you can do the same in C2.

    You can do

    + condition A
        -> Action 1
    + else
    + condition B
        -> Action 2
    + else
    + condition C
        -> Action 3
    + else
    + condition D
        -> Action 4
  • Excal

    Four of the globals are semantic constant use every where. (well the EMPTY and WALL are just used for the Maze Generation part so you could put them in local constant in this group if you really want)

    There shouldn't be any issue with them, and I found out that they were more helpfull in global scope than in local. If you were to define the same constant at other places you wouldn't be sure of if they have the same value or not. I think local constant can lead to confusion.

    Now the 3 other constant (WIDTH,HEIGHT and DENSITY) are parameters for the whole algorithm. Soooo I think they have their place on global scope as well.

    As far as the runtime variable, generating is a kind of global state of the algorithm so well.. makes sense to be global, and for the three last, if I could initialize them with an expression as it's possible in C they would also be constant.

    So yeah as much as I would agree with you that too much globals is bad because of global namespace cluttering and overall incertainty (which doesn't exist with constant). I think these ones are justified.

    Now as far as the vector list is concerned, you could actually put the function on start of layout.

    The vector list is just a look-up table of the four possible directions you can travel in the maze.

    It looks like:

    Array.At(0,0) =  1
    Array.At(0,1) =  0
    Array.At(1,0) =  0
    Array.At(1,1) =  1
    Array.At(2,0) = -1
    Array.At(2,1) =  0
    Array.At(3,0) =  0
    Array.At(3,1) = -1

    This way can just represent a direction by a number (the X index of the array)

    For instance going West is the #2 direction.

    It's the same as goint X + Array.At(2,0), Y + Array.At(2,1)

    If you look at the dig function, you have a local variable named choice with the four direction represented in a string. I should one of this number at random and then remove it, and run the dig function on this direction recursively.

    Since the variable is local the list is rebuilt automagically for each new cell you travel.

    So for a clear and simple answer, no, you don't need to create other vector list, it's not something that gets modified (which you could create constant array :D)

    Also, placing the createVectorList call in start of layout would make more sense (:

    Hope I was clear.

    Edit: you can redownload my capx, I implemented multiple steps (another constant to control how many)

  • Excal

    Maybe you can run the maze algo more than once to create 2 or 3 different path before generating the entire map the way I did it.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • thehen

    Oh yeah sorry, that's a bug happening when the polygon got no size, ctx.drawImage() doesn't like it.

    I corrected the bug, but forgot to update :D

    Should be updated in less than an hour (:

    Edit:

    hop! updated

    not sure if I solved it the right way (I force the width and height to be at a minimum of 1)

  • shinkan

    Hey sorry to hear that, I can download them from twitch, and they don't seem too heavy so maybe I can throw them on a ftp somewhere...

    I'll let you know if I find some solution (:

Yann's avatar

Yann

Member since 31 Dec, 2010

Twitter
Yann has 5 followers

Connect with Yann