Package javax.microedition.lcdui.game

Examples of javax.microedition.lcdui.game.TiledLayer


    int tw = 20;
    int th = 20;
    int xmax = getWidth()/tw;
    int ymax = getHeight()/th;
   
    TiledLayer frontLayer = new TiledLayer(lenght,ymax,tile,tw,th);
   
    int caveSize=(getHeight() * 1)/3;
    int caveGeneratorPos = getHeight()/2;
    int caveGeneratorSpeed=2;
    int caveGeneratorRandomSpeedReverse=10;
    int caveGeneratorRandomSpeedChange=35;
   
    // generate new terain to the empty part on the right
   
    int h = getHeight();
    int w = getWidth();
   
    for(int i=0;i<lenght;++i)
    {
      if(rnd.nextLong()%(100)<caveGeneratorRandomSpeedReverse) caveGeneratorSpeed=-caveGeneratorSpeed;
      if(rnd.nextLong()%(100)<caveGeneratorRandomSpeedChange)
      {
        caveGeneratorSpeed+= (rnd.nextLong()%(2)==0?-1:1);
        if(caveGeneratorSpeed>=3 || caveGeneratorSpeed<=-3) caveGeneratorSpeed=0;
      }

      if(caveGeneratorPos>=h || caveGeneratorPos<0) caveGeneratorSpeed=-caveGeneratorSpeed;
      caveGeneratorPos += caveGeneratorSpeed;
     
      for(int j=0 ;j<(caveGeneratorPos-(caveSize/2))/th;++j) frontLayer.setCell(i,j,1);
      for(int j=(caveGeneratorPos+(caveSize/2))/th ;j<ymax;++j) frontLayer.setCell(i,j,1);
    }
   
    return frontLayer;
  }
View Full Code Here

TOP

Related Classes of javax.microedition.lcdui.game.TiledLayer

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.