Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (538)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (600)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  LibGDX Stuttering/Jumping Movement, TiledMap, no Delta Timing  (Read 1611 times)
0 Members and 1 Guest are viewing this topic.
Offline Memoryz

Senior Newbie


Exp: 2 years



« Posted 2014-02-02 00:42:06 »

It's jumpy and warpy, not all the time, but I'd say 95% of the time when moving.

I'm using:

OrthographicCamera camera;
TiledMap map;
OrthogonalTiledMapRenderer renderer;

My rendering method is simply:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
@Override
public void render(float delta)
{
   if(Gdx.input.isKeyPressed(Keys.DPAD_LEFT))    currentX -= moveSpeed;
   if(Gdx.input.isKeyPressed(Keys.DPAD_RIGHT)) currentX += moveSpeed;
   if(Gdx.input.isKeyPressed(Keys.DPAD_UP))) currentY += moveSpeed;
   if(Gdx.input.isKeyPressed(Keys.DPAD_DOWN)) currentY -= moveSpeed;

   Gdx.gl.glClearColor(0.0f, 0.0f, 0.0f, 1);
   Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);

   camera.position.set(currentX, currentY, 0.0F);
   camera.update();
   
   renderer.setView(camera);
   renderer.render();

   fpslogger.log();
}


Can anyone offer some help? I'm having a rough time getting this to just simply move a camera around a TiledMap, I haven't added anything but this!
Online Jimmt
« League of Dukes »

JGO Kernel


Medals: 139
Projects: 4
Exp: 3 years



« Reply #1 - Posted 2014-02-02 01:58:48 »

Apparently you know what delta timing is, so why don't you just implement it? Also, try checking what kind of fps you're getting.
Offline wreed12345

JGO Knight


Medals: 25
Projects: 2
Exp: 2 years


http://linebylinecoding.blogspot.com/


« Reply #2 - Posted 2014-02-02 01:59:29 »

In your topic it says "no Delta Timing" Why is that? Have you tried using delta for this?

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
@Override
public void render(float delta)
{
--   if(Gdx.input.isKeyPressed(Keys.DPAD_LEFT))    currentX -= moveSpeed;
++  if(Gdx.input.isKeyPressed(Keys.DPAD_LEFT))    currentX -= (moveSpeed * delta);
   if(Gdx.input.isKeyPressed(Keys.DPAD_RIGHT)) currentX += moveSpeed;
   if(Gdx.input.isKeyPressed(Keys.DPAD_UP))) currentY += moveSpeed;
   if(Gdx.input.isKeyPressed(Keys.DPAD_DOWN)) currentY -= moveSpeed;

   Gdx.gl.glClearColor(0.0f, 0.0f, 0.0f, 1);
   Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);

   camera.position.set(currentX, currentY, 0.0F);
   camera.update();
   
   renderer.setView(camera);
   renderer.render();

   fpslogger.log();
}


[EDIT]
Looks like Jimmt beat me to this one. Also if you multiply by delta you will have to increase the move speed values since delta is such a small number.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Memoryz

Senior Newbie


Exp: 2 years



« Reply #3 - Posted 2014-02-02 02:26:20 »

I've done this as well with delta, but the issue remains. I didn't use delta thinking that there would be less room for error as each render it'd move a set pixel amount.

FPSLogger shows ~60FPS.

Quote
FPSLogger: fps: 60
FPSLogger: fps: 61
FPSLogger: fps: 60
FPSLogger: fps: 60
FPSLogger: fps: 60
FPSLogger: fps: 60
FPSLogger: fps: 60
FPSLogger: fps: 59
FPSLogger: fps: 59
FPSLogger: fps: 59
FPSLogger: fps: 59
FPSLogger: fps: 60
FPSLogger: fps: 61

I think the reason it bugs out with delta timing is because of the delta spiking up sometimes.

For example: http://pastebin.com/CBZu2PtV

In the entire data sample above, we can see 0.016 - 0.017, with 0.033 showing up twice. Not sure why it's spiking up, nothing different is being called other than this map rendering.
Online Jimmt
« League of Dukes »

