Java 2d RPG game with multiplayer support - java

I want to make an top-down RPG game, with multiplayer support for up to 4 players. I have no need for graphics right now, the map can be a black grid and the player a red dot.
The game features are:
A 10000*10000 map that will feature some treasure chests, which will give stat boost
each player will have the basic rpg stats(attk,def,speed,etc) which he should be able to divide 30 points on each of these before the game starts.
The players will move real time using the arrow keys.
Each player will have a visible field of view of 20*20.
If a player comes in proximity of 5*5 or closer to another player there will be a battle which will compare the stats along with some dice rolls.
The game must have a pause feature and also a lobby feature.
The game must be in Java
The reason i am asking is because i have very limited knowledge on the way of programming such a project, and the guides i have found on youtube mostly are two complicated because of graphics or do not support the multiplayer feature.
I would like if this community could give me some directions about how I should start this game, or better if they could give me the link to some internet tutorial/video or book that can teach me the things I need to finish this.
Thank you!

This video is how my good friend learned java development. Obviously you're not going to find any tutorial that follow your exact needs, but this one is semi-close. I believe it goes into networking later in the series. This video is also very good, but it is farther away from your specifications. Another, better thing you can do is follow simpler tutorials until you know what you are doing, then change the source around to fit your specifications.
Generally if you do not know any java at all, starting with a game like this is not a very good idea. But if you are very motivated, it can be done.
By the way, this broad type of question is not very well suited for a Q & A site like this, so expect downvotes from others unless you edit your question.

Related

Something more effective than Sprite/BufferedImage.

Background information
In school we learned 2 languages, Java and Processing
I know that Java and Processing arent the best languages for programming games.
It doesnt cared me ^^ so i started to work on a simple pacman ...
Question 1
Is there something more effective than Sprites/BufferedImages ?
Question 2
For rendering and drawing huge maps, is there a method to do that ?
Normally it would lag when drawing it cause of all the images :)
But how i can render/draw large maps without any fps collapse?
Short answer: Don't bother optimizing before you have a problem.
Longer answer: The most efficient way to do this is by using a game development framework, which handles this kind of thing for you. But really, stick with what you're comfortable with until you actually have a reason to change.
Java and Processing are fine languages for game development. There was a game called Recluse a few years ago that did very well at Ludum Dare (a game programming competition), and it was done in Processing.
On the Java side, there are a ton of very popular game development frameworks. LibGDX is probably the most popular. In fact, the libGDX Jam just happened, and you can check that out for a bunch of examples of what's possible in Java game development. You might also want to check out JMonkeyEngine and LWJGL.
I would say this: program with whatever you're comfortable with. If you're comfortable with Processing and Java and using sprites and BufferedImages, then do that. Don't worry about efficiency until you actually have a problem.
Processing is a great language to make some simple games. Start with Pong and Space Invaders. When you're ready to "graduate" to more complicated games, then check out libGDX. Don't worry about making everything as efficient as possible- focus on finishing games, which is much harder.
You'll also find a very active community of Java game developers on JGO.
Good luck!
Is there something more effective than Sprites/BufferedImages ?
No, not at your level of programming experience.
For rendering and drawing huge maps, is there a method to do that ?
Tiles. Generally tiles are 256 x 256 pixel images of one section of the map. Like floor tiles, you place tiles together until you have a large enough graphic for your view. As the player moves, you add the tiles in the direction the player is moving and remove the tiles from where the player came.
Here's an introduction to creating a tile map engine.

Artificial Intelligence for a 'Blokus' game (1-4 Player)

