Author Topic: can't be instantiated  (Read 4885 times)

Offline Pellinore

  • byte
  • *
  • Posts: 4
    • View Profile
    • http://www.goldenoakdesign.net
can't be instantiated
« on: June 21, 2006, 12:37:17 pm »
i started a gameproject some few months ago with some friend...first we implented to use c++, but after a very...very...very long discussion we decided to use java...so...the problem is that i'm totally new to java.

we are using jcpt engine offcourse  :shock: .
so together with some modellers we adjusted the example fps,
everything worked well...
but when is was trying to make an applet of it...i get a strange error:

Java Plug-in 1.5.0_07
Using JRE version 1.5.0_07 Java HotSpot(TM) Client VM
User home directory = C:\Documents and Settings\Eigenaar


----------------------------------------------------
c:   clear console window
f:   finalize objects on finalization queue
g:   garbage collect
h:   display this help message
l:   dump classloader list
m:   print memory usage
o:   trigger logging
p:   reload proxy configuration
q:   hide console
r:   reload policy configuration
s:   dump system and deployment properties
t:   dump thread list
v:   dump thread stack
x:   clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------

load: fps/BOH1.class can't be instantiated.
java.lang.InstantiationException: fps.BOH1
   at java.lang.Class.newInstance0(Unknown Source)
   at java.lang.Class.newInstance(Unknown Source)
   at sun.applet.AppletPanel.createApplet(Unknown Source)
   at sun.plugin.AppletViewer.createApplet(Unknown Source)
   at sun.applet.AppletPanel.runLoader(Unknown Source)
   at sun.applet.AppletPanel.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)

i'm using netbeans btw...but i tryed jcreator to..but i gives the same error.
i looked up some forums to see or there are other peeps with the same error...but didn't really found...i think it ussually appears when ur class is abstract...or an interface.... anyway..here is my adjusted source code:

import java.io.*;

import java.lang.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.applet.*;

import com.threed.jpct.*;
import com.threed.jpct.util.*;

/**
 * This is a simple demonstration of how a first-person-shooter like application
 * can be implementated using jPCT. It shows fps-like movement and collision detection
 * as well as loading a 3DS-level, some OcTree-stuff etc.
 */
public class BOH1 extends java.applet.Applet{

   /**
    * The starting position of the player
    */
   private final static SimpleVector STARTING_POS=new SimpleVector(80, -120, -400);

   /**
    * The radius of the sphere used for sphere/polygon collision detection
    */
   private final static float COLLISION_SPHERE_RADIUS=8f;

   /**
    * The "height" of the player, i.e. how many units the camera is loacted above the ground.
    */
   private final static float PLAYER_HEIGHT=80f;

   /**
    * The dimensions of the ellipsoid used for collision detection. This represents the "size"
    * of the player
    */
   private final static SimpleVector ELLIPSOID_RADIUS=new SimpleVector(COLLISION_SPHERE_RADIUS,PLAYER_HEIGHT/2f,COLLISION_SPHERE_RADIUS);

   /**
   * The speed with which the player will fall if there's no ground below his feet
   */
   private final static float GRAVITY=16f;

   /**
    * How fast the player will move (in world units)
    */
   private final static float MOVE_SPEED=8.5f;

   /**
    * How fast the player will turn
    */
   private final static float TURN_SPEED=0.1f;

   /**
    * A flag that signals a change of the renderer (don't ask about the 35 here....)
    */
   private final static int SWITCH_RENDERER=35;

   /**
    * Should we try to do fullscreen?
    */
   private boolean fullscreen=false;

   /**
    * Are we using OpenGL?
    */
   private boolean openGL=false;

   /**
    * Are we rendering in wireframe mode?
    */
   private boolean wireframe=false;

   /**
    * Some jPCT related stuff...
    */
   private Object3D level=null;
   private Object3D weapon=null;
   private Object3D elevator=null;
   private FrameBuffer buffer=null;
   private World theWorld=null;
   private TextureManager texMan=null;
   private Camera camera=null;

   /**
    * The texture used for blitting the framerate
    */
   private Texture numbers=null;

