Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (480)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (547)
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 467 times)
0 Members and 1 Guest are viewing this topic.
Offline samcp12

Junior Member


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 Member


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: 41


From rags to riches...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.

 

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

The first screenshot will be displayed as a thumbnail.

atombrot (25 views)
2014-08-19 09:29:53

Tekkerue (24 views)
2014-08-16 06:45:27

Tekkerue (23 views)
2014-08-16 06:22:17

Tekkerue (13 views)
2014-08-16 06:20:21

Tekkerue (20 views)
2014-08-16 06:12:11

Rayexar (58 views)
2014-08-11 02:49:23

BurntPizza (38 views)
2014-08-09 21:09:32

BurntPizza (30 views)
2014-08-08 02:01:56

Norakomi (37 views)
2014-08-06 19:49:38

BurntPizza (67 views)
2014-08-03 02:57:17
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

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!