Yann's Recent Forum Activity

  • Ashley

    Yeah I know about the next top level thingy, but that makes a capx look a bit harder to read when you do that:

    on left click
      -> create object
    on left click
      -> function call "checkThings"
    
    on right click on object
      -> destroy object
    on right click on object // should that trigger by the way?
      -> function call "checkThings"

    instead of:

    on left click
      -> create object
      -> next tick
      -> function call "checkThings"
    
    on right click on object
      -> destroy object
      -> next tick
      -> function call "checkThings"

    (plus you probably would have to repeat some picking condition/calculation to end up with the same context in more complex situations)

    And the idea behind creating an alias to wait 0 seconds, is that it looks less wrong ('cause if I understand, you actually wait more or less dt seconds)

  • Hey there,

    I just had this simple idea.

    It's ver well know, now that when we have a newly created or destroyed object, we need to wait for the next tick to access them.

    For instance when we use functions a lot even when the function is called in the created block, the newly created object won't be visible.

    My usual work around is to put a wait 0 seconds

    But it's not really intuitive. And at some point, nothing insure that this behavior will be kept in future versions (since it's more like a hack). Maybe in the future, the implementation of wait will be changed and wait 0 seconds will trigger instantly... who knows?... and why should we care about internal implementation? (:

    So maybe an action dedicated for just that situation, like a "Wait next tick" OR "trigger next tick" action would be better (although "triger next tick" looks more like a condition)

    What do you think Ashley ? (:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Global constant number TRUE  = 1
    Global constant number FALSE = 0
    + Function: On function "isCovered" :
       Local number result = 0
       -> System: set result to TRUE
       + System: for "y" from 0 to rectangle.Width
          + System: for "x" from 0 to rectangle.Height
             Local number covered = 0
             Local number px = 0
             Local number py = 0
             -> System: set px to rectangle.X - rectangle.width/2  + loopindex("x")
             -> System: set py to rectangle.Y - rectangle.height/2 + loopindex("y")
             + System: Foreach circle
             + System: distance(circle.X,circle.Y,px,py) <= circle.width/2
                -> System: covered = TRUE
                -> System: stop loop  // stop the foreach
             + System: covered = FALSE
                -> System: set result to FALSE
                -> System: stop loop  // stop the "x" loop
                -> System: stop loop  // stop the "y" loop
       -> Function: set return value to result[/code:a9ngkl9o]
    
    Untested. But the idea is to sample each pixel of your rectangle and see if there's a circle for which the distance from the center of the circle to this point is lower than its radius.
    I make several assumption here:
      - you only have one rectangle shape in your layout
      - your circle.width is exactly equal to your circle's diameter (I use width/2 for the radius)
      - the origin of your rectangle and circle is in the middle
    
    Be carefull the amount of computation will be proportionnal to rectangle.width*rectangle.height*circle.Count  at worst case, which is if the rectangle is completely covered since all the loop are stopped as soon as an out of circle point is found.
    
    If you happen to use some kind of grid snapping, you can probably lower the amount of computation since you shouldn't have to check every single point of the rectangle (but not sure)
    
    In any case you shouldn't run this function every tick, but probably only when you drop a circle.
    
    Also using any kind of C2's built-in overlap check isn't really reliable since a circle's collision polygon is usually an octogon and also, checking for radius is probably faster than using polygon based collision detection.
    
    Edit:
    here's a working implementation:
    [url=https://app.box.com/s/vbkvbkmkt2yjq5kd37w9]rectCoveredByCircle.capx[/url]
    as you can see it can get quickly slow.Yann2013-03-26 08:36:17
  • Whiteclaws

    You don't make an omelette without breaking some eggs.

    If he wants to make a nonogram with C2, I gave him a decent way.

    I won't presume of his level. If he understood what I said, he should be ok, if he didn't, he just have to postpone that project and learn C2 and programming a bit more.

    In any case, my answer has its uses.

    3D array?... wtf?

  • oh nonogram, I did that once

    https://dl.dropbox.com/u/23551572/C2-Ga ... index.html

    If I remember, I just set some strings like

    000########000
    0##00000000##0
    0#00##00##00#0
    #000##00##000#
    #000000000000#
    0#0#000000#0#0
    0#00######00#0
    00#00000000#00
    000########000[/code:dc9g5ywl]
    
    parse it to fill an array
    deduce the numbers to put on the sides.
    check what the player draws each time against the same array for win condition.Yann2013-03-24 12:34:54
  • sqiddster

    all in one file?... doable

    {
      "c2dictionary":true,
      "data": {
        "lvl1_nbClouds":20,
        "lvl1_xSpawn": 102,
        "lvl1_ySpawn": 503,
        "lvl1_greeting": "Hello young traveler, you'll have to... blahblah",
        "lvl2_nbClouds":13,
        "lvl2_xSpawn": 251,
        "lvl2_ySpawn": 134,
        "lvl2_greeting": "Already second level! I might need to get ,
        "lvl3_nbClouds":5,
        "lvl3_xSpawn": 124,
        "lvl3_ySpawn": 162,
        "lvl3_greeting": "Ok, I'm starting to get angry!",
         etc...
      }
    }

    Then you just have to get your data from the "lvl"&curLevel&"_...." keys

  • XML is a pain in the behind

    Just use JSON, it's easy to write and load.

    If you want a list of parameters for your level and if your parameters aren't too complex, you can use a dictionnary JSON. It should looks like that:

    {
      "c2dictionary":true,
      "data": {
        "nbClouds":20,
        "xSpawn": 102,
        "ySpawn": 503,
        "greeting": "Hello young traveler, you'll have to... blahblah"
      }
    }

    That's pretty easy to read, edit and load.

    Unless you have something more complex like a list of different enemies with different parameters... It'should be good enough.

    And well... If you DO have something more involved with a deeper arborescence, you could still do something like

    level1.json:

    {
      "c2dictionary":true,
      "data": {
        "nbClouds":20,
        "xSpawn": 102,
        "ySpawn": 503,
        "greeting": "Hello young traveler, you'll have to... blahblah",
        "enemyDefinition": "enemyDef.json"
      }
    }

    enemyDef.json:

    {
      "c2array":true,
      "size":[4,5,1]
      "data": [[
      //[     type, hp, mp,atk,mag]  <-- that's a comment
        [  "troll",100, 10, 50,  0],
        [  "witch", 50,100, 10, 60],
        ["pikachu", 70, 30, 24, 12],
        [  "demon", 85, 20, 16, 34]
      ]]
    }

    Though using the array syntax it's a bit less clear

  • interesting problem

    decimalToFraction.capx

  • darktoad

    hey thanks for the feedback (:

  • labithiotis

    nope, it's strictly a "polygon" plugin. as in

    a polygon (pron.: /'p?l?g?n/) is a flat shape consisting of straight lines that are joined to form a closed chain or circuit

    If one day I feel good enough in js and if I find a good way to interface it in ACE, and if I find a good way to generate corresponding collision polygon, I might decide to make a "Shape" plugin.

    But as you can see, there's many "ifs" (:

    And if you don't need collision polygons, I suggest you look at the canvas plugin from R0J0hound

    On another subject, I just updated the polygon plugin, I had left some bugs in the boundingbox calculations.

    Enjoy (:

  • Jeff Skyrunner

    Yeah I'm still a bit shy as far as playing with the xml files.

    For now I just use .bat to commit some changes when I work on game series.

    I just split my event sheet into a common event sheet for the engine, and a specific event sheet for specific differences per games in the series.

Yann's avatar

Yann

Member since 31 Dec, 2010

Twitter
Yann has 5 followers

Connect with Yann