Yann's Forum Posts

  • Argh! those damn frenchies!

    There's some inventory topic form not long ago

    http://www.scirra.com/forum/need-help-with-something_topic47602_page3.html

  • smitchell

    be carefull:

    0 = right

    1 = down

    2 = left

    3 = up

    The angle of the arrow sprite = a*90 that's why

    if you use 4 the arrow sprite will be properly displayed (4*90 = 360), but the 'a' instance variable is also used to compare the input.

  • What I wrote was just a kind of add-on, you still had to keep most of what was in the base capx. But you blindly remove too much stuff. Like setting the order instance variable, the start of layout destruction and x0,y0 setting and of course it was only the loop at start of layout, you have to copy the same one when you end a line (you can also use function to avoid copying this loop code)

    Anyway

    smitchArrow.capx

  • smitchell

    yeah int(tokenat()) I sometimes forget too

    Ah yeah 'cs' is an old habit of mine it means "cell Size" I always use that in grid based stuff. If I remember I used arrow.width instead.

  • Reading the guts of the Sprite plugin, It's possible.

    Maybe it's a Ash forgot to check that, but if you put a negative number into the speed property values you'll have a buggy animation.

    However if you set the animation speed by event to a negative value, the animation will be read backward.

    Unfortunately the loop value won't be taken into account and you'll have to 'manually' set the starting frame. In event and/or in properties.

    In short,

    +System: On start of layout
      -> Sprite: set animation to self.AnimationFrameCount-1
      -> Sprite: set animation speed to -5
    +Sprite: Animation Frame = 0
      -> Sprite: set animation to self.AnimationFrameCount-1

    Works.

    But note that the 0 frame will never be seen, so you should put a blank frame for first frame.

  • Weeell yeah you can

    1/ set some specific patterns in a string like

    Global test patList = ""
    Global number index=0
    Global number line=0
    +System: start of layout
      Local variable curLine=""
      -> System: set patList to "01321320
    03213210
    02313210
    23132120
    02030102"
      -> System: set curLine to tokenat(patList,line,newline)
      +System: for "" from 0 to tokencount(curLine,"")-1
        -> System: create arrow at x0+loopindex*cs,y0
        -> arrow: set a to tokenat(curLine,loopindex,"")

    etc. And you increment the 'Line' global variable when a line is finished and you redo the creation loop as I did in the capx.

    2/ You can use seeded random basically you have to set a seed number (it can be any number) and you have to keep a random value you will use to pseudorandomize stuff.

    It looks like that :

    Global number seed=123456
    Global number srand=0
    Global number a = 22695477  // just a constant
    Global number c = 1  // just a constant
    Global number m = 4294967296  // just a constant
    +System: On start of layout
      -> Set srand to seed
    // Each time you want to do a random(3) you do things like that:
    +System: for "" from 0 to aCount
      -> System: create arrow at x0+loopindex*cs,y0
      -> System: Set srand to (srand*a+c)%m
      -> arrow: set a to floor((srand/m)*3)

    That's seeded random in a nutshell

    For more indepth read that http://en.wikipedia.org/wiki/Linear_congruential_generator (I used the Borland C/C++ constants)

    3/ r0j0 recently post a capx on weighted random... You could use that too.

    4/ If you think about convoluted system like recognizing patterns which leads to error and increase the chance to draw these pattern, it will drive you insane.

  • smitchell

    not so random... what do you mean?

  • As a rule of thumb, if you end up with repetition of code, you're doing things wrong.

  • here is how you properly do things

    arrowGame.capx

  • revealGhost.capx

    need the canvas plugin

  • You can make a layer visible or invisible by event (:

  • nest the 4th event under the 3rd event

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Didn't you try what I wrote ?