Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (567)
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]
1  Java Game APIs & Engines / OpenGL Development / Re: JOGL and JBOX2D on: 2011-08-22 21:13:43
oh Thx!  gouessej that actually works! ,  and i realized that the gravity was inverted too xD
2  Java Game APIs & Engines / OpenGL Development / Re: JOGL and JBOX2D on: 2011-08-22 19:08:41
my problem is moving the box, it supposed to fall down just with that set
3  Java Game APIs & Engines / OpenGL Development / JOGL and JBOX2D on: 2011-08-22 17:59:50
Hello, im doing a test with JBox2D with Jogamp (JOGL)

so my problem is the "Box" doesnt fallout , i made this test , reading a bunch of examples that appears to work, but not to me,

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  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
140  
141  
142  
143  
144  
145  
146  
147  
148  
149  
150  
151  
152  
153  
154  
155  
156  
157  
158  
159  
160  
161  
162  
163  
164  
165  
166  
167  
168  
169  
170  
171  
172  
173  
174  
175  
176  
177  
178  
179  
180  
181  
182  
183  
184  
185  
186  
187  
//AWT
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

//OpenGL
import javax.media.opengl.*;
import javax.media.opengl.glu.*;
import javax.media.opengl.awt.GLCanvas;
import com.jogamp.opengl.util.*;

//Box2D
import org.jbox2d.dynamics.*;
import org.jbox2d.common.*;
import org.jbox2d.collision.*;
import org.jbox2d.collision.shapes.PolygonShape;

public class SimpleScene implements GLEventListener {

   private final int SCREEN_WIDTH = 800;
   private final int SCREEN_HEIGHT = 600;
   
   private GLU glu;
   
    private World world;
   
    private Body block;
    private int blockW = 50;
    private int blockH = 50;

   
    public static void main(String[] args) {
        GLProfile glp = GLProfile.getDefault();
        GLCapabilities caps = new GLCapabilities(glp);
        GLCanvas canvas = new GLCanvas(caps);

        Frame frame = new Frame("JBox2D Test");
        frame.setSize(800, 600);
        frame.add(canvas);
        frame.setVisible(true);

        frame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });

        canvas.addGLEventListener(new SimpleScene());
       
        FPSAnimator animator = new FPSAnimator(canvas, 60);
        animator.add(canvas);
        animator.start();

    }
   
    public SimpleScene(){
        //InitPhysx
       initPhysx();

    }
   
    private void initPhysx(){
        Vec2 gravity = new Vec2(0.f,-9.8f);
         world = new World(gravity, true);
         world.setGravity(gravity);
         
         createBlock();
    }

    private void createBlock(){
        BodyDef blockDef;
        PolygonShape blockShape;

        blockDef = new BodyDef();
        blockDef.type = BodyType.DYNAMIC;
        blockDef.position.set(100, 100);
       

        blockShape = new PolygonShape();
        blockShape.setAsBox(blockW, blockH);
     
        FixtureDef fixtureDef = new FixtureDef();
        fixtureDef.shape = blockShape;
        fixtureDef.density = 1.0f;
        fixtureDef.friction = 0.8f;
        fixtureDef.restitution = 0.3f;
       
   
        block = world.createBody(blockDef);
        block.createFixture(fixtureDef);
        block.setType(BodyType.DYNAMIC);
       
    }
   
    @Override
    public void display(GLAutoDrawable drawable) {
       
        update();
        render(drawable);
    }

    @Override
    public void dispose(GLAutoDrawable drawable) {
    }

    @Override
    public void init(GLAutoDrawable drawable) {
       
       GL2 gl = drawable.getGL().getGL2();
        glu = new GLU();
       
        establishProjectionMatrix(gl,SCREEN_WIDTH,SCREEN_HEIGHT);
        gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);        
        gl.glEnable(GL2.GL_TEXTURE_2D);
       
    }

    @Override
    public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) {
         GL2 gl = drawable.getGL().getGL2();
         establishProjectionMatrix(gl,SCREEN_WIDTH,SCREEN_HEIGHT);
         
    }

    public void establishProjectionMatrix(GL2 gl,int width,int height){

       gl.glViewport(0, 0, width, height);
        gl.glMatrixMode(GL2.GL_PROJECTION);
        gl.glLoadIdentity();

        glu.gluOrtho2D(0,width,height,0);
    }
   
    private void update() {
       world.step(1/60, 8, 1);

    }

    private void render(GLAutoDrawable drawable) {
        GL2 gl = drawable.getGL().getGL2();

        gl.glClear( GL2.GL_COLOR_BUFFER_BIT );
        gl.glMatrixMode( GL2.GL_MODELVIEW );
        gl.glLoadIdentity();
     
        //RED
       gl.glColor3f(1.0f, 0.0f, 0.0f);
       
        for (Body body = world.getBodyList(); body != null; body = body.getNext()) {
           
            Vec2 p = body.getPosition();
            float angle = (float) Math.toDegrees(body.getAngle());
           
           
             drawQuad(gl,p.x,p.y,blockW,blockH,angle);
              System.out.println(body.getPosition() +" " + world.getGravity());
        }
    }
   
   private void drawLine(GL2 gl, float x1,float y1, float x2, float y2){
       
       gl.glBegin(GL.GL_LINES);
         gl.glVertex2f((x1), (y1));
         gl.glVertex2f((x2), (y2));
      gl.glEnd();

   }
   
   private void drawQuad(GL2 gl, float x,float y, float w, float h,float angle){
       
      gl.glTranslatef(x, y, 0.0f);
      gl.glRotatef(angle, 0, 0, 1);
       //gl.glBindTexture(GL.GL_TEXTURE_2D, textures[3]);  
     
       gl.glBegin(GL2.GL_QUADS);  
            gl.glTexCoord2f(0.0f,0.0f); gl.glVertex2f(-w, h);
         gl.glTexCoord2f(0.0f,1.0f); gl.glVertex2f(-w,-h);
          gl.glTexCoord2f(1.0f,1.0f); gl.glVertex2f( w,-h);
         gl.glTexCoord2f(1.0f,0.0f); gl.glVertex2f( w, h);
       gl.glEnd();        
           

   }
   


}
4  Java Game APIs & Engines / Java 2D / Re: Collision Maps on: 2011-01-30 08:40:34
Thanks guys , it works like a charm! Cheesy
5  Java Game APIs & Engines / Java 2D / Collision Maps on: 2011-01-29 21:59:24
 Hello, i need a help to figer out how to do a Collision detectition using collision maps,

  i want to do something like

