• Post Reply Bookmark Topic Watch Topic
  • New Topic

is java good for making roguelikes?  RSS feed

 
neil harper
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i know im far from having the ability to make games but i have loved roguelike for a long time and would love to try to make one. is java good for that? is it harder than it would be with other languages?

thanks.
 
Stephan van Hulst
Saloon Keeper
Posts: 7993
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think Java is an excellent language for this kind of purpose. I don't think it's easier to make a game like that in Java than in other languages, but it's definitely harder to screw up.
 
neil harper
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
cool, i imagine the lack of native consoles ASCII is an issue?
 
Stephan van Hulst
Saloon Keeper
Posts: 7993
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nope, Java can print to console just fine, and you can always make a very simple interface using Swing.
 
neil harper
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
great can i see some example code of a very simple roguelike?
 
Stephan van Hulst
Saloon Keeper
Posts: 7993
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hehe, that's not how it works. Start with studying Java first: http://download.oracle.com/javase/tutorial/

Then, when you're confident you have the basics down, or as you study the tutorials, you can work on making a model of your game. A model is all the code needed to perform the game 'logic'. Don't worry about the interface just yet.
When you're having problems with your code, you can post the parts that aren't working here, and we'll tell you how you can improve it.
 
neil harper
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks, i was just wanting to see it so i know what to expect in the future

im currently reading head first java, do you think i should read the official tutorial too? i dont mind because im really enjoying learning, haven't even played my precious starcraft because i spend all my time doing java.
 
Stephan van Hulst
Saloon Keeper
Posts: 7993
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I'm not familiar with Head First Java, so I don't know how much overlap there is. I would still recommend at least going over the tutorials quickly, if only to see if you know all the basics.

It's been four years since I started Java, and I also still enjoy learning things about the language that I didn't know before. I hope you enjoy, and that we'll be seeing you around these parts.
 
Mohamed Sanaulla
Bartender
Posts: 3185
34
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From my personal experience, for beginners- Head First Java is a really good book
 
neil harper
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks guys, i have started reading the java tutorial too, it goes over suff i've sone in the book but in a not more detail. but i really dont understand the 'Arbitrary Number of Arguments' http://download.oracle.com/javase/tutorial/java/javaOO/arguments.html

and the book is fantastic, very hands on which is great since i'm kinesthetic

EDIT: also, which java api documentation do i want? there are a lot of them here: http://www.oracle.com/technetwork/java/javase/documentation/api-jsp-136079.html
 
Stephan van Hulst
Saloon Keeper
Posts: 7993
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Methods can accept an arbitrary number of arguments, using the ... or 'varargs' declaration.

I usually declare my main method like this:

For the method itself, it doesn't really change a lot. String... means the exact same thing as String[]. You use both as an array.
The difference however, is in how these methods are called.

A method with an array (String[]) as a parameter, can only be called by using an array as an argument. A method with varargs as a parameter, can be called using an array as an argument, but instead of doing that, you can also pass a comma separated list of arguments, that fit in the array. Here is an example:


Note that you can only use one varargs parameter in a method declaration, and it has to be the very last parameter.

As for the API, you'll probably want this one: http://download.oracle.com/javase/6/docs/api/
 
neil harper
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh so, it allows you to provide an array of arguments to a method with nicer syntax?

so if you have a method a(String...) and call it as a("a","b","c") it is compiled as if you did a(new String[]{"a","b","c"})
 
Stephan van Hulst
Saloon Keeper
Posts: 7993
143
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Be careful with them though. you should only use them when it conceptually makes sense to provide a variable amount of arguments. Don't use varargs when you have to do work on an array, even if it's technically possible with varargs.

I think the main method is a prime example where it makes sense to use varargs. After all, the main method expects a variable amount of arguments.

You should also be wary that varargs methods are very easy to hide.

Consider what this program prints:
 
Mohamed Sanaulla
Bartender
Posts: 3185
34
Google App Engine Java Ruby
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
neil harper wrote:i know im far from having the ability to make games but i have loved roguelike for a long time and would love to try to make one. is java good for that? is it harder than it would be with other languages?

thanks.


You can even have a look at JavaFX- Might be helpful in designing the UI.
 
neil harper
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for all the help, i'm sure i'll be posting again soon enough with more questions
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!