Skip to main content
gamedev.net
🔒 Locked

[java] Please, help me find resources

Started by projectjava126 Aug 4, 2005 at 7:19 PM 12 replies 2k views
Original Post
projectjava126
projectjava126
Hello all, this is my first post in this forum - I hope you are all well. Firstly, i have been reading these forums on and off for around a year now, and i have finally registered! There are alot of posts regarding people making new games eg rpgs, and i am one of those people! However, i am starting at the very basics. Basically i want to create a map consisting of a 4x4 grid (tiles), with a character that can move 1 space every time a jbutton is pressed (ie 1 movement point/end turn button) - Please note, i do not intend to develop a side scrolling tile based game, but a strategy game (think civ but 100xsimplier). The purpose of this post is for someone with knowledge, not to give me the exact code (although it would be nice), but to link a url/pdf to a complete tutorial/walkthrough IN JAVA. Now, i would like to make clear, that i have been doing extensive searching on google (web pages and pdfs) for weeks now. Most of the topics i find are for vb, c++ or flash. Secondly, there are a lot of tutorials that explain things such as pathfinding, ai, influence mapping etc - these i have on favorites. I also have alot of source code from many java sights on similar game engines (such as laser squad remakes,chaos remakes,civ remakes) - but as a relative beginner to "game programming", its hard to make sense of it all (which is why my first goal is so simple). The best tutorial/walkthrough i have found, is unfortunately for flash , and is for a side scroller (although concepts could be used). It is found at http://www.tonypa.pri.ee/tbw/start.html. So far i have worked out this. 1) a java file for the map - creating using an array with 1 and 0. 2) a java file for identying 1 and 0 as a wall or grass. the closest thing i can find to what i want to create can be found at http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=3352&lngWId=2 Unfortunately i cannot get it to run, but there is a screenshot there. I have used many keywords while searching eg tile-based, turn-based, java, tutorial, article, source-code, walkthrough, development etc.but cant find exactly what i require. If no such site exists what would my best course of action be? what beginner game should i make? Chess? tic tac toe? thankyou for reading, and i SINCERELY apoligize for the length of this post - I wanted to show i have set my target to the very simplest of concepts, i had some knowledge of what to do, and that i had been searching! p.s. i realise there is a section on 2d tile-based/isometric maps - i have checked through tutorials and forums. i beileved that a "java" forum would be the best to post! :-)
INsanityDesign
INsanityDesign
First of all, Welcome!!!

You wanna make a tilebased strategy game in java, and you are looking for a tutorial that is describing that sort of thing!?
If thats the fact then you are not really making a game on your own, someone else has...
Please, do not get offended but if you really wanna make such a game, all the pieces of tuts you said you found should be enough. basically java tutorials should be what you read first... then graphics... then... and so on, and so on...
If you have a tutorial that describes exactly what you want, you will make it like that tutorial. there will be only a basic of own programming and that is not a good attempt.
you should rather surf the net, post in this forum with what you currently wanna do. Wanna do graphics, but dont know how? post it! search for it! wanna do ai? post it! search for it! in my opinion that is a far better way to learn and do. everything else would narrow your horizon.


ps: developing games in java by brackeen (often discussed in this forum) is a great book for beginners. it uses tiles for a sidescroller... but maybe because of that basics you can figure out a way to do it like you want.

[Edited by - INsanityDesign on August 5, 2005 7:01:58 AM]
-----The next statement is not true!The previous statement is true!
Son of Cain
Son of Cain
This kind of game relies on many techniques that are independent from language; For example, A* for path-finding. You'll find A* implementations for many languages, most of them for C++ and Java.

So, you'll have to search for the involved techniques. For AI, you'll surely need a good algorithm for path-finding (A*, for example), and possibly FSM to control enemies behavior. For the graphics, there are several tile-based games written in Java whose source is open, a bit of googling will give you many insights. The game logic is tied to your design, so searching for a known implementation will kill the originality of your game ;)

Is this your first game? If so, I think you should reconsider your choice. I'm also a fan of turn-based strategy games, and I know it's irresistible to follow up our tastes when choosing a new game to develop. However, set your goals a bit lower before going into these "complex" genres - there are a lot of small games you could try out that could teach you the necessary techniques to build your TBS game, someday.

