亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? gamescreen.java

?? 大量j2me源代碼
?? JAVA
字號:
import javax.microedition.lcdui.*;
import java.util.Vector;

/**
 * The main drawing and control class for the game Road Run.
 * @author Martin J. Wells
 */
public class GameScreen extends Canvas implements Runnable
{
   private RoadRun theMidlet;
   private int cps;
   private int cyclesThisSecond;
   private long lastCPSTime = 0;
   private long lastCycleTime;
   private Vector actorList;
   private WombatActor wombat;

   // Rendering setup
   private static int statusLineHeight = 10;
   private int laneHeight = 0;
   private static final int topMargin = 3;

   // Game state
   private Image offScreenBuffer;
   private boolean running=true;

   /**
    * Constructor for a GameScreen.
    * @param midlet A reference to the MIDlit controlling the game.
    */
   public GameScreen(RoadRun midlet)
   {
      theMidlet = midlet;

      // create the game thread
      Thread t = new Thread(this);
      t.start();

      initResources();
   }

   /**
    * convenience method to return the y position of a lane number
    * @param lane The lane position
    * @return The y postiion of the given lane
    */
   public int getLaneYPos(int lane)
   {
      return (lane * laneHeight) + 1 + topMargin;
   }

   /**
    * Initialize the resources for the game. Should be called to setup the game
    * for play.
    */
   private void initResources()
   {
      offScreenBuffer = Image.createImage(getWidth(), getHeight());
      int heightMinusStatus = getHeight() - statusLineHeight;
      laneHeight = ((heightMinusStatus) / 9);

      actorList = new Vector();

      // add the actors
      wombat = new WombatActor(this, getWidth() / 2, getLaneYPos(8));
      actorList.addElement( wombat );

      // add a car
      for (int i=1; i < 4; i++)
      {
         actorList.addElement(new TruckActor(this, 1, getLaneYPos(i), (i * 2) + 1));
         actorList.addElement(new CarActor(this, getWidth()/2, getLaneYPos(i), (i*2)+1));
      }

      for (int i = 5; i < 8; i++)
      {
         actorList.addElement(new TruckActor(this, 0, getLaneYPos(i), i));
         actorList.addElement(new CarActor(this, getWidth() / 2, getLaneYPos(i), i));
      }
   }

   /**
    * Number of cycles we want to have per second.
    */
   private static final int MAX_CPS = 50;

   /**
    * The number of milliseconds allowed per cycle/frame.
    */
   private static final int MS_PER_FRAME = 1000 / MAX_CPS;

   /**
    * Called when thread is started. Controls the main game loop including the
    * framerate based on the timing set in MS_PER_FRAME. On every cycle it
    * calls the cycle and repaint methods.
    */
   public void run()
   {
      while(running)
      {
         // remember the starting time
         long cycleStartTime = System.currentTimeMillis();

         // run the cycle
         cycle();
         repaint();

         // update the CPS
         if (System.currentTimeMillis() - lastCPSTime > 1000)
         {
            lastCPSTime=System.currentTimeMillis();
            cps = cyclesThisSecond;
            cyclesThisSecond = 0;
         } else
            cyclesThisSecond++;

         // Here we calculate how much time has been used so far this cycle. If
         // it is less than the amount of time we should have spent then we
         // sleep a little to let the MIDlet get on with other work.
         long timeSinceStart = (cycleStartTime - System.currentTimeMillis());
         if (timeSinceStart < MS_PER_FRAME)
         {
            try
            {
               Thread.sleep(MS_PER_FRAME - timeSinceStart);
            }
            catch(java.lang.InterruptedException e)
            { }
         }
      }

      // If we've reached this point then the running boolean has been set to
      // false by something (such as a quit command) and it's time to fall back
      // to the menu system. The gameOver method displays an alert telling the
      // user their time has come and then returns to the menu.
      theMidlet.gameOver();
   }

