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 (406)
games submitted by our members
Games in WIP (290)
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
1  Game Development / Newbie & Debugging Questions / Re: KeyListener on an Array (2D Dungeon Crawler) on: 2013-05-17 12:21:39
Try to use the recommendations from here:
Quote
Note:

To fire keyboard events, a component must have the keyboard focus.

To make a component get the keyboard focus, follow these steps:

    Make sure the component's isFocusable method returns true. This state allows the component to receive the focus. For example, you can enable keyboard focus for a JLabel component by calling the setFocusable(true) method on the label.
    Make sure the component requests the focus when appropriate. For custom components, implement a mouse listener that calls the requestFocusInWindow method when the component is clicked.

2  Game Development / Newbie & Debugging Questions / Re: how to check collision between object from the same arrayList on: 2013-04-29 16:00:31
I think this could be useful for you.
3  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Problems with key-framed (MD2) animations on: 2013-04-23 18:10:03
I think _nextFrame < _keyframes.size() should be in line 639 (and 671 too):

1  
2  
3  
4  
5  
6  
//line 639 
for (_nextFrame = 0; _nextFrame < _keyframes.size() - 1; _nextFrame++) {
    if (getMinTime() <= _keyframes.get(_nextFrame)._time) {
        break;
    }
}
4  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Problems with key-framed (MD2) animations on: 2013-04-23 08:43:08
I wonder if the variable containing the index of the next frame can take a wrong value, for example the first frame of the next part would be picked instead of the last frame of the current part.
Looks like that. Suspicious lines:

