Exemple #1
0
  private void starsDir() {

    for (Star s : (List<Star>) w.getObjects(Star.class)) {

      s.setRotation(this.getRotation() - 180);
    }
  }
 private StarsSector declareSector(
     ZoomCamera camera,
     int count,
     Color blue,
     int x,
     int y,
     int width,
     int height,
     VertexBufferObjectManager mgr,
     ArrayList<TextureRegion> starRegions) {
   Entity sector = new Entity(x * width, y * height);
   for (int i = 0; i < count; i++) {
     int nextInt = Core.random.nextInt(starRegions.size());
     TextureRegion textureRegion = starRegions.get(nextInt);
     Star star2 = new Star(textureRegion, mgr);
     float _x = camera.getXMin() + Core.random.nextInt(width);
     float _y = camera.getYMin() + Core.random.nextInt(height);
     star2.setLocation(_x, _y);
     star2.setScale(1 - this.scrollFactor);
     star2.setColor(blue);
     sector.attachChild(star2);
   }
   if (Core.settings.starsLayerBorder) {
     Line top = new Line(0, 0, width, 0, mgr);
     Line bottom = new Line(0, height, width, height, mgr);
     Line left = new Line(0, 0, 0, height, mgr);
     Line right = new Line(width, 0, width, height, mgr);
     sector.attachChild(top);
     sector.attachChild(bottom);
     sector.attachChild(left);
     sector.attachChild(right);
   }
   return new StarsSector(sector, x, y, mgr);
 }
Exemple #3
0
  @Override
  public void update() {
    super.update();

    for (Star s : m_stars) s.update();

    m_exitDoor.update();
  }
Exemple #4
0
  private void parseStar(Element starElement) {
    system = starElement.getAttribute("system");
    Star star = new Star();
    star.setType(getInnerTagContent(starElement, "type"));

    parseBody(starElement, star);
    systemsMap.put(system, star);
  }
 public void update(float deltaTime) {
   for (int i = MAX_COUNT - 1; i >= 0; --i) {
     Star p = points[i];
     if (!p.update(deltaTime)) {
       initStar(i, 0); // create new on ith place
     }
   }
 }
  @Override
  public void onDrawFrame(GL10 unused) {
    GLES20.glClearColor(0f, 0f, 0f, 1f);
    GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);

    if (mShaderCompilerSupport[0] == false) {
      return;
    }

    GLES20.glEnable(GLES20.GL_BLEND);
    GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA);

    long time = SystemClock.uptimeMillis();

    if (mLastRenderTime == -1) {
      for (Star star : mStarArray) {
        star.randomize();
        star.mPosition[2] = (float) (Math.random() * 4 - 2);
      }
      mLastRenderTime = time;
    }

    float t = (time - mLastRenderTime) / 1000f;
    mLastRenderTime = time;

    mShaderStar.useProgram();

    GLES20.glUniformMatrix4fv(
        mShaderStar.getHandle("uModelViewProjectionM"), 1, false, mMatrixModelViewProjection, 0);
    GLES20.glUniform1f(mShaderStar.getHandle("uSize"), .01f);

    GLES20.glVertexAttribPointer(
        mShaderStar.getHandle("aPosition"), 2, GLES20.GL_BYTE, false, 0, mBufferVertices);
    GLES20.glEnableVertexAttribArray(mShaderStar.getHandle("aPosition"));

    for (Star star : mStarArray) {
      star.mPosition[2] += star.mSpeed * t;
      if (star.mPosition[2] > 2) {
        star.randomize();
      }
    }

    Arrays.sort(
        mStarArray,
        new Comparator<Star>() {
          @Override
          public int compare(Star arg0, Star arg1) {
            return arg0.mPosition[2] < arg1.mPosition[2] ? -1 : 1;
          }
        });

    for (Star star : mStarArray) {
      GLES20.glUniform3fv(mShaderStar.getHandle("uPosition"), 1, star.mPosition, 0);
      GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
    }

    GLES20.glDisable(GLES20.GL_BLEND);
  }
Exemple #7
0
  @Override
  public void draw(Graphics2D g) {
    super.draw(g);

    for (Star s : m_stars) s.draw(g);

    m_exitDoor.draw(g);

    m_player.draw(g);
  }
Exemple #8
0
 public static void main(String[] args) {
   realStar realStar = new realStar();
   starHandler handler = new starHandler(realStar);
   Star proxyStar =
       (Star)
           Proxy.newProxyInstance(
               ClassLoader.getSystemClassLoader(), new Class[] {Star.class}, handler);
   proxyStar.sing();
   proxyStar.bookTicket();
 }
Exemple #9
0
  public static void main(String[] args) {
    Star star = new RealStar();
    StarHandler handler = new StarHandler(star);

    Star proxy =
        (Star)
            Proxy.newProxyInstance(
                ClassLoader.getSystemClassLoader(), new Class[] {Star.class}, handler);

    proxy.sing();
  }
Exemple #10
0
  public void update(long dt) {
    float movement = (((float) dt) / 20000) * Constants.sGameSpeed;

    for (Star star : mStars) {
      star.mAge += dt;
      star.mX *= 1f + movement;
      star.mY *= 1f + movement;
      if (star.mX < -0.5f || 0.5f < star.mX || star.mY < -0.5f || 0.5f < star.mY) {
        star.reset();
      }
    }
  }
 public void drawStar(Graphics g) {
   // draws the stars
   for (Star i : starList) {
     g.drawImage(
         i.getPics().get(i.getCounter()), i.getX(), i.getY(), i.getWidth(), i.getHeight(), null);
     i.count();
   }
 }
Exemple #12
0
  @Before
  public void init() {

    Nonterminal X = Nonterminal.withName("X");

    Nonterminal A = Nonterminal.withName("A");
    Nonterminal B = Nonterminal.withName("B");
    Nonterminal C = Nonterminal.withName("C");

    Rule r1 =
        Rule.withHead(X)
            .addSymbol(Nonterminal.builder(A).setLabel("a").build())
            .addSymbol(
                Star.builder(
                        Sequence.builder(
                                Code.code(
                                    Nonterminal.builder(B)
                                        .addPreCondition(predicate(equal(rExt("a"), lExt("b"))))
                                        .build(),
                                    stat(println(lExt("b")))),
                                Code.code(
                                    Nonterminal.builder(C).setLabel("b").build(),
                                    stat(println(var("b")))))
                            .build())
                    .setLabel("b")
                    .build())
            .build();

    Rule r2 = Rule.withHead(A).addSymbol(Terminal.from(Character.from('a'))).build();
    Rule r3 = Rule.withHead(B).addSymbol(Terminal.from(Character.from('b'))).build();
    Rule r4 = Rule.withHead(C).addSymbol(Terminal.from(Character.from('c'))).build();

    grammar = Grammar.builder().addRules(r1, r2, r3, r4).build();
  }
 @Override
 public Expression visit(Star star) {
   Star result = new Star();
   if (star.getExpr().getClass() == Choice.class) {
     String name = "star" + Integer.toString(count);
     count++;
     Nonterminal nt = new Nonterminal(name);
     Expression exp = star.getExpr().accept(this);
     newRules.put(nt, exp);
     result.setExpr(nt);
   } else {
     Expression exp = star.getExpr().accept(this);
     result.setExpr(exp);
   }
   return result;
 }
Exemple #14
0
  public ClientGUI(Client c) throws LWJGLException {
    this.client = c;
    // this.mesh = new Mesh();
    try {
      xFighterObject = WavefrontLoader.loadWavefrontObject(new File("xwing.obj"));
    } catch (IOException e1) {
      e1.printStackTrace();
    }
    for (int i = 0; i < 500; i++) {
      stars.add(
          new Star(
              (float) (Math.random() - .5f) * 50f,
              (float) (Math.random() - .5f) * 50f,
              (float) (Math.random() - .5f) * 50f));
    }
    Display.setDisplayMode(new DisplayMode(768, 768));
    Display.create();
    // Display.setLocation(0, 1050);

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    double aspect = 1f;
    GL11.glFrustum(
        -horizontalTan, horizontalTan, aspect * -horizontalTan, aspect * horizontalTan, 1, 100000);
    GL11.glEnable(GL11.GL_DEPTH_TEST);

    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_COLOR_MATERIAL);
    GL11.glEnable(GL11.GL_LIGHT0);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glShadeModel(GL11.GL_SMOOTH);

    // GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);

    while (!Display.isCloseRequested()) {
      for (ClientPlayer p : client.getPlayers()) {
        p.update();
      }

      GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
      GL11.glMatrixMode(GL11.GL_MODELVIEW);
      GL11.glLoadIdentity();

      GL11.glTranslatef(0, -.5f, -5f);
      GL11.glRotatef(6, 1, 0, 0);
      ClientPlayer me = client.getPlayers().get(client.getClientID());
      if (me != null) {
        GL11.glMultMatrix(me.laggedMatrix);
      }

      GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, light);
      GL11.glLight(GL11.GL_LIGHT0, GL11.GL_AMBIENT, lightAmbient);
      GL11.glLight(GL11.GL_LIGHT0, GL11.GL_DIFFUSE, lightDiffuse);

      GL11.glLight(GL11.GL_LIGHT1, GL11.GL_POSITION, lightB);
      GL11.glLight(GL11.GL_LIGHT1, GL11.GL_DIFFUSE, lightDiffuseB);

      GL11.glLight(GL11.GL_LIGHT2, GL11.GL_POSITION, lightC);
      GL11.glLight(GL11.GL_LIGHT2, GL11.GL_DIFFUSE, lightDiffuseC);

      GL11.glColor3f(1f, 1f, 0f);
      for (Star s : stars) {
        s.render();
      }

      GL11.glEnable(GL11.GL_TEXTURE_2D);
      for (ClientPlayer p : client.getPlayers()) {
        GL11.glPushMatrix();
        GL11.glMultMatrix(p.currentMatrix);
        GL11.glRotatef(180, 0, 1, 0);
        GL11.glColor3f(1f, 1f, 1f);
        xFighterObject.render();
        GL11.glColor3f(1f, 0f, 0f);
        // xFighterObject.renderBoundingBox();

        GL11.glPopMatrix();
      }
      GL11.glDisable(GL11.GL_TEXTURE_2D);

      Display.update();
      Display.sync(60);
      byte keystate = 0;
      if (Keyboard.isKeyDown(Keyboard.KEY_D)) {
        keystate |= PacketInfo.KEY_ROLL_LEFT_MASK;
      }
      if (Keyboard.isKeyDown(Keyboard.KEY_A)) {
        keystate |= PacketInfo.KEY_ROLL_RIGHT_MASK;
      }
      if (Keyboard.isKeyDown(Keyboard.KEY_W)) {
        keystate |= PacketInfo.KEY_PITCH_DOWN_MASK;
      }
      if (Keyboard.isKeyDown(Keyboard.KEY_S)) {
        keystate |= PacketInfo.KEY_PITCH_UP_MASK;
      }
      if (Keyboard.isKeyDown(Keyboard.KEY_Q)) {
        keystate |= PacketInfo.KEY_ACCEL_UP_MASK;
      }
      if (Keyboard.isKeyDown(Keyboard.KEY_E)) {
        keystate |= PacketInfo.KEY_ACCEL_DOWN_MASK;
      }
      if (keystate != me.getKeyState()) {
        me.localUpdateKeystate(keystate, System.currentTimeMillis());
        try {
          client.sendKeyStates(keystate);
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
    }
  }
 public void checkStarCollision() {
   for (Star s : starList) {
     if (s.getOnScreen()) { // if the star is on the screen we need to check if player collides
       if (s.checkCollision(
           s.getPics().get(s.getCounter()),
           player1)) { // if the player collides with the star we remove it then change the
         // velosity to the distance that the star provides
         sRemove.add(s); // remove star once you collide with it
         player1.setVelo(s.getDist()); // changes the velocity
         player1.setInvi(true); // sets the player invisble for a few seconds
         score += s.getPoints(); // points increase by the star type
         if (musicOn) {
           starSound.play(); // playthe star sound
         }
       }
     } else {
       sRemove.add(s); // remove the star if its not on the screen
     }
   }
   for (Star s : sRemove) {
     poofList.add(new Poof(s.getX(), s.getY(), s.getNum() + 3)); // make the poof effect
     starList.remove(s);
   }
   sRemove = new ArrayList<Star>();
 }
Exemple #16
0
  private static void mainMenu() {
    System.out.println("\n\nWhat do you want to do?");
    System.out.println("1. Search movies by actor");
    System.out.println("2. Add a star");
    System.out.println("3. Add a customer");
    System.out.println("4. Delete a customer");
    System.out.println("5. Provide metadata");
    System.out.println("6. Run custom SQL query");
    System.out.println("7. Logout");
    System.out.println("\nPlease make a choice");
    choice = inp.nextInt();
    switch (choice) {
      case 1:
        System.out.println(" Please enter a name: ");
        String a = inp.nextLine();
        searchmovies(a);
        break;

      case 2: // Insert a new star to database
        BufferedReader br1 = new BufferedReader(new InputStreamReader(System.in));
        System.out.println("Adding Star...");
        System.out.println(" Please enter the id: ");
        int id1;
        try {
          id1 = inp.nextInt();
        } catch (InputMismatchException e1) {
          System.out.println("You did not enter a number!!");
          System.out.println("Try again");
          id1 = inp.nextInt();
        }

        String[] prompts1 = {
          "Please enter a first name: ",
          "Please enter a last name: ",
          "Please enter a dob: ",
          "Please enter an photo url: ",
        };
        ArrayList<String> ar1 = new ArrayList<String>();
        for (String prompt : prompts1) {
          System.out.println(prompt);
          try {
            ar1.add(br1.readLine());
          } catch (IOException e) {
            System.out.println(e);
          }
        }

        Star star = new Star(id1, ar1.get(0), ar1.get(1), ar1.get(2), ar1.get(3));
        try {
          addstar(
              star.getId(),
              star.getFirst_name(),
              star.getLast_name(),
              star.getDob(),
              star.getPhotoURL());
        } catch (SQLException e) {
          System.out.println("Could not add star");
        }
        break;

      case 3:
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        System.out.println("Adding Customer...");
        System.out.println(" Please enter the id: ");
        int id;
        try {
          id = inp.nextInt();
        } catch (InputMismatchException e1) {
          System.out.println("You did not enter a number!!");
          System.out.println("Try again");
          id = inp.nextInt();
        }
        String[] prompts = {
          "Please enter a first name: ",
          "Please enter a last name: ",
          "Please enter a credit card number: ",
          "Please enter an address: ",
          "Please enter an email id: ",
          "Please enter the customer's password: "******"Could not add customer");
        }
        break;

      case 4:
        break;

      case 5:
        break;

      case 6:
        break;

      case 7:
        break;

      default:
        System.out.println("INVALID OPTION...");
        break;
    }
  }
 public void scrollStars() {
   for (Star i : starList) {
     i.setY(i.getY() + (int) (player1.getVelocity() * 0.3));
   }
 }
    public void map(
        LongWritable key,
        Star value,
        OutputCollector<BlockIDWritable, PairWritable> output,
        Reporter reporter)
        throws IOException {

      loc.set(value.ra, value.dec);
      int zoneNum = loc.zoneNum;
      int raNum = loc.raNum;
      p.set(value, null);

      /*
       * When the block size increases (> theta), only part of a block
       * needs to be copied to its neighbor.
       */
      output.collect(loc, p);

      /*
       * only replicate objects in the border of a block. I expect most of
       * objects don't need to be copied.
       */
      if (value.dec > zoneRanges[zoneNum][0] + theta
          && value.dec < zoneRanges[zoneNum][1] - theta
          && value.ra > blockRanges[raNum][0] + maxAlphas[zoneNum]
          && value.ra < blockRanges[raNum][1] - maxAlphas[zoneNum]) return;

      /*
       * the code below is to copy the star to some neighbors. We only
       * need to copy an object to the bottom, left, left bottom, left top
       * neighbors
       */
      value.margin = true;

      /*
       * we should treat the entire zone 0 as a block, so we only needs to
       * copy some objects at the corner to their neighbors
       */
      if (loc.zoneNum == 0) {
        /* copy the object to the right top neighbor */
        if (value.ra >= blockRanges[raNum][1] - maxAlphas[zoneNum]
            && value.ra <= blockRanges[raNum][1]
            && value.dec >= zoneRanges[zoneNum][1] - theta
            && value.dec <= zoneRanges[zoneNum][1]) {
          //					BlockIDWritable loc1 = new BlockIDWritable();
          /* raNum of objects in zone 0 is always 0,
           * we need to recalculate it. */
          //					loc1.raNum = BlockIDWritable.ra2Num(value.ra) + 1;
          //					if (loc1.raNum == numBlocks) {
          //						loc1.raNum = 0;
          //						value.ra -= 360;
          //					}
          //					loc1.zoneNum = loc.zoneNum + 1;
          ///					output.collect(loc1, p);
        }
        return;
      } else if (loc.zoneNum == numZones - 1) {
        /* copy the object to the bottom neighbor */
        if (value.dec >= zoneRanges[zoneNum][0] && value.dec <= zoneRanges[zoneNum][0] + theta) {
          /* raNum of objects in zone zoneNum - 1 is always 0,
           * we need to recalculate it. */
          loc1.raNum = BlockIDWritable.ra2Num(value.ra);
          loc1.zoneNum = loc.zoneNum - 1;
          output.collect(loc1, p);

          /* copy the object to the right bottom neighbor */
          while (value.ra >= blockRanges[loc1.raNum][1] - maxAlphas[zoneNum]
              && value.ra <= blockRanges[loc1.raNum][1]) {
            loc1.raNum++;
            if (loc1.raNum == numBlocks) {
              loc1.raNum = 0;
              value.ra -= 360;
            }
            loc1.zoneNum = loc.zoneNum - 1;
            output.collect(loc1, p);
          }
        }
        return;
      }

      boolean wrap = false;
      loc1.raNum = loc.raNum;
      /* copy the object to the right neighbor */
      while (value.ra >= blockRanges[loc1.raNum][1] - maxAlphas[zoneNum]
          && value.ra <= blockRanges[loc1.raNum][1]) {
        loc1.raNum++;
        loc1.zoneNum = loc.zoneNum;
        /*
         * when the object is copied to the right neighbor, we need to
         * be careful. we need to convert ra and raNum if ra is close to
         * 360.
         */
        if (loc1.raNum == numBlocks) {
          loc1.raNum = 0;
          value.ra -= 360;
          wrap = true;
        }
        output.collect(loc1, p);
        /* copy the object to the right bottom neighbor */
        if (value.dec >= zoneRanges[zoneNum][0] && value.dec <= zoneRanges[zoneNum][0] + theta) {
          loc1.zoneNum = loc.zoneNum - 1;
          output.collect(loc1, p);
        }
        /* copy the object to the right top neighbor */
        if (value.dec >= zoneRanges[zoneNum][1] - theta && value.dec <= zoneRanges[zoneNum][1]) {
          loc1.zoneNum = loc.zoneNum + 1;
          output.collect(loc1, p);
        }
      }
      if (wrap) {
        value.ra += 360;
      }

      /* copy the object to the bottom neighbor */
      if (value.dec >= zoneRanges[zoneNum][0] && value.dec <= zoneRanges[zoneNum][0] + theta) {
        loc1.raNum = loc.raNum;
        loc1.zoneNum = loc.zoneNum - 1;
        if (loc1.zoneNum == 0) loc1.raNum = 0;
        output.collect(loc1, p);
      }
    }