Toddler's Recent Forum Activity

  • Is there a way to create my own updated version of nw.js since construct 2's is not update anymore ?

  • Lite Tween have an "Enforce Mode": Enforce and Compromise.

    What does either of the two means ?

  • It's ok I have fixed it !

    Looks like my Delta time function works !

    Hopefully someone will find this useful.

    <!DOCTYPE HTML>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Delta Time</title>
    <style type="text/css">
    body,td,th 
    {
    	font-family: consolas;
    	font-weight:bold;
    	font-size: 50px;
    	color: #F90;
    }
    body 
    {
    	border:0;
    	margin:0;
    	padding:0;
    	background-color: #000;
    	overflow:hidden;
    }
    #container
    {
    	width:100vw;
    	height:100vh;
    	display:grid;
    	place-items:center;
    }
    #delta_Time
    {
    	color:#7f84ff;
    }
    </style>
    <script src="jquery-1.11.1.min.js"></script>
    <script>
    
    var Delta_Time_Last_Update = Date.now();
    var Delta_Time_Now = 0;
    var Delta_Time = 0;
    
    var delta_time_enterframe_handle = requestAnimationFrame(delta_time_enterframe);
    function delta_time_enterframe(event)
    {
    	Delta_Time_Now = Date.now();
    	Delta_Time = (Delta_Time_Now - Delta_Time_Last_Update) / (1000/60);
    	Delta_Time_Last_Update = Delta_Time_Now;
    	
    	$("#delta_Time").html(Delta_Time);
    	$("#ball").css("left",(parseFloat($("#ball").css("left").replace(/[^-\d\.]/g, ''))+(0.2 * Delta_Time))+"px");
    	console.log($("#ball").css("left").replace(/[^-\d\.]/g, ''));
    	
    	delta_time_enterframe_handle = requestAnimationFrame(delta_time_enterframe);
    	//cancelAnimationFrame(delta_time_enterframe_handle);
    }
    </script>
    
    </head>
    
    <body>
    <div id="container">
    <table width="800px" border="1">
    <tr>
    <td align="right" style="color:#cc99cc;" width="330px">Delta Time:</td>
    <td>
    <div id="delta_Time" style="margin-left:7px;">
    0000
    </div>
    </td>
    </tr>
    </table>
    </div>
    <div id="ball" style="position:absolute; left:10px; top:10px; background-color:#0F0; width:100px; height:100px; border-radius:100px;"></div>
    </body>
    
    </html>
    
    
  • <!DOCTYPE HTML>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Delta Time</title>
    <style type="text/css">
    body,td,th 
    {
    	font-family: consolas;
    	font-weight:bold;
    	font-size: 50px;
    	color: #F90;
    }
    body 
    {
    	border:0;
    	margin:0;
    	padding:0;
    	background-color: #000;
    	overflow:hidden;
    }
    #container
    {
    	width:100vw;
    	height:100vh;
    	display:grid;
    	place-items:center;
    }
    #delta_Time
    {
    	color:#7f84ff;
    }
    </style>
    <script src="jquery-1.11.1.min.js"></script>
    <script>
    
    var Delta_Time_Last_Update = Date.now();
    var Delta_Time_Now = 0;
    var Delta_Time = 0;
    
    var delta_time_enterframe_handle = requestAnimationFrame(delta_time_enterframe);
    function delta_time_enterframe(event)
    {
    	Delta_Time_Now = Date.now();
    	Delta_Time = (Delta_Time_Now - Delta_Time_Last_Update) / (1000/60);
    	Delta_Time_Last_Update = Delta_Time_Now;
    	
    	$("#delta_Time").html(Delta_Time);
    	$("#ball").css("left",(parseFloat($("#ball").css("left").replace(/[^-\d\.]/g, ''))+0.2)*Delta_Time+"px");
    	console.log($("#ball").css("left").replace(/[^-\d\.]/g, ''));
    	
    	delta_time_enterframe_handle = requestAnimationFrame(delta_time_enterframe);
    	//cancelAnimationFrame(delta_time_enterframe_handle);
    }
    </script>
    
    </head>
    
    <body>
    <div id="container">
    <table width="800px" border="1">
    <tr>
    <td align="right" style="color:#cc99cc;" width="330px">Delta Time:</td>
    <td>
    <div id="delta_Time" style="margin-left:7px;">
    0000
    </div>
    </td>
    </tr>
    </table>
    </div>
    <div id="ball" style="position:absolute; left:10px; top:10px; background-color:#0F0; width:100px; height:100px; border-radius:100px;"></div>
    </body>
    
    </html>
    
    
    I couldn't get it to work, deltatime is not accurate, if I remove delta time everything works perfectly.
    
  • var Delta_Time_Last_Update = Date.now();
    var Delta_Time_Now = 0;
    var Delta_Time = 0;
    
    var delta_time_enterframe_handle = requestAnimationFrame(delta_time_enterframe);
    function delta_time_enterframe(event)
    {
    	Delta_Time_Now = Date.now();
    	Delta_Time = (Delta_Time_Now - Delta_Time_Last_Update) / (1000/60);
    	Delta_Time_Last_Update = Delta_Time_Now;
    	
    	$("#delta_Time").html(Delta_Time);
    	
    	
    	delta_time_enterframe_handle = requestAnimationFrame(delta_time_enterframe);
    	//cancelAnimationFrame(delta_time_enterframe_handle);
    }

    This code works and almost always reports 0.969999998~

    Is this more or less the way Construct 2 get its dt ?

    Thanks !

  • What is the diff between a global variable and a local variable with static checked ?

    They both retain their data so...

  • BadMario, your method is insane ! You must be a genius, this is way too much for me.

    I will use dop2000 is sleeping method for now.

  • How do I detect when all physics object has finally come to a complete stop ?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Found it:

    "https://www.scirra.com/manual.zip"

  • Here:

    scirra.com/manual/87/8-direction

    On the left side it says "Download the Official Construct 2 Manual (2.2mb)".

    It will try to link to "https://www.scirra.com/manual/87/manual.zip"

    which will bring you...back to the page you click it from...

  • Wow, that's just painful...

  • Simplifying the codes, removing all unnecessary stuff, I know there are two functions with the same name but I am still simplifying the function to make it a self contain useful function for now so naming doesn't matter for now, still work in progress:

    function shake()

    {

    this.shakeMag = 0;

    this.shakeStart = 0;

    this.shakeEnd = 0;

    this.shakeMode = 0;

    this.shakeEnforcePosition = 0;

    this.shakeOriginalX = 0;

    this.shakeOriginalY = 0;

    this.axis = 0;

    }

    function tick2()

    {

    if (!this.enabled)

    {

    return;

    }

    // Is in a shake?

    var now = this.runtime.kahanTime.sum;

    var offx = 0, offy = 0;

    if (now >= this.shakeStart && now < this.shakeEnd)

    {

    var mag = this.shakeMag * Math.min(this.runtime.timescale, 1);

    // Mode 0 - reducing magnitude - lerp to zero

    if (this.shakeMode === 0)

    {

    mag *= 1 - (now - this.shakeStart) / (this.shakeEnd - this.shakeStart);

    }

    var a = Math.random() * Math.PI * 2;

    var d = Math.random() * mag;

    offx = Math.cos(a) * d;

    offy = Math.sin(a) * d;

    }

    //update only when necessary and one more time to enforce object position

    if (offx != 0 || offy != 0 || (this.shakeEnforcePosition === 1 && this.shakeStart > 0))

    {

    if (this.axis == 1)

    {

    this.inst.x = this.shakeEnforcePosition ? this.shakeOriginalX + offx : this.inst.x + offx;

    }

    else if (this.axis == 2)

    {

    this.inst.y = this.shakeEnforcePosition ? this.shakeOriginalY + offy : this.inst.y + offy;

    }

    else

    {

    this.inst.x = this.shakeEnforcePosition ? this.shakeOriginalX + offx : this.inst.x + offx;

    this.inst.y = this.shakeEnforcePosition ? this.shakeOriginalY + offy : this.inst.y + offy;

    }

    this.inst.set_bbox_changed();

    //turn off

    if (this.shakeEnforcePosition === 1 && now > this.shakeEnd)

    {

    this.shakeStart = 0;

    }

    }

    }

    function Shake(mag, dur, mode, enforcePosition, axis)

    {

    this.shakeMag = mag;

    this.shakeStart = this.runtime.kahanTime.sum;

    this.shakeEnd = this.shakeStart + dur;

    this.shakeMode = mode;

    this.shakeEnforcePosition = enforcePosition;

    this.shakeOriginalX = this.inst.x;

    this.shakeOriginalY = this.inst.y;

    this.axis = axis;

    }

Toddler's avatar

Toddler

Member since 19 Jan, 2012

Twitter
Toddler has 1 followers

Trophy Case

  • 12-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Email Verified

Progress

14/44
How to earn trophies