Questions tagged [java]

Java is both a popular object-oriented programming language and runtime environment which allows Java programs to run unchanged on most hardware and software platforms.

java logo

Initial help

Before asking a question, use the search box in the upper right corner to see if it has been asked before by others (we have many duplicates), and please read Writing the perfect question to learn how to get Jon Skeet to answer your question.


Background

Java is a high-level, platform-independent, object-oriented programming language originally developed by Sun Microsystems and released in 1995. Java is currently owned by Oracle, which purchased Sun on April 20, 2009.

Very few computers can run Java programs directly. Therefore the Java environment is normally made available by installing a suitable software component. For Windows computers, this is usually done by downloading the free Java Runtime Environment (JRE) from Oracle which allows the system to run Java programs. The easiest way to do this is from java.com.

Developers frequently need additional tools which are available in the free Java Development Kit (JDK) alternative to the JRE, which for Windows must be downloaded from Oracle and installed manually.

Note: Other vendors exist but usually have license fees. For Linux and other platforms consult the operating system documentation.

More information:

Java source code is compiled to an intermediate form (bytecode instructions for the Java Virtual Machine) that can be executed with the java command.

Beginners' resources

  • The Java Tutorials - Starts from scratch on Windows/Linux/Mac and covers most of the standard library.

Day to day resources

Advanced resources

3436 questions
96
votes
12 answers

What data-type should I use for in-game currency?

In a simple business simulation game (built in Java + Slick2D), should a player's current amount of money be stored as a float or an int , or something else? In my use-case, most transactions will use cents ($0.50, $1.20, etc.), and simple interest…
Lucas Tulio
  • 1,317
  • 1
  • 11
  • 17
65
votes
8 answers

Is Java viable for serious game development?

I have scoured the internet, but there are not very many resources for Java game development, not nearly as many as C++. In fact, most engines are written in C++. I tried to play a game made with jMonkeyEngine, but the game was terribly slow, to the…
tehtros
  • 1,093
  • 1
  • 10
  • 10
41
votes
5 answers

How can I give the illusion of height to a ball in 2D?

In 2D top down soccer games, sometimes a ball is given the illusion of being in the air, like below: How can I achieve this?
Donald
  • 524
  • 1
  • 4
  • 8
37
votes
6 answers

What is a good file format for saving game data?

I need to save some custom game data. Map, player, etc. All of them will have "sub objects". For example, a map and map will have an "array" of tiles. ie, hierarchical data. Hopefully nothing binary. What would be a good format for these? So far…
user697111
  • 646
  • 1
  • 5
  • 9
35
votes
7 answers

How can I improve rendering speeds of a Voxel/Minecraft type game?

I'm writing my own clone of Minecraft (also written in Java). It works great right now. With a viewing distance of 40 meters I can easily hit 60 FPS on my MacBook Pro 8,1. (Intel i5 + Intel HD Graphics 3000). But if I put the viewing distance on 70…
Martijn Courteaux
  • 1,812
  • 1
  • 14
  • 21
23
votes
3 answers

Efficiently pathfinding many flocking enemies around obstacles

I'm working on trying to improve the pathfinding for my game's enemies. Right now, they basically just constantly move towards the player's exact position by calculating the angle between themselves and the players and moving in that direction. I…
Darin Beaudreau
  • 529
  • 1
  • 3
  • 11
23
votes
4 answers

How to implement a never-rebooting test world?

Am looking for ideas on how to do the following: I want to write a simple "world" in Java. One which I could start and then add new objects later at a later date to simulate/observe different behaviours between existing objects. The plan is then to…
d33j
  • 486
  • 4
  • 10
21
votes
2 answers

How can I define items in my RPG like Java game?

I am casually working on an RPG type game in Java but I am having trouble figuring out how I can have items that can do many different things without creating a different class for every item. As an example, how would I create an Axe that could chop…
MESLewis
  • 499
  • 1
  • 5
  • 13
21
votes
3 answers

Polling vs event driven input

I'm developing a game using polling for the input method. However, now that I'm delving deeper into the game menus and other UI components, I'm finding that I'd probably like to have event driven input. Perhaps even having both, using event driven…
House
  • 73,582
  • 17
  • 189
  • 279
20
votes
4 answers

Is there any harm in having the main game loop run uncontrolled?

I was wondering if there is any possible harm when my game loop runs as fast as the system allows? I currently have a loop, that, by measuring passed time in nanoseconds, runs the game logic and rendering logic at predefined speeds without a…
dot_Sp0T
  • 2,062
  • 2
  • 16
  • 25
20
votes
8 answers

Imperfect pong AI

So I'm starting to learn Java and some OpenGL while using the LWJGL. To start off easy, I'm writing a clone of the Atari Pong. I got set up correctly the game screen, collision detection, and all the game is mostly working, actually, if it were a 2…
Setzer22
  • 480
  • 2
  • 5
  • 17
18
votes
2 answers

LibGDX - Check if currently on Android/Desktop

I'm using LibGDX and flixel-android to build a Desktop/Android game. It feels like there should be a way of checking to see if you're currently being run on an Android device, the Desktop, and so on, but I can't find it anywhere. Am I supposed to…
mtrc
  • 301
  • 1
  • 3
  • 7
17
votes
14 answers

Advice for a first year CS major

I'm coming to the end of my first year of CS which has been primarily a Java based course. I'd like to get my feet wet with some game development but I'm not sure where to start. Some people have suggested I start with game maker which has a…
kontrarian
  • 283
  • 1
  • 4
17
votes
3 answers

How do I efficiently code both the client and server at the same time?

I'm coding my game using a client-server model. When playing on singleplayer, the game starts a local server, and interacts with it just like a remote server (multiplayer). I have done this to avoid coding separate singleplayer and multiplayer code.…
liamzebedee
  • 1,256
  • 12
  • 21
17
votes
3 answers

How can I make OpenGL textures scale without becoming blurry?

I'm using OpenGL through LWJGL. I have a 16x16 textured quad rendering at 16x16. When I change it's scale amount, the quad grows, then becomes blurrier as it gets larger. How can I make it scale without becoming blurry, like in Minecraft. Here is…
adorablepuppy
  • 273
  • 1
  • 2
  • 6
1
2 3
…
99 100