Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (407)
games submitted by our members
Games in WIP (293)
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 ... 63
1  Discussions / General Discussions / Re: Xbox 720 - IllumiRoom, we'll be stacked in our living room for ever on: 2013-04-30 14:24:04
Looks really quite an impressive way of compensating for the restrictive fov common in most console games.

Though I wonder what the performance impact would be, and whether it'd be cheaper for people to just adopt wider screen TVs/projectors & bump up the fov appropriately.
2  Game Development / Newbie & Debugging Questions / Re: Finding the time at which intersection takes place. on: 2013-04-15 14:12:37
Here's some keywords to set you on the right track:

swept volume, convex polygon, separating axis theorem.

As to the issue of multiple collisions between more than 2 actors;

- check all collisions that occur within the next frame, looking for the earliest.
- step your simulation to that point, and resolve the single collision that occurs.
- repeat until you've processed all collisions that occur that frame.
3  Game Development / Newbie & Debugging Questions / Re: Calling method that needs to be static but cant be? on: 2012-12-24 18:04:21
You need an instance of a class implementing the Pixmap interface.
4  Game Development / Newbie & Debugging Questions / Re: Detecting Collision between a polygon and a circle? PRECISE on: 2012-12-12 01:50:45
Is the polygon (character), or circle (snowball) moving?

If so, for precise collision detect you'll need to consider the collision as a swept circle <-> polygon interaction.

Google points me to this: http://www.three14.demon.nl/sweptellipsoid/SweptEllipsoid.pdf
5  Game Development / Newbie & Debugging Questions / Re: how to draw Sprites that turned to the left. on: 2012-12-08 04:32:15
You should have additional data that goes alongside that sprite sheet, defining the bounds for each frame (and possibly separate collision bounds too).
For rotating or flipping you'll want each frame to have an anchor point defined too, around which the operations are performed.

How you store that additional data is up to you; artists tend to like using paint packages, so having the bounds & anchor points defined as additional layers in the same image file can be a neat solution. (though obviously needs a little pre-processing in your code to extract the numerical offsets of the various pixel flags)
6  Game Development / Newbie & Debugging Questions / Re: Slick input keys on: 2012-12-06 00:12:25
This did the trick.

1  
2  
3  
4  
5  
6  
7  
8  
    @Override
    public void keyPressed(int key, char c) {
        if (c == 'Æ') {
            tekst += "Æ";
        } else if (c == 'æ') {
            tekst += "æ";
        }
    }


It's good practice to use the unicode character escape codes rather than embedding the characters themselves in your source files; so that your source files make sense to people not using ISO 8859-1 or UTF-8.

In your case that'd be '\u00C6' and '\u00E6' respectively.
7  Discussions / Miscellaneous Topics / Re: Age is just a number.... on: 2012-11-11 03:49:58
Remember fellas: When you reach 28 you'll disappear from any statistics.
...and our life expectancy doesn't look all that promising either  Clueless
8  Discussions / General Discussions / Re: What's your preference is spacing on: 2012-11-06 14:10:15
My preference: Ctrl+Shift+f

Though I wish formatters would detect uses of the fluent interface pattern, as I prefer to see method chaining broken 1 per line (or some other constant, if logical), rather than after an arbitrary number of chained invocations determined by the line width.

e.g.

this:
1  
2  
3  
4  
5  
6  
7  
      sb.append(callStart.toString(outputFormat)).append(',')
        .append(dataDuration).append(',')
        .append(callDuration).append(',')
        .append(destination).append(',')
        .append(area).append(',')
        .append(charge).append(',')
        .append(balance).append(',');


not this:
1  
2  
      sb.append(callStart.toString(outputFormat)).append(',').append(dataDuration).append(',').append(callDuration).append(',').append(destination)
            .append(',').append(area).append(',').append(charge).append(',').append(balance).append(',');
9  Discussions / General Discussions / Re: The hidden cost of C++ on: 2012-10-30 18:28:43
- Array syntax is counterintuitive. int array[] rather than int[] array.

Want to see something really weird? C++ lets you write the array access backwards. ie.

1  
2  
3  
4  
5  
char[] array = "hello";
int index = 4;

char ch1 = array[index]; // 'ch1' is 'o'
char ch2 = index[array]; // same as above


No, I have never found a use for this.