630                 _nextFrame = 1;
...
639                 for (_nextFrame = 0; _nextFrame < _keyframes.size() - 1; _nextFrame++) {
5  Game Development / Newbie & Debugging Questions / Re: File Not Found Exception on: 2013-04-16 18:41:53
look at accepted answer of:

http://stackoverflow.com/questions/10830460/java-io-filenotfoundexception-file-not-found-using-scanner-whats-wrong-in-my
6  Game Development / Newbie & Debugging Questions / Re: IllegalArgumentException ? on: 2013-04-15 21:14:35
look at these:
http://stackoverflow.com/questions/14544759/java-imageio-throws-illegalargumentexception
http://stackoverflow.com/questions/12841741/java-unknown-source-with-imageio
7  Game Development / Newbie & Debugging Questions / Re: [libGdx] Loading screen on: 2013-04-09 12:55:01
Maybe this will help.
8  Game Development / Newbie & Debugging Questions / Re: how to reset or change value of final variable? on: 2013-03-19 17:41:26
Do you really want to add new listener on every call of move_AE() ?
9  Game Development / Newbie & Debugging Questions / Re: how to reset or change value of final variable? on: 2013-03-19 14:17:56
Declaring a variable as 'final' does not matter here because you don't reassign it.
I can only guess that problem is in (member) variable 'event'.
10  Game Development / Newbie & Debugging Questions / Re: [Question] Array returning null. on: 2013-01-25 12:02:16
Do the following:

1  
2  
3  
4  
5  
6  
7  
8  
9  
for (int i = 0; i < chunks.length; i++) {
         for (int j = 0; j < chunks[i].length; j++) {
            if (Math.random() > 0.5) {
               chunks[i][j] = new Chunk(true);
            } else {
               chunks[i][j] = new Chunk(false);
            }
         }
      }
11  Game Development / Newbie & Debugging Questions / Re: Random Spazzes from the player. on: 2013-01-24 07:23:58
These lines (#91-94, method move) look suspiciously:

1  
2  
3  
4  
} else if (grid[temp.x][temp.y].state == "moveable") {
         Location temp2 = temp.translate(i, j);
         if (grid[temp2.x][temp2.y].state != "moveable"
               && grid[temp2.x][temp2.y].state != "solid") {


Strings should be tested on equality via 'equals method.
12  Game Development / Newbie & Debugging Questions / Re: Java Web Start: ZipException on: 2012-12-25 12:04:51
I've successfully downloaded and run pre-beta/ardor3d version (title and menu appeared).

Java(TM) SE Runtime Environment (build 1.7.0_10-b18)
Java HotSpot(TM) Client VM (build 23.6-b04, mixed mode, sharing)

Windows 7 64-bit.
13  Game Development / Game Mechanics / Re: Euler angles to quaternion: Is this correct? on: 2012-12-18 08:33:32
This should work:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
 public static Quaternion4f eulerToQuaternion( float eulerX, float eulerY, float eulerZ )
    {
        double sx = Math.sin( eulerX / 2 );
        double sy = Math.sin( eulerY / 2 );
        double sz = Math.sin( eulerZ / 2 );
        double cx = Math.cos( eulerX / 2 );
        double cy = Math.cos( eulerY / 2 );
        double cz = Math.cos( eulerZ / 2 );
        double cycz = cy * cz;
        double sysz = sy * sz;
        double d = cycz * cx - sysz * sx;
        double a = cycz * sx + sysz * cx;
        double b = sy * cz * cx + cy * sz * sx;
        double c = cy * sz * cx - sy * cz * sx;

        Quaternion4f q = new Quaternion4f( ( float ) a, ( float ) b, ( float ) c, ( float ) d );
        q.normalize();

        return ( q );
    }
14  Java Game APIs & Engines / Java 2D / Re: Direct3D Pipeline problems on: 2012-11-29 07:29:45
Try to specify  -Dsun.java2d.d3d=true in command line.
15  Game Development / Newbie & Debugging Questions / Re: Type mismatch: cannot convert from List on: 2012-08-26 13:33:40
I think you'd define the method in this way:
1  
2  
3  
   public <T extends Entity> List<EntityRef<T>> getForeignEntities() {
      return new ArrayList<EntityRef<T>>(players);
   }
16  Game Development / Game Mechanics / Re: Random thoughts: Extreme speed 2D physics on: 2012-04-27 12:54:50
E = mv^2 ---> E/m = v^2 ---> v = sqrt(E/m)Huh

IIRC, E = 1/2mv^2  ...  Smiley
17  Game Development / Newbie & Debugging Questions / Re: How do you manage your resusable code and get it into jar files? on: 2012-04-18 16:20:33
...
1  
BufferedImage im = ImageIO.read(getClass().getResource("/images//n0.png"));

...
I have a src folder, inside that folder is my images folder

Does it mean that you actually have path "/src/images//n0.png" in your jar?
18  Game Development / Newbie & Debugging Questions / Re: Buffered image? on: 2012-04-17 11:48:51
You'd perform io operations with images via ImageIO class:
1  
2  
3  
4  
5  
    BufferedImage img = null;
    try {
    img = ImageIO.read(new File("strawberry.jpg"));
    } catch (IOException e) {
    }


see http://docs.oracle.com/javase/tutorial/2d/images/loadimage.html
19  Game Development / Newbie & Debugging Questions / Re: Bytes And Java Strings on: 2012-04-16 13:05:08
I think the problem is in wrong encoding/decoding of strings.
So, this possibly can help you: http://stackoverflow.com/questions/1252468/java-converting-string-to-and-from-bytebuffer-and-associated-problems.
20  Java Game APIs & Engines / Java 2D / Re: First small Java Game on: 2012-04-15 20:03:18
looks ok for me.
21  Discussions / General Discussions / Re: "goto" could be added to JDK8 on: 2012-04-03 10:45:46
You didn't mention returns & exceptions.
22  Game Development / Networking & Multiplayer / Re: Networking & Multiplayer - Resources on: 2012-04-01 07:52:41
This also may be interesting: https://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking
23  Java Game APIs & Engines / OpenGL Development / Re: Quat4f and rotation around local axis on: 2012-03-16 19:24:39
Try to apply this:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
    public static void mul(Vector4f q, Vector3f vCoord, Vector3f scale, Vector3f result) {
        Matrix3f m1 = new Matrix3f();

        setFromQuat(q.getX(), q.getY(), q.getZ(), q.getW(), m1);

        Matrix3f tmp = new Matrix3f();

        tmp.setIdentity();
        tmp.m00(scale.getX());
        tmp.m11(scale.getY());
        tmp.m22(scale.getZ());

        m1.mul(tmp);

        transform(m1, vCoord, result);
    }

    private static void setFromQuat(float a, float b, float c, float d, Matrix3f m) {
        final float n = a * a + b * b + c * c + d * d;
        final float s = (n > 0.0f) ? (2.0f / n) : 0.0f;

        final float xs = a * s, ys = b * s, zs = c * s;
        final float wx = d * xs, wy = d * ys, wz = d * zs;
        final float xx = a * xs, xy = a * ys, xz = a * zs;
        final float yy = b * ys, yz = b * zs, zz = c * zs;

        m.m00(1.0f - (yy + zz));
        m.m01(xy - wz);
        m.m02(xz + wy);
        m.m10(xy + wz);
        m.m11(1.0f - (xx + zz));
        m.m12(yz - wx);
        m.m20(xz - wy);
        m.m21(yz + wx);
        m.m22(1.0f - (xx + yy));
    }

    private static void transform(Matrix3f m, Vector3f t3f, Vector3f result) {
        result.set(m.m00() * t3f.getX() + m.m01() * t3f.getY() + m.m02() * t3f.getZ(),
                m.m10() * t3f.getX() + m.m11() * t3f.getY() + m.m12() * t3f.getZ(),
                m.m20() * t3f.getX() + m.m21() * t3f.getY() + m.m22() * t3f.getZ()
        );
    }

It's a draft solution. Unfortunately, I can't test it now, so hopefully it will work with a little changes.
24  Game Development / Performance Tuning / Re: sun.java2d.opengl=true in applet with BufferStrategy on: 2012-03-13 09:40:25
how can i specify more than one flag in the applet tag?
For example:
1  
<param name="java_arguments" value="-Dsun.java2d.opengl=true -Dsun.java2d.d3d=false -Dsun.java2d.noddraw=true">

Here is the thread related to your problem.
25  Game Development / Performance Tuning / Re: sun.java2d.opengl=true in applet with BufferStrategy on: 2012-03-12 08:22:07
Try to specify these parameters:

• -Dsun.java2d.opengl=true
• -Dsun.java2d.d3d=false
• -Dsun.java2d.noddraw=true
26  Game Development / Newbie & Debugging Questions / Re: Getting a variable from an extended class on: 2012-03-11 12:27:17
You can do something like this:
1  
2  
3  
4  
UIElement el = elements[index];
if (el instanceof  ArrayButton){
    ((ArrayButton)el).<ArrayButtonVar>
}
27  Game Development / Newbie & Debugging Questions / Re: Need help with quanterion (cube rotate) on: 2012-03-07 10:55:08
@Roquen: I had in mind general case, just to get it working. Of course, the code can be optimized (if any).
28  Game Development / Newbie & Debugging Questions / Re: Organizing ArrayLists for item lists? on: 2012-03-07 08:30:06
Another way. If you can't have multiple stacks you can have a HashSet<Item, Integer> and use that to manage your item list, instead of an ArrayList.
A hashset sounds good. Thanks! If I need more help, I'll let you guys know!

EDIT!
So I messed with hashsets, but I have no idea how to get data from it. lol. Can someone explain? I add in the elements, then I can check if an element is there...but then what?

it's meant HashMap<Item, Integer>. You can put into and get data from it.
If order of  insertion is important you may use LinkedHashMap.
29  Game Development / Newbie & Debugging Questions / Re: Need help with quanterion (cube rotate) on: 2012-03-05 13:29:05
Here is some code. Hope it will work with minor changes.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
...

   private void update(){
      roll();
      for(int i = 0;i<array.length;i+=3) {
         change = new Vector3f(array[i], array[i+1], array[i+2]);
         MathUtils.transform(roll, change, change);
         array[i] = change.x;
         array[i+1] = change.y;
         array[i+2] = change.z;
      }
       vertexData.put(array);
       vertexData.flip();
   }

...

public class MathUtils {
   public static Vector3f transform( Quaternion q, Vector3f vector, Vector3f result )
    {
        Quaternion inv = new Quaternion(-q.getX(), -q.getY(), -q.getZ(), q.getW() );
        inv.normalize();
       
        Quaternion tmp = new Quaternion();
       
        mul(q, vector, tmp );
        tmp.mul( inv );
       
        result.set( tmp.getX(), tmp.getY(), tmp.getZ() );
       
        return ( result );
    }

    public static Quaternion mul(Quaternion q, Vector3f t, Quaternion out )
    {
        out.set( ( q.getW() * t.getX() ) + ( q.getY() * t.getZ() ) - ( q.getZ() * t.getY() ),
                    ( q.getW() * t.getY() ) + ( q.getZ() * t.getX() ) - ( q.getX() * t.getZ() ),
                    ( q.getW() * t.getZ() ) + ( q.getX() * t.getY() ) - ( q.getY() * t.getX() ),
                   -( q.getX() * t.getX() ) - ( q.getY() * t.getY() ) - ( q.getZ() * t.getZ() )
               );
       
        return ( out );
    }
  }
30  Game Development / Newbie & Debugging Questions / Re: Need help with quanterion (cube rotate) on: 2012-03-05 09:56:20
If you want to use quaternion Q to rotate point (vertex) P with respect to translated origin G use this formula:

 P' = Q(P-G)Q' + G

where P' is the transformed point, and Q' is the quaternion inverse.
Pages: [1] 2
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Browse for soundtracks 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 (62 views)
2013-05-17 21:29:12

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

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

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

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

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

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

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

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

UnluckyDevil (175 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.361 seconds with 20 queries.