Yann's Recent Forum Activity

  • whiteheat,

    you can also do it like that

    scrollingStyles.capx

  • as described in the post just before

    you create an instance variable named 'name' for slid_line

    and you set the value of 'name' for your volume slid_line object to "volume"

    +slid_line: name = "volume"
      -> Audio: set "your tag" volume to slid_line.value
  • if your enemy always go left you can do something like:

    You set the maximum speed to 800 or higher in properties

    Bullet: On collision with enemy
      -> enemy: Set Platform vector X to 800
    Every tick
      -> enemy: Simulate Platform pressing Left
      -> enemy: Set Platform vector X to clamp(self.platform.vectorX,-15,800)

    (setting the vector X to something greater than 800 is useless since you'll just be clamped to maximum speed)

  • that? LoS.capx

  • Oh right, I think the jittering is caused by the fact that when you set angles to a negative value, c2 converts it to a 0-360 range.

    so, as soon as you rotate counter clockwise past 0 degree it will go to 360 then it's clamped to 15...

    So basically you have a sequence of values like that (if isMirrored is true and you have a steady 60fps which gives you a 1/60=0.017 for the value of dt) :

    frame 1: 0

    frame 2: clamp(0-120*0.017,-15,15) = -2.04

    -> converted to 357.96

    frame 3: clamp(357.96 - 2.04,-15,15) = 15

    ... ... ...

    and it will go back to 0 as long as you're jumping

    So yeah using your RotateTo variable is a good idea (:

    And for the dt... Basically to understand how things work, look at how the values evolve when using it.

    dt is the time between the previous and the current frame.

    in a 60fps game,

    <font face="Courier New, Courier, mono">dt = 1/fps = 1/60 = 0.01666666666</font>

    (dt is the "second per frame" so spf = 1/fps :D )

    let's simplify to 0.017

    If you add dt to a value every frame:

    <font face="Courier New, Courier, mono">0.017+0.017+0.017+..... </font>

    After exactly one second, which is 60 frames, the value will be equal to

    <font face="Courier New, Courier, mono">60*1/60 = 1</font>

    in a 30 fps game, after one second, which is 30 frames, you'll get

    <font face="Courier New, Courier, mono">30*1/30 = 1</font>

    So basically, in whatever fps you are, the succession of addition will all reach 1 after one second.

    if you add 5*dt, the value will reach 5 after one second

    so basically, if you

    <font face="Courier New, Courier, mono">set X to self.X + 5*dt </font>

    you add 5px to X every one second, so you move your object at exactly 5px per second

    It works the same with angle:

    <font face="Courier New, Courier, mono">set angle to self.angle + 5*dt </font>

    will rotate at 5 degree per second.

    that's the holy magic of dt in a nutshell =)

  • Oh cool (: Thanks Ash

  • WebFont display correctly on preview, but after an export I get a default font instead.

    Works fine on firefox, seems like a chrome-only bug (didn't test IE or Safari though)

    Here is my simple testing capx

    Chrome-WebFont.capx

    As well as an export

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

  • Don't use the same sprite for rotation and platforming. Because of collision issue, when your sprite is rotated 15 degree one corner will touch the ground.

    Then you set it to 0 degree it goes back in fall mode. Probably creating some wiggling.

    You should then do something like setting another sprite to follow your platform sprite. I usually set the platform behavior on my collision box only and then set the eye candy graphics of the character on another sprite that doesn't handle collision.

    Let's call it "PlayerSkin"

    (You'll have to put your mirroring logic to the PlayerSkin instead by the way)

    Global number JRotSpeed = 120  // in degree per second
    Global number JAngleLimit = 15  //Limit of jump rotation angle
    
    Player: On Jump 
      -> PlayerSkin: set rotSpeed to PlayerSkin.isMirrored ? JRotSpeed : -JRotSpeed
    
    Player: On Fall 
      -> PlayerSkin: set rotSpeed to PlayerSkin.isMirrored ? -JRotSpeed : JRotSpeed
    
    Player: On Landed 
      -> PlayerSkin: set rotSpeed to 0
      -> Player: set angle to 0
    
    Every Ticks:
      -> PlayerSkin: Set Angle to Clamp(Player.angle+rotSpeed*dt,-JAngle,JAngle)

    (Sorry, didn't keep your awesomely long variable names :D)

    Use dt, this way your movement isn't fps dependant

    if you rotate 2 degree per frame the movement won't have the same speed at 30 and 60fps

    By multiplying by dt (time delta = time (in seconds) between the previous and the current frame) you'll always keep the same speed.

    And also it allows you to express your values per seconds (adding 1*dt to a value each frame, this value will go up to 1 per second)

    Anyway it should work

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • mouse button is down -> add 5*dt to power

    will progresively add 5 to power per second so 1 per 0.2 seconds

  • System: set scroll X to scrollX+100*dt

  • Cool Thanks (:

Yann's avatar

Yann

Member since 31 Dec, 2010

Twitter
Yann has 5 followers

Connect with Yann