Featured games (91)
games approved by the League of Dukes
Games in Showcase (580)
games submitted by our members
Games in WIP (500)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1] 2 3 ... 48
1  Game Development / Newbie & Debugging Questions / Re: How to create arbitrary shapes? on: 2014-04-18 12:01:58
I think it's a pretty cool idea, too. Check this "Vector Shooter" out Wink (Only look at the videos and the idea. The code itself is for the jMonkeyEngine).

What do you mean by Vector Diagram?

In the end, Java2D is pretty strong when it comes to drawing shapes. As far as I know, it's even possible to draw concave shapes, which needs additional triangulation in case it's not rendered in software Smiley

I would also suggest to use something else than Java2D, because it's API is not really made for games and it can be really slow in some cases. You could try out LibGDX, and if you do, try out it's "ShapeRenderer".
2  Game Development / Networking & Multiplayer / Re: Slick2D + Kryonet guidance on: 2014-04-18 11:51:24
I like that your questions are really concise! Smiley (Adding that to the "Good Examples" Wiki Page Grin )

  • Should I be running Slick from the client, server, or both?
    It's a good idea to have Game Logic and Rendering seperated strong enough, so that you can run your Game without rendering anything. That'd allow your Server to run as a terminal / console program or in the background of a already running Slick game Wink
  • Should I be sending the whole game state or just things like entity data, positions, etc?
    You might want to start with sending the whole game state. Later you might try out something like only sending the changes. You can experiment with either only sending what the User Clicks and Types (Mouse & Keyboard Input), with the server responding with the current game state (No client-side prediction, "Server like a terminal", how John Carmack called it). You can always try out everything else later.
  • How often should I be sending the information to the client?
    It really depends. What I'd suggest is sending it about ~20 Times a second (I think that's just as frequent as in Minecraft) and interpolate between the gamestates so that you can render at 60 Times a second Smiley
  • How and how often would input be sent from the client to the server?
    I'd have the same update rates from client -> server like from server -> client.
  • What code should I have on both the client and the server?
    Ideally, the game logic code should be exactly the same Smiley Note, that many programs don't do that. The Minecraft server, for example, does only route the recieved game updates from one client to the other clients, while also checking that they don't fly in the air for too long (Do you know the "You got kicked from the server because of flying" dialoge? Wink ). It also checks the speed at which the client's player travel, afaik.

Hope this helps you Smiley
3  Game Development / Newbie & Debugging Questions / Re: New vector from known angle on: 2014-04-17 19:23:00
Don't fight math. It will help. Especially vector-math is a very valuable tool for games. Inverting the axis is just a shortcut in this special case. Next time you need to calculate your balls movement (nice wording Wink) in another case, you'll need to learn it anyway or fall back to another shortcut for another special case, and on and on and on...

If you limit your solutions to special cases, you limit your game to special cases and therefor limit your creativity to special cases...

I completely understand, and I think so too. In the long run vector mathematics is really useful, but for beginners, it's a good idea to start of simple.
You might even learn vector mathematics this way.
For example you might learn the dot product between a and b this way:
Special cases:
  • (1, 0) dot (1, 0) = 1
  • => Equal vectors -> 1
  • (1, 0) dot (-1, 0) = -1
  • => 180° between vectors -> -1
  • (1, 0) dot (0, 1) = 0
  • (0, 1) dot (1, 0) = 0
  • => 90° between vectors -> 0
  • (1, 0) dot (2, 0) = 2
  • (2, 0) dot (2, 0) = 4
  • (3, 0) dot (2, 0) = 6
  • => 0° between non-normalized-vectors -> |a| * |b|
... and so on Smiley
4  Discussions / General Discussions / Re: What genre/artists do you listen to while coding? on: 2014-04-16 21:45:39

Ehehehehe Cheesy
5  Game Development / Newbie & Debugging Questions / Re: LibGDX and Getting Pixels From Sprite on: 2014-04-16 13:45:35
He doesn't want tinting. He wants to replace certain gray colors with custom colors in code.