1  
2  
3  
 if ( collisionMaps( collisionWorldMap, actor ) == COLOR_RED ) {
   //do whatever
}


i have this maps to test , but i can't get it
http://img201.imageshack.us/i/mascara2.png/ , the collision map
http://img88.imageshack.us/i/mascara1b.png/ // the original



6  Java Game APIs & Engines / Java 2D / EvenListener or Thread? on: 2010-04-13 23:14:41
Hey everyone, im working on a game, so i want to have some handles, one for the painting the "Draw method", other for the logic that usually called "Update Method" , so i want those two methods work for their own, because in this way i will be able to put some loops instructions like for, while in the Update method, without interrupt the painting

i did two threads called PaintHandle and UpdateHandle , and they have a While that called the Draw and the Update method from each Actor
at first was really messy so i put a Thread Delay

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
private final int DELAY = 40;

public void run(){

while (true) {
    for (int i=0 ; i < actors.size() ; i++){
      ( (Actor)(actors.get(i)) ).update();
    }  

    try{
     Thread.sleep(DELAY);
   }catch(Exception e){}
}

}


the same with the paint handle, just change the update with draw() , well it work at first, but sometime it get messy again, so i think the thread is to fast or i dont know, so i was wondering, if you recommend to used EventListener insted or a better way

hope you could understand my problem
7  Java Game APIs & Engines / Java 2D / Re: canvas into applet? on: 2009-10-08 00:49:22
hello people, i posted this topic long time ago,  since i couldn't figer out the problem i stopped try to make it works

so today i openned the code again, and i tried the suggestion that cylab replied in the post, i didn't tried before i dont know why xD  , so i did it, and it worked ! ^^ , i changed Applet to JApplet
and it rendered my custom Canvas

I have no idea. You could try to extend JApplet instead of Applet since you are adding a swing panel:


thx cylab, and sorry for my late reply and testing

8  Java Game APIs & Engines / JOGL Development / Re: loading a TGA image , wrong colors on: 2009-08-16 20:42:10
hey Cork i did that you told me and i was able to figer out the problem ,  the color was in the wrong order

i changed this

1  
2  
3  
4  
                        
                        rawData[i + 2] = dis.readByte();     // R
        rawData[i + 1] = dis.readByte();    // G
        rawData[i      ] = dis.readByte();    // B

