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

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

?? tilemapper.java

?? java 結構模式
?? JAVA
字號:
package com.javapatterns.adapter.demos;
import java.awt.*;
import java.applet.*;
import java.awt.event.*;

     
/**
* TileMapper.java<p>
* Draws a simple tile based image map on the screen and allows the user
* to scroll the map with the arrow keys.
* @author Eric R. Northam (enorth1@gl.umbc.edu)
* @version 1.0 9 May 1999
*/
public class TileMapper extends Applet
{
  Image screenImage;  // Image used for double buffering and its respective
  Graphics screenGC;  // graphics context
  static final int screenWidth = 400;
  static final int screenHeight = 400;
  Image tileImage; // Use to store the image for the tiles
  static final int numTiles = 6; // The number of tiles
  static final int scrollInc = 8;  // How much pixels to move at each scroll

  int tileWidth;
  int tileImageHeight;
  int tileHeight;
  Tile[] tiles; // An array to hold all of the tiles

  static final byte[][] bgMap = {
			      {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
            {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
            {1, 1, 2, 0, 0, 0, 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
            {1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
            {1, 1, 0, 1, 1, 1, 1, 1, 5, 0, 0, 0, 0, 0, 0, 0, 0, 3, 1, 1},
            {1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1},
            {1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1},
            {1, 1, 5, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1},
            {1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1},
            {1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1},
            {1, 1, 1, 0, 1, 1, 1, 1, 2, 0, 0, 0, 0, 3, 1, 1, 1, 0, 1, 1},
            {1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1},
            {1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1},
            {1, 1, 1, 5, 0, 0, 0, 0, 4, 1, 1, 1, 1, 5, 0, 0, 0, 4, 1, 1},
            {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
            {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}};

  static final int bgmapTileWidth = 20;
  static final int bgmapTileHeight = 16;
  int bgWidth;
  int bgHeight;

  int numXtiles;
  int numYtiles;
  int mapX = 0;
  int mapY = 0;


  public void init()
  {
    addKeyListener(new KeyAdapter(){
      public void keyPressed(KeyEvent e)
      {
        int keyCode = e.getKeyCode();

        switch(e.getKeyCode()){

          case KeyEvent.VK_UP:
            scrollUp();
            break;
          case KeyEvent.VK_RIGHT:
            scrollRight();
            break;
          case KeyEvent.VK_DOWN:
            scrollDown();
            break;
          case KeyEvent.VK_LEFT:
            scrollLeft();
            break;
          case KeyEvent.VK_PAGE_UP:
            scrollUpRight();
            break;
          case KeyEvent.VK_PAGE_DOWN:
            scrollDownRight();
            break;
          case KeyEvent.VK_HOME:
            scrollUpLeft();
            break;
          case KeyEvent.VK_END:
            scrollDownLeft();
            break;
        }
        repaint();
      }
    });
  }

  /**
  * Loads an image, splits it into tiles, and then displays each of the tiles
  * diagonally.
  * note: Netscape does not properly load the applet if calls to getImage() are
  * in the init() method, so I decided to just use the start() method
  */
  public void start()
  {
    resize(screenWidth, screenHeight);
    requestFocus();
    tileImage = getImage(getDocumentBase(), "images/road.gif");

    // Wait for the image to load
    MediaTracker tracker = new MediaTracker(this);
    tracker.addImage(tileImage, 0);
    try { tracker.waitForID(0); }
    catch (InterruptedException e) {}

    // Get tile dimensions
    tileImageHeight = tileImage.getHeight(this);
    tileWidth = tileImage.getWidth(this);
    tileHeight = tileImageHeight/numTiles;

    // Get the dimensions of the map
    bgWidth = tileWidth * bgmapTileWidth;
    bgHeight = tileHeight * bgmapTileHeight;

    // Create an offsreen image for double buffering
    // Give it a border with tilesize larger than the screen
    screenImage = createImage(screenWidth + 2*tileWidth,
                              screenHeight + 2*tileHeight);
    screenGC = screenImage.getGraphics();

    // Break image into tiles.
    prepareTiles();

    // Draw the upper left portion of the map
    numXtiles = screenWidth/tileWidth;
    numYtiles = screenHeight/tileHeight;
    drawMap();

  }

  /**
  * Break the tile image into tiles
  */
  public void prepareTiles()
  {
    tiles = new Tile[numTiles];

    // Assume the tile images are arranged vertically
    for(int i = 0; i < numTiles; i++)
      tiles[i] = new Tile(tileImage, tileWidth, tileHeight, i);
  }

  /**
  * Draw a portion of the map
  */
  public void drawMap()
  {
    int curX = 0, curY = 0;
    int xInc, yInc;
    int xTile, yTile;

    // Calculate the starting matrix entry for the tiles
    xTile = mapX / tileWidth;
    yTile = mapY / tileHeight;

    // Calculate the tile increments
    xInc = mapX % tileWidth;
    yInc = mapY % tileHeight;

    // Last column or row in the map is not drawn unless the screen width or
    // height is divisible by the tile dimensions
    for(int i = 0; i <= numYtiles; i++){
      for(int j = 0; j <= numXtiles; j++){
        tiles[bgMap[yTile + i][xTile + j]].paint(screenGC, curX - xInc, curY - yInc);
        curX += tileWidth;
      }
      curY += tileHeight;
      curX = 0;
    }
    repaint();
  }

  /**
  * scroll the map up
  */
  public void scrollUp()
  {
    // First check to see if at the top of the map
    if((mapY - scrollInc) < 0)
      return;

    mapY -= scrollInc;
    drawMap();
  }

  /**
  * scroll the map down
  */
  public void scrollDown()
  {
    // First check to see if at the bottom of the map
    if((mapY + scrollInc + screenHeight) >= bgHeight)
      return;

    mapY += scrollInc;
    drawMap();
  }

  /**
  * scroll the map left
  */
  public void scrollLeft()
  {
    // First check to see if at the left of the map
    if((mapX - scrollInc) < 0)
      return;

    mapX -= scrollInc;
    drawMap();
  }

  /**
  * scroll the map right
  */
  public void scrollRight()
  {
    // First check to see if at the right of the map
    if((mapX + scrollInc + screenWidth) >= bgWidth)
      return;

    mapX += scrollInc;
    drawMap();
  }

  /**
  * scroll the map up and right
  */
  public void scrollUpRight()
  {
    // Check to see if at the top of the map
    if((mapY - scrollInc) >= 0)
      mapY -= scrollInc;

    // Check to see if at the right of the map
    if((mapX + scrollInc + screenWidth) < bgWidth)
      mapX += scrollInc;

    drawMap();
  }

  /**
  * scroll the map up and left
  */
  public void scrollUpLeft()
  {
    // Check to see if at the top of the map
    if((mapY - scrollInc) >= 0)
      mapY -= scrollInc;

    // Check to see if at the left of the map
    if((mapX - scrollInc) >= 0)
      mapX -= scrollInc;

    drawMap();
  }

  /**
  * scroll the map down and right
  */
  public void scrollDownRight()
  {
    // Check to see if at the bottom of the map
    if((mapY + scrollInc + screenHeight) < bgHeight)
      mapY += scrollInc;

    // Check to see if at the right of the map
    if((mapX + scrollInc + screenWidth) < bgWidth)
      mapX += scrollInc;

    drawMap();
  }

  /**
  * scroll the map down and left
  */
  public void scrollDownLeft()
  {
    // Check to see if at the bottom of the map
    if((mapY + scrollInc + screenHeight) < bgHeight)
      mapY += scrollInc;

    // Check to see if at the right of the map
    if((mapX - scrollInc) >= 0)
      mapX -= scrollInc;

    drawMap();
  }



  public void update(Graphics g)
  {
    paint(g);
  }

  public void paint(Graphics g)
  {
    g.drawImage(screenImage, 0, 0, null);
  }

  public void destroy()
  {
    screenGC.dispose();
  }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久久久久久久久久久久夜| 国产欧美日韩在线看| 国产成人午夜精品影院观看视频 | 中文字幕综合网| 日韩三级电影网址| 欧美三级电影在线看| 成人动漫一区二区在线| 久久精品国产色蜜蜜麻豆| 一区二区三区免费观看| 欧美国产丝袜视频| 精品99999| 7777精品伊人久久久大香线蕉| 99久久国产综合精品女不卡| 国产一区二区伦理| 青青草原综合久久大伊人精品| 亚洲精选视频在线| 欧美国产精品中文字幕| 久久综合色播五月| 日韩视频一区在线观看| 欧美久久久一区| 欧美无砖专区一中文字| 欧洲另类一二三四区| 99久久精品免费| 成人激情校园春色| 成人免费高清在线观看| 国产成人精品三级麻豆| 国精产品一区一区三区mba桃花| 日韩高清一区二区| 日韩电影在线观看一区| 日韩在线一区二区三区| 水蜜桃久久夜色精品一区的特点| 亚洲精品国产第一综合99久久 | 在线电影国产精品| 欧美色图天堂网| 欧美图片一区二区三区| 欧美在线免费视屏| 在线观看av一区二区| 欧洲激情一区二区| 在线日韩av片| 欧美日韩精品三区| 欧美三电影在线| 在线不卡的av| 91精品欧美久久久久久动漫| 亚洲综合丁香婷婷六月香| 樱花影视一区二区| 亚洲国产精品一区二区www| 亚洲3atv精品一区二区三区| 亚洲午夜精品一区二区三区他趣| 亚洲aⅴ怡春院| 开心九九激情九九欧美日韩精美视频电影| 免费黄网站欧美| 国产精品综合久久| av激情成人网| 在线亚洲+欧美+日本专区| 欧美喷水一区二区| 日韩精品一区二区三区在线| 久久精品人人做人人综合| 中文字幕一区二区三区不卡在线| 亚洲精品精品亚洲| 视频一区中文字幕| 久久精品国产网站| aa级大片欧美| 欧美日韩精品一二三区| 久久影院电视剧免费观看| 亚洲欧洲日韩一区二区三区| 亚洲成人精品一区| 国产综合色产在线精品| 91捆绑美女网站| 911精品国产一区二区在线| 26uuu精品一区二区| 亚洲欧美成人一区二区三区| 日韩在线一二三区| 福利一区福利二区| 欧美色男人天堂| 国产日产欧产精品推荐色 | 精品不卡在线视频| 中文字幕亚洲电影| 全国精品久久少妇| 丁香天五香天堂综合| 欧美三级在线视频| 国产日产亚洲精品系列| 一区二区三区在线观看国产| 麻豆成人免费电影| 欧美主播一区二区三区美女| 欧美精品一区二区三区四区| 亚洲影视在线观看| 国产1区2区3区精品美女| 欧美性生活大片视频| 久久人人97超碰com| 婷婷成人综合网| www.欧美精品一二区| 日韩欧美一区二区三区在线| 亚洲免费伊人电影| 国内偷窥港台综合视频在线播放| 91福利视频在线| 国产香蕉久久精品综合网| 日韩专区一卡二卡| 色综合久久99| 国产午夜精品在线观看| 日韩成人免费电影| 色一区在线观看| 亚洲国产经典视频| 国产又黄又大久久| 日韩午夜在线观看| 亚洲专区一二三| 99精品桃花视频在线观看| 欧美成人vps| 视频在线观看一区二区三区| 91麻豆国产精品久久| 欧美经典三级视频一区二区三区| 日本亚洲一区二区| 一区二区三区在线影院| 成人黄色在线视频| 久久伊人蜜桃av一区二区| 日本成人在线看| 欧美日本视频在线| 一区二区三区精品在线观看| 成人性生交大片免费看中文网站| 欧美成人a视频| 午夜日韩在线观看| 欧美乱熟臀69xxxxxx| 亚洲综合在线电影| 一本色道a无线码一区v| 一区在线观看免费| 一道本成人在线| 亚洲日本中文字幕区| 91免费国产在线观看| 亚洲色图制服诱惑| 日本电影欧美片| 亚洲最快最全在线视频| 欧美私模裸体表演在线观看| 夜夜爽夜夜爽精品视频| 欧美午夜精品理论片a级按摩| 亚洲一区成人在线| 欧美日韩高清在线播放| 日韩精品成人一区二区三区| 91麻豆精品国产自产在线 | 91福利国产成人精品照片| 亚洲色欲色欲www在线观看| 95精品视频在线| 亚洲欧美国产高清| 欧美日韩一区二区欧美激情| 亚洲国产精品一区二区尤物区| 欧美亚洲动漫精品| 日本美女视频一区二区| 精品99999| av资源站一区| 亚洲一区二区在线免费观看视频 | 色菇凉天天综合网| 亚洲国产日日夜夜| 91精品欧美久久久久久动漫| 另类小说一区二区三区| 久久久亚洲高清| 99re成人精品视频| 亚洲主播在线观看| 91精品国产综合久久精品| 国产麻豆成人精品| 综合激情成人伊人| 91精品国产综合久久精品| 国产在线麻豆精品观看| 1024精品合集| 日韩一区二区在线看片| 成人午夜视频免费看| 亚洲黄色免费网站| 日韩欧美亚洲国产另类| 成人黄色片在线观看| 亚洲不卡一区二区三区| 久久久精品国产99久久精品芒果| 91啪亚洲精品| 青娱乐精品视频在线| 中文字幕免费不卡在线| 欧美日韩一区国产| 国产精品中文欧美| 亚洲一区在线视频| 久久精品水蜜桃av综合天堂| 色综合久久综合网| 精品无人码麻豆乱码1区2区 | 亚洲人成精品久久久久久| 日韩午夜小视频| 91农村精品一区二区在线| 欧美一区二区福利视频| 国产美女久久久久| 一区二区三区在线免费| 26uuu亚洲综合色欧美 | 精品国产欧美一区二区| 不卡的av在线| 欧美嫩在线观看| 成人黄色小视频| 久久99九九99精品| 亚洲午夜在线视频| 欧美国产日本视频| 精品美女一区二区| 欧美三级日韩三级| 91在线视频免费观看| 精品一区二区三区蜜桃| 亚洲香蕉伊在人在线观| 国产精品久久久久久久久久免费看| 7777精品伊人久久久大香线蕉经典版下载 | 色综合天天天天做夜夜夜夜做| 五月综合激情网|