Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (603)
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  
  Flickering textures (borders) in slick2D  (Read 2284 times)
0 Members and 1 Guest are viewing this topic.
Offline Kronos

Junior Devvie


Medals: 1



« Posted 2013-06-19 19:57:34 »

Hello Smiley

I noticed a very bad looking flickering in my "game". I put several images together, so that it looks like a house with 4 floors. Each floor has 3 images. The borders are not seamless everytime ( yes I counted every pixel Tongue ). And the edges of straight lines are flickering during movement of the character. Could this be because I am using lots of loops iterating arraylists and so on? I cannot think that this is the problem, because it still runs at 60fps (targeted).
In some positions and with luck the overlays are seamless.

Thanks for help

Kronos
Offline Kronos

Junior Devvie


Medals: 1



« Reply #1 - Posted 2013-06-19 20:20:34 »

Or is this approach, displaying 1024x384 sized pictures in a grid a bad idea? What could be better?
Offline wreed12345

JGO Knight


Medals: 25
Projects: 2
Exp: 2 years


http://linebylinecoding.blogspot.com/


« Reply #2 - Posted 2013-06-20 15:10:39 »

I am not sure if this is exactly what is happening with you but I had a problem where I was updating some textures position in two different methods, which creates problems since they are updated at different times and created a little bit of a flickering effect when I started and stopped movement. I am not sure if this is the case here but try and keep all movement things close together in the render loop

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

Junior Devvie


Medals: 1



« Reply #3 - Posted 2013-06-23 13:09:02 »

I found out why there is a flickering. It is because of the g.translate at the Camera Class. While the graphics is not being translated, there is no flickering.

This ist the translate Method of my camera class:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
   public void translate(Graphics g, Entity entity) {

      if (entity.x - width / 2 + entity.width < 0) {
         transX = 0;
      } else if (entity.x + width / 2 + entity.width > world.width) {
         transX = -world.width + width;
      } else {
         transX = -entity.x + width / 2 - entity.width;
      }
         
      if (entity.y -height / 2 + entity.height < 0) {
         transY = 0;
      } else if (entity.y + height / 2 + entity.height > world.height) {
         transY = -world.height + height;
      } else {
         transY = -entity.y + height / 2 - entity.height;        
      }

      g.translate(transX, transY+marginTop);
   }


Has anybody an idea what could be improved? Thanks Smiley
Offline wreed12345

JGO Knight


Medals: 25
Projects: 2
Exp: 2 years


http://linebylinecoding.blogspot.com/


« Reply #4 - Posted 2013-06-23 15:07:37 »

update and translate at same location (or as close as it can be)

Offline Kronos

Junior Devvie


Medals: 1



« Reply #5 - Posted 2013-06-23 15:57:12 »

Hi thanks for your answer. I don't know when Slick2d envokes the update and render methods, but I envoke the translate method at the beginning of the render method. Isn't this close enough?
Offline wreed12345

JGO Knight


Medals: 25
Projects: 2
Exp: 2 years


http://linebylinecoding.blogspot.com/


« Reply #6 - Posted 2013-06-23 19:28:49 »

I am not sure about slick but I know in libgdx this will occur when you update the camera and move something at different locations. I don't even see the point of using slick anymore

Offline Kronos

Junior Devvie


Medals: 1



« Reply #7 - Posted 2013-06-26 08:29:05 »

I couldn't fight this flickering yet Sad
But I think the way I handle my background could be a hughe factor for this appearance. I have a 1024*512 big PNG for the background. I scale it during runtime every frame by 3, so it's 3072* 1536.
First I had this size, but slick said this would be too big for the current Hardware (onBoard Graphics). So we decided to scale it down do meet the requirements, since it is pixelart it could be scaled anyway.

But is this the proper way? I mean it works, but the flickering (only during camera translation) is not beatiful at all  Undecided
Offline Nitram

Senior Newbie


Medals: 1



« Reply #8 - Posted 2013-06-26 08:45:45 »

Is the graphic itself flickering or only the borders of the graphics where the graphics touch each other.

In case its the second, that sometimes happen in case you perform sub-pixel translations. So the short moment where one texture defines one half of a pixel and the next texture defines the second half. That is the moment of the flicker. This was the problem for me at least.

Other than that only vsync comes to mind. But I guess you know what that looks like and that is not it.

Nitram

Playable work in progress online RPG: http://illarion.org
Jabber user: nitram0815@jabber.ccc.de
Offline Kronos

Junior Devvie


Medals: 1



« Reply #9 - Posted 2013-06-26 08:58:50 »

Hey vsync really removed the flickering Cheesy thanks, I didn't thought of it, because I always thought I enabled it.

But now the translation looks jerky ( I hope it is the right word), like it would stuck after every "centimetre". Is there something in my translation code, that causes this?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Nitram

Senior Newbie


Medals: 1



« Reply #10 - Posted 2013-06-26 09:08:19 »

I guess it does. For a smooth looking transition you can't use a constant movement value per frame.

You need the time between two frames (that changes very slighty from frame to frame) as a factor to your movement. As you are using Slick2D this value you need is provided by the update function call as "delta" (time in milliseconds since the last call of the update method)

Use this value to scale your movement. So you say you want to move x pixels in x seconds. The rest is simple math  Wink

Nitram

Playable work in progress online RPG: http://illarion.org
Jabber user: nitram0815@jabber.ccc.de
Offline Kronos

Junior Devvie


Medals: 1



« Reply #11 - Posted 2013-06-27 08:33:45 »

HI, do you mean the movement from the character or camera? The character is multiplied with delta. But the in the translation method I dont use any delta.
Offline Nitram

Senior Newbie


Medals: 1



« Reply #12 - Posted 2013-06-27 08:38:02 »

I guess you can use it as thumb rule. All visible animations need to be related to the delta time. All movements, all frame switches, everything the player is able to see. Because you can't be sure that the time per frame is the same at very players computer.

Playable work in progress online RPG: http://illarion.org
Jabber user: nitram0815@jabber.ccc.de
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 (33 views)
2014-12-15 09:26:44

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

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

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

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

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

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

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

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

toopeicgaming1999 (32 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!