2d game lagging.

Started by
9 comments, last by aregee 9 years, 8 months ago

So, i'm making a 2d rpg tile scrolling game in java, everything went smooth until about a week ago. The rendering area in the game is based on the player coords, when the player moves, the rendering area moves. About a week ago everything "scrolled" perfectly smooth, but now the scrolling "lags". The rendering area moves like 1 pixel back and forth very quickly for about 3 sec, then for 0.5 sec it's very smooth. I've searched my code for a week to try and find any rendering issues, but nothing found. Then i played realm of the mad god and i saw the exact same thing there(never been there before), is there something wrong with my computer?, what should i do?, has anyone else experienced this? My pc is not too slow, the game is running @ 4800fps.

Advertisement
Off the top of my head I would say it's not Java related in the sense that Java needs to be reinstalled, since rotmg is created in flash. I would probably try to reinstall the graphics drivers, maybe something went wrong during an update.

Edit:
If this doesn't work, maybe you should make sure that you are clearing the memory in the game so that you don't just continuously allocate more and more memory just because u aren't flushing/clearing ur graphics after each redraw or something like that.

Otherwise I think we need more information, when exactly did it start, what's the difference between the code when it worked and the week that didn't work etc. What did you add? Without this it's extremely difficult to give an accurate answer.

Off the top of my head I would say it's not Java related in the sense that Java needs to be reinstalled, since rotmg is created in flash. I would probably try to reinstall the graphics drivers, maybe something went wrong during an update.

Edit:
If this doesn't work, maybe you should make sure that you are clearing the memory in the game so that you don't just continuously allocate more and more memory just because u aren't flushing/clearing ur graphics after each redraw or something like that.

Otherwise I think we need more information, when exactly did it start, what's the difference between the code when it worked and the week that didn't work etc. What did you add? Without this it's extremely difficult to give an accurate answer.

Tried to reinstall drivers, didn't work, i'm clearing memory, and never seen any fps drops. It worked fine before i implemented online multiplayer i think, but i have backups from before that and they lag the same way now, so i don't think it's the code, none of my friends i tested multiplayer experienced any lag. So i think it's my computer, i've installed some random games lately, might try to remove some..

Edit: Didn't work.

Alright, if no one else experiences it then it's definitely related to something local on us computer. Hope you find the culprit :)

Have you had any program running for a long time or use frequently?

1. Figure out how to repeat the behavior.

2. Use the jconsole utility that comes with the jdk to profile what is happening.

3. Assume that it is your code, and not Java (this is really hard).

I think, therefore I am. I think? - "George Carlin"
My Website: Indie Game Programming

My Twitter: https://twitter.com/indieprogram

My Book: http://amzn.com/1305076532

I know this is gonna sound dumb, but have you restarted your computer and cleared unnecessary start up programs? XD lol

Just my 2 cents.

This sound to me like one of these times you did an obvious change somewhere in the code, a change that you thought wouldn't alter anything (but it did), and you left it untested because you thought you just made a cosmetic change. Then maybe you wrote a bunch of new code, and then suddenly the game starts behaving in weird ways, and now you forgot exactly what changes you did...

I have done that myself a few times, swearing at not checking my code in to the SVC system more often than I do, since it would be trivial to do a DIFF to find exactly what changes I have actually done lately...

Sometimes I even play my code backwards to find out what exactly I have done (lots of undos - if I even have the change in the undo buffer), in desperation to see what changes I actually did.

Morale of the story is to use the SVC system as often as reasonable. (For every logical unit of change.)

Oh, and on the undo - game, make sure you make a full copy of your source before you do a massive undo, since even a touch of a wrong key will make you lose everything so you can't redo it again. (Or even if the IDE crashes for some reason.)

This sound to me like one of these times you did an obvious change somewhere in the code, a change that you thought wouldn't alter anything (but it did), and you left it untested because you thought you just made a cosmetic change. Then maybe you wrote a bunch of new code, and then suddenly the game starts behaving in weird ways, and now you forgot exactly what changes you did...

I have done that myself a few times, swearing at not checking my code in to the SVC system more often than I do, since it would be trivial to do a DIFF to find exactly what changes I have actually done lately...

Sometimes I even play my code backwards to find out what exactly I have done (lots of undos - if I even have the change in the undo buffer), in desperation to see what changes I actually did.

Morale of the story is to use the SVC system as often as reasonable. (For every logical unit of change.)

Oh, and on the undo - game, make sure you make a full copy of your source before you do a massive undo, since even a touch of a wrong key will make you lose everything so you can't redo it again. (Or even if the IDE crashes for some reason.)

He has already stated that this happens with previous builds as well:


Tried to reinstall drivers, didn't work, i'm clearing memory, and never seen any fps drops. It worked fine before i implemented online multiplayer i think, but i have backups from before that and they lag the same way now, so i don't think it's the code, none of my friends i tested multiplayer experienced any lag. So i think it's my computer...

I would start by tracing the coordinates of the rendered area vs the player coordinate, just to be sure that it behave as expected.

If the trace shows that coordinates changes smoothly, then there is a problem with the rendering. If not, then there is a problem in the scrolling code.

Space Zig-Zag, a casual game of skill for Android by Sporniket-Studio.com

This topic is closed to new replies.

Advertisement