we are working on a little Java game, based on the game Blokus.
Blokus-Manual
I'm a Java-beginner and plan to implement an advanced artificial intelligence. We already have a random AI (picks a random valid move) and an AI with a simple move-rating mechanism. We also want an AI which should be as good as possible (or at least very good ;) ).
The question is: Which AI-concept would be suitable for our purpose?
The minimax-algorithm seems to be a valid choice, but how do you adapt it to a 4-player-game? Are there better concepts for a game like blokus?
Thanks already :)
Min-max is hard to implement in a 4 player game because:
Decision tree grows exponentially, so you're going to be bounded by memory and/or computation time to a log(medMoves)=N steps. For a 4 player game, this is down to N/4. If N is 8 for example, you're only going to be able to see 2 moves ahead for each player.
Player collusion is hard to account for. In a realistic game, some players might help each other out (even if they're not on the same team). This will cause them to deviate from their personal 'maximum'.
If you want Minmax, you're going to have to do a lot of pruning to make it viable. What I would suggest is learning a few patterns so the AI would know how to react. This can be done via neural net, or reinforcement learning with a few tweaks.
These patterns could be be static (you can create the input scenario manually or programmatically), or dynamic (create all valid scenarios and randomly makes moves select the ones with the best score).
Theoretically speaking, an "as good as possible AI" is a perfect AI, which is an AI that has, at any moment in the game, full knowledge of the game state (if the full game state is not known by human players). In case of games that everyone has full game state knowledge (like Blokus), a good as possible AI is an AI that can try to predict the very best move to make (minimax here, as you said). You can also google for genetic algorithms and simulated annealing, as they are valid, depending on what you want. Also, you can use minimax for more than 2 players.
I would recommend minimax algorithm. One thing you can add to make it more efficient (meaning you should be able go more moves deep into the future) is alpha-beta pruning.
The problem with minimax search is that the number of games states it has to examine is exponential in the depth of the tree. Unfortunately, we can't eliminate the exponent, but it turns out we can effectively cut it in half.
The quote is from Chapter 5.3 of Artificial Intelligence: A Modern Approach third edition by Stuart Russel and Peter Norvig. It was holding up my monitor, and I used it in a few of my classes in college. I know people don't often reference books on SO, but it's extremely relevant. I have used it extensively, and I do really recommend it for both being understandable, and covering a wide range of AI content.
It is available on amazon for $104, or * cough cough * I'm sure you can find it online if you don't have that kind of money for a textbook floating around. Looking up the minimax algorithm and alpha beta pruning online should also get you good results.
I think the only circumstance that would make Minimax a poor option for you is if the game state is only partially observable to any given player (they don't know everything about what's going on), or if the game is non-deterministic (it has random elements). Because neither of these are the case for Blokus, I think you made an excellent choice with Minimax.
The area of AI is called Adversarial Search in the textbook (Chapter 5: Adversarial Search), so looking up more info online with that term may get you more helpful information, or help you find an example Java implementation. I do not consider this a beginner's task, but it sounds like you are up to it, if you made the game and can pick random valid moves. Keep up the good work!
In 2011, with many updates since then, a program called Pentobi
was released, and it is a very strong Blokus playing program.
The only one known to date, in fact, which is any good at all, and it
surpasses all the others by a great deal. It will beat many good human players and gives even the best a run for their money.
Its main algorithm is Monte Carlo Search Tree, but it also uses a "book" of openings and some heuristics.
There is documentation and download information at
http://pentobi.sourceforge.net/
I found that using a very simple heuristic provides a fairly intelligent player even using only 1-step look ahead. I implemented what I called "space heuristic" which takes the board state and floods it by coloring all squares adjacent to each placed piece the color of that piece. Then, the total number of colored squares is counted once the flooding terminates. The space heuristic gives a rough estimate of how much a play claims or occupies board space, and way outperforms random play. Could be combined with minimax or MCTS to get way stronger as well.

Writing a 2d Java LWJGL game

All the game tutorials I've sen on 2d games are tile based. Does someone know a Java tutorial non-tile based games, like Limbo for instance?
Well in my opinion "wing it" I have always considered the tile thing more of a box concept so that you can manage it more easily but I have always found it more confusing, to say the least I have given up on searching for non tile-based tutorials and am now winging it or so to speak but it still remains important be able to see a problem for what it really is.

Reading .vxl file (Ace of Spades)

I have been busy in the last couple of days designing and coding a voxel for Java.
My ultimate goal is to have a small game with a player who can move around and shoot things in a voxel-based world. Everything has been working great so far - I have gotten the voxel engine to work and to load a map saved in a simple XML format. However, I would like to be able to load .vxl maps from Ace of Spades (I believe it uses Voxlap).
I found this as a manual on how a .vxl is structured. However, how would I go about implementing something similiar in Java, instead of the C++ pseudo-code? I'm not asking for code, just for a direction on how to do something like that.

Where do I start to write/use a 3D physics simulation engine?

I need to write a very simple 3D physics simulator in Java, cube and spheres bumping into each other, not much more. I've never did anything like that, where should I start? Any documentation on how it is done? any libraries I could re-use?
Physics for Game Programmers By Grant Palmer (not Java)
Phys2D (Java code)
Assuming you want to get started on how to do it, best way to start is with a Pen and Paper. Start defining focal points of your app (like the entities sphere, cube etc, rules like gravity, collision etc, decide hierarchy of objects etc..)
If you know how to do this, and want a primer on the technology side, Swing is a good option to make UIs in Java.
Also take a look here: http://www.myphysicslab.com/
NeHe's lesson 39 is a good starting point, it's in C++ but the theory is pretty easy to understand.
A nice java physics library is jmephysics (http://www.jmonkeyengine.com/jmeforum/index.php?topic=6459); it is quite easy to use and sits on top of ODE (http://www.ode.org/) and jmonkeyengine (http://www.jmonkeyengine.com) which gives you a scenegraph (http://en.wikipedia.org/wiki/Scene_graph), again something that you'll need for anything beyond a very simple 3d application.
I haven't used it for some time though, and see that they haven't released since late 2007 so not sure how active the community is now.
How about first defining a class for physical object? It has position, velocity, mass and maybe subclasses with other features like shape, elasticity etc.
Then create an universe (class) where to place these physical objects. Sounds like fun :)
If you all you need to simulate is spheres/circles and cubes then all you need is a bit of Vector math.
Eg to simulate a simple pool game each ball (sphere) would have a position, 3d linear velocity and 3d linear acceleration vector. Your simulation would involve many little frames which continually updates each and every ball. If two or more balls collide you simply sum the vectors and calculate the new velocities for all balls. If a ball hits a wall for instance all that is required is to flip the sign of the ball to have it bounce back...
If you want to do this from scratch, meaning coding your own physics engine, you'll have to know the ins and outs of the math behind to accomplish this. If you have a fairly good math background you'll have a headstart otherwise a steep learning curve is ahead.
You can start on this community forum to gather information on how things are done:
gamedev.net
Ofcourse you could use an opensource engine like Ogre if you don't want to code your own.
Check out bulletphysics. bulletphysics.com is the forum or check out the project on Sourceforge.

Categories