Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (108)
games submitted by our members
Games in WIP (536)
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 ... 5
1  Game Development / Newbie & Debugging Questions / Re: Libgdx Graphics/Particles on: 2014-07-31 09:17:36
Hi there. Smiley
If my game should be working on  desktop and android, which resolution should the different parts have in order
to look good on both, desktop and android?
Mobile devices seem to go crazy in the last few years with their resolution, so I don't think you need separate assets for desktop and android. Maybe include a 50% downscale of all your textures for lower-resolution (and presumably low RAM) devices.

At the beginning I had some problems because I didn't use png files which didn't have a size of a multiple of two
 but later when I used drawables from a skin, this didn't really matter anymore. Why is that? And do the textures
 need to be a multiple of two?
NPOT textures are supported since OpenGL 2.0, however I still recommend using power-of-two textures because NPOT can mess up mipmapping and some other built-in functions. Quote from the linked OpenGL wiki: "While modern hardware no longer has the power-of-two limitation on texture dimensions, it is generally a good idea to keep using power-of-two textures unless you specifically need NPOTs. Mip-mapping with such textures can have slightly unintended consequences, compared to the power-of-two case."

For particles, is it necessary to use the particle editor in libgdx or can you import other particles(after effects)
 or something? Could you also use hand drawn animations instead of some particle effects?
I don't know much about LibGDX but since you can access OpenGL you can make any kind of particles you want without using a particle editor. I've just made a particle system using pure LWJGL and it turned out nice. However, I still recommend using the visual editor, because trying to tweak particle effects with a hit-and-miss technique is way harder than getting instant visual feedback. Smiley
2  Discussions / General Discussions / Re: So... state of the art 3D "engines" in Java on: 2014-07-30 16:11:36
@PandaMoniumHUN End users aren't always aware of the use of the JVM in a game especially when it doesn't use the one of the system.
Huh What does this have to do with what I said?
3  Discussions / General Discussions / Re: So... state of the art 3D "engines" in Java on: 2014-07-30 12:41:25
This is an interesting topic. While I'm not planning to make the next Crysis game, it would be nice to know what's going on under the hood of nowadays' AAA game engines.
I know UDK4's source code is semi-open (open to the subscribers) but I'm rather interested in the techniques and their explanation instead of browsing through tens of thousands of lines in the source code that I'm likely won't understand anyways without the explanation.

Problem is, when it comes to 3D everything becomes so much more complex compared to 2D that you can't really be a jack of all trades anymore and that's bad news for the likes of me who feels an urge to understand everything that he deals with. Every area (physics, collision detection, lighting, level design, shaders, etc.) requires you to be an expert, or at least decent at the given topic and learning all of that takes up years. Sad