   /**
    * playerDirection stores the player's current orientation, so that the player's
    * movement is decoupled from the actual camera.
    */
   private Matrix playerDirection=new Matrix();
   private SimpleVector tempVector=new SimpleVector();

   /**
    * Default size of the framebuffer
    */
   private int width=640;
   private int height=480;

   /**
    * Some AWT related stuff
    */
   private Frame frame=null;
   private Graphics gFrame=null;
   private BufferStrategy bufferStrategy=null;
   private GraphicsDevice device=null;
   private int titleBarHeight=0;
   private int leftBorderWidth=0;

   private int switchMode=0;

   private int fps;
   private int lastFps;
   private long totalFps;

   private int pps;
   private int lastPps;

   private boolean isIdle=false;
   private boolean exit=false;

   /**
    * Flags for the keys
    */
   private boolean left=false;
   private boolean right=false;
   private boolean up=false;
   private boolean down=false;
   private boolean forward=false;
   private boolean back=false;

   /**
    * The KeyMapper that offers a uniform way to access
    * the keyboard in hard- and software-mode
    */
   private KeyMapper keyMapper=null;

   /**
    * Some vars to handle the elevator
    */
   float elevatorOffset=-0.8f;
   float elevatorPosition=-90f;
   int elevatorCountdown=50;

   /**
    * Very complex stuff...impossible to explain...
    */
   public static void main(String[] args) {
      BOH1 start=new BOH1(args);
   }