Son Of Cain

[Edit: Oh yes, Welcome to the forums ;) ]
a.k.a javabeats at yahoo.ca
Lucidquiet
Lucidquiet
Hello projectjava126, welcome.

I know you are specifically looking for Java, but I would recommend the following for a start for the AI/Pathfinding/Techtree etc:

AI Junky

I personally skip the code but read the comments, as long as I can understand the idea behind the algorithm -- and Graphs well they aren't exactly easy to get working the way you'd like them to.

The guy's book on practical AI is great!! Unfortunately a little expensive, and a little watered down -- that is until you get to A* and Graphs in general. FSM and Steering behaviors delt with first, and Pathfinding/GoalSeeking later.
All C++ however.

Greatbook -- pretty darn good site as well.

Keep posting though -- I'm sure if you get some code going and have questions there are a lot of knowledgable people to help. Son of Cain, CaptainMidnight, just to name a two.

L-
"Education is when you read the fine print; experience is what you get when you don't." -Pete Seegerwww.lucid-edge.net
jsgcdude
jsgcdude
click

check the demo and source
------------------
rohde
rohde
There's a great book called "Killer Game Programming in Java", and in the first many chapters it deals with 2D programming and seems well suited for you. You can either buy the book, or read the draft chapters on-line: Killer Game Programming.
"We confess our little faults to persuade people that we have no large ones." -Francois de La Rochefoucauld (1613 - 1680). | My blog
Son of Cain
Son of Cain
Good sites:
GameAI.com
Amit Patel's Game Programming website

The first site deals with AI for games, and has code for several techniques, in many languages, including Java. The second is a brilliant site mantained by Amit Patel, a known game developer, and home to his incredible tutorials - there's one for A* that you would surely appreciate.

Son Of Cain
a.k.a javabeats at yahoo.ca
javaprojecttime126
javaprojecttime126
hello and thankyou everyone for your replies.

I apoligize, as i have had to make a new account as i accidently deleted the password sent to my email address.
Alot of the links look good - a few i have seen before, such as amits site(i was actually in contact via email to him last october for a short while i was working on an artificial intelligence map generator). I will definitely bookmark these urls for future reference.
As stated before, i realise that implementing ai and the such is a long way off - currently i am aiming only to make a 4x4 grid made of white boxes and black boxes, and a red box that has movement points and can move 1 square a turn - i learnt from my previous project to simplify each program function as much as possible, in order to understand it.
The demo that was linked - although it is a real time rpg engine, im sure once i print out the code and analyse it, i would be able to figure out how to write my own version, with "movement points" added in. Wish me luck on this lonf journey and good luck to you on yours!
CaptainJester
CaptainJester
Sometimes your problems can stem from lack of understanding the language. I would highly recommend that you do the entire Java tutorial on Sun's website first. This will give you a thorough understanding of the langauge and APIs.

http://java.sun.com/docs/books/tutorial/index.html
"None of us learn in a vacuum; we all stand on the shoulders of giants such as Wirth and Knuth and thousands of others. Lend your shoulders to building the future!" - Michael Abrash[JavaGaming.org][The Java Tutorial][Slick][LWJGL][
Nice Coder
Nice Coder
Wikipedia and google are always good to know. (together, they know everything)



Please unban me on #Gamedev. I won't use my client there ever again.
Click here to patch the mozilla IDN exploit, or click Here then type in Network.enableidn and set its value to false. Restart the browser for the patches to work.
javaprojecttime126
javaprojecttime126
hi and thanks for you replies.

Captain Jester - Yes, i know to look through tutorials. I havent as such gone thorugh every single one. What i do is look for information through forums, then look at the tutorial. E.G. 7 months ago i was suggested to use arrays for a particular task. i then went to tutorial and learnt arrays :-)

Nice Coder - Why should i read your post when you didnt read mine? In case you dont understand, i quote from my first post "Now, i would like to make clear, that i have been doing extensive searching on google (web pages and pdfs) for weeks now.". Please dont take this the wrong way :-)

Anyway, here is what i have learnt in past few days from bits and pieces of websites and stuff.

