Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

putting a game engine together need some pointers

$
0
0

im putting a game that looks sorta like StarFox 64 pretty old Nintendo game i used to play growing up, so here i am trying to replicate this game with my own material and plot, what i have so far is the environment where the ship flies the ship it self "well a few for user choice" and i have the enemy ships which will be the other ships that the player did not chose. Now where im having trouble is importing the obj file to the flying environment where the game takes place, or the level if you will (levels map) "which by the way i have 5 maps" and i load the obj to the window and everything runs good or as normal but the ship is no where to be found?

star-fox-64_sep6-13_51_19

void setup()
{
 /*
  AS YOU CAN SEE HERE IS THE OBJ OF THE SHIP OF THE PLAYERS GAME
  size(1800, 900, P3D);
  frameRate(30);//added
  model = new OBJModel(this, "drone.obj", "absolute", TRIANGLES);
  model.enableDebug();

  model.scale(15);//20 is good but play with this
  model.translateToCenter();

  stroke(255);
  noStroke();
  */
  cursor(CROSS);

  IN HERE I SETUP ALL THE TERRAIN AND WALLS TO THE GAME

  HERE I DECLARED THE NUMBER OF ENEMIES
  {
  HERE I HAVE A CODE BLOCK FOR THE ENEMY RENDERING
  }
 HERE I HAVE A CODE BLOCK THATS FOR THE ENEMY SHIP
}

IN HERE I TRY PLACING THE DRONE CODE ONLY " found in void ship() " IN THE DRAW BUT NOTHING AND IT WAS SORTA LAGGING SO I ENDED UP MAKING A VOID SHIP() AND THIS RUNS BETTER BUT NO SHOW OF SHIP

void draw()
{
  background(0);
  // Get elapsed time
  long t = millis() - time;
  time = millis();

  update(t/1000.0);  // Update shapes on terrain
  if (mousePressed)   // Update camera speed and direction
    processMousePressed();
  if (keyPressed)
    processKeyPressed(t);
  if (clicked)  // Clicked on artefact?
    processMouseClick();
  cam.move(t/250.0);  //1000
  // Calculate amount of movement based on velocity and time
  // Adjust the cameras position so we are over the terrain
  // at the given height.
  cam.adjustToTerrain(terrain, Terrain.WRAP, camHoversAt);
  // Set the camera view before drawing
  cam.camera();
  obelisk.draw();
  tube.draw();
  terrain.draw();
  // Get rid of directional lights so skybox is evenly lit.
  skybox.moveTo(cam.eye().x, 0, cam.eye().z);
  skybox.draw();
}

AS YOU CAN SEE HERE IS WHERE I THOUGHT I SHOULD PLACE THIS FUNCTION BUT I DONT KNOW, YOU TELL ME ?! IT SHOULD GO IN DRAW OR IN HERE BUT IF IN HERE WHAT DO I DO IN DRAW TO MAKE IT DISPLAY?

void ship()
{
   background(0);
    lights();
    pushMatrix();
    translate(900, 700);
    rotateX(rotY);
    rotateY(rotX);
    model.draw();
    popMatrix();
}

IN HERE IM USING THE LEFT CLICK AND DRAG TO MOVE THE SHIP IN ITS CENTER AXIS USING MOUSEDRAGGED()

void mouseDragged()
{
    rotX += (mouseX - pmouseX) * 0.01;
    rotY -= (mouseY - pmouseY) * 0.01;
}

void processMousePressed()
{
  float achange = (mouseX - pmouseX) * PI / width;
  cam.rotateViewBy(achange);  // Keep view and move directions the same
  cam.turnBy(achange);
}

HERE IM USING THE KEYBOARDS ARROW FOR NOW TO MOVE THE PLAYERS VIEW "CAMERA ANGLE VIEW"

void processKeyPressed(long t)
{
  if (key == 'W' || key =='w' || key == 'P' || key == 'p')
  {
    camSpeed += (t/25.0);
    cam.speed(camSpeed);
  } else if (key == 'S' || key =='s' || key == 'L' || key == 'l')
  {
    camSpeed -= (t/5.0);
    cam.speed(camSpeed);
  } else if (key == 'o')
  {
    camSpeed = 0;
    cam.speed(camSpeed);
  }
}

AS YOU CAN SEE THIS IS WHAT THE GAME LOOKS LIKE IN THIS PARTICULAR MAP BUT THE ISSUE IS THAT THAT DRONE IN THE BOTTOM CENTER IS NOT SHOWING UP THERE AS IT SHOULD, THATS THE OBJ FILE IN SETUP NAMED DRONE.OBJ

Screenshot (85)

Capture


Viewing all articles
Browse latest Browse all 2896

Trending Articles