Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (777)
Games in Android Showcase (231)
games submitted by our members
Games in WIP (856)
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  
  Continuous 2D Worlds using chunks and rendering.  (Read 1851 times)
0 Members and 1 Guest are viewing this topic.
Offline unenergizer

Junior Devvie

Medals: 5
Exp: 5 years

Trying to figure it all out

« Posted 2018-09-26 09:30:12 »

Hello everyone,

I could use some help and hopefully someone here can put me on the right path.

My overall goal, is I want stream 2D world chunks to client machines.  I can do the networking, but I am having a problem figuring out how to render the world as the player travels through it.  I can write a loop to get exactly what tiles to display, but I don't know how to render these tiles.  I have looked at the source of map renders in LibGDX and most parts of the code I don't understand. It looks like the renderTileLayer does some sort of 3D work, but I don't know anything about 3D to fully understand what is going on.

If someone can point me in the right direction to achieve this effect that would be greatly appreciated! Smiley

JGO is Awesome!
Steam: unenergizer
Offline CommanderKeith
« Reply #1 - Posted 2018-09-26 11:48:12 »

I'm not familiar with libgdx but you could write your own tile renderer to draw the tiles directly using the libgdx graphics drawing commands. Often it's easier to roll your own code rather than learning someone else's heavily abstracted general purpose code. That being said, libgdx is held in high regard.

The usual way to quickly render tiles is to figure out where your player is in tile coordinates and then calculate the tile coordinates of a corner of the screen, then render that tile and all the rows and columns from that corner to the opposite one in a big rectangle. Then you won't waste processor time drawing non-visible off screen tiles.

The libgdx code looks to be doing just that, but with some extra vertice flipping going on which is probably just an optimisation to draw a quad in some other orientation to what is stored in the sprite sheet in an efficient way that requires no additional sprite textures to be stored in VRAM.

Pages: [1]
  ignore  |  Print  

hadezbladez (290 views)
2018-11-16 13:46:03

hadezbladez (160 views)
2018-11-16 13:41:33

hadezbladez (291 views)
2018-11-16 13:35:35

hadezbladez (72 views)
2018-11-16 13:32:03

EgonOlsen (2151 views)
2018-06-10 19:43:48

EgonOlsen (2177 views)
2018-06-10 19:43:44

EgonOlsen (1366 views)
2018-06-10 19:43:20

DesertCoockie (1984 views)
2018-05-13 18:23:11

nelsongames (1626 views)
2018-04-24 18:15:36

nelsongames (2274 views)
2018-04-24 18:14:32
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46 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‑
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!