for this
1  
2  
3  
                   rawData[i      ] = dis.readByte();      // R
        rawData[i + 2] = dis.readByte();    // G
        rawData[i + 1] = dis.readByte();    // B


is a little bit strange because the TGA colors are BGR , so you have to swap the B with the R and that's it , but in this case is RBG ? well, thx for everything Cheesy
9  Java Game APIs & Engines / JOGL Development / Re: loading a TGA image , wrong colors on: 2009-08-16 01:54:29
oh thx a lot cork , it worked so good, i didnt know about that class, i will use this in the future insted of my own class

but if somebody can tell me the error why it shows me the wrong color i will be so thankful too, i just curious and i want to know what happened in there  too
10  Java Game APIs & Engines / JOGL Development / Re: loading a TGA image , wrong colors on: 2009-08-14 20:46:43

OpenGLDemo.java
[CODE]
package com.ogltest;

import com.sun.opengl.util.Animator;
import java.awt.Frame;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCanvas;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.glu.GLU;


public class OpenGLDemo implements GLEventListener,KeyListener {

  static Frame frame=null;
  static int windowWidth=500;
  static int windowHeight=500;

  float cubeRotateX = 45.0f;
  float cubeRotateY = 45.0f;

  boolean keys[]=new boolean[255];
 
 com.ogltest.Texture texture = null;

    public void init(GLAutoDrawable drawable) {
        GL gl = drawable.getGL();
        establishProjectionMatrix(gl,windowWidth,windowHeight);

        gl.glShadeModel(GL.GL_SMOOTH);

        gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);

        gl.glEnable(GL.GL_DEPTH_TEST);
        gl.glDepthFunc(GL.GL_LEQUAL);