   /**
    * Handles the cycling of all the Actors in the world by calculating the
    * elapsed time and then call the cycle method on all Actors in the local
    * Vector. At the end this method also checks to see if any Actor struck
    * the Wombat.
    */
   protected void cycle()
   {
      if (lastCycleTime > 0)
      {
         long msSinceLastCycle = System.currentTimeMillis() - lastCycleTime;

         // cycle all the actors
         for (int i = 0; i < actorList.size(); i++)
         {
            Actor a = (Actor) actorList.elementAt(i);
            a.cycle((int)msSinceLastCycle);

            // check if any hit the wombat
            if (a.isCollidingWith(wombat) && a != wombat)
               running = false;
         }

      }
      lastCycleTime = System.currentTimeMillis();
   }

   /**
    * Draws the background graphics for the game using rudimentary drawing
    * tools. Note that we draw to the offscreenBuffer graphics (osg) not the
    * screen. The offscreenBuffer is an image the size of the screen we render
    * to and then later "flip" (draw) onto the display in one go (see the paint
    * method).
    */
   private void renderWorld()
   {
      // grab our off-screen graphics context
      Graphics osg = offScreenBuffer.getGraphics();
      int y=0;

      // draw the top roadside
      osg.setColor(0x00209020);
      y += (laneHeight)+topMargin;
      osg.fillRect(0, 0, getWidth(), y);

      // kirb edge
      osg.setColor(0x00808080);
      osg.drawLine(0, y-2, getWidth(), y-2);
      osg.setColor(0x00000000);
      osg.drawLine(0, y-1, getWidth(), y-1);

      // draw the first three lanes
      osg.setColor(0x00000000);
      osg.fillRect(0, y, getWidth(), laneHeight * 3);

      // draw the line markings on the road
      osg.setStrokeStyle(Graphics.DOTTED);
      osg.setColor(0x00AAAAAA);
      y += laneHeight; osg.drawLine(0, y, getWidth(), y);
      y += laneHeight; osg.drawLine(0, y, getWidth(), y);
      y += laneHeight; osg.drawLine(0, y, getWidth(), y);

      // draw the middle safety strip
      osg.setColor(0x00666666);
      osg.fillRect(0, y-2, getWidth(), 2);
      osg.setColor(0x00aaaaaa);
      osg.fillRect(0, y, getWidth(), laneHeight); y+= laneHeight;
      osg.setColor(0x00666666);
      osg.fillRect(0, y - 2, getWidth(), 2);

      // draw the next three lanes
      osg.setColor(0x00000000);
      osg.fillRect(0, y, getWidth(), laneHeight * 3);

      // draw the line markings on the road
      osg.setStrokeStyle(Graphics.DOTTED);
      osg.setColor(0x00AAAAAA);
      y += laneHeight; osg.drawLine(0, y, getWidth(), y);
      y += laneHeight; osg.drawLine(0, y, getWidth(), y);
      y += laneHeight; osg.drawLine(0, y, getWidth(), y);

      // curb edge
      osg.setStrokeStyle(Graphics.SOLID);
      osg.setColor(0x00808080);
      osg.drawLine(0, y, getWidth(), y);
      y++;
      osg.setColor(0x00000000);
      osg.drawLine(0, y, getWidth(), y);

      // draw the bottom roadside
      osg.setColor(0x00209020);
      osg.fillRect(0, y, getWidth(), y + (laneHeight * 2));
      y += laneHeight * 2;

      // draw the status bar along the bottom
      osg.setColor(0, 0, 128);
      osg.fillRect(0, getHeight() - statusLineHeight, getWidth(), getHeight());
      osg.setFont(Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_PLAIN, Font.SIZE_SMALL));
      osg.setColor(0x00ffffff);

      osg.setColor(0x00ffffff);
      osg.drawString("" + cps + " cps", 5, getHeight() - statusLineHeight + 1,
                     Graphics.LEFT | Graphics.TOP);

