Jump to content


Photo

Physics in HTML5


  • Please log in to reply
18 replies to this topic

#1 tice666

tice666

    GMC Member

  • GMC Member
  • 13 posts
  • Version:GM:HTML5

Posted 24 May 2012 - 09:44 PM

Do they work?
Because it wont work for me..
  • 0

#2 Nocturne

Nocturne

    Nocturne Games

  • Administrators
  • 16996 posts
  • Version:GM:Studio

Posted 24 May 2012 - 09:50 PM

Yes they do work. There was a minor bug that shows up in the Angry Cats demo but that has been fixed (the update should be out soon). What are you trying to do? What code have you used? Also, note that the HTML5 runner will give slightly different (but consistent) results to the windows one due to the fact that it is JavaScript that is being used.
  • 0

#3 tice666

tice666

    GMC Member

  • GMC Member
  • 13 posts
  • Version:GM:HTML5

Posted 24 May 2012 - 09:58 PM

Im trying to make ropes, and im using the "use physics" checkbutton in the object editor.

Create event (obj_rope) (Base code from him, thanks!)
new_chain = self;
smooth = 8;

for (i = 0; i < 16; i += 1) {
  old_chain = new_chain;
  new_chain = instance_create(x, y + smooth * i, obj_chain);
  new_chain.par = old_chain;
  physics_joint_distance_create(old_chain, new_chain, x, y + smooth * (i - 1), x, y + smooth * i,false);
  
  // random impulse
  if (i == 14)
   with (new_chain) 
     physics_apply_local_force(0, 0, 6000, -2500);
}

Edited by tice666, 24 May 2012 - 09:59 PM.

  • 0

#4 @Alex@

@Alex@

    Retired GMC Reviewer

  • Reviewer
  • 3142 posts
  • Version:Unknown

Posted 24 May 2012 - 10:00 PM

I tried running the astroids physics demo in html5 and was treated to nothing in FireFox, really wish there was an option to use non-default browsers to launch html5 games from within studio.
  • 0

#5 tice666

tice666

    GMC Member

  • GMC Member
  • 13 posts
  • Version:GM:HTML5

Posted 24 May 2012 - 10:01 PM

I tried running the astroids physics demo in html5 and was treated to nothing in FireFox, really wish there was an option to use non-default browsers to launch html5 games from within studio.

Yeah i also tried that, with chrome.
The canvas wont show up.
  • 0

#6 Nocturne

Nocturne

    Nocturne Games

  • Administrators
  • 16996 posts
  • Version:GM:Studio

Posted 24 May 2012 - 10:54 PM

The demo should run in a browser... so please file a bug if it doesn't. http://bugs.yoyogame.../login_page.php

As for the browser, you CAN change the default one from the preferences tab. So, go to the drop down FILE menu, select PREFERENCES then the WEB SERVER tab. Second from the top you can select any browser you wish to be the default one (no browser means the default browser you normally use).çç

Finally, to create a chain you want something more like this...


var par, yy, i;
par = id;
yy=y+sprite_get_height(spr_CHAIN);
i=0;

//Create the chain
repeat(5)
    {
    with (instance_create(x,yy,obj_CHAIN))
        {
        other.link[i]=id;
        parent = par; //The parent section is the previously created section OR the player ship
        par = id; //for the next instance made...
        joint=physics_joint_revolute_create(parent, id, x, y - sprite_height / 2, -90, 90, false, 0, 0, false, false); //create the joint
        }
    yy += sprite_get_height(spr_CHAIN);
    i+=1;
    }

  • 0

#7 bobhoil

bobhoil

    GMC Member

  • GMC Member
  • 1523 posts

Posted 25 May 2012 - 02:56 AM

I am actually recreating a game of mine that used custom physics with the physics in studio. Everything is working fine on my end in both firefox and chrome running at full speed.
  • 0

#8 SafetyBear

SafetyBear

    GMC Member

  • GMC Member
  • 18 posts
  • Version:GM:HTML5

Posted 25 May 2012 - 02:40 PM

Hmm.. I can't get the canvas to show either. Works in windows though.
  • 0

#9 jfroco

jfroco

    GMC Member

  • GMC Member
  • 15 posts

Posted 19 June 2012 - 02:24 AM

Hello,

I tried a simple Physics project using the "Room Physics World" and "Object->Uses Physics" and works OK in Android and Windows but in HTML5 the page remains black. I tried the "Angry Cats" demo and it worked in HTML5 but I noticed that it doesn't use "Room Physics World" nor "Uses Physics" all is made in GML.