If my understanding is correct, that only holds true for when the sizeof() the datatype of the array is equal to 1?
Otherwise the pointer arithmetic would be wrong.
10  Discussions / General Discussions / Re: Character could (should?!) implement CharSequence? on: 2012-10-18 23:33:29
Because a Character cannot somehow implement the required methods? Wink

Seems pretty trivial to implement IMO.

Quote
Stop being lazy and just replace the single quotes with double quotes Tongue

hehe, true.
11  Discussions / General Discussions / Character could (should?!) implement CharSequence? on: 2012-10-18 19:36:54
I came across this when helping a noobie understand why this doesn't compile:

1  
someString.replace('A',"BB")


It got me thinking; why doesn't the Character class implement CharSequence.
Logically a Character is a sequence of 1, thus there's no reason it shouldn't implement it.

Doing so would have interesting consequence when mixed with autoboxing.

Thanks to autoboxing, the uncompilable code above would start compiling. (char autoboxes to Character, which would implement CharSequence & thus meet the contract of replace(CharSequence,CharSequence))

I'm obviously not advocating such a change, as it'd introduce all sorts of potential confusion as to precisely what method was being invoked, and possible performance problems in the event of typos.

Still, it was something I hadn't noticed or considered before.
12  Discussions / Java Gaming Wiki / Re: ArrayList vs LinkedList on: 2012-09-19 02:24:28
I think this might go back to that fascinating talk given by Jon Blow on making computer games. Please watch it. It is massively significant to how good you will be at making games, or even just software.

Cas Smiley

I appreciate what he's talking about, and when you're hand-coding the data structures in question then it makes sense to keep it simple.
However, we have access to Java's wonderful Collections api; so using a HashXYZ is no more effort than using a less complex structure like an ArrayList.
13  Discussions / Miscellaneous Topics / Re: Things you disagree with in the java language on: 2012-09-07 10:31:21
I don't think that using varargs for methods that perform a transformation is their intended usage, nor is it good programming practice.

Arrays should definitely implement Iterable though.
14  Discussions / General Discussions / Re: double-checked locking... in the JDK core?! on: 2012-09-04 18:11:17
The source I have for java.util.Random in JDK7 looks nothing like that and has no public static methods at all.


Sorry, Math.
15  Discussions / General Discussions / Re: double-checked locking... in the JDK core?! on: 2012-09-04 14:01:23
http://bugs.sun.com/view_bug.do?bug_id=6633229

Found it in the bug database.
Reported 5 years ago....... Still not fixed.
16  Discussions / General Discussions / double-checked locking... in the JDK core?! on: 2012-09-04 13:19:47
While doing something completely unrelated, I ended up inadvertently browsing java.util.Random src, and noticed....

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
    private static Random randomNumberGenerator;

    private static synchronized Random initRNG() {
        Random rnd = randomNumberGenerator;
        return (rnd == null) ? (randomNumberGenerator = new Random()) : rnd;
    }

    public static double random() {
        Random rnd = randomNumberGenerator;
        if (rnd == null) rnd = initRNG();
        return rnd.nextDouble();
    }


Isn't that an obtuse implementation of double-checked locking?

I thought out of order writes made the double-checked locking idiom all kinds of bad?

No doubt if it is a bug it'd be hideously complicated to detect it in any kind of unit test.
17  Discussions / Business and Project Discussions / Re: Closed for business - Android vs. iOS on: 2012-08-16 05:49:29
Entertainment media (films/music/games) are luxury goods.
Thus I believe people will only pay what they think the product is worth.
If they can't get it for this, they'll walk away.
Once this happens you've already lost the sale, so it's mostly irrelevant if they subsequently pirate it or not.

I believe attempting to fight piracy directly is costly, counter-productive and ultimately futile.
18  Game Development / Newbie & Debugging Questions / Re: help ! stuck with maths problem i think.. on: 2012-07-22 23:48:27
foreach

The important part is this:

Quote
When you see the colon ":" read it as “in”.

Applying this to the example:

1  
for(Pixel p: panel.pixels)

...should be read as...

Quote
for each(Pixel p in panel.pixels)

I personally hated it at first, but now I've come to like it.
My only gripe with it is the occasional problem it causes when bodging new functionality into old code.
You'll sometimes find you need access to the Iterator or the iteration index and have to re-factor the loop construct - which can be a bit of a faff.
19  Game Development / Newbie & Debugging Questions / Re: About a static superclass and overridden static methods on: 2012-07-22 23:37:39
It's probably not worth going into the finer points of static method hiding, as it's almost certainly not what you want to be do. (there are situations it's useful, but they're extremely specialized)