      // now draw all the actors
      for (int i=0; i < actorList.size(); i++)
      {
         Actor a = (Actor)actorList.elementAt(i);
         a.render(osg);
      }
   }

   /**
    * Canvas overridden paint method that calls the renderWorld method (which
    * draws to the offscreenBuffer) and then draws the offscreenBuffer image
    * onto the display.
    * @param graphics The graphics context of the Canvas.
    */
   protected void paint(Graphics graphics)
   {
      renderWorld();
      graphics.drawImage(offScreenBuffer, 0, 0, Graphics.LEFT | Graphics.TOP);
   }

   /**
    * @return The height of a lane.
    */
   public int getLaneHeight()
   {
      return laneHeight;
   }

   /**
    * Called when a key is pressed. Based on which key they hit it moves the
    * WombatActor.
    * @param keyCode The key that was pressed.
    */
   protected void keyPressed(int keyCode)
   {
      switch (getGameAction(keyCode))
      {
         case UP:
            wombat.setY( wombat.getY() - laneHeight );
            break;
         case DOWN:
            wombat.setY(wombat.getY() + laneHeight);
            break;
         case RIGHT:
            wombat.setX(wombat.getX() + laneHeight);
            break;
         case LEFT:
            wombat.setX(wombat.getX() - laneHeight);
            break;
      }
   }

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩av二区在线播放| 国产成人免费9x9x人网站视频| 亚洲自拍偷拍av| 天堂va蜜桃一区二区三区漫画版| 免费高清在线视频一区·| 极品销魂美女一区二区三区| 高清久久久久久| 欧美专区亚洲专区| 精品国产一二三区| 中文字幕日韩欧美一区二区三区| 亚洲午夜免费电影| 国产一区二区久久| 欧美亚洲高清一区| www久久精品| 一区二区三区不卡在线观看 | eeuss鲁片一区二区三区在线观看| 在线视频一区二区免费| 精品国产乱子伦一区| 亚洲男人电影天堂| 九色综合狠狠综合久久| 色综合咪咪久久| 精品久久久网站| 亚洲最快最全在线视频| 国产麻豆日韩欧美久久| 欧美性猛交一区二区三区精品| 久久久天堂av| 亚洲成av人片一区二区三区| 国产999精品久久久久久绿帽| 欧美精品日日鲁夜夜添| 国产精品色呦呦| 免费成人结看片| 色久综合一二码| 中文字幕乱码日本亚洲一区二区 | 色八戒一区二区三区| 欧美videos中文字幕| 亚洲精品久久嫩草网站秘色| 国产乱妇无码大片在线观看| 欧美中文字幕一区二区三区| 国产日产精品1区| 日韩电影网1区2区| 91麻豆福利精品推荐| 久久久久国产免费免费| 免费成人深夜小野草| 欧美丝袜丝交足nylons| 中文字幕永久在线不卡| 国内成人精品2018免费看| 欧美欧美午夜aⅴ在线观看| 亚洲欧美一区二区视频| 国产精品18久久久久| 在线不卡一区二区| 一区二区三区在线观看欧美 | 一区二区三区在线视频观看58| 国产91露脸合集magnet| 精品成人在线观看| 蜜臀av一区二区| 91麻豆精品国产91久久久久| 一区二区三区在线看| 欧美体内she精高潮| 国产精品污www在线观看| 国产呦精品一区二区三区网站| 69堂成人精品免费视频| 亚洲成a人片综合在线| 在线国产电影不卡| 亚洲一区二区三区四区五区黄| 色香色香欲天天天影视综合网 | 色一情一乱一乱一91av| 亚洲图片激情小说| www..com久久爱| 国产精品免费久久久久| 国产一区二区成人久久免费影院| 日韩欧美一级二级| 免费成人深夜小野草| 欧美一级爆毛片| 美女一区二区视频| 精品少妇一区二区三区在线播放| 久久超碰97人人做人人爱| 精品蜜桃在线看| 国产精品2024| 中文字幕一区二区三中文字幕| 成a人片国产精品| 亚洲日本va在线观看| 91免费观看视频| 亚洲一区二区三区精品在线| 欧美日韩视频不卡| 捆绑调教美女网站视频一区| 精品乱码亚洲一区二区不卡| 韩国三级中文字幕hd久久精品| 久久免费美女视频| 成人av综合在线| 亚洲免费av在线| 国产一区久久久| 亚洲最大成人综合| 久久免费的精品国产v∧| 亚洲人妖av一区二区| av高清久久久| 亚洲卡通动漫在线| 国产91丝袜在线观看| 亚洲欧洲精品一区二区三区不卡| 成人av在线一区二区三区| 国产精品每日更新| 色婷婷av一区二区三区大白胸| 一区二区三区四区国产精品| 欧美亚洲动漫精品| 亚洲成a人片在线观看中文| 678五月天丁香亚洲综合网| 日韩av电影免费观看高清完整版在线观看| 欧美三级三级三级| 五月天一区二区| 日韩欧美一卡二卡| 国产成人精品免费| 自拍偷拍国产精品| 91国偷自产一区二区三区观看| 亚洲一区成人在线| 欧美mv和日韩mv国产网站| 国产成人精品免费在线| 国产拍欧美日韩视频二区| 91麻豆福利精品推荐| 亚洲最大的成人av| 欧美一区二区国产| 国产黄色精品网站| 夜夜嗨av一区二区三区网页| 日韩西西人体444www| 成人黄色免费短视频| 亚洲综合丁香婷婷六月香| 日韩一区二区免费视频| 国产夫妻精品视频| 一区二区三区在线视频播放| 欧美日韩精品一二三区| 国产麻豆精品theporn| 自拍偷拍亚洲综合| 日韩欧美激情四射| 成人性生交大片免费看在线播放| 亚洲精品国产无天堂网2021| 日韩女优电影在线观看| 91丨porny丨国产入口| 国产一区二区三区蝌蚪| 亚洲精品精品亚洲| 精品久久久三级丝袜| 一本大道久久a久久精品综合| 日本网站在线观看一区二区三区| 国产欧美日韩三级| 欧美人狂配大交3d怪物一区| 国产高清在线精品| 亚洲一级二级在线| 精品少妇一区二区三区日产乱码| 色综合天天综合网天天看片| 美洲天堂一区二卡三卡四卡视频| 国产精品久久久久久户外露出 | 麻豆成人久久精品二区三区红| 国产精品丝袜91| 色噜噜偷拍精品综合在线| 精久久久久久久久久久| 一区二区三区国产豹纹内裤在线| 精品福利一区二区三区| 日本韩国视频一区二区| 美腿丝袜亚洲三区| 亚洲午夜视频在线| 亚洲国产精品v| 日韩一级免费一区| 日本道色综合久久| 国产精品一品二品| 极品少妇一区二区| 亚洲国产成人精品视频| 国产偷国产偷精品高清尤物| 在线观看91av| 在线亚洲一区二区| 九九**精品视频免费播放| 日韩精品久久久久久| 亚洲蜜桃精久久久久久久| 久久九九全国免费| 欧美大胆一级视频| 精品久久久久久久久久久院品网| 欧美日韩日日夜夜| 欧美日韩一级片在线观看| 99久久99久久精品国产片果冻| 粉嫩av一区二区三区粉嫩| 国产中文一区二区三区| 国产真实乱偷精品视频免| 亚洲v日本v欧美v久久精品| 亚洲欧洲国产日本综合| 中文字幕一区免费在线观看| 国产亚洲一区二区三区在线观看| 久久网这里都是精品| 日韩欧美一区二区视频| 欧美va日韩va| 日韩欧美一级在线播放| 日韩精品一区在线观看| 91精品在线免费观看| 日韩欧美在线网站| 欧美日韩免费观看一区三区| 97精品国产露脸对白| 国产一区二区在线观看免费| 经典三级在线一区| 麻豆一区二区三区| 视频精品一区二区| 五月天久久比比资源色| 日韩电影在线免费看| 蜜臀av一区二区在线观看 | 国产传媒日韩欧美成人| 国产成人精品亚洲午夜麻豆|