   /**
    * The constructor. Here we are initializing things...
    */
   private BOH1(String[] args) {
      /**
       * Evaluate the commandline parameters
       */
      for (int i=0; i<args.length; i++) {
         if (args.equals("fullscreen")) {
            fullscreen=true;
            Config.glFullscreen=true;
         }
         if (args.equals("mipmap")) {
            Config.glMipmap=true;
         }
         if (args.equals("trilinear")) {
            Config.glTrilinear=true;
         }

         if (args.equals("16bit")) {
            Config.glColorDepth=16;
         }
         try {
            if (args.startsWith("width=")) {
               width=Integer.parseInt(args.substring(6));
            }
            if (args.startsWith("height=")) {
               height=Integer.parseInt(args.substring(7));
            }
            if (args.startsWith("refresh=")) {
               Config.glRefresh=Integer.parseInt(args.substring(8));
            }
            if (args.startsWith("zbuffer=")) {
               Config.glZBufferDepth=Integer.parseInt(args.substring(8));
               if (Config.glZBufferDepth==16) {
                  Config.glFixedBlitting=true;
               }
            }

         } catch (Exception e) {
            // We don't care...
         }
      }

      isIdle=false;
      switchMode=0;
      totalFps=0;
      fps=0;
      lastFps=0;

      /**
       * Initialize the World instance and get the TextureManager (a singleton)
       */
      theWorld=new World();
      texMan=TextureManager.getInstance();

      /**
       * Setup the lighting. We are not using overbright lighting because the OpenGL
       * renderer can't do it, but we are using RGB-scaling. Some hardware/drivers
       * for OpenGL don't support this.
       */
      Config.fadeoutLight=true;
      Config.linearDiv=4000;
      Config.lightDiscardDistance=400;
      theWorld.getLights().setOverbrightLighting(Lights.OVERBRIGHT_LIGHTING_DISABLED);
      theWorld.getLights().setRGBScale(Lights.RGB_SCALE_2X);
      theWorld.setAmbientLight(100, 100, 100);



      /**
       * We are using fog. Please note that the fog implementation is not very well suited for
       * any other fog color than black when using OpenGL's lighting model.
       */
      theWorld.setFogging(World.FOGGING_ENABLED);
      theWorld.setFogParameters(5000, 0, 0, 0);
      Config.farPlane=30000;

      /**
       * Load the textures needed and add them to the TextureManager. We are loading the "numbers"
       * texture for blitting the framerate as well as the weapon's environment map and all JPGs
       * that can be found in the "textures"-directory. The 3DS file of the level contains
       * materials that are pointing to these textures (identified by name).
       */
      char c=File.separatorChar;
      numbers=new Texture("textures"+c+"other"+c+"numbers.jpg");
      texMan.addTexture("numbers", numbers);
      texMan.addTexture("envmap", new Texture("textures"+c+"other"+c+"envmap.jpg"));
      texMan.addTexture("GRASS2", new Texture("textures"+c+"GRASS2.jpg"));
      texMan.addTexture("grass3", new Texture("textures"+c+"grass3.jpg"));
     
      File dir=new File("textures");
      String[] files=dir.list();
      for (int i=0; i<files.length; i++) {
         String name=files;
         if (name.toLowerCase().endsWith(".jpg")) {
            texMan.addTexture(name, new Texture("textures"+c+name));
         }
      }

      /**
       * Load and setup the weapon. To ease the placement of the weapon in the gameloop,
       * we are transforming the mesh here too.
       */
      Object3D[] miss=Loader.load3DS("3ds"+c+"weapon.3ds", 2);
      weapon=miss[0];
      weapon.rotateY(-(float) Math.PI/2f);
      weapon.rotateZ(-(float) Math.PI/2f);
      weapon.rotateX(-(float) Math.PI/7f);

      // Make the rotations permanent
      weapon.rotateMesh();
      weapon.translate(6, 6, 10);

      // Make the translation permanent
      weapon.translateMesh();
      weapon.setRotationMatrix(new Matrix());
      weapon.setTranslationMatrix(new Matrix());

      weapon.setTexture("envmap");
      weapon.setEnvmapped(Object3D.ENVMAP_ENABLED);
      weapon.setEnvmapMode(Object3D.ENVMAP_WORLDSPACE);
      theWorld.addObject(weapon);

      /**
       * Load the level...
       */
      Object3D[] levelParts=Loader.load3DS("3ds"+c+"Castle_beta_69.3ds", 50);
      level=new Object3D(0);

      for (int i=0; i<levelParts.length; i++) {
         Object3D part=levelParts;
         /**
          * The level is not rotated correctly after loading (something all Quake3 levels
          * share when converted to 3DS-format, because Quake3 uses a different coordinate
          * system than jPCT.
          */
         part.setCenter(SimpleVector.ORIGIN);
         part.rotateX((float)-Math.PI/2);
         part.rotateMesh();
         part.setRotationMatrix(new Matrix());

         /**
          * Merge all parts into one object. This is usefull for this level, because the parts
          * don't represent sectors or zones but are widespreaded over the level, which would render
          * an octree useless for this level. By merging them all, the octree can be used much
          * more efficient.
          */
         level=Object3D.mergeObjects(level, part);
      }

      /**
       * Create triangle strips (good for OpenGL performance) and setup the collision
       * detection mode. Furthermore, an octree is created for the level.
       */
      level.createTriangleStrips(2);
      level.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
      level.setCollisionOptimization(Object3D.COLLISION_DETECTION_OPTIMIZED);

      OcTree oc=new OcTree(level, 100, OcTree.MODE_OPTIMIZED);
      oc.setCollisionUse(OcTree.COLLISION_USE);
      level.setOcTree(oc);

      /**
       * The level won't move, so...
       */
      level.enableLazyTransformations();

      /**
       * Done! Now add the result to the world.
       */
      theWorld.addObject(level);

      /**
       * Setup the elevator. The elevator is a more or
       * less hardcoded entity in this level that serves
       * demonstration purposes only. You'll most
       * likely have to implement a more advanced elevator
       * management if you want to use elevators at all.
       */
      elevator=Primitives.getBox(0.01f,0.01f);
      elevator.rotateY((float)Math.PI/4);
      elevator.setOrigin(new SimpleVector(800,-90,-450));
      elevator.setCollisionOptimization(Object3D.COLLISION_DETECTION_OPTIMIZED);
      elevator.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
      elevator.setTexture("envmap");
      elevator.setEnvmapped(Object3D.ENVMAP_ENABLED);
      elevator.setEnvmapMode(Object3D.ENVMAP_CAMERASPACE);
      theWorld.addObject(elevator);

      /**
       * Place the camera at the starting position.
       */
      camera=theWorld.getCamera();
      camera.setPosition(STARTING_POS);

      /**
       * Now build() all objects.
       */
      theWorld.buildAllObjects();

      /**
       * This is needed for weapon movement, but has to be done after calling build()
       * on the weapon because build() resets the rotation pivot to the object's
       * (calculated) center.
       */
      weapon.setRotationPivot(new SimpleVector(0, 0, 0));

      /**
       * Setup some optimizations for outdoor rendering (the level is not very outdoorish at
       * all, but at least the framebuffer needs clearing because the level is not closed.
       */
      Config.collideOffset=250;
      Config.tuneForOutdoor();

      /**
       * Do some AWT setup work
       */
      initializeFrame();

      /**
       * Here we go...!
       */
      gameLoop();
   }

