Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (794)
Games in Android Showcase (234)
games submitted by our members
Games in WIP (864)
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 3100 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.

Offline fenaryh
« Reply #2 - Posted 2018-12-14 22:34:56 »

Hello, unenergizer,

About your link, it's about TWO-D graphics using a map format made with the software Tiled.

Regarding you doubt, render a map is quite easy, you just need to walk through the 2d array rendering each element. This can help:

And to make the map move with the player, you will need a camera. Just need to move the camera as the player moves.


Pages: [1]
  ignore  |  Print  

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

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

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

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

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

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

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

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

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

nelsongames (4603 views)
2018-04-24 18:14:32
Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

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 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!