The best bethod for me to produce a 4x4 grid is to produce the map from an array. This i havent been able to do, although i have been able to make a predetermined map, and transfer THAT to an array (ie in reverse).

I have managed to do this : -

********************CODE SNIPPET******************
int max_rows = 2;
int max_cols = 2;
int x = 0;

JLabel[][] grid = new JLabel[max_rows][max_cols];

grid[0][0] = t0;
grid[0][1] = t1;
grid[1][0] = t2;
grid[1][1] = t3;

for (int r = 0; r < max_rows; r++) {
for (int c = 0; c < max_cols; c++) {
grid[r][c].setName("t" + x);

x = x + 1;
}
}
******************************************************
- A nested loop creates references to each grid number.
- Premade JLabels(eg t0,t1), (with icons) ,are then put into the gridnumbers. They are premade because if they are made in the loop, they do not appear in a 2x2 grid with the right size.

QUESTION - Can anyone advise me on how to give each grid[r][c] attributes? My aim is to use a nested loop, and if the grid[r][c] has a particular icon, then attributes (eg movement cost) is applied to it. Off the top of my head, i have to make a class with attributes(eg final int terrain type, final int terrain movement), and make each grid[r][c] a part of that class.

As more experienced coders, you have probably looked at my code snippet and laughed, or thought "why is he doing that? why not this?". The reason is simple! Its the only way i know how after weeks of reading + examing sourcecode.

Good day! :-)
Son of Cain
Son of Cain
Hi dude,

First off, let me tell you something: use "[ code ]" and "[/ code ]" to post snippets of code, or "[ source ]" and "[ / source ]" tags for big source code snippets.

Now, listen :D - CaptainJester is a wise man, and what he said is true dude: first thing to do is to learn the basics of the language. I understand that you want to print a pretty grid on the screen, but before you do that, wouldn't it be wise to get a grasp on the OOP concepts? Because that is what you need now dude, to "solve" the problem in your hands.

Here goes some amateur code:

// Nodepublic interface Node {    void render(Graphics2D g2d);  int getCost();}// A Tilepublic class Tile implements Node {    // Init your resources and cache them  // Send a reference ("pointer") of the image to this object  private Image tileImage;  // For basic A* implementation  private int cost;  public Tile(Image img, int cost) {}  public int getCost() {    return cost;  }  public void render(Graphics2D g2d) {    // draw!!  }}// Gridpublic class Grid {    public static final int WIDTH = 10;  public static final int HEIGHT = 10;    private Tile[ WIDTH ][ HEIGHT ];    public Grid() {    }  public void init() {    // loop through, instantiate tiles, etc...   }  public void draw(Graphics2d g2d) {    // call render() for every tile...  }}


I hope that gives you some ideas... And don't try to use this code, it's simply stupid :D

Son Of Cain
a.k.a javabeats at yahoo.ca
CaptainJester
CaptainJester
Quote:
Original post by javaprojecttime126
Captain Jester - Yes, i know to look through tutorials. I havent as such gone thorugh every single one. What i do is look for information through forums, then look at the tutorial. E.G. 7 months ago i was suggested to use arrays for a particular task. i then went to tutorial and learnt arrays :-)


I am not talking about tutorials around the 'Net. I am talking about THE Tutorial. "The Java Tutorial" is the definitive place to learn practically everthing about the Java language and the standard edition API. You should read it cover to cover before attempting anything.
"None of us learn in a vacuum; we all stand on the shoulders of giants such as Wirth and Knuth and thousands of others. Lend your shoulders to building the future!" - Michael Abrash[JavaGaming.org][The Java Tutorial][Slick][LWJGL][
javaprojecttime126
javaprojecttime126
Hello you two, and thanks for the help given so far.

I have been going through the tutorial again, most of it isnt relavent at the moment (not being used or already understand) - but the parts on objects/classes/methods etc i am finding a good help.

i have changed a class from my program. The end results produce exactly the same reulst when called upon from my application. I was wondering if you could explain what method 2 does differently from method 1;

method 1

public class map1 {public map1(){int MovementCost;int TerrainName;}


method 2
********

public class map1 {    public int MovementCost;    public String TerrainName;public map1(    String TerrainName,    int MovementCost){this.TerrainName = TerrainName;this.MovementCost = MovementCost;}

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.