   /**
    * This initializes the AWT frame either in fullscreen or in windowed mode.
    * This is not a waterproof intialization, but i didn't want to do a AWT
    * tutorial here (and i would be the wrong person to do this anyway...:-)).
    * Change whatever you think that needs change here...
    */
   private void initializeFrame() {
      if (fullscreen) {
         GraphicsEnvironment env=GraphicsEnvironment.getLocalGraphicsEnvironment();
         device=env.getDefaultScreenDevice();
         GraphicsConfiguration gc=device.getDefaultConfiguration();
         frame=new Frame(gc);
         frame.setUndecorated(true);
         frame.setIgnoreRepaint(true);
         device.setFullScreenWindow(frame);
         if (device.isDisplayChangeSupported()) {
            device.setDisplayMode(new DisplayMode(width, height, 32, 0));
         }
         frame.createBufferStrategy(2);
         bufferStrategy=frame.getBufferStrategy();
         Graphics g=bufferStrategy.getDrawGraphics();
         bufferStrategy.show();
         g.dispose();
      } else {
         frame=new Frame();
         frame.setTitle("jPCT "+Config.getVersion());
         frame.pack();
         Insets insets = frame.getInsets();
         titleBarHeight=insets.top;
         leftBorderWidth=insets.left;
         frame.setSize(width+leftBorderWidth+insets.right, height+titleBarHeight+insets.bottom);
         frame.setResizable(false);
         frame.show();
         gFrame=frame.getGraphics();
      }

      /**
       * The listeners are bound to the AWT frame...they are useless in OpenGL mode.
       */
      frame.addWindowListener(new WindowEvents());
      keyMapper=new KeyMapper(frame);
   }

   /**
    * The fps counter is blitted into the rendered framebuffer here and the results
    * will be displayed (hence the name of the method...:-))
    */
   private void display() {
      blitNumber((int) totalFps, 5, 2);
      blitNumber((int) lastPps, 5, 12);

      if (!openGL) {
         if (!fullscreen) {
            buffer.display(gFrame, leftBorderWidth, titleBarHeight);
         } else {
            Graphics g=bufferStrategy.getDrawGraphics();
            g.drawImage(buffer.getOutputBuffer(), 0, 0, null);
            bufferStrategy.show();
            g.dispose();
         }
      } else {
         buffer.displayGLOnly();
      }
   }

   /**
    * A simple method that does the number-blitting.
    */
   private void blitNumber(int number, int x, int y) {
      if (numbers!=null) {
         String sNum=Integer.toString(number);
         for (int i=0; i<sNum.length(); i++) {
            char cNum=sNum.charAt(i);
            int iNum=cNum-48;
            buffer.blit(numbers, iNum*5, 0, x, y, 5, 9, FrameBuffer.TRANSPARENT_BLITTING);
            x+=5;
         }
      }
   }

