Yann's Recent Forum Activity

  • Or use another object for the "death" animation. An object that isn't set to collide.

    Or use a boolean on the object itself, if the boolean is set to true, don't hit.

    As far as pretty things goes like fx you have to wait for the scirra team to decide when it will be the time to add them. As it will probably be a webGL only feature, and for now they keep the c2 into a canva 2D/WebGL compatible state.

    draw box/circle/ etc ... yeah missing that kind of plugin, but you can still do some stuff with canvas (:

  • randomAngledArea.capx

    What I wrote earlier works fine for me...

  • It depends. If it's just the simple mecanisms (detecting right/wrong moves, winning/losing condition), It's fairly easy.

    If you're talking about game AI to play against. I becomes way harder.

  • Be carefull, the layerangle is a bit tricky. I would advise to not use it, especially if you use scrolling. It behave pretty weirdly.

    I think that Ash did say somewhere that it's not the layer that rotate but something like, rotate layout -> paste Layer into main canvas -> rotate back. So event layerangle is reversed...

  • newt

    well, it's really generate a random point and then take it's angle AND distance from the origin.

    It's not just a random angle

    it's not just a random distance frome the origin

    it's not event a random angle and a random distance, 'cause you have to stay within the rectangle boundaries. If you take a random angle and then a random distance from the origin (from 0 to how much?), you can't be sure you are within the rectangle. Angle and distance are linked to discribe a specific point.

    So it's really a random point you convert into distance and angle from origin -> rotate -> translate.

  • ninjaTurn4.capx

    Somehow, the walking animation was set one tick later. So the turn animation frame 0 was displayed. Very weird. But setting the animation in the state="Walk" subevent make sure you set frame 0 from animation "Walk" and not "Turn". Well look at it you'll see.

  • newt's idea is to sample a value in an unrotated rectangle and then rotate the values arround the center.

    Let see then :

    sample values inside a rectangle :

    x = rectangle.x+random(-rectangle.Width/2,rectangle.Width/2)
    y = rectangle.y+random(-rectangle.Height/2,rectangle.Height/2)

    Then you rotate the value around the center

    xRot = rectangle.x + cos(angle(rectangle.x,rectangle.y,xSample,ySample)+rectangle.angle)*distance(rectangle.x,rectangle.y,xSample,ySample)
    yRot = rectangle.y + sin(angle(rectangle.x,rectangle.y,xSample,ySample)+rectangle.angle)*distance(rectangle.x,rectangle.y,xSample,ySample)

    We can simplify that by sampling the rectangle at 0,0 and then offsetting the restult

    x0 = random(-rectangle.Width/2,rectangle.Width/2)
    y0 = random(-rectangle.Height/2,rectangle.Height/2)

    And then

    xRot = rectangle.x + cos(angle(0,0,x0Sample,y0Sample)+rectangle.angle)*distance(0,0,x0Sample,y0Sample)
    yRot = rectangle.y + sin(angle(0,0,x0Sample,y0Sample)+rectangle.angle)*distance(0,0,x0Sample,y0Sample)

    So basically, sampling a random number in a rectangle is the same as chosing a random angle and distance from the center of this rectangle and applying a rotation.

    In short it will be something like that:

    +On what you want
      Local number randX=0  //random X position withing the rectangle
      Local number randY=0  //random Y position withing the rectangle
      Local number randA=0  //random angle before rotation
      Local number randD=0  //random distance
      -> System: set randX to  random(-rectangle.Width/2,rectangle.Width/2)
      -> System: set randY to  random(-rectangle.Height/2,rectangle.Height/2)
      -> System: set randA to angle(0,0,randX,randY)
      -> System: set randD to distance(0,0,randX,randY)
      -> System: set randX to rectangle.x + cos(randA + rectangle.angle) * randD
      -> System: set randY to rectangle.y + sin(randA + rectangle.angle) * randD

    Should work...

  • hehe sure you know I'm french :D

    I saw it, I was planning to answer with another pic but didn't find the time to do so :D (I'm on rotary mode and bit of rush at work)

  • ok (:

    could help to have at least some visual to be sure but let see

    if you're on :

    • top left (0,0) angle should be 0
    • top right (layoutwidth,0) angle should be 90
    • bottom right (layoutwidth,layoutheight) angle should be 180
    • bottom left (0,layoutheight) angle should be 270

    so then hmmm I see

    +When you want
      -> tiledBg: set position to choose(-1,1),choose(-1,1)
      -> tiledBg: set angle to angle(0,0,self.X,self.Y)+135
      -> tiledBg: set position to clamp(self.X,0,1)*layoutWidth,clamp(self.Y,0,1)*layoutHeight

    should work (:

    Explanation:

    Let's look each of these 3 actions one by one

    1/ basically the first action gives you this kind of possible result:

    (-1,-1)

    (1,-1)

    (1,1)

    (-1,1)

    2/ If you draw these points on a graph you'll notice that angles from origin to these points are multiple of 45...

    But the most important, these 4 possibilities are 90 degrees appart and in a proper order.

    So by adding 135 you end up with somthing like :

    angle(0,0,-1,-1)=-135 -> -135 + 135 = 0

    angle(0,0,1,-1)=-45   -> -45 + 135 = 90

    angle(0,0,1,1)=45    -> 45 + 135 = 180

    angle(0,0,-1,1)=135   -> 135 + 135 = 270

    3/ And then if you clamp at min 0 max 1 these kind of value you end up with

    (0,0)

    (1,0)

    (1,1)

    (0,1)

    you then just have to multiply these value by (layoutWidth,layoutHeight)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • why don't you put the hotspot of the tiledbg in the middle and just do a

    set angle to floor(random(4))*90 ?

  • Basically this question leads two different answers to my knowledges :

    1/ Either, as Tasty did, you use c2 as a level editor & game engine. So each layout is a level and you associate or include your event sheet engines.

    Advantages:

    • you don't have to create a level editor
    • you have an unlimited level of tweaking

    Disadvantages:

    • creating a level can take a bit more time and you can make mistakes
    • maintaining a level is a pain if you want to add new stuff (like a particle fx to makes things cuter) you have to add them on all your level or use the global trick.

    2/ Or you use one only game layout, but you create your own level editor.

    Advantages:

    • creating level is easier as you made the level editor to speed up the process
    • you can make dramatic changes in UI or in-game Looks in no time
    • you avoid the too-much-layout hell

    Disadvantages:

    • you have to create your own level editor. Which isn't super hard but need time. The only good thing about that is that if you don't release it publicly you can make crappy UI and just put what you need. You will probably be the only one to know how it works :D
    • you have a bit less freedom once you created your data format so you have to think this through:

    ----what infos do you store?

    most of the time: position,angle,scale,opacity and type of object

    ----how do you store them?

    CSV format seems at the moment the only practical way in c2 (no xml parser or binary array loader as far as I know)

    ----how do you recreate the level?

    I usually spawn the same object sprite in which I put different animation according to the "type of object" stored.

    If we could access family members by indexes that could simplify this process a bit by not having all objects in one sprite. (thus separating behaviors and instance variables) Would need an ordering feature in the family manager though.

    Hope Ashley will think about that (:

Yann's avatar

Yann

Member since 31 Dec, 2010

Twitter
Yann has 5 followers

Connect with Yann