Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (711)
Games in Android Showcase (213)
games submitted by our members
Games in WIP (785)
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 tile scrolling?  (Read 1007 times)
0 Members and 1 Guest are viewing this topic.
Offline samcp12

Junior Devvie

Medals: 1

« Posted 2013-06-14 23:44:21 »

Hello, I am currently making a small 2D game using Java2D, I have been able to implement tile scrolling by creating a 2d array and simply setting all the indexes in the array to a particular to tile and using x and y offsets. But of course the amount of tiles is limited and I am curious how I would be able to generate more tiles as the player moves closer to the edge of the screen (almost like an endless amount of tiles if that makes sense). Any help is appreciated!
Offline UprightPath
« Reply #1 - Posted 2013-06-15 00:40:26 »

You have a few options as to how you want to do this. One is to have a 'loading' section when you get to the edge of your current tile map. Think something like the old Zelda games where you moved from screen to screen. Basically, designate the edge, then when you move across it, hold for a moment and load the next chunk of tiles.

If you're worried about that hold, and having smooth edges you can take a hint from Minecraft here. Basically, you have a set of 'chunks', which is a set of tiles, typically square. An example is something like a 3x3 array of these chunks with your character always wandering around the middle one. When you move across the line between chunks you shift your array in that direction then load up new blocks for the edges. The reason for the 3x3 is to have a buffer of chunks so that you can slowly load the new edge chunks. This can be done in another thread, or some sort of in-the-logic loading functionality that doesn't try to load or generate the entire map at once.

Offline samcp12

Junior Devvie

Medals: 1

« Reply #2 - Posted 2013-06-15 11:56:37 »

hmm, that wasn't really what i was going for if I'm honest. I was going for more of an open world idea, kind of like no matter how far right the player traveled more tiles would just keep rendering. As you said similar to minecraft but not randomly generated.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline UprightPath
« Reply #3 - Posted 2013-06-15 14:52:38 »

Well, where would you be getting the tiles?

I'm assuming that the entire world would be randomly generated some how. But, beyond that, the blocks that have been touched/viewed would be saved somewhere and could be loaded somewhere/somehow if your character went by them. I guess you could also just do a looping scenario, where when the player hits the edge he loops back to the start, but I'm unsure if that's what you meant either. :\

Offline CodeHead

JGO Knight

Medals: 52

From rags to rags.

« Reply #4 - Posted 2013-06-15 15:51:48 »

Are you talking about a looping map where the edges of the world are connected to each other? In other words if you start at a point on your map, and walk in straight line away from that point, you will eventually arrive at that point again (like would happen when walking around a sphere)? If that's the effect you're going for, then you will just need to do a modulo of your current rendering point with your map/world dimensions. This would allow infinite travel on a finite set of tiles.

Arthur: Are all men from the future loud-mouthed braggarts?
Ash: Nope. Just me baby...Just me.
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

numerical (371 views)
2017-02-21 07:32:16

numerical (372 views)
2017-02-21 07:31:46

theagentd (483 views)
2017-02-18 13:42:33

theagentd (481 views)
2017-02-18 13:35:16

h.pernpeintner (1646 views)
2017-01-24 22:39:11

h.pernpeintner (1632 views)
2017-01-24 22:38:32

Galdo (2202 views)
2017-01-12 13:44:09

Archive (2161 views)
2017-01-02 05:31:41

0AndrewShepherd0 (2699 views)
2016-12-16 03:58:39

0AndrewShepherd0 (2355 views)
2016-12-15 21:50:57
List of Learning Resources
by elect
2016-09-09 09:47:55

List of Learning Resources
by elect
2016-09-08 09:47:20

List of Learning Resources
by elect
2016-09-08 09:46:51

List of Learning Resources
by elect
2016-09-08 09:46:27

List of Learning Resources
by elect
2016-09-08 09:45:41

List of Learning Resources
by elect
2016-09-08 08:39:20

List of Learning Resources
by elect
2016-09-08 08:38:19

Rendering resources
by Roquen
2016-08-08 05:55:21 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!