   /**
    * Does the collision detection and the movement of the player.
    */
   private void doMovement() {

      /**
       * The first part handles the "physics", i.e. it allows the player to fall down.
       */

      SimpleVector camPos=camera.getPosition();
      camPos.add(new SimpleVector(0, PLAYER_HEIGHT/2f, 0));
      SimpleVector dir=new SimpleVector(0, GRAVITY, 0);
      dir=theWorld.checkCollisionEllipsoid(camPos, dir, ELLIPSOID_RADIUS, 1);
      camPos.add(new SimpleVector(0, -PLAYER_HEIGHT/2f, 0));
      dir.x=0;
      dir.z=0;
      camPos.add(dir);
      camera.setPosition(camPos);

      /**
       * The "falling" part of the player is now finished. Now we care for the horizontal movement.
       * Nothing special here and no problems either. One thing worth mentioning is, that the player is
       * always moving in the same plane regardless of where he's looking. playerDirection takes
       * care of this.
       */

      // forward and back may change during excution (threaded!), so we have to ensure to
      // reset the camera only if has been changed before.
      boolean cameraChanged=false;

      if (forward) {
         camera.moveCamera(new SimpleVector(0,1,0), PLAYER_HEIGHT/2f);
         cameraChanged=true;
         tempVector=playerDirection.getZAxis();
         theWorld.checkCameraCollisionEllipsoid(tempVector, ELLIPSOID_RADIUS, MOVE_SPEED, 5);
      }
      if (back) {
         if (!cameraChanged) {
            camera.moveCamera(new SimpleVector(0,1,0), PLAYER_HEIGHT/2f);
            cameraChanged=true;
         }
         tempVector=playerDirection.getZAxis();
         tempVector.scalarMul(-1f);
         theWorld.checkCameraCollisionEllipsoid(tempVector, ELLIPSOID_RADIUS, MOVE_SPEED, 5);
      }

      if (left) {
         camera.rotateAxis(camera.getBack().getYAxis(), -TURN_SPEED);
         playerDirection.rotateY(-TURN_SPEED);
      }
      if (right) {
         camera.rotateAxis(camera.getBack().getYAxis(), TURN_SPEED);
         playerDirection.rotateY(TURN_SPEED);
      }

      if (up) {
         camera.rotateX(TURN_SPEED);
      }
      if (down) {
         camera.rotateX(-TURN_SPEED);
      }

      if (cameraChanged) {
         camera.moveCamera(new SimpleVector(0, -1, 0), PLAYER_HEIGHT/2f);
      }
   }


   /**
    * Move the elevator up/down
    */
   private void moveElevator() {

      if ((elevator.wasTargetOfLastCollision()&&elevatorCountdown--<=0)||
          (elevatorPosition!=-90f&&elevatorPosition!=-180f)) {

         float tempElevator=elevatorPosition+elevatorOffset;
         float tempOffset=elevatorOffset;

         if (tempElevator<-180f) {
            tempOffset=-180f-elevatorPosition;
            elevatorCountdown=50;
            elevatorOffset*=-1f;
         } else {
            if (tempElevator>-90f) {
               tempOffset=-90f-elevatorPosition;
               elevatorCountdown=50;
               elevatorOffset*=-1f;
            }
         }
         elevatorPosition+=tempOffset;
         elevator.translate(0, tempOffset, 0);
      }
   }

   /**
    * Poll the keyboard using the KeyMapper from com.threed.jpct.util
    */
   private void poll() {
      KeyState state=null;
      do {
         state=keyMapper.poll();
         if (state!=KeyState.NONE) {
            keyAffected(state);
         }
      } while (state!=KeyState.NONE);
   }

   /**
    * This is the game's main loop. We are doing some additional setup work here and
    * rendering the scene in a loop, as well as calling doMovement() to handle the movement
    * and the collision detection before each frame.
    */
   private void gameLoop() {
      World.setDefaultThread(Thread.currentThread());

      buffer=new FrameBuffer(width, height, FrameBuffer.SAMPLINGMODE_NORMAL);
      buffer.enableRenderer(IRenderer.RENDERER_SOFTWARE);
      buffer.setBoundingBoxMode(FrameBuffer.BOUNDINGBOX_NOT_USED);

      buffer.optimizeBufferAccess();

      Timer timer=new Timer(25);
      timer.start();

      Timer fpsTimer=new Timer(1000);
      fpsTimer.start();

      long timerTicks=0;

      while (!exit) {

         if (!isIdle) {

            long ticks=timer.getElapsedTicks();
            timerTicks+=ticks;

            for (int i=0; i<ticks; i++) {
               /**
                * Do this as often as ticks have passed. This can
                * be improved by calling the method only once and letting
                * the collision detection somehow handle the ticks passed.
                */
                doMovement();
                moveElevator();
            }

            poll();

            if (switchMode!=0) {
               switchOptions();
            }

            buffer.clear();

            weapon.getTranslationMatrix().setIdentity();
            weapon.translate(camera.getPosition());
            weapon.align(camera);
            weapon.rotateAxis(camera.getDirection(), (float) Math.sin(timerTicks/6f)/20f);

            theWorld.renderScene(buffer);

            if (!wireframe) {
               theWorld.draw(buffer);
            }
            else {
               theWorld.drawWireframe(buffer, Color.white);
            }

            buffer.update();
            display();

            fps++;
            pps+=theWorld.getVisibilityList().getSize();

            if (fpsTimer.getElapsedTicks()>0) {
               totalFps=(fps-lastFps);
               lastFps=fps;
               lastPps=pps;
               pps=0;
            }

            Thread.yield();

         } else {
            try {
               Thread.sleep(500);
            } catch (InterruptedException e) {}
         }
      }

      if (openGL) {
         buffer.disableRenderer(IRenderer.RENDERER_OPENGL);
      } else {
         if (fullscreen) {
            device.setFullScreenWindow(null);
         }
      }
      System.exit(0);
   }

   /**
    * This is for switching settings. Currently, only switching from OpenGL to software and
    * back is supported here.
    */
   private void switchOptions() {
      switch (switchMode) {
         case (SWITCH_RENDERER): {
            isIdle=true;
            if (buffer.usesRenderer(IRenderer.RENDERER_OPENGL)) {
               keyMapper.destroy();
               buffer.disableRenderer(IRenderer.RENDERER_OPENGL);
               buffer.enableRenderer(IRenderer.RENDERER_SOFTWARE, IRenderer.MODE_OPENGL);
               openGL=false;
               if (fullscreen) {
                  device.setFullScreenWindow(null);
               }
               frame.hide();
               frame.dispose();
               initializeFrame();
            } else {
               frame.hide();
               keyMapper.destroy();
               buffer.enableRenderer(IRenderer.RENDERER_OPENGL, IRenderer.MODE_OPENGL);
               buffer.disableRenderer(IRenderer.RENDERER_SOFTWARE);
               openGL=true;
               keyMapper=new KeyMapper();
            }
            isIdle=false;
            break;
         }
      }
      switchMode=0;
   }


   private void keyAffected(KeyState state) {
      int code=state.getKeyCode();
      boolean event=state.getState();
      switch (code) {
         case (KeyEvent.VK_ESCAPE): {
            exit=event;
            break;
         }
         case (KeyEvent.VK_LEFT): {
            left=event;
            break;
         }
         case (KeyEvent.VK_RIGHT): {
            right=event;
            break;
         }
         case (KeyEvent.VK_UP): {
            forward=event;
            break;
         }
         case (KeyEvent.VK_DOWN): {
            back=event;
            break;
         }
         case (KeyEvent.VK_Z): {
            up=event;
            break;
         }
         case (KeyEvent.VK_S): {
            down=event;
            break;
         }
         case (KeyEvent.VK_1): {
            if (event&&buffer.supports(FrameBuffer.SUPPORT_FOR_RGB_SCALING)) {
               theWorld.getLights().setRGBScale(Lights.RGB_SCALE_DEFAULT);
            }
            break;
         }

         case (KeyEvent.VK_2): { // 2x scaling
            if (event&&buffer.supports(FrameBuffer.SUPPORT_FOR_RGB_SCALING)) {
               theWorld.getLights().setRGBScale(Lights.RGB_SCALE_2X);
            }
            break;
         }

         case (KeyEvent.VK_4): { // 4x scaling
            if (event&&buffer.supports(FrameBuffer.SUPPORT_FOR_RGB_SCALING)) {
               theWorld.getLights().setRGBScale(Lights.RGB_SCALE_4X);
            }
            break;
         }

         case (KeyEvent.VK_W): { // wireframe mode (w)
            if (event) {
               wireframe=!wireframe;
            }
            break;
         }

         case (KeyEvent.VK_X): { // change renderer  (x)
            if (event) {
               switchMode=SWITCH_RENDERER;
            }
            break;
         }
      }
   }

   /**
    * The WindowApapter used for software mode
    */
   private class WindowEvents extends WindowAdapter {

      public void windowIconified(WindowEvent e) {
         isIdle=true;
      }

      public void windowDeiconified(WindowEvent e) {
         isIdle=false;
      }
   }



   private class Timer {
      private long ticks=0;
      private long granularity=0;

      public Timer(int granularity) {
         this.granularity=granularity;
      }

      public void start() {
         ticks=System.currentTimeMillis();
      }

      public void reset() {
         start();
      }

      public long getElapsedTicks() {
         long cur=System.currentTimeMillis();
         long l=cur-ticks;

         if (l>=granularity) {
            ticks=cur-(l%granularity);
            return l/granularity;
         }
         return 0;
      }
   }
}

and here is my html stuff:

<HTML>
<HEAD>
   <TITLE>Applet HTML Page</TITLE>
</HEAD>
<BODY>

<!--
*** GENERATED applet HTML launcher - DO NOT EDIT IN 'BUILD' FOLDER ***

If you need to modify this HTML launcher file (e.g., to add applet parameters),
copy it to where your applet class is found in the SRC folder. If you do this,
the IDE will use it when you run or debug the applet.

Tip: To exclude an HTML launcher from the JAR file, use exclusion filters in
the Packaging page in the Project Properties dialog.

For more information see the online help.
-->

<H3><HR WIDTH="100%">Applet HTML Page<HR WIDTH="100%"></H3>

<P>
<APPLET codebase="classes" code="fps/BOH1.class" archive="BOH1.jar" width=350 height=200></APPLET>
</P>

<HR WIDTH="100%"><FONT SIZE=-1><I>Generated by NetBeans IDE</I></FONT>
</BODY>
</HTML>

i think the prob is in my html cos, when i run javaviewer directly from netbeans...without html i guess..it works...but when i'm using my html file to start it i get that weird error...
when i just try a simple applet...showning a text...it works perfectly...

i don't really know cos i never worked with applets.....c++ only supports stand alone apps...i have been looking around i noticed most of the projects use swing gui..., is it really important to have included?
and do i have to put .3ds files and textures in the jar-file? if yes...do i have to change the directory pointing to the 3ds files?
and how do i include bump mapping?...we use UWV mapping now...but i thougt it supported bump  :lol: , anyway...srry if this are noob questions..wot they probally are...


any clue what it could be? :lol:

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
can't be instantiated
« Reply #1 on: June 21, 2006, 04:52:31 pm »

Offline Pellinore

  • byte
  • *
  • Posts: 4
    • View Profile
    • http://www.goldenoakdesign.net
can't be instantiated
« Reply #2 on: June 21, 2006, 09:58:16 pm »
nah...i didn't really helped...i don't think the prob has something to do with the classpath.

anyway, i tryed using swing stuff... but i'm getting this error  :roll: :

java.lang.NoClassDefFoundError: org/jdesktop/layout/GroupLayout$Group
   at java.lang.Class.getDeclaredConstructors0(Native Method)
   at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
   at java.lang.Class.getConstructor0(Unknown Source)
   at java.lang.Class.newInstance0(Unknown Source)
   at java.lang.Class.newInstance(Unknown Source)
   at sun.applet.AppletPanel.createApplet(Unknown Source)
   at sun.plugin.AppletViewer.createApplet(Unknown Source)
   at sun.applet.AppletPanel.runLoader(Unknown Source)
   at sun.applet.AppletPanel.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)

most part of it is the same error i had when not using swing...



java.lang.NoClassDefFoundError: org/jdesktop/layout/GroupLayout$Group