        gl.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST);
        gl.glEnable(GL.GL_PERSPECTIVE_CORRECTION_HINT);
       
        gl.glEnable(GL.GL_TEXTURE_2D);

       texture = new com.ogltest.Texture("data/joyal_wood_texture.tga", "Joyal Box",drawable);


     }
    public void establishProjectionMatrix(GL gl,int width,int height){
        GLU glu = new GLU();

        gl.glViewport(0, 0, width, height);
        gl.glMatrixMode(GL.GL_PROJECTION);
        gl.glLoadIdentity();

        glu.gluPerspective(45.0f, (float)width/(float)height, 0.1f, 200.0f);
    }
    public void display(GLAutoDrawable drawable) {
        GL gl = drawable.getGL();


        gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);

        gl.glMatrixMode(GL.GL_MODELVIEW);
        gl.glLoadIdentity();

        gl.glTranslatef(0,0,-5.0f);
        gl.glRotatef(cubeRotateX,1,0,0);
        gl.glRotatef(cubeRotateY,0,1,0);
       
        gl.glColor3f(1.0f, 1.0f, 1.0f);
        gl.glBindTexture(GL.GL_TEXTURE_2D, texture.texID[0]);

        //Draw Cube
        gl.glBegin(GL.GL_QUADS);

        //Top face

       gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f( 1.0f, 1.0f,-1.0f);
        gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f(-1.0f, 1.0f,-1.0f);
        gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f(-1.0f, 1.0f, 1.0f);
        gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f( 1.0f, 1.0f, 1.0f);

       //Bottom face

        gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f( 1.0f,-1.0f,-1.0f);
        gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f(-1.0f,-1.0f,-1.0f);
        gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f(-1.0f,-1.0f, 1.0f);
        gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f( 1.0f,-1.0f, 1.0f);

       //Front face

       gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f( 1.0f, 1.0f, 1.0f);
        gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f(-1.0f, 1.0f, 1.0f);
        gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f(-1.0f,-1.0f, 1.0f);
        gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f( 1.0f,-1.0f, 1.0f);

       //Back face

        gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f( 1.0f, 1.0f,-1.0f);
        gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f(-1.0f, 1.0f,-1.0f);
        gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f(-1.0f,-1.0f,-1.0f);
        gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f( 1.0f,-1.0f,-1.0f);

       //Left face

       gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f(-1.0f, 1.0f, 1.0f);
        gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f(-1.0f, 1.0f,-1.0f);
        gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f(-1.0f,-1.0f,-1.0f);
        gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f(-1.0f,-1.0f, 1.0f);

       //Right face

       gl.glTexCoord2f(0.0f, 1.0f); gl.glVertex3f( 1.0f, 1.0f, 1.0f);
        gl.glTexCoord2f(1.0f, 1.0f); gl.glVertex3f( 1.0f, 1.0f,-1.0f);
        gl.glTexCoord2f(1.0f, 0.0f); gl.glVertex3f( 1.0f,-1.0f,-1.0f);
        gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f( 1.0f,-1.0f, 1.0f);


        gl.glEnd();
        gl.glFlush();

        displayFPS();
    }

  long lastTime = System.currentTimeMillis();
  long loops = 0;
  float fps= 0.0f;

    public void displayFPS(){
     
        long newTime = System.currentTimeMillis();

       
        if (newTime - lastTime > 100)
        {
            float newFPS = (float)loops / (float) (newTime -  lastTime) * 1000.0f;
            fps = (fps + newFPS) / 2.0f;

            frame.setTitle("OpenGL Demo - "+fps);

            lastTime = newTime;
            loops=0;
        }

        loops++;

    }
   
  long lastTimeKeys = System.currentTimeMillis();
 
    public boolean checkKeys(){
       
       final float speed = 1.0f;
        final long updateTime = 2;
       
        long newTime = System.currentTimeMillis();
       
        if (newTime - lastTimeKeys > updateTime){
       
           if (keys[KeyEvent.VK_LEFT])
               cubeRotateY -= speed;
   
           if (keys[KeyEvent.VK_RIGHT])
                cubeRotateY += speed;
   
           if (keys[KeyEvent.VK_UP])
                cubeRotateX -= speed;
   
           if (keys[KeyEvent.VK_DOWN])
                cubeRotateX += speed;
          
           lastTimeKeys = newTime;
        }

        return false;
    }

    public void keyPressed(KeyEvent e) {

        keys[e.getKeyCode()]=true;

   
    }

    public void keyReleased(KeyEvent e) {

        keys[e.getKeyCode()]=false;

   
    }
    public static void main(String[] args) {
          
      OpenGLDemo ogl=new OpenGLDemo();
      initWindow("OpenGL Demo",windowWidth, windowHeight,ogl);
          
      boolean done=false;
          while  (!done){
                  ogl.checkKeys();
       
          }

   }

    public static void initWindow(String title,int width, int height,OpenGLDemo ogl)
    {
        frame = new Frame(title);
        GLCanvas canvas = new GLCanvas();   

        canvas.addGLEventListener(ogl);
        frame.addKeyListener(ogl);
        frame.add(canvas);
        frame.setSize(width, height);
        final Animator animator = new Animator(canvas);
        frame.addWindowListener(new WindowAdapter() {

            @Override
            public void windowClosing(WindowEvent e) {
                // Run this on another thread than the AWT event queue to
                // make sure the call to Animator.stop() completes before
                // exiting
                new Thread(new Runnable() {

                    public void run() {
                        animator.stop();
                        System.exit(0);
                    }
                }).start();
            }
        });
        // Center frame
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
        animator.start();


    }
    public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
        GL gl = drawable.getGL();
        GLU glu = new GLU();

    }
    public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {
    }


    public void keyTyped(KeyEvent e) {
       
    }


}
[/CODE]
11  Java Game APIs & Engines / JOGL Development / loading a TGA image , wrong colors on: 2009-08-14 20:46:01
hello, i started to learn OpenGL watching the 3dbuzz OpenGL VTMs (www.3dbuzz.com) , and i decided to port my C++ code to jogl, because im a java coder ^^ and i love java, so i was doing the TGA texture loader (uncompress) and it worked fine, i had to do some changes because jogl manage a BufferByte insted of a byte array , well my problem is that the loader show the colors wrong, i textured a cube,  i know that the TGA file format use BGR insted of RGB but i already flip the order, and it show wrong still, if you can help me with this, here is the 2 code i used, btw i used the JOGL version with comes with the NeHe demos


this the texture = http://www.joyalstudios.com/files/joyal_wood_texture.tga

Texture.java
[CODE]
package com.ogltest;


import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;

import com.sun.opengl.util.BufferUtil;

import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.Vector;

public class Texture{
   

public ByteBuffer imageData;
public int   bpp;
public int   width;
public int   height;
public int texID[] = new int[1];

public String   name;


private GLAutoDrawable drawable;

static Vector<Texture>textures = new Vector<Texture>();


public Texture(String in_filename, String in_name,GLAutoDrawable drawable)
{

   this.drawable = drawable;
   
   loadTGA(in_filename);

   name = in_name;

   textures.add(this);
}
boolean loadTGA(String filename)
{
   
  try{
   FileInputStream file = new FileInputStream(filename);
   DataInputStream dis = new DataInputStream(file);
   
      
   // TGA_Header
   byte ID_Length             =  dis.readByte();
   byte ColorMapType          =  dis.readByte();
   byte ImageType             =  dis.readByte();
   byte ColorMapSpecification[]=  new byte[5];
   
   dis.read(ColorMapSpecification);

   short xOrigin             = flipEndian(dis.readShort());
   short yOrigin             = flipEndian(dis.readShort());
   short ImageWidth          = flipEndian(dis.readShort());
   short ImageHeight         = flipEndian(dis.readShort());
   
   byte pixelDepth =  dis.readByte();
   
   
   bpp = pixelDepth;
   width = ImageWidth;
   height = ImageHeight;
   
   int bytesPerPixel = bpp / 8;
   int imageSize = width * height * bytesPerPixel;
   

   if (ImageType != 2)
      return false;
   
   if ( width <=0 || height <= 0 || (bpp != 24 && bpp != 32))
      return false;


   int type;
   byte[] rawData = new byte[imageSize];

   if ( bpp == 24){
      type = GL.GL_RGB;
      for ( int i = 0; i < imageSize; i += bytesPerPixel )
      {
         rawData[i + 2] = dis.readByte();    // R
         rawData[i + 1] = dis.readByte();    // G
         rawData[i    ] = dis.readByte();    // B
   
      }
   }else{
      type = GL.GL_RGBA;
      for ( int i = 0; i < imageSize; i += bytesPerPixel )
      {
         rawData[i + 2] = dis.readByte();    // R
         rawData[i + 1] = dis.readByte();    // G
         rawData[i    ] = dis.readByte();    // B
         rawData[i + 3] = dis.readByte();    // Alpha

      }
   }
   
   
   imageData = BufferUtil.newByteBuffer(rawData.length);
   imageData.put(rawData);
   imageData.flip();

   createTexture(imageData, width, height,type);

  }catch(IOException e){
    e.printStackTrace();
  }
   return true;



}
boolean createTexture(ByteBuffer imageData, int width, int height, int type)
{
   GL gl = drawable.getGL();

   
   gl.glGenTextures(1, texID,0);
   
   gl.glBindTexture(GL.GL_TEXTURE_2D, texID[0]);

   gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR);
   gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);
   

   gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, type, width, height, 0, type, GL.GL_UNSIGNED_BYTE , imageData);
   
   return true;

}

//this method is provided by Slick engine https://bob.newdawnsoftware.com/repos/slick/trunk/Slick/src/org/newdawn/slick/opengl/TGAImageData.java
private short flipEndian(short signedShort) {
   int input = signedShort & 0xFFFF;
   return (short) (input << 8 | (input & 0xFF00) >>> Cool;
}

}
[/CODE]

12  Java Game APIs & Engines / Tools Discussion / Re: JDIV , a 2d engine for java (fully java2d) on: 2009-03-25 18:51:57
oh yes, the particle engine test, should be not there ^^. is not working fine, because the blending modes are too slow , if you recompile the sample without the blending mode just erasing the part "this.blend=BLEND_ADD;" on Particle.java , should be fine, sorry about that, just ignore it for now ^^, and i will put applet version as soon i can
13  Java Game APIs & Engines / Tools Discussion / Re: JDIV , a 2d engine for java (fully java2d) on: 2009-03-25 18:02:02
Behave, gouessej.

Pure java will work in applets and webstart apps without requiring signing the app or having the user agree to hand over his computer to you.
thx Markus_Persson , to answer Smiley , other thing is in others non java2d mostly all the time you have to get a specific version depending on the OS you have, because of their dll or .o , etc, native code , something that with java2d doesnt happend

you're probably right, with opengl you can get more advance features, and it's more powerful, but java2d is not bad at all Smiley , you can do a very decent game with this

i think the main goal of my engine is be able to do game in a very easy way, honestly opengl can be very complicated, and for the people who are starting in the game development world can be very hard to get used to it, i think that is the only different thing i can offer with this engine

zip version: http://www.joyalstudios.com/files/jdiv.zip

14  Java Game APIs & Engines / Java 2D / Blending modes on java2d? on: 2009-03-25 05:40:25
hello guys, i was wondering is there a way to do the blending modes? (add, multiply, screen, overlay...), i know that are some request to implement this on the new version of the JVM , i found some code to do it, but i doesnt work fine for me, tooo slow , and hard to handle
15  Java Game APIs & Engines / Tools Discussion / JDIV , a 2d engine for java (fully java2d) on: 2009-03-25 05:34:59
hello guys, im working in a 2d engine that i called JDIV , 100% java2d, without other 3rd partys , the project is still young, and im still working on it, so i wanted to share with you, some test that i've done using my engine, and i hope you like it and be helpful, maybe to decide on the future with tool use

the file has the source code of the all the samples include, to show how's the programing method using this tool, i base my engine in a 2d game language called Fenix , you can see the original compiler in http://fenix.divsite.net , im using their own formats from fenix , that are FPG a file to store image files, a easy way to store sprites and do animation, and FNT , font image files, a very easy way to do bitmap fonts

you can download the engine in this url : http://www.joyalstudios.com/files/jdiv.rar

any comments, any suggestion will be so helpful
16  Java Game APIs & Engines / Java 2D / Re: canvas into applet? on: 2008-08-01 05:40:33
Quote
Can you explain exactly what "didn't work"? It threw an exception, or nothing got rendered, or what?

sure, i mean do nothing, nothing got rendered,

Quote
My guess is that you didn't resize your canvas properly. You should either set the preferred size, or
set the size explicitly.

i added to the init() method
1  
setPreferredSize(new Dimension(320,240));


and nothing

Quote

Another thing: do not cache the graphics context of buffer strategy. You are supposed to get it
every time in the rendering loop before rendering, see the example in the top comment:
  http://java.sun.com/javase/6/docs/api/java/awt/image/BufferStrategy.html

ohh thx dude Cheesy i didnt notice that Cheesy, very good tip
17  Java Game APIs & Engines / Java 2D / Re: canvas into applet? on: 2008-07-30 01:00:38
thx man, i tried it, but didnt work for me T_T , i use Frame , maybe is my implementation maybe is wrong. I do all on a canvas, i thought is going to be easy, just add the canvas on the applet and that's it , but it didnt
18  Java Game APIs & Engines / Java 2D / Re: canvas into applet? on: 2008-07-29 17:22:32
i tried it and didnt work T_T , i dont know what should i do..
19  Java Game APIs & Engines / Java 2D / Re: canvas into applet? on: 2008-07-27 15:53:39
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  
package com.jdiv.samples.zelda.applet;

import java.applet.Applet;
import java.awt.Panel;
import java.net.URL;

import com.jdiv.JDiv;

public class Main extends Applet{

static Link link;
static int fpg_enemigo,fpg_ambiente;

   public void init(){

   URL urlLink= getClass().getClassLoader().getResource("res/fpg/link.fpg"),
      urlEnemigo=getClass().getClassLoader().getResource("res/fpg/enemigo.fpg");
     
      JDiv.load_fpg(urlLink);
      fpg_enemigo=JDiv.load_fpg(urlEnemigo);
   
      link=new Link();
      new Enemigo();

      Panel panel = new Panel();
                panel.add(JDiv.getCanvas());
                add(panel);
     
     
   }
   public void start(){
      JDiv.appletInit(JDiv.m320x240);
   }
   
}


this code below is the Class who extends Canvas

1  
2  
3  
4  
public void appletInit(int resolution){
          setResolution(resolution);
         coreInit();    
    }


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
private void setResolution(int resolution){
    int width=0, height=0;
         switch (resolution){
           case 0: width=320; height=200; break;
           case 1: width=320; height=240; break;  
           case 2: width=320; height=400; break;  
           case 3: width=360; height=240; break;  
           case 4: width=360; height=260; break;  
           case 5: width=376; height=282; break;  
           case 6: width=400; height=300; break;  
           case 7: width=640; height=400; break;  
           case 8: width=640; height=480; break;  
           case 9: width=800; height=600; break;  
           case 10: width=1024; height=768; break;  
        }
      this.width=width;
         this.height=height;  
 }


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  
   