JGO Kernel


Medals: 139
Projects: 4
Exp: 3 years



« Reply #4 - Posted 2014-02-02 02:34:00 »

Delta time is the time between frames, so it's never going to be 100% consistent.  A range of 0.001 delta time is perfectly normal.
Offline jrenner
« Reply #5 - Posted 2014-02-02 02:40:05 »

related to vsync?
Offline Memoryz

Senior Newbie


Exp: 2 years



« Reply #6 - Posted 2014-02-02 02:51:28 »

Delta time is the time between frames, so it's never going to be 100% consistent.  A range of 0.001 delta time is perfectly normal.

It's bumping up from 0.016 to 0.030 randomly with vsync.

I disable vsync and I still get chunked movement 90% of the time, which is visibly noticeable.
Offline jrenner
« Reply #7 - Posted 2014-02-02 02:52:21 »

try a profiler like visualvm and see what's happening on the frame.  It could be something external to your program in which case you won't see anything.
Offline opiop65

JGO Kernel


Medals: 160
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #8 - Posted 2014-02-02 02:54:58 »

I've had issues with the same thing before. I would code my game on my computer, and then go test it at school or a friends computer and suddenly the "lag spikes" disappeared. I don't know if the issue is hardware related or what, but LibGDX has never played nicely with my computer. Maybe it was poor coding, I don't know.

Offline Memoryz

Senior Newbie


Exp: 2 years



« Reply #9 - Posted 2014-02-02 02:59:02 »

I've given my .jar to a friend to test out, as well as I have tested it out on my gaming PC and a laptop.

My PC and laptop is using an AMD processor, my friend is using an Intel processor, we both get the chunky camera movement, so I don't believe it is isolated to our computers.

Not sure how I would use VisualVM to even test this out as I believe the code I use to render the map is extremely small, I can't really see how something would be affected by this. I've tried out 3 different maps, so I don't think it is something map related.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Online Jimmt
« League of Dukes »

JGO Kernel


Medals: 139
Projects: 4
Exp: 3 years



« Reply #10 - Posted 2014-02-02 03:44:24 »

Delta time is the time between frames, so it's never going to be 100% consistent.  A range of 0.001 delta time is perfectly normal.

It's bumping up from 0.016 to 0.030 randomly with vsync.

I disable vsync and I still get chunked movement 90% of the time, which is visibly noticeable.
Is the render method the only thing you are doing every frame? Maybe you're binding textures or something?
Offline Memoryz

Senior Newbie


Exp: 2 years



« Reply #11 - Posted 2014-02-02 03:56:15 »

Delta time is the time between frames, so it's never going to be 100% consistent.  A range of 0.001 delta time is perfectly normal.

It's bumping up from 0.016 to 0.030 randomly with vsync.

I disable vsync and I still get chunked movement 90% of the time, which is visibly noticeable.
Is the render method the only thing you are doing every frame? Maybe you're binding textures or something?

The render method in the first post is the only render method I am using :/
Offline trollwarrior1
« Reply #12 - Posted 2014-02-02 07:20:44 »

I have kinda same looking problem on my PC.. It happens on top 1/4 of the screen. It only happens when game window is at the upper most position on screen. If I move game window down, shuttering disappears o-o
Offline Memoryz

Senior Newbie


Exp: 2 years



« Reply #13 - Posted 2014-02-03 03:16:54 »

Hmm, I believe this is some sort of LibGDX thing with TiledMap?

I've also made a little rendering loop myself to render and it's still the same jitteryness.

Here it is if you want to take a look: http://pastebin.com/xivG7mrN

I've seen a few games with LibGDX, how are you guys getting past or just not even coming across this issue? It's frustrating persecutioncomplex
Offline LiquidNitrogen
« Reply #14 - Posted 2014-02-03 03:25:00 »

this might not help, but i had a similar problem once when my laptop was on power saver mode and for some reason the cpu time% allocated to my program was lowered by windows. it made the frame rate very erratic.

Offline Cero
« Reply #15 - Posted 2014-02-03 06:11:33 »

