Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lagging when the screen is full of "monsters" #14

Closed
Bahjesaispas opened this issue Jul 6, 2016 · 12 comments
Closed

lagging when the screen is full of "monsters" #14

Bahjesaispas opened this issue Jul 6, 2016 · 12 comments

Comments

@Bahjesaispas
Copy link

http://hpics.li/ad4eff6

As you can see on the picture the screen is full of "monsters". But on the screenshot you cannot see that at this point the game is lagging a lot !!

@Almtesh
Copy link

Almtesh commented Jul 7, 2016

Yes, that's quite normal. Your phone is very busy to render all the assets on the screen. A lot of tower defense have this problem.

@mvdan
Copy link
Contributor

mvdan commented Jul 7, 2016

You could look into profiling the app to see if the framerate drop could be avoided until a bigger number of enemies are on screen. Then you could open either issues or pull requests about specific issues that you find. But this one is just too broad as @Almtesh pointed out.

@mjaun
Copy link
Owner

mjaun commented Jul 8, 2016

I think there are two ways to address this problem:

  • Optimizing the game engine (any hints are much appreciated! Like @mvdan pointed out, profiling would probably be the way to go)
  • Altering the gameplay like limiting the total amount of active waves (maybe reduces the fun factor but would basically limit the total amount of enemies in game)

@mjaun mjaun added the bug label Jul 8, 2016
@mvdan
Copy link
Contributor

mvdan commented Jul 9, 2016

Note that another strategy would be skipping frames. As in, make the game drop FPS instead of lag to render always the same number of frames per in-game second.

I don't know what the current FPS is, but perhaps you could make the app accept a range like 15-60. At best, it would do 60 frames per second, and at worst 15. You don't want it to drop to something like 4 frames per second.

@Almtesh
Copy link

Almtesh commented Jul 12, 2016

Otherwise, you have large delays in waves

@Bahjesaispas
Copy link
Author

You're losing the bonus if you do that. Maybe a button to do faster wave will be great too. Around wave 6X it's reeeeeaaaaaaally long.

@Xodem
Copy link

Xodem commented Apr 21, 2017

You should consider to use lengthsquared whenever possible. Sqrt is quite expensive. Maybe save the actual towerrange once (for displaying purposes in the popup) but calculate the squaredrange once and compare to that.

@Almtesh
Copy link

Almtesh commented Apr 21, 2017

I heard about it too. It's a trick to save lot of time. I don't even know how to compute a square root.

@notpokey
Copy link

I think a lot of computing power must be used in tallying all of the damage done by all of the projectiles (tens of shots per second by each Gatling tower) to all of the hit counters (one for each enemy). I have a pretty robust phone, and it gets HOT playing this game. Is it really harder for the processor to render the graphics than it is to keep score?

I agree that most Tower Defense games that I've played slow down at some point, even on a computer. The only way to stop it from happening for sure seems to be to make the enemies stronger so the game ends earlier.

@civyshk
Copy link
Contributor

civyshk commented Jul 10, 2017

I've replaced some distances with squared distances and it doesn't seem to make a big difference. What I see while profiling with lots of enemies, is that there are tons of calls to iterator methods like LazyIterator.hasNext, SmartIterator.fetchNext and similar.

I'm having problems running Android Device Monitor to further analyze the trace so I leave two useful trace files in this zip here.

@civyshk
Copy link
Contributor

civyshk commented Jul 30, 2017

I've run the current version of the app in the emulator with +1000 enemies and it doesn't seem to lag. Is anybody still having lags?

2000 enemies now and still smooth. At 8x, however, it starts to drop frames, but who cares.

Edit: I'm sorry, it seems the emulator was pretty fast. On a physical phone, it still lags.

@mjaun
Copy link
Owner

mjaun commented Sep 24, 2018

Moving to #141.

@mjaun mjaun closed this as completed Sep 24, 2018
@mjaun mjaun added enhancement and removed bug labels Sep 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants