Author Topic: Project AuNG/zG  (Read 6731 times)

Crowley

  • Guest
Project AuNG/zG
« on: June 29, 2004, 06:55:02 pm »
AuNG/zG is a codename for a project that has been brewing in my mind for about seven years and now jpct has given me the opportunity to move ahead with it. I've spent the last four days working on creating the basic graphical framework so that I have something to show others, and here it is now, at http://www.zaren.net/the_project

The screeshots don't really show much, but it will show you the direction where I am headed with this game. Any feedback would, of course, be welcome :)

Anonymous

  • Guest
Project AuNG/zG
« Reply #1 on: July 01, 2004, 12:01:40 am »
Reminds me of "Into the eagle's nest" on the CBM64. It looks much better than that of course.:wink:  It's just that it reminds me of it. Is the headless player a 3d model or a sprite?

Anonymous

  • Guest
Project AuNG/zG
« Reply #2 on: July 01, 2004, 12:04:28 am »
Here's a pic of "Into the eagle's nest":

Crowley

  • Guest
Project AuNG/zG
« Reply #3 on: July 01, 2004, 04:59:57 pm »
A sprite. Actually, the characters will be made of three sprites - the legs, the torso and the head. This will allow you to aim to one direction and move in another as all the parts can rotate independently. I'm still trying to figure out a way to make the torso turn towards the mouse cursor so that you could use the mouse to aim. (I know, trigonometry is propably the way to go, but I haven't quite figured it out)  :oops:

Basically I am going for the feel of the first two GTA games but with a couple of improvements, such as the aiming. Those who have played the first GTA will remember that aiming was really not that easy at times.

Btw, I'm not able to view the pic at this time as my net connection is acting weird. I can access some servers and some I cant. I'll have to check "Into the eagle's nest" out later.  :)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11769
    • View Profile
    • http://www.jpct.net
Project AuNG/zG
« Reply #4 on: July 01, 2004, 10:06:45 pm »
Assuming that you are looking at your sprite from above (i.e. down the y-axis), this code may serve as a starting point (you just have to draw yourself an arrow-texture with the arrow pointing up to test it):

One last thing: Please use this code with the updated jPCT 1.02 from today. The version from yesterday had a bug in it that this code will suffer from).

Code: [Select]
import java.io.*;

import java.awt.*;
import java.awt.event.*;
import com.threed.jpct.*;
import com.threed.jpct.util.*;

class TargetDemo {
 
   private FrameBuffer buffer=null;
   private World theWorld=null;
   private TextureManager texMan=null;

   private int width=640;
   private int height=480;

   private Frame frame=null;
   private Graphics gFrame=null;
   private int titleBarHeight=0;
   private int leftBorderWidth=0;

   private boolean exit=false;
   private KeyMapper keyMapper=null;
   
   private int mouseX;
   private int mouseY;
   private Object3D arrow=null;

   public static void main(String[] args) {
      new TargetDemo();
   }

   private TargetDemo() {

      theWorld=new World();
      texMan=TextureManager.getInstance();

      Config.fadeoutLight=false;
      theWorld.setAmbientLight(255, 255, 255);

      texMan.addTexture("arrow", new Texture("textures"+File.separatorChar+"arrow.jpg"));

      arrow=Primitives.getPlane(1,10);
      arrow.setTexture("arrow");
      arrow.setTransparency(1);
      arrow.rotateX((float) (Math.PI/2d));
      arrow.rotateMesh();
      arrow.setRotationMatrix(new Matrix());
      arrow.build();
      theWorld.addObject(arrow);
     
      theWorld.getCamera().setPosition(0,-100,0);
      theWorld.getCamera().rotateCameraX((float) (Math.PI/2d));
         
      Config.tuneForOutdoor();
      initializeFrame();

      gameLoop();
   }

   private void initializeFrame() {
      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();
      keyMapper=new KeyMapper(frame);
      frame.addMouseMotionListener(new MouseMotionAdapter(){
         public void mouseMoved(MouseEvent e) {
            mouseX=e.getX()-frame.getInsets().left;
            mouseY=e.getY()-frame.getInsets().top;
         }
      });
   }

   private void display() {
      buffer.display(gFrame, leftBorderWidth, titleBarHeight);
   }

   private void gameLoop() {

      World.setDefaultThread(Thread.currentThread());
      Thread.currentThread().setPriority(Thread.NORM_PRIORITY);

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

      while (!exit) {
         
            poll();
            buffer.clear();

            theWorld.renderScene(buffer);
            theWorld.draw(buffer);

            buffer.update();
            display();
           
            // Rotation stuff
           SimpleVector arrowCenter=Interact2D.projectCenter3D2D(buffer, arrow);
           if (arrowCenter!=null) {
              arrowCenter.z=0;
              SimpleVector delta=arrowCenter.calcSub(new SimpleVector(mouseX, mouseY, 0));
 
              delta.z=delta.y;
              delta.x*=-1;
              delta.y=0;
 
              Matrix rotMat=delta.getRotationMatrix();
              arrow.setRotationMatrix(rotMat);
 
              if (delta.length()>5) {
                 // Move the arrow slowly...
                 SimpleVector t=arrow.getZAxis();
                 t.scalarMul(0.1f);
                 arrow.translate(t);
              }
           }
           
           Thread.yield();
      }

      keyMapper.destroy();
      System.exit(0);
   }

   
   private void poll() {
      KeyState state=null;
      do {
         state=keyMapper.poll();
         if (state!=KeyState.NONE) {
            keyAffected(state);
         }
      } while (state!=KeyState.NONE);
   }


   private void keyAffected(KeyState state) {
      int code=state.getKeyCode();
      boolean event=state.getState();

      switch (code) {
         case (KeyEvent.VK_ESCAPE): {
            exit=event;
            break;
         }
      }
   }
}

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11769
    • View Profile
    • http://www.jpct.net
Project AuNG/zG
« Reply #5 on: July 01, 2004, 10:07:33 pm »
And by the way: Nice project... :D

Offline Crowley

  • byte
  • *
  • Posts: 1
    • View Profile
    • http://www.zaren.net/the_project
Thanks
« Reply #6 on: July 11, 2004, 05:19:26 pm »
Thanks, Egon :) I haven't really attempted to implement the rotation just yet as I've spent the last ten days creating other, non-graphical parts of the game, but I'll look into the rotation when I start working on the graphical engine again. As you can see, I did finally decide to register in the forums here.

As far as the engine is concerned, we aren't actually looking down from above, but from the side, along the Z-axis. I went this way for a couple of reasons: first, I was too lazy to move the camera and second, I've programmed 2d tile base games in the past so I wanted to keep the X and Y where they have been before :)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11769
    • View Profile
    • http://www.jpct.net
Re: Thanks
« Reply #7 on: July 11, 2004, 05:40:35 pm »
Quote from: "Crowley"
As far as the engine is concerned, we aren't actually looking down from above, but from the side, along the Z-axis.
Shouldn't matter that much. The code may still work with some additional rotation magic applied to it. In fact, i wrote a little demo application for myself, where a MD2-model was moving towards the mouse. The camera was looking from somewhere between z and y axis down to the origin and it worked fine.