Where precisely do you read that he "does not want tinting"? I'm curious.

I dont see how my solution does not give him what he wants. You can flip and scale a tinted texture to your heart's content.

It's because he wants to do it like notch did it in minicraft. And notch didn't tint the textures in minicraft Wink
6  Discussions / Java Gaming Wiki / Re: Complex number cookbook on: 2014-04-15 15:32:19
Yeah I've seen that site.  Diagrams are great and very helpful...interactive is even better.  And I can't motivate myself to do either.
7  Game Development / Newbie & Debugging Questions / Re: Space Invaders - Defense Thing on: 2014-04-15 11:39:14
Yeah of course it is Smiley

You might want to look into Destructible terrain, GameDevTuts+ always makes very, very good gamedevelopment articles ^^
8  Java Game APIs & Engines / Engines, Libraries and Tools / Re: [Libgdx] Problem with ImmediateModeRenderer20 on: 2014-04-15 11:13:35
1. Please show some code, I don't get what you're doing ^^
2. A screenshot can be really helpful for us to understand what you mean with "noisy".

Also, ImmediateModeRenderer20 is deprecated. You shouldn't use it. You should use one of the following:
  • SpriteBatch for rendering Textured, moving images
  • ShapeRenderer for rendering Shapes without textures (circles, lines, rectangles)
  • SpriteCache for rendering Textured, static images like scenery
9  Discussions / Java Gaming Wiki / Re: Complex number cookbook on: 2014-04-15 10:49:26
I think it's really hard to understand without any pictures describing what is going on. I have to do this in my mind and that only works if I have already understood it. It's the Bret-Victor-Syndrom I'm talking about Grin Someone made a really nice intro to Complex numbers and why they can be used to represent sqrt(-1) and how we should picture them:
See the first Presentation on that page (Initially shows the number line).

You might like other things from him as well, so check his blog out, he does exactly what Bret Victor initially encouraged to do Smiley
10  Game Development / Newbie & Debugging Questions / Re: New vector from known angle on: 2014-04-14 23:16:09
What the actual ...?

Normal vectors and dot product? Come on.

I'd suggest exactly what Screem suggested, and I'll add a little bit of code to it, too:

