Package org.mt4j.util

Examples of org.mt4j.util.MTColor


  public AirHockeyScene(MTApplication mtApplication, String name) {
    super(mtApplication, name);
    this.app = mtApplication;
//    this.setClearColor(new MTColor(120,150,150));
//    this.setClearColor(new MTColor(190, 190, 170, 255));
    this.setClearColor(new MTColor(0, 0, 0, 255));
//    this.setClearColor(new MTColor(40, 40, 40, 255));
    this.registerGlobalInputProcessor(new CursorTracer(app, this));
   
    this.scorePlayer1 = 0;
    this.scorePlayer2 = 0;
   
    float worldOffset = 10; //Make Physics world slightly bigger than screen borders
    //Physics world dimensions
    AABB worldAABB = new AABB(new Vec2(-worldOffset, -worldOffset), new Vec2((app.width)/scale + worldOffset, (app.height)/scale + worldOffset));
    Vec2 gravity = new Vec2(0, 0);
    boolean sleep = true;
    //Create the pyhsics world
    this.world = new World(worldAABB, gravity, sleep);
   
    //Update the positions of the components according the the physics simulation each frame
    this.registerPreDrawAction(new UpdatePhysicsAction(world, timeStep, constraintIterations, scale));
   
    physicsContainer = new MTComponent(app);
    //Scale the physics container. Physics calculations work best when the dimensions are small (about 0.1 - 10 units)
    //So we make the display of the container bigger and add in turn make our physics object smaller
    physicsContainer.scale(scale, scale, 1, Vector3D.ZERO_VECTOR);
    this.getCanvas().addChild(physicsContainer);
   
    //Create borders around the screen
    this.createScreenBorders(physicsContainer);
   
    //Create gamefield marks
    MTLine line = new MTLine(mtApplication, mtApplication.width/2f/scale, 0, mtApplication.width/2f/scale, mtApplication.height/scale);
    line.setPickable(false);
//    line.setStrokeColor(new MTColor(0,0,0));
    line.setStrokeColor(new MTColor(150,150,150));
    line.setStrokeWeight(0.5f);
    physicsContainer.addChild(line);
   
    MTEllipse centerCircle = new MTEllipse(mtApplication, new Vector3D(mtApplication.width/2f/scale, mtApplication.height/2f/scale), 80/scale, 80/scale);
    centerCircle.setPickable(false);
    centerCircle.setNoFill(true);
//    centerCircle.setStrokeColor(new MTColor(0,0,0));
    centerCircle.setStrokeColor(new MTColor(150,150,150));
    centerCircle.setStrokeWeight(0.5f);
    physicsContainer.addChild(centerCircle);
   
    MTEllipse centerCircleInner = new MTEllipse(mtApplication, new Vector3D(mtApplication.width/2f/scale, mtApplication.height/2f/scale), 10/scale, 10/scale);
    centerCircleInner.setPickable(false);
    centerCircleInner.setFillColor(new MTColor(160,160,160));
//    centerCircleInner.setStrokeColor(new MTColor(150,150,150));
//    centerCircleInner.setStrokeColor(new MTColor(0,0,0));
    centerCircleInner.setStrokeColor(new MTColor(150,150,150));
    centerCircleInner.setStrokeWeight(0.5f);
    physicsContainer.addChild(centerCircleInner);
   
    //Create the paddles
    PImage paddleTex = mtApplication.loadImage(imagesPath + "paddle.png");
    redCircle = new Paddle(app, new Vector3D(mtApplication.width - 60, mtApplication.height/2f), 50, world, 1.0f, 0.3f, 0.4f, scale);
    redCircle.setTexture(paddleTex);
    redCircle.setFillColor(new MTColor(255,50,50));
    redCircle.setNoStroke(true);
    redCircle.setName("red");
    redCircle.setPickable(false);
    physicsContainer.addChild(redCircle);
   
    blueCircle = new Paddle(app, new Vector3D(80, mtApplication.height/2f), 50, world, 1.0f, 0.3f, 0.4f, scale);
    blueCircle.setTexture(paddleTex);
    blueCircle.setFillColor(new MTColor(50,50,255));
    blueCircle.setNoStroke(true);
    blueCircle.setName("blue");
    blueCircle.setPickable(false);
    physicsContainer.addChild(blueCircle);
   
    //Create the ball
    ball = new HockeyBall(app, new Vector3D(mtApplication.width/2f, mtApplication.height/2f), 38, world, 0.5f, 0.005f, 0.70f, scale);
//    MTColor ballCol = new MTColor(0,255,0);
//    ball.setFillColor(ballCol);
    PImage ballTex = mtApplication.loadImage(imagesPath + "puk.png");
    ball.setTexture(ballTex);
//    ball.setFillColor(new MTColor(160,160,160,255));
    ball.setFillColor(new MTColor(255,255,255,255));
    ball.setNoStroke(true);
    ball.setName("ball");
    physicsContainer.addChild(ball);
    ball.getBody().applyImpulse(new Vec2(ToolsMath.getRandom(-8f, 8),ToolsMath.getRandom(-8, 8)), ball.getBody().getWorldCenter());
   
    //Create the GOALS
    HockeyGoal goal1 = new HockeyGoal(new Vector3D(0, mtApplication.height/2f), 50, mtApplication.height/4f, mtApplication, world, 0.0f, 0.1f, 0.0f, scale);
    goal1.setName("goal1");
    goal1.setFillColor(new MTColor(0,0,255));
    goal1.setStrokeColor(new MTColor(0,0,255));
    physicsContainer.addChild(goal1);
   
    HockeyGoal goal2 = new HockeyGoal(new Vector3D(mtApplication.width, mtApplication.height/2f), 50, mtApplication.height/4f, mtApplication, world, 0.0f, 0.1f, 0.0f, scale);
    goal2.setName("goal2");
    goal2.setFillColor(new MTColor(255,0,0));
    goal2.setStrokeColor(new MTColor(255,0,0));
    physicsContainer.addChild(goal2);
   
    //Make two components for both game field sides to drag the puks upon
    MTRectangle leftSide = new MTRectangle(
        PhysicsHelper.scaleDown(0, scale), PhysicsHelper.scaleDown(0, scale),
        PhysicsHelper.scaleDown(app.width/2f, scale), PhysicsHelper.scaleDown(app.height, scale)
        , app);
    leftSide.setName("left side");
    leftSide.setNoFill(true); //Make it invisible -> only used for dragging
    leftSide.setNoStroke(true);
    leftSide.unregisterAllInputProcessors();
    leftSide.removeAllGestureEventListeners(DragProcessor.class);
    leftSide.registerInputProcessor(new DragProcessor(app));
    leftSide.addGestureListener(DragProcessor.class, new GameFieldHalfDragListener(blueCircle));
    physicsContainer.addChild(0, leftSide);
    MTRectangle rightSide = new MTRectangle(
        PhysicsHelper.scaleDown(app.width/2f, scale), PhysicsHelper.scaleDown(0, scale),
        PhysicsHelper.scaleDown(app.width, scale), PhysicsHelper.scaleDown(app.height, scale)
        , app);
    rightSide.setName("right Side");
    rightSide.setNoFill(true); //Make it invisible -> only used for dragging
    rightSide.setNoStroke(true);
    rightSide.unregisterAllInputProcessors();
    rightSide.removeAllGestureEventListeners(DragProcessor.class);
    rightSide.registerInputProcessor(new DragProcessor(app));
    rightSide.addGestureListener(DragProcessor.class, new GameFieldHalfDragListener(redCircle));
    physicsContainer.addChild(0, rightSide);
   
    //Display Score UI
    MTComponent uiLayer = new MTComponent(mtApplication, new MTCamera(mtApplication));
    uiLayer.setDepthBufferDisabled(true);
    getCanvas().addChild(uiLayer);
    IFont font = FontManager.getInstance().createFont(mtApplication, "arial", 50, new MTColor(255,255,255), new MTColor(0,0,0));
   
    t1 = new MTTextArea(mtApplication, font);
    t1.setPickable(false);
    t1.setNoFill(true);
    t1.setNoStroke(true);
View Full Code Here


//    this.fontSize         = 50;
//    this.unitsPerEm = f.getHeadTable().getUnitsPerEm();
  }

  public VectorFont createFont(PApplet pa, String fontFileName){
    return this.createFont(pa, fontFileName, 50, new MTColor(0,0,0,255), new MTColor(0,0,0,255));
  }
