Microsoft MakeCode

Help with floating sprites

I am working on my next game, Rygary, which I intend to make as a spin off the game ‘Rygar’. For those that have never seen the game: https://www.youtube.com/watch?v=fYSUq_RHybw&t=1515s

I am wondering if you can test the game for me.

Everything works fine when playing on a computer. When playing on my phone (Nokia 7.2 Chrome), and when the enemies appear, they all become ‘Matrix Revolution’-like and start floating in the air. This is usually happening when I start swinging the sword. In a game update I keep setting the position of the sword sprite relative to the player.

I thought about limiting the number of enemies. Can someone help me out? I appreciate all the help I can get and value your feedback. Thanks.

3 Likes

@jwunderl @richard @peli @mmoskal @AlexK

Sorry to all spam you about this, but I am desperate in finding out what the issue is here.

On a computer when there are about 90-100 sprites and the fps drops around 10, then all sprites begin to float. If I try playing this on hardware, even on my mobile phone mentioned above, then as soon as one/two sprites appear the same problems occurs.

I know I can limit the number of sprites, but even after one it becomes an issue. I tried so many things, from removing the background entirely, making the tilemap smaller (100x8; I don’t mind if it should be smaller again) , removing all animations (even when the player shoots). The moment that the player jumps the problem occurs . I set a sprite to be in front of the player and have that sprite follow the camera. In a game update I set the player to be some distance away from the other sprite. Could it be that the ‘game update’ methods are computationally intensive? Even without any enemies, when the player jumps, it jumps erratically (way too high).

I am really pleased with the platform, and love and appreciate the community support, but I am starting too lose faith in stability of the platform. It seems to me that the moment a game becomes too large, it doesn’t work on a phone, on my PyGamer. I was able to play it on my PyGamer but that stopped working after some time. I don’t mind playing it on a computer, but it would be nice if it worked on a my phone and/or hardware.

Can someone please help? :confounded:

My apologies in advance for the methods being spread out all over the place. That happens unfortunately whenever I have to switch to Javascript and remove an extension. After which all the methods have moved.

Running a low power laptop with chromium browser and I’m seeing the floating issues pretty quickly. It definitely gets worse as I make my way across the map. I couldn’t make it to the end of the map without killing enemies due to the float/lag.

Good luck. Looks like some intense code.

1 Like

Thank you for getting back to me on this. There are quite a number of different functions, but really the only ones which should affect performance are the ones called in game update. Even after I removed all calls to use animation, it was still a problem.

This is a physics bug that happens whenever the computer is not giving enough resources to the iframe or when the game is very resource intensive. In this case, it’s probably the number of sprites combined with the large tilemap.

You’re most likely to see this happen when focused on the workspace and scrolling around, because that is resource intensive and takes away processing time from the simulator. Also more likely to happen on lower-end hardware.

I believe we have a bug open for this somewhere

Thanks for getting back to me on this Richard. I am trying to cut down on the number of methods in the game update, and moving this to ‘event’ driven checks.
Just curious…
Is it better to check in a game update interval method (even if this means it is not real time) when a player is doing something? Does this give the hardware more time to process things?

No, you should do it in on game update! Your code doesn’t look particularly heavy, this is probably just due to the physics engine itself.

1 Like

Hey @cosmoscowboy! I’ve had that same problem but it’s on my laptop and on my phone. When I play this game, all the coins float all the way up. I believe it’s because of all the sprites in a game update block.

This is my link. It’s an automated Plinko game and it kills me. If you survive for a while, you will see all the balls still going, and eventually, it will lag and all the coins go up

2 Likes

I know this is an old post, but I would like to pick up this game again. I am not sure what you mean by the statement above. Could you explain ‘focused on the workspace and scrolling around’?

If you are using the blocks workspace and scrolling it around (panning), your computer needs to spend extra time re-rendering all of the blocks. As a result, it takes away some resources from things it thinks you aren’t using, like the simulator iframe.

As stated in my original post, this problem only occurs when playing the game on hardware, or on my phone. Playing the game within a browser on my computer is not a problem.

If I am playing the game (on hardware or on my phone) without seeing the code, surely that should not need to spend time recalculating the block code. (If you are using the blocks workspace and scrolling it around (panning), your computer needs to spend extra time re-rendering all of the blocks.)

This is because you are spawning too many sprites that what the platform can handle. My problem with the floating sprites was occurring even when I just spawned one enemy sprite.

1 Like

I love Rygar. Great MakeCode edition! I think I will play the original tonight.

1 Like