As others have suggested, it's much easier to give a 'right' answer if we know precisely what it is you are trying to achieve.
Show us a code example.
20  Game Development / Newbie & Debugging Questions / Re: Find out who is creating objects? on: 2012-05-10 14:57:29
As ra4king suggested, why don't they just use the NOT (~) unary operator? Huh
21  Discussions / General Discussions / Re: Oracle vs Google on: 2012-05-08 13:38:55
Quote
The jury also found that Android infringes on nine lines of Java coding, but that claim probably won't be worth more than $150,000 in damages, based on statements made earlier in the trial. When an Oracle lawyer suggested Monday that the infringement verdict on the nine lines could be worth substantially more, Alsup said the idea "borders on the ridiculous."

This makes the "What Religion Are You?" thread somewhat more pertinent Grin
22  Game Development / Game Mechanics / Re: Random thoughts: Extreme speed 2D physics on: 2012-05-01 13:01:46
Forgot to add that if you are doing a galactic simulation i would galaxy centered coordinates, almost all the mass is in the center. But you can't then also simulate solar systems on each star without some difficulty. For a solar system sun centered works well enough for many things, but don't forget that say Jupiter moons will have issues if you don't deal with numerical errors.

....and when you're traveling through a nebula cloud, you fudge it.  Grin
23  Discussions / General Discussions / Re: Oracle vs Google on: 2012-04-30 10:36:13
(I assume the they didn't drop the patent bits.)

The slides seemed to only focus on the copyright infringement of the API design and implementation.

On a side-note this slide puzzles me:

(Oracle's Slide 76)
Quote
Java Specification License Requirements Are Designed To
Avoid Fragmentation

License Requirements:

• Adhere to Java requirements
• Don’t do less or more than what
is required
• Do a “clean room” implementation
• License and pass compatibility
tests

How does requiring a "clean room" implementation reduce fragmentation?

100 monkeys writing 100 independent implementations of any given method will result in 100(+) different bugs.
J2ME is a perfect example of this; it's API might have been consistent across the many hundreds of different handsets, but each implementation was so riddled with unique bugs that the platform itself became nonviable due to fragmentation.

Perhaps this is a failing of the compatibility tests (or Sun's historically lackluster enforcement of them), rather than a problem with clean room implementations per se.
Though if that's the case, I think it's naive to expect even the most thorough of compatibility tests to catch all problems.
24  Discussions / General Discussions / Re: Oracle vs Google on: 2012-04-30 00:44:18
Obviously Google are in the wrong, but in this case I simply don't care.

This might strike at the very heart of copyright law itself, but I don't feel the law is serving it's intended purpose.

Quote
The United States Constitution 
Article I, Section 8, Clause 8
empowers the United States Congress

To promote the progress of science
and useful arts, by securing for
limited times to authors and
inventors the exclusive right to their
respective writings and discoveries.

Sun's repeated failures at creating a viable consumer platform for Java development are evidence enough that penalizing Google's success does not serve scientific progress.

It's the dichotomy of where to draw the line between the word of the law Vs the spirit of the law.
25  Game Development / Newbie & Debugging Questions / Re: Switch Statement Versus If Statements on: 2012-04-09 03:05:51
For strings (1.7 and up) it switches on the string's hashCode, which should be a great deal faster than testing them in series.  The important part is not which is faster, it's which is appropriate.

I'm torn as to whether that's a 'good thing' (tm).

I'm sure there are a few useful situations where it's perfectly reasonable to switch on Strings, and doing so will no doubt avoid some boiler plate.

However I've a feeling it'll be misused to create bad, or poorly structured code. Using Strings where enums would be a better fit for instance.
26  Game Development / Newbie & Debugging Questions / Re: When to reset input on: 2012-03-13 01:04:55


But I would just use a mouse listener. If you need them you can also have state variables that you set from within the listeners.
e.g.
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
boolean leftMouseDown = false;
...
panel.addMouseListener(new MouseAdapter() {
    public void mousePressed(MouseEvent e) {
        if(e.getButton() == MouseEvent.BUTTON1) leftMouseDown = true;
    }
    public void mouseReleased(MouseEvent e) {
        if(e.getButton() == MouseEvent.BUTTON1) leftMouseDown = false;
    }
});


Now I'm starting to feel like I'm going in circles cause that's pretty much what I had. And I was told that the methods need to be synchronized, and the variables volatile. I was also told I was mixing polling and event based , and that it was a fragile solution.

I'd love to see code for an input class that a few people could agree that was a good solution. If I don't, I think I will just have to go ahead with something like was already doing but with synchronized methods.



Yes, that is fragile code.
Your game code will undoubtably be assuming that the mouse/keyboard state remains the same throughout the duration of 1 game loop iteration.
This would not be the case using the above code.

If you were to implement your keylistener like that you'd need to take a copy of the mouse/keyboard state @ the start of each game loop so the value seen by your game code remained constant for the duration.
27  Games Center / 4K Game Competition - 2012 / Re: Galactic Conquest 4K on: 2012-01-08 23:54:35
If you need to save a few bytes, avoid using Random & just inline the implementation of Random.next(...); it's very simple, and will cut a load of String entries in the constants pool.
28  Game Development / Newbie & Debugging Questions / Re: Yet another game loop >< on: 2011-12-24 00:18:09
Thread.sleep is very inaccurate on most hardware/OSs, use this trick to force the OS to use the high precision timer:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
new Thread() {
    {
        setDaemon(true);
        start();
    }

    public void run() {
        while(true) {
            try {
                Thread.sleep(Long.MAX_VALUE);
            }
            catch(Exception exc) {}
        }
    }
};

Put this in your main.

Also different computers run at different speeds, so it is best to use a deltaTime when moving your sprites. DeltaTime is the time that last frame took to complete. You then pass this number to your update method. To use this deltaTime value, you divide it by 1e9 (nanoseconds per second) and multiply it by the speed at which you want to move per second.
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
long lastTime = System.nanoTime();
long frameTime = (long)(FPS/1e9);
while(true) {
    long now = System.nanoTime();
    long deltaTime = now - lastTime;
    lastTime += frameTime;
   
    gameUpdate(deltaTime);
   
    ....
}

public void gameUpdate(deltaTime) {
    speed += accelPerSecond * deltaTime / 1e9;
   
    playerPos.x += (speed * deltaTime / 1e9) * Math.cos(direction);
    playerPos.y += (speed * deltaTime / 1e9) * Math.sin(direction);
}


Setting a minimum of 10 milliseconds is also not good because if the game loop is late and needs to catch up, it will never be able to. Don't set a minimum at all.

Calling repaint() every frame and letting another thread to draw the screen is called passive rendering. The best way to render is active rendering. This is where you call paint in your game loop.

There are schools of thought that disagree with everything (except the sleep daemon Thread to force high precision timer) you've said there Smiley

It depends upon what you are doing as to the best approach.
29  Game Development / Game Mechanics / Re: Circle collision response on: 2011-12-19 15:18:39
Last time I approached this problem, I made it so only 1 collision could occur per iteration by reducing the delta t of the timestep to equal the earliest collision that frame & resolved the collision.
I then continued the remainder of the frame as a new iteration (which might again be subdivided if further collisions are detected).

Thinking about it, there was a flaw in my implementation - I only ever calculated the collision response with two actors; when three or more actors intersected each other at precisely the same time there was a potencial it'd screw up. Not an insurmountable problem, it'd just have made my collision response calculation a bit more complicated.
30  Game Development / Networking & Multiplayer / Re: TCP or UDP for my game? on: 2011-10-29 02:00:14
Quote
My physic is DETERMINISTIC

Independent of the networking aspect to your question, are you absolutely sure about this?
Pages: [1] 2 3 ... 63
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Get high quality music tracks for your game!

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

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (88 views)
2013-05-17 21:29:12

alaslipknot (96 views)
2013-05-16 21:24:48

gouessej (128 views)
2013-05-16 00:53:38

gouessej (123 views)
2013-05-16 00:17:58

theagentd (131 views)
2013-05-15 15:01:13

theagentd (119 views)
2013-05-15 15:00:54

StreetDoggy (161 views)
2013-05-14 15:56:26

kutucuk (184 views)
2013-05-12 17:10:36

kutucuk (185 views)
2013-05-12 15:36:09

UnluckyDevil (191 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
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!
Page created in 0.268 seconds with 21 queries.