View Full Code Here

      character.xRotate(new Vector3D((float)(xadv/2.0),0,0), 180);
      character.scale((float)(1.0/(float)this.unitsPerEm), new Vector3D(0,0,0));
      character.scale(fontSize , new Vector3D(0,0,0));
       */

      character.setStrokeColor(new MTColor(strokeColor));
      character.setFillColor(new MTColor(fillColor));
     
      if (MT4jSettings.getInstance().isOpenGlMode())
        character.generateAndUseDisplayLists();
     
      return character;
View Full Code Here

    int charIndex = cmapFmt.mapCharCode(charCodeMapIndex);
    int default_advance_x   = f.getHmtxTable().getAdvanceWidth(charIndex);
   
    Glyph glyph  = f.getGlyph(charIndex);
    if (glyph != null){
      VectorFontCharacter character = this.getGlyphAsShape(f, glyph, charIndex, 0, new MTColor(0,0,0,255), new MTColor(0,0,0,255));
      if (character != null){
        character.setHorizontalDist(default_advance_x);
        return character;
      }else{
        return null;
View Full Code Here

   */
  private void init(float x, float y, float width, float height){
//    this.setNoFill(true);
    this.setNoStroke(true);
//    this.setFillColor(new MTColor(255,100,100,100));
    this.setFillColor(new MTColor(255,255,255,150));
//    this.unregisterAllInputProcessors();
//    this.setPickable(false);
   
    overlayGroup = new MTOverlayContainer(app, "Window Menu Overlay Group");
   
    if (menuImage == null){
      menuImage = app.loadImage(MT4jSettings.getInstance().getDefaultImagesPath() +
          "blackRoundSolidCorner64sh2.png");
         
    }
   
    if (MT4jSettings.getInstance().isOpenGlMode()){
//      GLTextureParameters tp = new GLTextureParameters();
//      tp.wrap_s = GL.GL_CLAMP;
//      tp.wrap_t = GL.GL_CLAMP;
////      GLTexture glTex = new GLTexture(app, MT4jSettings.getInstance().getDefaultImagesPath()+
////          "blackRoundSolidCorner64sh2.png", tp);
//      GLTexture glTex = new GLTexture(app, menuImage.width, menuImage.height, tp);
//      glTex.putPixelsIntoTexture(menuImage);
//      this.setTexture(glTex);
     
      GLTextureSettings ts = new GLTextureSettings();
      ts.wrappingHorizontal = WRAP_MODE.CLAMP;
      ts.wrappingVertical = WRAP_MODE.CLAMP;
      GLTexture glTex = new GLTexture(app, menuImage.width, menuImage.height, ts);
      glTex.loadGLTexture(menuImage);
      this.setTexture(glTex);
    }else{
      this.setTexture(menuImage);
    }
   
    AbstractShape menuShape = this;
    menuShape.unregisterAllInputProcessors();
    menuShape.removeAllGestureEventListeners(DragProcessor.class);
    menuShape.registerInputProcessor(new DragProcessor(app));
   
    float buttonWidth = 80;
    float buttonHeight = 80;
    final float buttonOpacity = 170;
   
    //CLOSE BUTTON
//    Vector3D a = new Vector3D(-width * 1.2f, height/2f);
    Vector3D a = new Vector3D(-width * 1.55f, 0);
    a.rotateZ(PApplet.radians(80));
    final MTRectangle closeButton = new MTRectangle(x + a.x, y + a.y, buttonWidth, buttonHeight, app);
   
    if (closeButtonImage == null){
      closeButtonImage = app.loadImage(MT4jSettings.getInstance().getDefaultImagesPath() +
//          "close_32.png"));
//          "126182-simple-black-square-icon-alphanumeric-circled-x3_cr.png"));
//          "124241-matte-white-square-icon-alphanumeric-circled-x3_cr.png");
          "closeButton64.png");
    }
   
    closeButton.setTexture(closeButtonImage);
    closeButton.setFillColor(new MTColor(255, 255, 255, buttonOpacity));
    closeButton.setNoStroke(true);
    closeButton.setVisible(false);
    this.addChild(closeButton);
   
    //Check if this menu belongs to a window Scene (MTSceneWindow)
    //or was added to a normal scene
    //-> if its not a windowed scene we dont display the Restore button
    if (this.windowedScene){
      //RESTORE BUTTON
      Vector3D b = new Vector3D(-width * 1.55f, 0);
      b.rotateZ(PApplet.radians(10));
      final MTRectangle restoreButton = new MTRectangle(x + b.x, y + b.y, buttonWidth, buttonHeight, app);
     
      if (restoreButtonImage == null){
        restoreButtonImage = app.loadImage(MT4jSettings.getInstance().getDefaultImagesPath() +
//            "window_app_32.png"));
//            "126630-simple-black-square-icon-business-document10-sc1_cr.png");
    //        restoreButton.setFillColor(new MTColor(150, 150, 250, 200));
            "restoreButton64.png");
      }
     
      restoreButton.setTexture(restoreButtonImage);
      restoreButton.setFillColor(new MTColor(255, 255, 255, buttonOpacity));
      restoreButton.setNoStroke(true);
      restoreButton.setVisible(false);
      this.addChild(restoreButton);
     
      menuShape.addGestureListener(DragProcessor.class, new IGestureEventListener() {
View Full Code Here

* Highlight button.
*
* @param shape the shape
*/
private void highlightButton(AbstractShape shape){
    MTColor c = shape.getFillColor();
    c.setAlpha(255);
    shape.setFillColor(c);
  }
View Full Code Here

   *
   * @param shape the shape
   * @param opacity the opacity
   */
  private void unhighlightButton(AbstractShape shape, float opacity){
    MTColor c = shape.getFillColor();
    c.setAlpha(opacity);
    shape.setFillColor(c);
  }
View Full Code Here

   
    // INIT FIELDS
    //Load the Key font
    keyFont = FontManager.getInstance().createFont(pa,
        "keys.svg", 30,
        new MTColor(0,0,0,255),
        new MTColor(0,0,0,255));
//        new MTColor(250,250,250,255),
//        new MTColor(250,250,250,255));
   
    keyList     = new ArrayList<MTKey>();
    shiftChangers   = new ArrayList<MTKey>();
View Full Code Here

    buttonBackGround.setPickable(false);
    buttonBackGround.setStrokeWeight(1.0f);
    buttonBackGround.setDrawSmooth(false);
    buttonBackGround.setNoFill(false);
    buttonBackGround.setNoStroke(true);
    buttonBackGround.setStrokeColor(new MTColor(210, 210, 210, 255));
    buttonBackGround.setFillColor(new MTColor(220, 220, 220, 255));
    //change drawmode to polygon, triangle fan doesent work (!?)
    buttonBackGround.setFillDrawMode(GL.GL_POLYGON);
//    buttonBackGround.scaleGlobal(0.95f, 0.95f, 1, buttonBackGround.getCenterPointGlobal());
  }
View Full Code Here

   *
   * @param pApplet the applet
   */
  public MTTextKeyboard(PApplet pApplet) {
    this(pApplet, FontManager.getInstance().createFont(pApplet,
        "arial.ttf", 35, new MTColor(0,0,0,255), new MTColor(0,0,0,255)));
//    this(pApplet, FontManager.getInstance().createFont(pApplet, "Eureka90.vlw", 35, new Color(0,0,0,255), new Color(0,0,0,255)));
//    this(pApplet, FontManager.getInstance().createFont(pApplet, "arial", 35, new Color(0,0,0,255), new Color(0,0,0,255)));
  }
View Full Code Here

TOP

Related Classes of org.mt4j.util.MTColor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.