i looked on google, and everyone is telling to import swing-layout...jar...
and it already was imported... so thats kinda strange... maybe its cos i'm not really using swing's vissually design...  


at sun.plugin.AppletViewer.createApplet(Unknown Source)

its seems like i forgot to import a file...(unkown source)...
but i really don't have a clue...

anyway...as stand alone app. it runs perfect, here is a screenie:



we just made a test level to see how things went... we have team of +/- 10 active peeps, and have 26 peeps registered on our forum...
normally we should start advertising for new expierenced people about this time...so it should be usefull to have this test level up and running...,
but...maybe it would be usefull if u would take a look at de source code and adjust it if neccesairy...thnx  8)

Offline Pellinore

  • byte
  • *
  • Posts: 4
    • View Profile
    • http://www.goldenoakdesign.net
can't be instantiated
« Reply #3 on: June 22, 2006, 02:33:58 pm »
hi, thnx for helping anyway...but i don't think java is the best choice...it has to much important disadvantages..so we will work with c++ from now on... :lol:

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
can't be instantiated
« Reply #4 on: June 23, 2006, 12:47:40 am »
Quote from: "Pellinore"
...it has to much important disadvantages...
I would like to know which disadvantages you are thinking of.

Offline Pellinore

  • byte
  • *
  • Posts: 4
    • View Profile
    • http://www.goldenoakdesign.net
can't be instantiated
« Reply #5 on: June 23, 2006, 11:37:48 am »
graphical part of c++ is much better...
but the prob is that we implentet to make an applet...
just take runescape as example (not that i like that game)...
runescape has everything very...very low poly...
and we are not trying to make a fake copy of runescape...and when using a java applet this will be hard.
we are trying to make a realistic medieval game, with a small amount of magic.
anyway...i hope u understand that making a full 3d realistic medieval game to run as an applet...is very hard..., we don't have that much experience in java, like jagex (java game experts  :?) has.
anyway..java applets seems to be a new hype...i think its caused (for  a part) by the succes runescape made.
but to make a better game then runescape...is hard.
and..i have much more experience in c++ then in java.
its seems a better idea to use a c++ stand alone application, with better graphics (probally i'm gonna pay for a game engine)...

 8)

Offline manumoi

  • long
  • ***
  • Posts: 121
    • View Profile
    • http://www.iro.umontreal.ca/~blanchae
can't be instantiated
« Reply #6 on: June 24, 2006, 06:23:29 am »
hello, I don t fully agree with your quote concerning the graphical part of C++... The language is not the problem since you have hardware acceleration API (OpenGL/Mesa in C++ --> LWJGL/JOGL in java --> JPCT engine)... I agree that there is much history of creating games (so much documentation) with C++ . But i think it is worth learning java (I began with c++) because it is far more easy to debug and for me very intuitive way of programming... And in fact, the time you don t spend to debug, you can use it to optimize your code... Anyway...

Concerning making game with applet... why don t you try webstart? Applets are known to be very slow so if you are disappointed with the performance, i think this is normal.

Anyway, good luck for your project.

Emmanuel

Offline Melssj5

  • double
  • *****
  • Posts: 715
    • View Profile
can't be instantiated
« Reply #7 on: June 24, 2006, 01:09:27 pm »
What cant be denied is that C games are faster that java games. Well, I have not tried yet those softwares to make an exe from the bytecode, but in anyway C is still faster. Thats the only one advantage I see. Many comercial engines are made in C to be used with C.

Java is better for me due to the easy way to create new objects without worring too much about the memory usage. In anyway, good luck in your project.
Nada por ahora

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
can't be instantiated
« Reply #8 on: June 24, 2006, 04:43:44 pm »
It (C++) may be faster most of the time (not always due to dynamic compilation in Java), but in most cases, that shouldn't matter. Especially for amateur or semi-professional project, that won't reach the level of a Quake4 anyway...no matter if you are doing them in Java or C. I prefer Java today, because it's fast enough for me, faster to develop with and the resulting code contains less bugs. And that's me...who has been a die hard assembler hacker a few years ago... :wink: