jmp909 Posted October 4, 2015 Share Posted October 4, 2015 Thanks Chg, i just meant how to improve on the algorithm that's already in there, eg by pre-rejecting some items that aren't directly optimally covered by that algorithm. Not specifically Phaser related, just to their algorithm in use with collide() that would be relevant if Phaser's collision was O(N^2), but it sounds like the spatial hash is already doing it the right way anyway.there's a comment on passing arrays vs groups into the function here though http://www.html5gamedevs.com/topic/12195-how-to-use-quadtree/?p=70279 old version (2.2.2). .not sure if it's changed sincehttp://examples.phaser.io/_site/view_full.html?d=arcade%20physics&f=quadtree+-+collision+infos.js&t=quadtree%20-%20collision%20infos j Link to comment Share on other sites More sharing options...
jmp909 Posted October 4, 2015 Share Posted October 4, 2015 DonFrag, as chg mentions.. we can't work out what the game is supposed to do, which makes it harder to advise I'm wondering if setting the blocks below the player to immovable would help, as they'd be skipped in checks anyway.http://www.html5gamedevs.com/topic/1974-using-collision-detection-without-physics/?p=13484 in fact do any of the blocks apart from those with a falling attribute and those at the top of each column even need physics? as opposed to just fixing them to a Y position. (i'm not sure if turning physics off/on on blocks would cause slowdowns though) ps I got stuck half way between two columns so I can take out both below.. I would consider your order of operations in terms of what is allowed to happen when. again I know it's early but it's good to get rid of these core gameplay issues early on Link to comment Share on other sites More sharing options...
DonFrag Posted October 4, 2015 Author Share Posted October 4, 2015 ok this is how the game is supposed to work: you have a stack of blocks with colors. They suppose to be infinite down. it's a endless down descent.the character can destroy blocks that are directly at his right side, left side or directly under his feet. the point it's going down as far as possible.if you destroy a block after a short time the above blocks start to fall. of they hit you in the head while are falling you are dead. like boulder dash.if you touch the ceiling you die. there is more complications and goals but obviously i'm stuck in the initial fase, but that is the base gameplay. OK so about implementation: blocks go up simulating that you are going down (this is for testing purpose, because if the rest work fine, the should go up when the character is "falling" . that means move the world up to simulate the character is going down. right now i set it go always up for testing reasons.another options it is with a empty tilemap and every time the character goes down the add a row to the tilemap and then resizeWorld() but i believe this method could kill performance. about the inmovable property it has a curious effect:if i set a block inmovable it can't be pushed by the character. so thats ok but.... when inmovable=true the collision event i not fired. so while it is falling i have to turn off inmovable and that;s why sometimes happens the character pushes the block. thats a bug about the error this.upBlock.FallSignal, yes im fixing this. Link to comment Share on other sites More sharing options...
chg Posted October 4, 2015 Share Posted October 4, 2015 another options it is with a empty tilemap and every time the character goes down the add a row to the tilemap and then resizeWorld() but i believe this method could kill performance.I think the trick would be to keep a constant world size (only keep track of a fixed number of levels above you) Link to comment Share on other sites More sharing options...
jmp909 Posted October 4, 2015 Share Posted October 4, 2015 have you played Pet Rescue Saga? the way I'd do it is: 1) move player2) destroy block3) tween falling blocks to position4) shift blocks up ie add new row below (if applicable)5) goto 1 that's a different core mechanic though than yours, it just avoids a whole bunch of issues.. including physics Link to comment Share on other sites More sharing options...
DonFrag Posted October 4, 2015 Author Share Posted October 4, 2015 im going to try tweens but i forsee a future problem. how to handle a falling by tween block when others blocks are going up.if the the block is tweened to move down and while is falling, befre arrives, the block under it is destroyed too. but im going to try Link to comment Share on other sites More sharing options...
jmp909 Posted October 4, 2015 Share Posted October 4, 2015 again that depends on your core mechanic.. personally I wouldn't do both tweening & movement at the same time, as per my example if your block is moving at constant speed though (linear tween) you could always just tween it to the new updated position. or you could implement your own physics equation https://en.wikipedia.org/wiki/Terminal_velocity Link to comment Share on other sites More sharing options...
DonFrag Posted October 4, 2015 Author Share Posted October 4, 2015 i think the main problem its not the movement.The problem it's the collision,overlap, overlap with no physics or whatever method is used to tell the block "ok you must stop moving" or "ok you must start to fall because no one is down you". @chgwhat do you mean with a constant world size? Link to comment Share on other sites More sharing options...
jmp909 Posted October 4, 2015 Share Posted October 4, 2015 Each block occupies a grid square (X,Y) . You stop moving because there is a block in (X, Y+1). No physics required. Link to comment Share on other sites More sharing options...
DonFrag Posted October 5, 2015 Author Share Posted October 5, 2015 well i resolved the FPS just not using collisions on falling blocks but in mobile im getting 34 to 40 ... right now only player is checking collision with blocks group.i will try to resolve this with the closer blocks and raise for fps... http://www.abstractpixel.cl/test/ http://www.abstractpixel.cl/test/js/ and added infinite looping (must be fixed but you get the general idea) i must resolve the block falling because your solutions doesnt work for me: im not using a grid for this. Link to comment Share on other sites More sharing options...
jmp909 Posted October 5, 2015 Share Posted October 5, 2015 is there a reason you call set bounds on every frame?game.world.setBounds(0,this.player.y-300,game.world.width, 2000); Link to comment Share on other sites More sharing options...
DonFrag Posted October 5, 2015 Author Share Posted October 5, 2015 it's a method for making a infinite world. Link to comment Share on other sites More sharing options...
jmp909 Posted October 5, 2015 Share Posted October 5, 2015 but why update world bounds on every frame rather than when you add a new row? by the way I've been looking at BunnyMark and realised a few things Pixi Bunnymark.. doesnt use Physics as such in the same way as Phaser.Physics, just basic calculations http://www.goodboydigital.com/pixijs/bunnymark/Phaser v3 Bunny Demo: doesn't use Phaser.Physics. it doesn't even use the Sprite system.. but hopefully this means we'll get better performance later http://labs.phaser.io/phaser3/v02/src/basic bunny demo with Phaser.Physics (arcade.. my quick test on desktop).. struggles even with a few hundred sprites, compared to the couple of hundred thousand those demos above can render is easy to make too many assumptions about what Phaser does and doesn't do. something to investigate a lot further! Link to comment Share on other sites More sharing options...
DonFrag Posted October 5, 2015 Author Share Posted October 5, 2015 This last version i made has no PhysicsMain Player has no Physicsno cube has physics max fps in my cellphone:51 fpsaverage 42lowest 31 so no physics low performance.my only toughts are...what the hell men? If you do it in every add row instead, if you go down too fast you reach and empty floor and the game is bugged. Link to comment Share on other sites More sharing options...
jmp909 Posted October 5, 2015 Share Posted October 5, 2015 like i said... strip your engine down to some basic demos and test the performance on your device, and then build back up eg 60 sprites on screen.. fps?60 stacked sprites with physics on screen.. fps? different resolutions.. fps? etc etc sorry I don't know too much about profiling to start eliminating issues Link to comment Share on other sites More sharing options...
chg Posted October 5, 2015 Share Posted October 5, 2015 so no physics low performance. my only toughts are...what the hell men?Sorry, kind of getting bored with this, so this may be my last post, but a few things to try ... How does disabling per-block tinting affect performance? What about trying to use a canvas size that matches the onscreen size (to avoid rescaling), and pre-scaling your block image to a temporary canvas to get it to the appropriate size for that canvas? (again to avoid rescaling the image each time it is drawn) What about setting roundPixels to true? See: http://www.html5gamedevs.com/topic/17539-what-does-this-mean-gamerendererrendersessionroundpixels-true/ (the block colouring may or may not be expensive, also if canvas is just slow on the device then prescaling and ensuring you can blit from the block image to the screen rather then doing a bunch of bilinear re-sampling may get you significant improvement) jmp909 1 Link to comment Share on other sites More sharing options...
jmp909 Posted October 5, 2015 Share Posted October 5, 2015 We are a "hot" topic now Chg! All of your input is appreciated... It's actually quite hard to find performance benchmarks (game size, number of physics bodies etc.... Obviously each game is different though)... So Donfrag's demo is kind of a good use case. It's not particularly heavy on complexity but it throws up a lot of issues. I've learned a lot. I was expecting my bunnymark demo to run 1000s of sprites on desktop using (non-colliding) arcade physics. I was very mistaken!Would be good to hear from anyone else that's faced similar challenges. Maybe it's just the wrong type of game to make for running outside of crosswalk/Cordova , or at least needs a different approachRegardsJ Link to comment Share on other sites More sharing options...
chg Posted October 5, 2015 Share Posted October 5, 2015 I was expecting my bunnymark demo to run 1000s of sprites on desktop using (non-colliding) arcade physics. I was very mistaken!Bunnymark was originally a flash blitting "benchmark", I assume the movement code is a port (I put benchmark in quotes as I believe the intention was more to demonstrate that it was possible) Link to comment Share on other sites More sharing options...
jmp909 Posted October 5, 2015 Share Posted October 5, 2015 Well the pixi and phaser 3 versions both use basic speed * gravity calculations. There's no other physics involved. The phaser 3 version has no "sprite" rotation currently and appears to be a more low level form of gpu surface rendering. (So not canvas I guess) As for the pixi version I thought phaser 2.4 performance would be similar (I swapped out the phaser arcade physics for the same movement code) but the performance is way off . I'm currently trying to work out what the difference is and what overheads the phaser renderer adds, as I had assumed the underlying setup was a similar PIXI renderer. I can get 3000 sprites in Pixi at 60fps on my iPad 3, but barely a few hundred in Phaser on my gaming class desktop PC.It doesn't mean I'm doing it right tho Link to comment Share on other sites More sharing options...
jmp909 Posted October 5, 2015 Share Posted October 5, 2015 donfrag... Try setting your physics sort direction to TOP_BOTTOM if you ever go back to using physics . It's explained herehttps://c9.io/andremalkine/phaser Link to comment Share on other sites More sharing options...
DonFrag Posted October 5, 2015 Author Share Posted October 5, 2015 Good morning everyone (in my country at least).i will be working today in all issues and recommendations that you offer me and i will post resultsthank you! jmp909 1 Link to comment Share on other sites More sharing options...
DonFrag Posted October 7, 2015 Author Share Posted October 7, 2015 at the end the performance is going down always when blocks are falling.i had to disable it in order to make the game playable on mobile. Link to comment Share on other sites More sharing options...
trasheater Posted October 7, 2015 Share Posted October 7, 2015 I am not sure if anyone has suggested this but I was having a huge performance hit on mobile when moving Tinted sprites. Simple fix and it really helped. jmp909 1 Link to comment Share on other sites More sharing options...
DonFrag Posted October 8, 2015 Author Share Posted October 8, 2015 what you mean moving?you mean not using them? because i changed them for sprite with colors.the thing that kills my performance it is when the blocks fall and while thay are afalling are waiting for colllide ( if state is falling update physics collide) Link to comment Share on other sites More sharing options...
jmp909 Posted October 8, 2015 Share Posted October 8, 2015 I am not sure if anyone has suggested this but I was having a huge performance hit on mobile when moving Tinted sprites. Simple fix and it really helped. thanks trasheater.. yes it was questioned further up the page .. good to know(http://www.html5gamedevs.com/topic/17615-performance-issues-in-mobileand-im-giving-up/?p=99448) Link to comment Share on other sites More sharing options...
Recommended Posts