ah you youngsters.
ok now listen
implementing delta time correctly is very very hard. it will make your problems worse. the reason you would use it would be if you expect your game to go above or under 60 fps frequently. if not, using a constant delta time is absolutely recommended. either set it to 0.016 or ignore it all together.
this board is old and there is a plethora of information, you may wanna read some of it.

bottom line, if this is pc only: cap fps to 60 make sure it doesnt go below, if it does then the game is slower, which is fine since it means the pc is too weak to play your game anyway.

Offline Memoryz

Senior Newbie


Exp: 2 years



« Reply #16 - Posted 2014-02-03 20:43:30 »

ah you youngsters.
ok now listen
implementing delta time correctly is very very hard. it will make your problems worse. the reason you would use it would be if you expect your game to go above or under 60 fps frequently. if not, using a constant delta time is absolutely recommended. either set it to 0.016 or ignore it all together.
this board is old and there is a plethora of information, you may wanna read some of it.

bottom line, if this is pc only: cap fps to 60 make sure it doesnt go below, if it does then the game is slower, which is fine since it means the pc is too weak to play your game anyway.

As I've mentioned earlier in this thread and in the title of this thread....

LibGDX Stuttering/Jumping Movement, TiledMap, no Delta Timing

I've done this as well with delta, but the issue remains. I didn't use delta thinking that there would be less room for error as each render it'd move a set pixel amount.
Offline Cero
« Reply #17 - Posted 2014-02-03 22:27:30 »

this is a common issue

check out gameloops and stuttering on jgo
its not really that much of an issue with libgdx vsync

generally speaking if more stuff is going on the less it stutters; that is my experience. I think it has to do with the fact that when the cpu isnt very busy these spikes are more noticable.
So my tip for is just keep developing the game and check back later

Offline Memoryz

Senior Newbie


Exp: 2 years



« Reply #18 - Posted 2014-02-03 22:40:33 »

this is a common issue

check out gameloops and stuttering on jgo
its not really that much of an issue with libgdx vsync

generally speaking if more stuff is going on the less it stutters; that is my experience. I think it has to do with the fact that when the cpu isnt very busy these spikes are more noticable.
So my tip for is just keep developing the game and check back later

Alright, thanks! So the best bet is to just enable vsync and keep on going?
Offline Cero
« Reply #19 - Posted 2014-02-04 05:08:52 »

yeah.
I mean gameloop stuff you can still change afterwards

Offline LiquidNitrogen
« Reply #20 - Posted 2014-03-24 08:07:11 »

generally speaking if more stuff is going on the less it stutters; that is my experience. I think it has to do with the fact that when the cpu isnt very busy these spikes are more noticable.

Just having experienced this problem myself, I asked google and found this thread. When moving around the map (Im not using tiled), the screen seems to get a small shunt or lag at a regular interval of about 1 second, even when I am multiplying my movement values by the delta.

I added in a for-loop to render all of my graphics 100x per frame, and the stuttering disappears completely. Very strange!

Does anyone know what is actually causing this? Something to do with the frame rate timer libgdx uses perhaps? It seems to me to be something that shouldnt really happen.

Offline Memoryz

Senior Newbie


Exp: 2 years



« Reply #21 - Posted 2014-03-25 22:40:48 »

My solution to this was basically to implement graphics options, and use fullscreen by default.

When it's run in fullscreen, the stuttering is no longer an issue, not sure how it works but it would be great to get it working in windowed mode as well.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

rwatson462 (29 views)
2014-12-15 09:26:44

Mr.CodeIt (20 views)
2014-12-14 19:50:38

BurntPizza (40 views)
2014-12-09 22:41:13

BurntPizza (76 views)
2014-12-08 04:46:31

JscottyBieshaar (37 views)
2014-12-05 12:39:02

SHC (50 views)
2014-12-03 16:27:13

CopyableCougar4 (47 views)
2014-11-29 21:32:03

toopeicgaming1999 (114 views)
2014-11-26 15:22:04

toopeicgaming1999 (102 views)
2014-11-26 15:20:36

toopeicgaming1999 (30 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!