About why there is no such engine in Java I can think of 2 things: Portability and performance.
These monstrous game engines must have the ability to export games to a huge variety of devices, and that includes consoles as well. While I don't know much about developing for console I doubt that running Java on them or converting Java to something they can use would be easy. But who knows what x86 brings to the table with the new console generation. Smiley
About the performance part: Java used to have bad reputation in the old times because it's "so slow compared to C++ and the rest" plus it doesn't give access to low-level features. While maybe that was true back then I think that the language and the JVM has evolved so much over time that I don't think JIT would be noticeably slower compared to compiled languages and we have JNI now that gives access to low-level features so that isn't a valid point either. However, people still likes to think that Java is a slow language and it is a common thing to troll Java developers with such statements.
4  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Shader libs? on: 2014-07-27 15:23:05
Why would you need a library for that?
You can implement shaders in less than 50 lines of code.
The process for a shader: Generate an id for the shader, attach source, compile, check if successfully compiled(, if not log the shader's infolog).
For a shader program: Generate an id, attach shaders, link, check if successfully linked(, if not print the program's infolog), detach and delete shaders, optionally validate the program.

It might seem scary at first written out like that but it is actually pretty simple. Smiley
Sorry for not providong code examples but I'm currently on mobile.

Edit: Oh, you mean pure Java as Java2D? In that case you can't use shaders since those are part of OpenGL.
5  Java Game APIs & Engines / OpenGL Development / Re: VBOs on: 2014-07-24 14:32:39
The problem is I still get around +15FPS if I use immediate mode instead of VBOs. Granted I'm just drawing cubes, but I'm drawing 5625 of them, so only 45,000 verts. I feel like I should be getting better FPS.
Immediate mode - 26 FPS
VBOs                - 12 FPS
There is no way you're getting worse performance using VBOs than with using immediate mode regardless of how many vertices are you putting into a VBO.

I mean, just think about it. Lets say you only put 100 vertices to 5 VBOs. That means you have to do 5 binding calls (if you're using VAOs, if not it should be around 10-15) and 5 drawing commands so about 10 commands in total versus 2+500 (the 2 is the
calls) every frame.

I think you're using VBOs wrong, maybe recreating them every frame instead of initializing them once and using them later.
The way you're supposed to use VBOs is:
Initialization (you only have to do this once):
- Create and bind VBO
- Fill up with data
- Unbind (this is not a must, but it's good practice to prevent errors)

Rendering (you do this every frame):
- Bind the already existing VBO
- Assign vertex pointers
- Draw command

You can make this process even easier by using VAOs to store buffers and vertex attribute pointers, this way you don't have to set them on every frame, just bind the VAO and call the draw command.

Edit: Oh and about the VBO sizes: Nvidia recommends that the VBO's size should be somewhere between 1MB and 4MB. However, my approach usually depends on the kind of game I'm making. If it's a 3D game with complex models featuring thousands of vertices I usually assign 1 VBO per mesh, but if it's a 2D game I usually use a single VBO for the entire scene and refill data in that VBO every frame with the visible object's vertices.
6  Discussions / Miscellaneous Topics / Re: What I did today on: 2014-07-24 12:58:47
I've been waiting for a viable C++ replacement for longer than some kids here have been on the planet...maybe someday I'll get my wish.
Or you know, you could just learn C++. Tongue

I know it's quite a pain but lots of devs are using it and it's not so hard to get used to.
I develop both in Java, C# and C++ and once you get over the most annoying little things like using headers, manually deleting pointers, makefiles, compiler options (yes, that's actually quite a lot to learn) it's not that bad. However, I still prefer Java out of these 3 because of the JIT compiler and the cross-platform capabilities. Smiley
7  Game Development / Game Mechanics / Re: "No Man's Sky" - Procedurally Generated Space Exploration on: 2014-07-24 12:49:31
I used to love randomized worlds and procedurally generated things because of their replayability but nowadays I came to a point where I prefer games with premade levels (and good storylines) instead of random ones with a very few exceptions.
Those few exceptions are mostly Minecraft, Spelunky and the rest where the random elements have a huge impact on the gameplay. However, most games that feature random elements doesn't affect the gameplay enough to compensate for the loss of a consistent world with a contiguous storyline.

This is why I'm afraid of this game's random elements too, it's nice to have random planets, but what's the point if those planets aren't important in any ways? When the guy was asked about the gameplay elements all he said is that there will be no scripted quests and similar, but he didn't say anything else meaningful. Player interaction is not core according to the interviewed developer, sooo what should a player do if there are no quests, no objectives and there is barely any player interaction?

With that being said I'm looking forward to this game and hope it turns out fun. Smiley
8  Discussions / Business and Project Management Discussions / Re: what now? on: 2014-07-23 14:57:09
Ha, yeah. It's almost like they purposely time them to coincide with the beginning of school in August or final tests in December and April. I wonder if it has something to do with the organizers' schedules?
Don't worry, LD timings are never good for me either. Since it's always on the weekends I always have something going on like traveling, parties, visiting relatives or friends (or they're visiting us), or just something more important to do. I only got to participate once and since it was my first game jam I got over ambiguous and couldn't finish in time. Guess it sucks to be a programmer with a social life. Cheesy
9  Discussions / Miscellaneous Topics / Re: What I did today on: 2014-07-23 13:07:39
Finally, I also got my streaming working and did my first dev stream, never been quite so mistake prone as I was when working with the stream running! Sad
Be careful about accidentally showing up passwords and private stuff.
If you have got multiple monitors it's a wise thing to stream only one of them and keep the log in, mail and other businesses on the other one.
Also I would be glad to watch your dev streams, can you give me a link please? Smiley
10  Discussions / General Discussions / Re: dalvik, you suck on: 2014-07-22 22:07:35
Stack trace?
It very well might be something obvious like ConcurrentModificationException, but from those 4 lines of code it would be hard to tell.
11  Discussions / Business and Project Management Discussions / Re: what now? on: 2014-07-22 17:37:46
Dedication is a skill that can be applied in many fields during your life so it's a good thing to master.
However, as I said it's a skill that you have to practice, and the way to practice it is to keep going, even if it's not fun anymore.
Development is not always fun, there are less fun parts and particularly annoying parts but if you can't get over them you'll never have anything on your hands that you can be proud of.
Nobody is going to tie you in front of your PC to finish your projects and there's no magic trick to keep motivated either, so it's all up to you. Smiley
12  Game Development / Newbie & Debugging Questions / Re: My game gives me a white screen when I run it with tiles moving enabled on: 2014-07-22 10:39:23
Welcome to the JGO. Smiley
We generally like to help, but please don't expect us to read through something like 500+ lines of code.
Use the [ code ] and [ /code ] tags (without spaces) and only share the part of your code that is relevant to your issue.
If you have to share really long code use JGO's Pastebin feature.

After a quick look at your code I would say that your issue should be inside your Screen class but I can't help any more then this because you haven't shared that class with us.
13  Game Development / Newbie & Debugging Questions / Re: My bullet(missile,magic) doesn't want to go to mouse x,y!? [solved] on: 2014-07-22 10:26:33
playerPosX += velocity.x * speed

Is it the magnitude(1 unit) * speed? Or is it the x value from normalizing the vector? I'm slightly confused on what info is actually being passed to the player position. I have a feeling that the magnitude is * by the speed and the vector then just goes it the direction?
The variable naming there is confusing. The 'velocity' shouldn't be called velocity but something like 'direction' instead, and it's supposed to be a normalized vector.
When you multiply a normalized vector with a value then essentially you're manipulating it's magnitude.
If we would use my previous example here [50; 18] which got normalized to ~ [0.9409; 0.3387] and let's say that speed is 20 then we would get the following:
playerPos.x = 0.9409f * 20f;
playerPos.y = 0.3387f * 20f;

If we would calculate playerPos's length now the result would be 20, or at least very close to it.
This is because floating point rounding errors, and you have to watch out for this because it can be a pain at times.
Last time when I was developing the AI for our game I've spent 2 days debugging only to find out that I have one of these nasty errors. Tongue
14  Game Development / Newbie & Debugging Questions / Re: Learning to create a 3D game in Java! on: 2014-07-21 10:27:11
3D is exponentially harder to develop compared to 2D.
In terms of math you'll need lots of trigonometry knowledge and all around linear algebra knowledge.
Unlike in 2D, when you're working with 3D in my opinion you can't get away without an engine (doesn't matter if the engine is yours, just separate the project and the engine behind it), it just gets too complex otherwise.
To make a good looking game you have to be confident with using all kinds of shaders (eg. vertex shader displacement, fragment shader lighting, geometry shader point sprite particles, etc) and be overall familiar with modern OpenGL.
Creating the 3D art assets is hard and time consuming, picking up 3D modeling alone can take up a significant amount of time.

All of this is not an easy task and unless you truly have the time and the dedication this takes you're probably better of using a premade engine like jMonkeyEngine 3.0 or something even more versatile like Unity or UDK4.
With that being said I wouldn't like to discourage you, if you feel like it go ahead, it's a nice learning experience but sadly most people who starts making these things end up developing engines instead of games. Sad
15  Game Development / Newbie & Debugging Questions / Re: My bullet(missile,magic) doesn't want to go to mouse x,y!? on: 2014-07-19 17:03:58
Panda, you helped me understand vector math with finding positions and normalizing them using the built in function that comes with LibGDX. As I understand, normalizing a vector gives it a unit length of 1 as we only care about the direction and not the length of the vector. However, i'm struggling to understand how the vector still knows which direction to go when it has a length of 1? If that makes sense. Sorry for the noob question, my math is poor Pointing
Normalization is all about scaling a value to be between 0 and 1. This is useful for many things, but most game developers only use this to remove the magnitude of a vector and only keep it's direction. You can achieve normalization by dividing a number with it's maximum possible value. So if you want to normalize numbers that can go from 0 to 50 to the range 0 and 1 you have to divide your numbers by the max value, that is 50.

Same thing with vectors, although not as easy because vectors have multiple components. If a 2D vector only travels on the X axis for example, e.g. a vector that is [50; 0] than the vector's length is 50, so you have to divide all components with 50 resulting in a 2D vector [1; 0] which correctly represent the direction of the original vector. Things get a bit more complicated when the vector travels on both the X and Y axis, e.g. when you have a 2D vector [50; 18]. In this case you have to calculate the vector's length which is ~53.1413 in this case and divide the components with that number, resulting in ~ [0.9409; 0.3387] which again correctly represent the direction of the original vector. Hope things are a bit clearer now.


Sorry, but in my world, objects are not moving from point a to point b, they are moving in the direction they are rotated to.
That's cool, in my world people usually represent directions like forward and right using 2D vectors (or with a single 3x3 or 4x4 matrix, for that matter) and not with angles because it's more efficient to do it this way instead of computing the direction every single time you want to use it. If we want to rotate something we just use rotation matrices. Smiley
No need to be arrogant or sarcastic, I was never doing that to you either. Pointing
16  Game Development / Newbie & Debugging Questions / Re: My bullet(missile,magic) doesn't want to go to mouse x,y!? on: 2014-07-19 13:15:39
Its called abstractions, and while it adds more complexity to the code, the code is easier to read, if you don't need to understand what is happening behind the scenes. 2 lines of very simple code to get the velocities is very small simple to me at least. Besides, you will probably want to render the sprites rotated, in which case you will need to calculated rotation anyway, so whatever.
Abstraction is not about adding levels of unnecessary code to the project. It's about providing a higher-level interface for easier development.
Even if you would like to render the sprites rotated, calculating the rotation (normally) has nothing to do with the mouse position.
The sad part is that you didn't even stop to think about my (or rather NegativeZero's) solution instead you continued to argue and only stopped because someone who has '10 times as much programming experience as you' proved you wrong. Sad
17  Game Development / Newbie & Debugging Questions / Re: My bullet(missile,magic) doesn't want to go to mouse x,y!? on: 2014-07-19 12:18:55
So why exactly did you open this thread when you already have one for the exact same purpose?

By the way NegativeZero's way of doing it is correct (the only mistake is that you have to cast Math.sqrt's result to be a float).
Basically you create a vector that points from your player's position to your mouse's position, normalize the vector (that's the part when you divide the components by the length of the vector) and then multiply it by the projectile speed. Ta da. Cheesy

@trollwarrior1: There's no need to involve angles in this, that just unnecessarily makes the code more complex.
18  Discussions / General Discussions / Re: What? Your game isn't a pixelated retro masterpiece? on: 2014-07-19 09:52:10
Should also be noted I disagree with the notion that pixel art is the "easy way out". In a lot of cases, I've found good pixel art even more challenging than my cartoony work. Cheesy
'Good' pixel art is easy to make in the terms of art, where 1 or 2 years of learning is considered a short time.
Go to DeviantArt, pick a few nice pieces and ask their drawers how long they've been drawing. I'm pretty sure 90% of the answers will be above 10 years. Pointing
And then there's 3D modeling which was barely mentioned in the topic. It takes just as much skill as drawing + teamwork, because apparently someone who's good at modeling might not be great at lighting, or animation, texturing, etc.
19  Discussions / General Discussions / Re: What? Your game isn't a pixelated retro masterpiece? on: 2014-07-18 17:24:04
In short: It's easy to learn pixel-art, and pixel art is easy to make. Creating an entire character from start to finish with animations shouldn't take more then 3-4 hours (but of course that depends on the complexity of the piece) if you know what you're doing compared to the regular few days (or to a few weeks in extreme cases) in drawing. Since retro looking games became popular recently small dev companies and startups simply don't feel the need to make their game look any more modern when they can get away with the old-style and less work. A really big point here is that not everyone can afford artists, and not everyone has years of time to learn drawing. Pointing

With that being said I would like to point out that pixel art can look just as good as AAA 3D games (but that of course that comes down to taste) with a nice art style, lighting and particle effects. Smiley
20  Game Development / Networking & Multiplayer / Re: 10 Player(instanced) 3D Game, would TCP Suffice? on: 2014-07-17 08:59:42
I'm not sure why the average playercount has gone down as sharply as it has in later years, but my guess is that the main bottleneck is in the amount of data.
@derail on:
It didn't go down. There's still quite a few games where 12+ players play together and in Battlefield games 64 players is still supported (and quite often those 64 slot servers are full).
In Guild Wars 2 WvW there are lots of ~50v50 player battles, same in WoW a few years ago (not sure about now, haven't played in a while).
There are Minecraft servers out there with 100+ slots and some of them really does have 100+ active online players.
I guess it was rather the style of the games that changed, they require more teamwork and strategy which is really hard to do when you try to command 31 people in your team. Smiley
@derail off
21  Discussions / General Discussions / Re: Java Swing GUI Creator on: 2014-07-16 09:17:37
Eclipse has a plugin called WindowBuilder, that's the most advanced GUI editor I used so far.
IMO, it's better than Netbeans' built-in solution and it doesn't force you to switch IDE if you are used to Eclipse. Smiley
22  Discussions / Miscellaneous Topics / Re: A rant on OpenGL's future on: 2014-07-15 10:56:29
Mantle is only for AMD and Apple chips now, OpenGL was only available for certain cards when it first came out. My point was we right abstractions so we can switch when and if we need. Why would we hand on to any particular library if it gets outdated and bloated *as soon* as the other options are viable?
We don't have to hold onto OpenGL, as soon as Mantle becomes as supported, capable, stable and multiplatform as OGL it'll probably be a better choice but I have a feeling that isn't gonna happen anytime soon.
Also most of the people here learnt OpenGL for years (or at least months), graphics libraries are not easy to wrap your head around and if we have the choice between fixing OpenGL and learning a new graphics API I think most of the community here will always vote on fixing OGL (me included Smiley ).

I agree on removing ALL the redundant features and go only with as few commands as needed (this way not only OGL becomes less bloated but the drivers are likely to be more stable too).
It's painful to see newcomers troubling with OpenGL, they keep mixing up old and new functionalities and honestly it's not their fault. Fix yo sh*t, OGL.

Also it would be nice to finally see a complete and capable OGL debugger. I know Valve has one on the way but it isn't out yet, is it? persecutioncomplex
23  Game Development / Game Mechanics / Re: Colision! How the fuq? on: 2014-07-15 01:06:07
Isn't this topic essentially the same as the one you opened yesterday and then marked as resolved?
We posted quite a lot of snippets in that topic, if you need help just check back in there.
24  Game Development / Newbie & Debugging Questions / Re: LibGDX - Unable to allocate audio buffers on: 2014-07-14 18:13:56
This should help haha Cheesy Clicky.
Good luck!
This isn't helpful. Emo
There's nothing wrong with asking him if he at least tried to research the subject before asking, but instantly implying that he made no research at all is rude.

Personally I don't use LibGDX too much but if you attach the LibGDX source code in Eclipse to the LibGDX JAR then you will be able to see what's going on inside the LibGDX classes when debugging and that could be helpful. Also could you share the music loading part of your code? Because it's very likely that is what's causing the issue. Smiley
25  Game Development / Newbie & Debugging Questions / Re: Generate random path on a 5x5 on: 2014-07-14 18:02:47
Why sometimes the real path length is smaller than the length i've choosen?
The real path length is smaller than the chosen path length when the path generator gets "trapped".
I've explained that in my previous comment:
Not sure how much thought you gave to this but essentially there will be times when you can't step as much as you would like to because you get trapped.
Getting trapped happens because you will be surrounded by tiles that you have used before and since you can't step on them again there will be no tile to move to.
You can handle this problem 2 ways: Allow in these situations to to move on a tile where you have already been, or stop movement. Pointing

As Riven said for such a simple thing you probably don't need backtracking, it's enough if you discard the track if it gets trapped and generate a new one.
26  Game Development / Newbie & Debugging Questions / Re: Generate random path on a 5x5 on: 2014-07-14 14:31:27
This sort of a problem can be approached in many ways.
Not sure how much thought you gave to this but essentially there will be times when you can't step as much as you would like to because you get trapped.
Getting trapped happens because you will be surrounded by tiles that you have used before and since you can't step on them again there will be no tile to move to.
You can handle this problem 2 ways: Allow in these situations to to move on a tile where you have already been, or stop movement. Pointing

Other than that the other thing that requires a bit of thought is that when you generate random movement you should only be able to move to valid tiles (aka, you shouldn't move outside of your matrix's length because you'll get IndexOutOfBoundsException).

Both of these problem are easily solvable and here's an implementation that stops movement when getting trapped, in less than a 100 lines:

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class RandomPath {
   public enum Movement{
   public static class Vector2{
      public Vector2(int x, int y){
         this.x = x;
         this.y = y;
      public int x;
      public int y;
   private static final int MIN_PATH_LENGTH = 4;
   private static final int MAX_PATH_LENGTH = 21;
   private static final int yourMatrix[][] = new int[5][5];
   private static final Random random = new Random();
   private static final List<Vector2> path = new ArrayList<Vector2>();
   private static int x = 0;
   private static int y = 0;
   public static void main(String[] args){
      // Gives a random value between MIN_PATH_LENGTH and MAX_PATH_LENGTH
     int pathLength = MIN_PATH_LENGTH + random.nextInt(MAX_PATH_LENGTH-MIN_PATH_LENGTH+1);
      // Add the starting position to the path
     path.add(new Vector2(x, y));
      // Generate a random path
     for(int i = 0; i < pathLength-1; i++){
         Movement movement = randomMovement();
         if(movement == null) break;
            case UP:
               y += 1;
            case DOWN:
               y -= 1;
            case LEFT:
               x -= 1;
            case RIGHT:
               x += 1;
         path.add(new Vector2(x, y));
      // Print out our path
     System.out.println("Path length: "+pathLength);
      System.out.println("Real path length: "+path.size());
      System.out.print("Path: ");
      for(int i = 0; i < path.size(); i++){
         Vector2 v = path.get(i);
         System.out.print("["+v.x+", "+v.y+"]");
         if(i < path.size()-1) System.out.print(", ");
   // Checks if the tile has not been used before
  private static boolean isUntouched(int x, int y){
      for(Vector2 v : path){
         if(v.x == x && v.y == y) return false;
      return true;
   // Generate a VALID random movement
  private static Movement randomMovement(){
      List<Movement> movementSet = new ArrayList<Movement>();
      if(x > 0 && isUntouched(x-1, y))
      if(x < yourMatrix.length-1 && isUntouched(x+1, y))
      if(y > 0 && isUntouched(x, y-1))
      if(y < yourMatrix[0].length-1 && isUntouched(x, y+1))
      if(movementSet.size() == 0) return null;
      return movementSet.get(random.nextInt(movementSet.size()));

The code is not heavily documented but there are some comments here and there.
If you have any questions feel free to ask me. Smiley
27  Discussions / Miscellaneous Topics / Re: [Girls] How to completely block them from our lives? on: 2014-07-14 09:10:50
Can't even have a decent discussion without half the internet yelling to please close off the topic. Huh
The problem is that the whole thread's topic wasn't why are there so few females in the IT field or drugs or inspiration (which are at least interesting misc topics to most of the people here);
It was all about how to block girls from our lives, which I think nobody really wants to do here (lol, quite the opposite), and while we have a lot of nice members who are willing to help out 13 year olds with this question this really isn't something that should be discussed on the JGO forums.

Personally I can't understand how the Keyboard WPM topic has ended up in chit-chat because it didn't fit JGO and this isn't. Clueless
28  Java Game APIs & Engines / OpenGL Development / Re: Deleting and Detaching Shaders on: 2014-07-14 08:58:59
As most of your links suggest: Detaching and deleting shaders after the shader program has been linked is the correct way to go. Pointing
This way you'll free up quite substantial memory in the VRAM: (Quote from your stackoverflow link)
That way the driver can free up all the memory it is using to hold a copy of the shader source and unlinked object code, which can be quite substantial. Measurements I have done indicate that NOT deleting the shader objects increases the incremental memory use per shader by 5-10x

The only reason why you might don't want to do this is because there are some buggy drivers out there which might not like this practice (even though this should be the standard way of dealing with shaders), but then again I would never implement hacky solutions or try to fit my code just so it runs on bad drivers too. AAA companies might have to do that, but we lone wolves have enough things already to put up with. Cheesy
29  Game Development / Newbie & Debugging Questions / Re: Java rectangles for collision? on: 2014-07-13 19:08:49
But that is what i have been doing and it's not working out. Maybe my code is wrong? Can you give me an a example?
What do you mean by "not working out"? Have you tried to debug your game? Do you have at least a slight idea that what is wrong with your code?
Basically all you have to do is make a bounding box for your sprites and when you're moving them iterate over all the other bounding boxes. If it collides with one of them prevent the movement (or do something like bouncing off). This should be trivial to implement, but here you go:
public void collisionDetection(){
   for(Sprite sprite1 : sprites){
      // Move sprite1 to it's new position (and it's bounding box too)
     // but before you do that you might want to save it's current position
     // to restore the player there if a collision happens.
     // ...
     Rectangle bb1 = sprite1.getBoundingBox();
      boolean collided = false;
      for(Sprite sprite2 : sprites){
         Rectangle bb2 = sprite2.getBoundingBox();
         if(sprite1 != sprite2 && bb1.intersects(bb2)){
            // Collision happened
           // Handle collision (prevent movement, bounce off, etc.)
           // ...
           collided = true;
         // The sprite didn't collide with anything else
        // so handle movement (increase position, etc.)  

I wrote this off the top of my head so hopefully there are no errors in the code. This uses Java's AWT Rectangle class for checking rectangle intersections. Implementing your own intersection "algorithm" shouldn't be hard either. Smiley

Edit: I forgot to mention that these kind of collision detections will never be perfect because if your sprite's acceleration goes high it can easily clip through slim walls and such. To prevent this you'll have to look into raycasting which is considered as a bit of an advanced topic (but it isn't terribly complex IMO). Pointing
30  Games Center / Showcase / Re: We Shall Wake demo (v6.0) on: 2014-07-13 10:03:27
Gigantic props to both of you, this looks very promising. Cheesy
Pages: [1] 2 3 ... 5

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

The first screenshot will be displayed as a thumbnail.

CogWheelz (16 views)
2014-07-30 21:08:39

Riven (22 views)
2014-07-29 18:09:19

Riven (14 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (32 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (43 views)
2014-07-24 01:59:36

Riven (42 views)
2014-07-23 21:16:32

Riven (30 views)
2014-07-23 21:07:15

Riven (31 views)
2014-07-23 20:56:16
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22 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!