AnsonH / plinko-game

A Plinko game built with Svelte
https://plinko-web-game.netlify.app/
11 stars 2 forks source link

Balls fall extremely slowly. #11

Open 5H2 opened 1 month ago

5H2 commented 1 month ago

This project is amazing, I love it but I found the balls to fall, VERY SLOWLY. This could just be me, but it feels as if the balls are falling in slow-motion. I went to /benchmark and found it to not fall slowly at all, but your website, as well as my localhost are both extremely slow.

I'm not sure what I'm talking about, since I have just started learning the languages, and this could be intentional, but I don't know.

Thank you for the amazing project, I love it!

Video example

Apologies for shit quality and cuts, but trying to keep it short, and no this is not slowed down at all.

https://github.com/AnsonH/plinko-game/assets/97614691/c5f1a621-c9ce-4330-a513-b996568d442b

AnsonH commented 1 month ago

Hi @5H2, thanks for stopping by 😄

I'm aware that the website can be slow on mobile devices, but your demo is on a different level of slowness lol

For easier debugging, would you like to supplement a few more info?

Huge thanks!

5H2 commented 1 month ago

Hey!

I am using chrome on a relatively low end computer, I have an Intel i5 and 16GB of RAM. I also tested on my phone, with zero lag, so it is definitely my device, but it's unbearable slow, so I figured I would ask if any optimization was possible, as my computer is able to run most things fine.

Video example 2

Below I will attach a comparison of the regular vs the benchmark

https://github.com/AnsonH/plinko-game/assets/97614691/4e1767ad-8561-45f5-bb2f-3be162a45a4c

denzhe22 commented 3 weeks ago

Hey!

I am using chrome on a relatively low end computer, I have an Intel i5 and 16GB of RAM. I also tested on my phone, with zero lag, so it is definitely my device, but it's unbearable slow, so I figured I would ask if any optimization was possible, as my computer is able to run most things fine.

Video example 2

Below I will attach a comparison of the regular vs the benchmark

Untitled.design.2.mp4

image this.render = Render.create add showPerformance:true,can see fps for matter.js(not web page,because It's has 2 canvas.)

If you want to change prams, Exp:

InitMatterPrams(){ let row = get(rowCount) let cfg = GConfig.matterCfgJson[row] if(!cfg){ console.log("dx 没有找到排数的配置", row); return } //空气摩擦力1 let friction_air_per = cfg.friction_air_per // 弹力设置0.8 this.restitution = cfg.restitution //密度0.001 this.ballDensity = cfg.ballDensity//0.001 //质量 this.ballMass = cfg.ballMass // 物体摩檫力0.5 PlinkoEngine.ballFrictions.friction = cfg.friction // PlinkoEngine.ballFrictions.friction = 0 /*静摩擦力 / this.frictionStatic = cfg.frictionStatic || 0.5 //球的大小百分比0.8 this.ballRadiusPer = cfg.ballRadiusPer // 空气摩檫力 PlinkoEngine.frictionAirByRow = { 8: 0.0395 friction_air_per, 9: 0.041 friction_air_per, 10: 0.038 friction_air_per, 11: 0.0355 friction_air_per, 12: 0.0414 friction_air_per 0.9, 13: 0.0437 friction_air_per 0.8, 14: 0.0401 friction_air_per, 15: 0.0418 friction_air_per, 16: 0.0364 * friction_air_per, } PlinkoEngine.ballFrictions.frictionAirByRowCount = PlinkoEngine.frictionAirByRow

this.engineInitInfo = {
  timing: {
    timeScale: 1,
  },
  gravity:{
    x: 0,
    y: cfg.gravity_y,//
    scale: cfg.gravity_scale//0.01 
  },
  velocityIterations:4,//4
  constraintIterations:2,//2
  positionIterations:6,//6
} 

}

}