Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
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  
  tile based game  (Read 8996 times)
0 Members and 1 Guest are viewing this topic.
Offline clankill3r

Innocent Bystander

« Posted 2011-07-02 20:23:34 »


does someone has a good tutorial or example of how to make a tile based game.
(rts kinda way like red alert).
I have been searching for more then a hour but didn't found any good.
I don't want to use any library.

plz help
Offline Cero
« Reply #1 - Posted 2011-07-03 00:13:31 »

well its a broad topic
you basically have an 2-dimensional array of fields/images/textures/tiles/whatever (per layer) used in an Orthographic or isometric fashion.

I don't know of any tutorial in particular but I liked the section in "Developing Games in Java" by David Brackeen in which this is covered.

Offline namrog84

JGO Ninja

Medals: 46
Projects: 4

Keep programming!

« Reply #2 - Posted 2011-07-03 06:57:04 »

Although it requires a little more knowledge and work.  Sometimes if you really cant find a "java tutorial"  look for a tutorial in similar languages, like C# has a similar syntax to Java.  Aside from the rendering and audio aspect, a lot of the game logic will be extremely similar between many different languages. 

Though a tile based game, like Cero said can be a broad topic.

Depending on how complicated your system or game is to be.  Id personally recommend a simple 2D array containing the terrain,  with identification of whats buildable terrain or not.  Then simply have an arraylist of all your buildings locations,  and 1 more list(or could be combined with the buildings one) to contain all your units.  Depending on how you want to handle it. 

Also, you may not find a good tutorial,  try just look for source code and examine how other people have done similiar things.

"Experience is what you get when you did not get what you wanted"
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline appel

JGO Wizard

Medals: 80
Projects: 4

I always win!

« Reply #3 - Posted 2011-07-05 14:40:42 »

Terrain is probably the least complicated part. Many start with that, because well, it's an obvious thing to start with. But without units moving on that terrain you don't have much of a game. Unit movement is probably more important, because it's difficult to implement. Jeeps, tanks, soldiers, etc. how are you going to add that so it's convincing like Red Alert?

Unit behavior, movement, AI, physics, pathfinding, etc. is very important.
Offline loom_weaver

JGO Coder

Medals: 17

« Reply #4 - Posted 2011-07-05 14:51:32 »

does someone has a good tutorial or example of how to make a tile based game.
(rts kinda way like red alert).

As other posters suggested, start with a simple 2D array for your terrain and show a character moving about in a 'roguelike' style.

I would forget the 'rts' portion for now.  Creating the interface, drawing the graphics, and moving the camera about is a much more complicated task and even if you know what you're doing, it will likely take months to create something that even rudimentary (think boxes and rectangles instead of any graphics) resembles a RTS.
Offline Eli Delventhal

JGO Kernel

Medals: 42
Projects: 11
Exp: 10 years

Game Engineer

« Reply #5 - Posted 2011-07-05 15:02:04 »

I like to use a 3D array, where the 3rd dimension is different rendering/logic layers. Alternatively, you can represent this in multiple 2D arrays, which I'll lay out here because that's probably a little simpler to understand.

//Contains pathing data, information about doors, switches, etc.
private int[][] logicGrid;
//Contains sprites that get rendered beneath the player. Might have null spaces.
private Sprite[][] backgroundSprites;
//Contains sprites that get rendered on top of the player. Might have null spaces.
private Sprite[][] foregroundSprites;
//Contains all the active entities that move around. Units, land mines, etc.
private ArrayList entities;

public static final int GRID_EMPTY = 0;
public static final int GRID_WALL = 1;
public static final int GRID_LAVA = 2;
public static final int GRID_SWITCH = 3;

public boolean canMoveTo(int x, int y)
    return (logicGrid[x][y] == GRID_EMPTY);

See my work:
OTC Software
Offline Mads

JGO Ninja

Medals: 26
Projects: 3
Exp: 6 years

One for all!

« Reply #6 - Posted 2011-07-07 09:43:25 »

Well, Somnium has two articles covering a simple tile based game, Felix. You can find it here:
While it doesn't go in depth with how the low-level code works, it's commented nicely so it should be easy to figure out. It comes with different tiles, animation and collisions (as far as I remember).

Pages: [1]
  ignore  |  Print  

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

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

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

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

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

nelsongames (158 views)
2018-04-24 18:14:32

ivj94 (901 views)
2018-03-24 14:47:39

ivj94 (162 views)
2018-03-24 14:46:31

ivj94 (813 views)
2018-03-24 14:43:53

Solater (177 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 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!