I will try to chage everything to GML to see if run in HTML5

Best regards

[EDIT]
It doesn't work.. I filled a bug report: http://bugs.yoyogame...iew.php?id=4505

[EDIT2]
According to Yoyogames, it will be resolved in v >= 1.0.252.
Looking forward to it!!!

Edited by jfroco, 19 June 2012 - 03:37 PM.

  • 0

#10 jfroco

jfroco

    GMC Member

  • GMC Member
  • 15 posts

Posted 20 June 2012 - 12:21 PM

Hi,

After upgrading to v1.0.253 I still get a black screen in my browser. Filed a new bug report: http://bugs.yoyogame...iew.php?id=4560

I don't understand why yoyogames closed my first report saying it will be solved in v1.0.252 and the bug is still there.... :(

Best regards
  • 0

#11 jfroco

jfroco

    GMC Member

  • GMC Member
  • 15 posts

Posted 21 June 2012 - 04:54 PM

They close my case again!!!!

Saying that they couldn't reproduce it

They asked me to reinstall GMS (I did it).. clean my browser cache (it has nothing to do but I did it anyway) and the same result: black screen of death.


After some research I got the error in Javascript generated by GMS:


var jb={kb:[],lb:[],mb:[{nb:"spritePelota",width:32,height:32,ob:!1,pb:16,qb:16,rb:31,sb:31,tb:[0]},{nb:"spriteBloque",width:32,height:32,ob:!1,pb:16,qb:16,rb:31,sb:31,tb:[1]},{nb:"spriteMono",width:32,height:32,ob:!1,pb:16,qb:16,rb:31,sb:31,tb:[2]},{nb:"spriteCaja",width:32,height:32,ob:!1,pb:16,qb:16,rb:31,sb:31,tb:[3]}],ub:[],vb:[],wb:[],xb:[],yb:[],zb:[{},],ac:[{nb:"objectPelota",bc:!0,parent:-100,cc:!0,dc:!1,ec:0,fc:0,5,gc:0,4,hc:1,ic:0,1,jc:0,1,kc:[0,0,16,lc],mc:nc,oc:[],pc:[]},{nb:"objectBloque",
Uncaught SyntaxError: Unexpected token ,


So, now I know what the error is!!!!!

In my country we use the , instead of . for decimals, and GMS uses locale but when compiling it to javascript doesn't translate the "," to "."

Workaround: change PC locale.
Fix: open a new case: third one (and I had to do all the troubleshooting ... sad )


But after passing that ... I'm hitting a lot of errors!!!! I can't imagine how they say that it is working :(



If I use circle shape:


var ed={fd:[],gd:[],hd:[{id:"sprite0",width:32,height:32,jd:!1,kd:16,ld:16,md:31,nd:31,od:[0]},{id:"sprite1",width:32,height:32,jd:!1,kd:16,ld:16,md:31,nd:31,od:[1]}],pd:[],qd:[],rd:[],sd:[],td:[],ud:[{},],vd:[{id:"object0",wd:!0,parent:-100,xd:!0,yd:!1,zd:1,ae:0,be:0.1,ce:1,de:0.1,ee:0.1,fe:[-16,-16,16,-16,16,16,-16,16],ge:[],he:[]},null,{id:"object2",ie:1,wd:!0,parent:-100,xd:!0,yd:!1,zd:0,ae:0.5,be:0.1,ce:1,de:0.1,ee:0.1,fe:[0,0,16,je],ge:[],he:[]}],ke:[{id:"room0",width:640,height:480,le:!0,me:0,
Uncaught ReferenceError: je is not defined


If I use only box shape:
var dmb=(av*ut.xt.yj+ix*ut.xt.zj);var emb=(av*ut.yt.yj+ix*ut.yt.zj);for(var em=0;em<this.nt;++em){et=this.pt[em];av=dmb-et.yj;ix=emb-et.zj;et=this.rt[em];var du=(et.yj*av+et.zj*ix);if(du>0.0){return !1}}return !0};co.prototype.hr=function(ir,jr,transform){var fmb=0.0;var gmb=jr.ucb;var av=0;var ix=0;var ut;var et;av=jr.nr.yj-transform.position.yj;ix=jr.nr.zj-transform.position.zj;ut=transform.vt;var ox=(av*ut.xt.yj+ix*ut.xt.zj);var px=(av*ut.yt.yj+ix*ut.yt.zj);av=jr.pr.yj-transform.position.yj;ix=jr.pr.zj-transform.position.zj;
ut=transform.vt;var qx=(av*ut.xt.yj+ix*ut.xt.zj);var rx=(av*ut.yt.yj+ix*ut.yt.zj);var zq=qx-ox;var ar=rx-px;var wj=parseInt((-1));for(var em=0;em<this.nt;++em){et=this.pt[em];av=et.yj-ox;ix=et.zj-px;et=this.rt[em];var hmb=(et.yj*av+et.zj*ix);var imb=(et.yj*zq+et.zj*ar);if(imb==0.0){if(hmb<0.0){return !1}}else {if(imb<0.0&&hmb<fmb*imb){fmb=hmb/imb;wj=em}else if(imb>0.0&&hmb<gmb*imb){gmb=hmb/imb}}if(gmb<fmb-Number.MIN_VALUE){return !1}}if(wj>=0){ir.yr=fmb;ut=transform.vt;et=this.rt[wj];ir.sr.yj=(ut.xt.yj*et.yj+ut.yt.yj*et.zj);
ir.sr.zj=(ut.xt.zj*et.yj+ut.yt.zj*et.zj);return !0}return !1};co.prototype.ojb=function(fr,jeb){var ut=jeb.vt;var et=this.pt[0];var jmb=jeb.position.yj+(ut.xt.yj*et.yj+ut.yt.yj*et.zj);var kmb=jeb.position.zj+(ut.xt.zj*et.yj+ut.yt.zj*et.zj);var lmb=jmb;var mmb=kmb;for(var em=1;em<this.nt;++em){et=this.pt[em];var keb=jeb.position.yj+(ut.xt.yj*et.yj+ut.yt.yj*et.zj);var leb=jeb.position.zj+(ut.xt.zj*et.yj+ut.yt.zj*et.zj);jmb=jmb<keb?jmb:keb;kmb=kmb<leb?kmb:leb;lmb=lmb>keb?lmb:keb;mmb=mmb>leb?mmb:leb}fr.wq.yj=jmb-this.ov;
Uncaught TypeError: Cannot read property 'yj' of undefined (repeated 1432 times)


Is there anybody from Yoyogames here?
  • 0

#12 Nocturne

Nocturne

    Nocturne Games

  • Administrators
  • 16996 posts
  • Version:GM:Studio

Posted 21 June 2012 - 05:28 PM

Hi there! Sorry to see your troubles with this... I have a Spanish local machine that uses the "," instead of the "." too... So, feel free to pm me your game file (export it as a *.gmz) and i'll happily test it for you and re-open your bug report if I can reproduce the error.
  • 0

#13 jfroco

jfroco

    GMC Member

  • GMC Member
  • 15 posts

Posted 22 June 2012 - 01:34 AM

Hi there! Sorry to see your troubles with this... I have a Spanish local machine that uses the "," instead of the "." too... So, feel free to pm me your game file (export it as a *.gmz) and i'll happily test it for you and re-open your bug report if I can reproduce the error.


Hello,

This is the most siple project I can imagine.

One object, one room. Physics enabled in the room. No physics in the object.

https://dl.dropbox.com/u/4281970/gamemaker/SuperSimple.gmx.rar

This is the error in javascript code when running in Chrome:

var hj={ij:[],jj:[],kj:[{lj:"sprite0",width:32,height:32,mj:!1,nj:16,oj:16,pj:31,qj:31,rj:[0]}],sj:[],tj:[],uj:[],vj:[],wj:[],xj:[{},],yj:[{lj:"object0",zj:!0,parent:-100,ak:[],bk:[]}],ck:[{lj:"room0",width:640,height:480,dk:!0,ek:0,fk:0,gk:640,hk:480,ik:0,jk:10,kk:0,1,lk:[{},{},{},{},{},{},{},{}],mk:[{},{},{},{},{},{},{},{}],nk:[{ok:192,pk:96,qk:0,rk:100000,sk:0,tk:1,uk:1,vk:4294967295}],wk:[]}],xk:[0],yk:[{ok:0,pk:0,zk:32,al:32,bl:0,cl:0,dl:32,el:32,fl:32,gl:32,hl:0}],il:["SuperSimple_texture_0.png"],
Uncaught SyntaxError: Unexpected token ,


But after changing the locale, I'm getting more errors, so this is not the issue right now, please see my previous post and the case here: http://bugs.yoyogame...iew.php?id=4600

Best regards
  • 0

#14 Nocturne

Nocturne

    Nocturne Games

  • Administrators
  • 16996 posts
  • Version:GM:Studio

Posted 22 June 2012 - 06:05 AM

Yes this is clearly a localisation error... I have added a note to your bug report too!

PS: In Chrome, if you run your HTML5 games in debug mode, when you open the console you can select "pretty print" and actually get READABLE code? It's a fantastic tool.. Posted Image
  • 0

#15 jfroco

jfroco

    GMC Member

  • GMC Member
  • 15 posts

Posted 22 June 2012 - 06:06 PM

Yes this is clearly a localisation error... I have added a note to your bug report too!

PS: In Chrome, if you run your HTML5 games in debug mode, when you open the console you can select "pretty print" and actually get READABLE code? It's a fantastic tool.. Posted Image


Great, thank you!!!

I didn't know that javascript code was readable when running in debug mode... now it was super simple to get the bug solved replacing the "," with ".":

from

physicsDensity: 0, physicsRestitution: 0,1, physicsGroup: 1, physicsLinearDamping: 0,1, physicsAngularDamping: 0,1,

to

physicsDensity: 0, physicsRestitution: 0.1, physicsGroup: 1, physicsLinearDamping: 0.1, physicsAngularDamping: 0.1,

and, from

physicsPixToMeters:0,1,

to

physicsPixToMeters:0.1,


But there's another bug:

When I use circle shape I get this:


{			pName: "object1",  spriteIndex: 1,  visible: true,  parent: -100,  physicsObject: true, physicsSensor: false, physicsShape: 0, physicsDensity: 0.5, physicsRestitution: 0.4, physicsGroup: 1, physicsLinearDamping: 0.1, physicsAngularDamping: 0.1, physicsShapeVertices: [  0, 0,  16, NeuN ],  TriggerEvents: [  ],
 CollisionEvents: [  ]
 }	],

and this error in Javascript:

Uncaught ReferenceError: NeuN is not defined


What is NeuN?

If I change this valuie to a number it works but Why GMS is adding this variable?

[EDIT:

I changed NeuN to null and it worked!!! I

]

JF

Edited by jfroco, 22 June 2012 - 06:14 PM.

  • 0

#16 GreenMeteorTeam

GreenMeteorTeam

    GMC Member

  • GMC Member
  • 149 posts
  • Version:GM:Studio

Posted 26 June 2012 - 02:24 PM

I'm also getting the blank canvas when I use physics. Chrome's Javascript console says "Cannot read property 'x' of undefined " it has a dropdown list of places where it occurs, the only thing on the list not obfuscated is physics_fixture_bind. And that's using the checkbox "uses physics" method to bind it. :confused:

Edited by GreenMeteorTeam, 26 June 2012 - 02:31 PM.

  • 0

#17 jfroco

jfroco

    GMC Member

  • GMC Member
  • 15 posts

Posted 26 June 2012 - 07:03 PM

I'm also getting the blank canvas when I use physics. Chrome's Javascript console says "Cannot read property 'x' of undefined " it has a dropdown list of places where it occurs, the only thing on the list not obfuscated is physics_fixture_bind. And that's using the checkbox "uses physics" method to bind it. :confused:


Unfortunately, it's been 5 days since I opened the case and still no answer from Yoyogames :(
  • 0

#18 jfroco

jfroco

    GMC Member

  • GMC Member
  • 15 posts

Posted 02 July 2012 - 11:57 PM


I'm also getting the blank canvas when I use physics. Chrome's Javascript console says "Cannot read property 'x' of undefined " it has a dropdown list of places where it occurs, the only thing on the list not obfuscated is physics_fixture_bind. And that's using the checkbox "uses physics" method to bind it. :confused:


Unfortunately, it's been 5 days since I opened the case and still no answer from Yoyogames :(



Hi,

OK. I don't understand what is happenning but it should be at least an answer from Yoyogames after 12 days. I really like Game maker but with this level of support is hard to work with them.
  • 0

#19 jfroco

jfroco

    GMC Member

  • GMC Member
  • 15 posts

Posted 14 July 2012 - 12:55 AM

Hi,

It is solved in v1.0.282.

Thank you, Yoyogames!!!
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users