This only works when both objects are considered to behave like two axis-aligned boxes:
// Assuming some kind of vector implementation like Vec2(int x, int y) with the fields "x" and "y".
// AABB = Axis Aligned Bounding Box
public Vec2 getCollisionVelocity(Vec2 velocity, AABB ball, AABB object) {
    // side is either TOP, LEFT, RIGHT or BOTTOM
   int side = getCollisionSide(ball, object);
    switch (side) {
    case TOP:
    case BOTTOM:
        return Vec2(velocity.x, -velocity.y);
    case LEFT:
    case RIGHT:
        return Vec2(-velocity.x, velocity.y);

The principle of reflecting along an axis is really easy. The hard thing is finding out the side at which they collided. But depending on what kind of game you are creating this might not actually be too hard.

You only need advanced vector math with normals similar when you want to bounce an object off from an arbitrary surface / edge. But then you might as well just use a Physics library like Box2D, because that stuff can get really hard when you want to add rotation upon colliding or similar ^^
11  Game Development / Newbie & Debugging Questions / Re: Space Invaders - Defense Thing on: 2014-04-14 23:05:04
What they do is pretty simple:

They have 5 different 'kinds' of defense-blocks:

1. The full Block
2. The half blocks:
  2.1. The upper-left-filled half
  2.2. The upper-right-filled half
  2.3. The lower-left-filled half
  2.4. the lower-right-filled-half

And then they have 4 different damage levels, and for each defense-block they have 4 images for each damage level.

If you shoot a sprite it, the damage level decreases, the sprite changes. If you shoot it 4 times, it disappears. Smiley

But thats not interesting enough, of course. And it's too easy to implement, too, I'm curious about the other ideas! Cheesy
12  Games Center / WIP games, tools & toy projects / Re: SCREENSHAKE: SixtyGig - Open World Retro RPG. on: 2014-04-14 16:05:02
Those pool balls must be stuck to the table.   Wink
"Those poor balls must be stuck in the table.  Wink" I have no Idea why I read it like that  persecutioncomplex
13  Games Center / Showcase / Re: [Android] Onigiri Escape on: 2014-04-14 14:18:52
Really cool game! Smiley

I don't actually understand what the Yeti does / is a reference to and how to win against it. Everytime I can't jump over it, it throws a block at me so fast I can't react or try out tapping somewhere I just get instantly killed. Would be cool if you'd get 2 times 10 seconds of trying to fuigure out how to win against him and if you won both 2 testing phases you will never get them back or something like that. But just don't make it so I'm just put in there and die Cheesy

Keep it up! Smiley
14  Game Development / Game Mechanics / Re: Mathematical curves. on: 2014-04-14 10:44:57
I blame a lack of coffee for my ability to read that more than once without mentally processing the word "root". You are quite correct.

Fun Fact: I posted that after a LAN-Party where I didn't sleep. Haven't slept for about 35 hours at the time I posted it... Grin
But, well, the same mistake could have happened made even when I had slept Wink
15  Game Development / Game Mechanics / Re: Mathematical curves. on: 2014-04-13 19:40:30
the value given by the cubic root plateus fairly quickly

No it doesn't. It tends to infinity, as does its first and second derivative.

Not really useful information here, but are you sure they do?

I think what you wanted to say is: They tend towards zero, but never approach it (and therefore the Cubic Root is never going to be flat at some point).
16  Game Development / Newbie & Debugging Questions / Re: Making a vector2f array based off a texture on: 2014-04-13 02:03:52
In most cases theagentd's second option is enough. Try that one out. There is also another pixel-perfect lighting techneque that davedes implemented, see this post:

This can be done with shaders. But I've already tried searching for the source code that davedes wrote once, but I couldn't find it, maybe you do Smiley
17  Game Development / Newbie & Debugging Questions / Re: Can you randomly bitwise shift an integer left or right? on: 2014-04-12 12:45:54
nextInt() will occasionally give you a zero... which is not a legal argument to << or >>. A bit arbitrary but there you go.

Wut. I didn't know that and it doesn't seem logical to me, but well Cheesy
That's like throwing an IllegalArgumentException when you do
5 + 0
42 * 1

18  Game Development / Newbie & Debugging Questions / Re: Can you randomly bitwise shift an integer left or right? on: 2014-04-12 12:17:11
Are you really sure, that you called the method with

This is what the docs say:

The doc says, the implementation looks like this:
 public int nextInt(int n) {
   if (n <= 0)
     throw new IllegalArgumentException("n must be positive");

   if ((n & -n) == n)  // i.e., n is a power of 2
    return (int)((n * (long)next(31)) >> 31);

   int bits, val;
   do {
       bits = next(31);
       val = bits % n;
   } while (bits - val + (n-1) < 0);
   return val;

Therefore the only reason you might get an
is when you provide a value lower
<= 0
19  Game Development / Game Mechanics / Re: Mathematical curves. on: 2014-04-12 11:49:50
You could try a universal system like bezier curves, or something like a cubic spline (I think thats how it's called, but I'm not sure...):

// For t between 0 and 1 you get an interpolation between 0 and 1
public float cubicSpline (float t) {
    // original function: 3t² - 2t³
   return (t * t) * (3f - 2f*t);
// Interpolating arbitrary values: (t between 0 and 1, again)
public float cubicSpline (float begin, float end, float t) {
    return begin + (cubicSpline(t) * (end-begin));

Edit: Be careful with LiquidNitrogen's example.
can maximally be 100 for the speed 20. Else speed will start to get negative and everything'll fail.
20  Games Center / WIP games, tools & toy projects / Re: MERCury - 2d Game Engine on: 2014-04-12 11:38:46
In other news, I totally did not copy the idea behind Gibbo's utility published just today thanks bro!. Here is how my totally original idea works:

You should really take a look at Java 8's Lambda's. They make this syntax look so much better Smiley
21  Game Development / Newbie & Debugging Questions / Re: LibGDX Mouse Position While Zoomed in on: 2014-04-10 22:00:36
I have not try it, but I think that camera.unproject() should work as well.

You should unproject IMO, multiplying by the zoom might cause inaccuracy, since it will round to the nearest pixel. Not much but yeah, unproject avoids this.

Even worse: If you don't use .unproject() and you add rotation of the viewport some day (for some visual shake effect, for example) the simple Multiplication wouldn't work anymore. Wink
22  Game Development / Newbie & Debugging Questions / Re: Advice on a faster way to check every pixel in an image. on: 2014-04-09 17:03:13
I don't know why nobody ever thought of this yet, but why not multi-thread?

You could (with java Cool use a parallel stream + map() Smiley

Doubt this would benefit much as it's a memory-bound operation, passing the buffers around from thread to thread is likely to only exacerbate the problem. That's how it works in my head anyway. As always, needs a benchmark to really be able know anything.

I think the Arrays would then be loaded into the CPU's cache, so it might be faster in the end.
Also, why should they need to pass buffers around?
23  Game Development / Newbie & Debugging Questions / Re: Advice on a faster way to check every pixel in an image. on: 2014-04-09 16:08:02
I don't know why nobody ever thought of this yet, but why not multi-thread?

You could (with java Cool use a parallel stream + map() Smiley
24  Game Development / Newbie & Debugging Questions / Re: How would you implement sokoban on: 2014-04-08 16:52:05
If you feel there are better designs, please enlighten me. (or why shouldn't I do this)

I realize this is somehow getting rediculous now, since it's only sokoban, but anways, I like thinking about "nearly perfect" design Smiley

Back on topic:

I don't see a reason why you should make a difference between Player and Boxes. I liked my approach (saving only walls, targets and free spaces in the 2D Array), because I would seperate movable objects from Static ones.

Also, I wouldn't call it "Grid", because a Grid encapsulates single Cells. On the first glance, something that is typed "Grid[][]" looks like a 2D array with 2D arrays (Grids) inside.

I would create the following types:

enum Cell {

    public boolean canBeMovedOn;

    Cell(boolean canBeMovedOn) {
        this.canBeMovedOn = canBeMovedOn;

abstract class Movable {
    private int x;
    private int y;
    public Movable(int startx, int starty) {
        this.x = startx;
        this.y = starty;
    // Direction is the direction the user has pressed
   public abstract void act(Direction dir, SokobanWorld world);

class Box extends Movable {
    public Box(int sx, int sy) {
        super(sx, sy);
    // Do nothing. A Box doesn't react to user input directly
   public void act(Direction dir, SokobanWorld world) {}

class Player extends Movable {
    public Player(int sx, int sy) {
        super(sx, sy);

    public void act(Direction dir, SokobanWorld world) // To be implemented

class SokobanWorld {
    public Cell[][] grid;
    public Map<Vec2i, Movable> movables;

But this might all be over-engineered Wink
25  Game Development / Newbie & Debugging Questions / Re: How would you implement sokoban on: 2014-04-08 16:24:00
Also, I have the box class. But then I find out I don't need this class. It will be much easier to just manuplate the 2D array. If I use 2D array, I can easily find out if the player can go where, if there is a box and what if the box is leaning on to the wall. However if the boxes are saved in a Set, I need to iterate through them every time, comparing with x, y, then checking the walls.

The enum is not a bad idea, it doesn't need to be used, but it doesn't hurt much anyways.
However, what if the socket tile is saved in Map's
and you finally moved the box to [icode]tile[4][4];[icode]? Would you overwrite the socket? But then you can't move the box or you would remove the socket.
26  Game Development / Newbie & Debugging Questions / Re: How would you implement sokoban on: 2014-04-08 15:51:10
Only a 2D array is not the way you should go, because you need to be able to place the gems onto the socket tiles.
Also, you might make a mistake in your game code somehow and end up with two players inside your array.

I would create a Grid class / simple 2D int[][], that holds what tiles are walls, what tiles are sockets and what tiles are ground that is walkable. You can simply create constants for them (i.e.
public static final int WALL = 1; public static final int GROUND = 2;
), no need for classes.
Then you add a Player and a Gem class that have x and y integer fields. They can move around, the 2D int[][] cannot change.
27  Game Development / Networking & Multiplayer / Re: Game Networking Framework on: 2014-04-07 21:24:36
I highly suggest to use Kryonet. It allows sending java objects over the internet via TCP / UDP with a lot of useful optimizations. It's pretty much the fastest Serialization library (Kryo) together with a very fast network implementation.
28  Game Development / Newbie & Debugging Questions / Re: LibGdx Entity error on: 2014-04-07 20:07:05
you never Initialized the "batch" instance. You have to call
batch = new SpriteBatch(...)
somewhere in your initialization code. Smiley
29  Game Development / Newbie & Debugging Questions / Re: LWJGL Orthographic projection render order based on Z on: 2014-04-07 17:45:42
You generally don't want to use depth testing with 2D due to the transparency problem. The most common solution for rendering transparent stuff with a depth buffer (regardless of 2D or 3D) is to disable depth writes and sort your objects. If you only need additive blending you don't need to sort your objects, but this is rarely the case.

What if I have two seperate lists:
1. Sprites that only have pixels with alpha 1 or alpha 0 or Sprites that are supposed to be rendered with additive blending,
2. Sprites that have pixels with other alpha values between 1 and 0.

Now, all sprites have some kind of "layer" variable, or in other words: A Z-position.
I don't need to sort list 1. I can simply render it non-sorted with additive blending, alpha test and depth testing enabled.
I sort list 2, then render it with normal blending and depth testing disabled.

Transparency should work and everything should be faster, no? Smiley
30  Discussions / General Discussions / Re: [LIBGDX] Particles disappearing and then reappearing on: 2014-04-06 22:30:08
So what you describe is almost what
does, but you want it to recursively mark all fields of that method as final...

1. It doesn't need to be an exception. It would be much better if it was a compiler error. Or else you might not notice your error it until some of your users has a PC that makes your code jump into some strange if-branch and then fail. The compiler can immediately see if you tried to change something from an Object that was marked to be
, just like it's with

2. I don't think this would be too useful. There is even a problem with My first point, that I just noticed Wink ... Let's take LibGDX's Color class as an example. If you'd mark it as immutable (and you had the compiler error method that I described in point 1) it wouldn't compile, because there'd be a compiler error with the
method... Therfore it would make sense to use Exceptions, yeah...


I don't like the idea of adding more runtime errors, though. I think the future lies in compilers that find out that your program is wrong before it even executed once. They find the bugs for you easily, because the coder is constrained in what he can do so that It's easy for the compiler to spot bugs. That's exactly why compile-time type-checkers were invented. They didn't want you to accidently use your "Color" as String, because that'd be impossible. They constrain us, though. We can't simply cast a "Vector3f" into a "Color", though, even though in C it would work...

Pages: [1] 2 3 ... 48

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (50 views)
2014-04-15 18:08:23

BurntPizza (46 views)
2014-04-15 03:46:01

UprightPath (62 views)
2014-04-14 17:39:50

UprightPath (44 views)
2014-04-14 17:35:47

Porlus (60 views)
2014-04-14 15:48:38

tom_mai78101 (84 views)
2014-04-10 04:04:31

BurntPizza (142 views)
2014-04-08 23:06:04

tom_mai78101 (242 views)
2014-04-05 13:34:39

trollwarrior1 (201 views)
2014-04-04 12:06:45

CJLetsGame (208 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30 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!