public void coreInit(){
     
     
        regions.add(new JRegion(0,0,0,getWidth(),getHeight()));      
   
        addKeyListener(this);    
         
         createBufferStrategy(2);
       bStrategy = getBufferStrategy();  
       gBackBuffer =(Graphics2D)bStrategy.getDrawGraphics();
       
       clearImg=new BufferedImage(getWidth(), getHeight(),BufferedImage.TYPE_INT_RGB);
       clearImg.createGraphics();
       Graphics g= clearImg.getGraphics();
       
       g.setColor(Color.black);
       g.fillRect(0,0,getWidth(),getHeight());
       
       
                     new JUpdate().start();    
           new JLoop().start();    
           
           
   }



this code is called in JUpdate Thread

1  
2  
3  
4  
5  
6  
7  
public void  update(){
 
updatePaint(gBackBuffer);
fps();
bStrategy.show();  
mFpsCount++;
}


all the paint stuff

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
 

 public void updatePaint(Graphics2D g){
 
  g.drawImage(clearImg,0,0,null);
 
  paintBackground(g);
  paintProcess(g);
  paintWrites(g);
 
}


public void update( Graphics g ) {

    if (bStrategy!=null)   bStrategy.show();  
 
  }

public void paint( Graphics g ) {
           update( g );
  }



it works perfectly in a Frame but it doesnt in an Applet

this the code for the frame

 
1  
2  
3  
4  
5  
                                                                   //title, canvas,w,h
   JDivWindow window=new JDivWindow(title,this,width,height);
      window.addKeyListener(this);
      window.setVisible(true);
   


Constructor of JDivWindow

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
   public JDivWindow(String title,Canvas canvas,int width,int height){
     
   setTitle(title);
   setSize(new Dimension(width+6,height+32));
   setLayout(null);
     
       addWindowListener( new WindowAdapter() {
             public void windowClosing(WindowEvent e) {
               System.exit(0);
             }
           });
     
          canvas.setBounds(3,29, width, height);
     add(canvas);

   }
20  Java Game APIs & Engines / Java 2D / canvas into applet? on: 2008-07-27 00:57:07
hey guys Smiley, i never used applet before , and i want to put my game into an applet, i have a class that exteds of canvas and i use buffer strategy, in this class i have a method

1  
2  
3  
public Canvas getCanvas(){
  return this;
}


and i tried to add it in an applet and didnt work....

could you explain me how i have to do it?
21  Java Game APIs & Engines / Java 2D / Re: get rgb from a canvas? on: 2008-07-26 19:34:24
i have a class that extends from Canvas,  and  i overrides the paint method to draw the images, the paint method used the Graphics from a BufferStrategy, i have an arraylist that  store somes classes which content  the BufferedImage and the X , Y information for their position,


sorry my english, spanish speaking , i hope that you can understand me Cheesy
22  Java Game APIs & Engines / Java 2D / Re: my first java game ("rpg" kind of ..) on: 2008-07-26 19:30:24
wow man, very good first game, i really want to see your newest version Smiley
23  Java Game APIs & Engines / Java 2D / get rgb from a canvas? on: 2008-07-26 18:29:49
hi people, im doing a game in java, and i want to get a pixel value by determinate X,Y coordinates , from a canvas , i tried to convert the canvas to bufferedimage, but the result bufferedimage is all black :S

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
  //Getting the Pixel value
 int pixel=canvasToImage(this).getRGB(x,y);

//Method to convert the canvas to BufferedImage
private BufferedImage canvasToImage(Canvas canvas) {
     int w = canvas.getWidth();
     int h = canvas.getHeight();
     int type = BufferedImage.TYPE_INT_RGB;
   
     BufferedImage image = new BufferedImage(w,h,type);
   
     Graphics2D g2 = image.createGraphics();
     canvas.paint(g2);
     g2.dispose();
     
     
     return image;
 }



what can i do?
Pages: [1]
 

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

The first screenshot will be displayed as a thumbnail.

Pippogeek (39 views)
2014-09-24 16:13:29

Pippogeek (30 views)
2014-09-24 16:12:22

Pippogeek (19 views)
2014-09-24 16:12:06

Grunnt (45 views)
2014-09-23 14:38:19

radar3301 (27 views)
2014-09-21 23:33:17

BurntPizza (63 views)
2014-09-21 02:42:18

BurntPizza (33 views)
2014-09-21 01:30:30

moogie (41 views)
2014-09-21 00:26:15

UprightPath (50 views)
2014-09-20 20:14:06

BurntPizza (54 views)
2014-09-19 03:14:18
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org 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‑gaming.org
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!