無人機動兵器ダンジョン探索ゲーム JAVAベース
タイルの基本サイズをブランクフロアタイルから取得、基本サイズに応じて各種タイルを変形して表示するようにした
弾丸タイルを他のタイルと同じ大きさに表示する様に変更
| @@ -25,7 +25,7 @@ | ||
| 25 | 25 | */ |
| 26 | 26 | public final class CarnageHack extends Panel implements ActionListener { |
| 27 | 27 | |
| 28 | - public static final String version = "CarnageHack2 V1.4.0 alpha"; | |
| 28 | + public static final String version = "CarnageHack2 V1.5.0 alpha"; | |
| 29 | 29 | public static final ResourceBundle resource; |
| 30 | 30 | public static CHArrayList main_weapon_list; |
| 31 | 31 | public static CHArrayList sub_weapon_list; |
| @@ -49,10 +49,12 @@ | ||
| 49 | 49 | public void paint(Graphics g) { |
| 50 | 50 | int y = 0; |
| 51 | 51 | int n; |
| 52 | + int cx; | |
| 52 | 53 | n = FloorTile.startup_image(g, 0, y, 256, this); |
| 53 | - y += ((n / 16) + 1) * 16; | |
| 54 | + cx = 256 / FloorTile.tileBaseX; | |
| 55 | + y += ((n / cx) + 1) * FloorTile.tileBaseY; | |
| 54 | 56 | n = OkeDungeon.startup_image(g, 0, y, 256, this); |
| 55 | - y += ((n / 16) + 1) * 16; | |
| 57 | + y += ((n / cx) + 1) * FloorTile.tileBaseY; | |
| 56 | 58 | n = OkeSoftChipPanel.startup_image(g, 0, y, 256, this); |
| 57 | 59 | y += ((n / 8) + 1) * 32; |
| 58 | 60 | g.drawImage(banner, 0, y, this); |
| @@ -428,9 +428,11 @@ | ||
| 428 | 428 | for (y = 0; y < cy; y++) { |
| 429 | 429 | if (x + bx > 0 && x + bx < FLOOR_X && y + by > 0 && y + by |
| 430 | 430 | < FLOOR_Y) { |
| 431 | - tile[x + bx][y + by].draw(g, x * 16, y * 16, compo); | |
| 431 | + tile[x + bx][y + by].draw(g, x * FloorTile.tileBaseX, | |
| 432 | + y * FloorTile.tileBaseY, compo); | |
| 432 | 433 | } else { |
| 433 | - wall.draw(g, x * 16, y * 16, compo); | |
| 434 | + wall.draw(g, x * FloorTile.tileBaseX, | |
| 435 | + y * FloorTile.tileBaseY, compo); | |
| 434 | 436 | } |
| 435 | 437 | } |
| 436 | 438 | } |
| @@ -292,7 +292,9 @@ | ||
| 292 | 292 | break; |
| 293 | 293 | } |
| 294 | 294 | if (icon != null) { |
| 295 | - g.drawImage(icon, (x - bx) * 16, (y - by) * 16, compo); | |
| 295 | + g.drawImage(icon, (x - bx) * FloorTile.tileBaseX, | |
| 296 | + (y - by) * FloorTile.tileBaseY, | |
| 297 | + FloorTile.tileBaseX, FloorTile.tileBaseY, compo); | |
| 296 | 298 | } |
| 297 | 299 | } |
| 298 | 300 | } |
| @@ -70,11 +70,13 @@ | ||
| 70 | 70 | for (i = 0; i < 8; i++) { |
| 71 | 71 | tsukikage[i] |
| 72 | 72 | = tk.getImage(obj.getClass(). |
| 73 | - getResource("tile/tsukikage" + dir_word[i] + ".png")); | |
| 73 | + getResource("tile/tsukikage" + dir_word[i] | |
| 74 | + + ".png")); | |
| 74 | 75 | mt.addImage(tsukikage[i], 0); |
| 75 | 76 | tsukikage2[i] |
| 76 | 77 | = tk.getImage(obj.getClass(). |
| 77 | - getResource("tile/tsukikage2" + dir_word[i] + ".png")); | |
| 78 | + getResource("tile/tsukikage2" + dir_word[i] | |
| 79 | + + ".png")); | |
| 78 | 80 | mt.addImage(tsukikage2[i], 0); |
| 79 | 81 | } |
| 80 | 82 | explosion |
| @@ -96,35 +98,38 @@ | ||
| 96 | 98 | ImageObserver obs) { |
| 97 | 99 | int i; |
| 98 | 100 | int n = 0; |
| 99 | - g.drawImage(hige, x, y, obs); | |
| 100 | - x += 16; | |
| 101 | + g.drawImage(hige, x, y, FloorTile.tileBaseX, FloorTile.tileBaseY, obs); | |
| 102 | + x += FloorTile.tileBaseX; | |
| 101 | 103 | if (x >= cx) { |
| 102 | 104 | x = 0; |
| 103 | - y += 16; | |
| 105 | + y += FloorTile.tileBaseY; | |
| 104 | 106 | } |
| 105 | 107 | n++; |
| 106 | - g.drawImage(explosion, x, y, obs); | |
| 107 | - x += 16; | |
| 108 | + g.drawImage(explosion, x, y, FloorTile.tileBaseX, FloorTile.tileBaseY, | |
| 109 | + obs); | |
| 110 | + x += FloorTile.tileBaseX; | |
| 108 | 111 | if (x >= cx) { |
| 109 | 112 | x = 0; |
| 110 | - y += 16; | |
| 113 | + y += FloorTile.tileBaseY; | |
| 111 | 114 | } |
| 112 | 115 | n++; |
| 113 | 116 | for (i = 0; i < 8; i++) { |
| 114 | - g.drawImage(tsukikage[i], x, y, obs); | |
| 115 | - x += 16; | |
| 117 | + g.drawImage(tsukikage[i], x, y, | |
| 118 | + FloorTile.tileBaseX, FloorTile.tileBaseY, obs); | |
| 119 | + x += FloorTile.tileBaseX; | |
| 116 | 120 | if (x >= cx) { |
| 117 | 121 | x = 0; |
| 118 | - y += 16; | |
| 122 | + y += FloorTile.tileBaseY; | |
| 119 | 123 | } |
| 120 | 124 | n++; |
| 121 | 125 | } |
| 122 | 126 | for (i = 0; i < 8; i++) { |
| 123 | - g.drawImage(tsukikage2[i], x, y, obs); | |
| 124 | - x += 16; | |
| 127 | + g.drawImage(tsukikage2[i], x, y, | |
| 128 | + FloorTile.tileBaseX, FloorTile.tileBaseY, obs); | |
| 129 | + x += FloorTile.tileBaseX; | |
| 125 | 130 | if (x >= cx) { |
| 126 | 131 | x = 0; |
| 127 | - y += 16; | |
| 132 | + y += FloorTile.tileBaseY; | |
| 128 | 133 | } |
| 129 | 134 | n++; |
| 130 | 135 | } |
| @@ -278,8 +283,8 @@ | ||
| 278 | 283 | int x; |
| 279 | 284 | int y; |
| 280 | 285 | Dimension winsize = getSize(); |
| 281 | - int view_x = winsize.width / 16; | |
| 282 | - int view_y = winsize.height / 16; | |
| 286 | + int view_x = winsize.width / FloorTile.tileBaseX; | |
| 287 | + int view_y = winsize.height / FloorTile.tileBaseY; | |
| 283 | 288 | Image offscreen = createImage(winsize.width, winsize.height); |
| 284 | 289 | Graphics g = offscreen.getGraphics(); |
| 285 | 290 | nowdraw = true; |
| @@ -330,7 +335,9 @@ | ||
| 330 | 335 | if (x >= basex && x < basex + view_x && y >= basey && y < basey |
| 331 | 336 | + view_y) { |
| 332 | 337 | g.drawImage(icon, |
| 333 | - (x - basex) * 16, (y - basey) * 16, this); | |
| 338 | + (x - basex) * FloorTile.tileBaseX, | |
| 339 | + (y - basey) * FloorTile.tileBaseY, | |
| 340 | + FloorTile.tileBaseX, FloorTile.tileBaseY, this); | |
| 334 | 341 | } |
| 335 | 342 | } |
| 336 | 343 | } |
| @@ -351,7 +358,9 @@ | ||
| 351 | 358 | // |
| 352 | 359 | //draw higeoyaji |
| 353 | 360 | if (havehige == false && higefloor == current_floor) { |
| 354 | - g.drawImage(hige, (higex - basey) * 16, (higey - basey) * 16, this); | |
| 361 | + g.drawImage(hige, (higex - basey) * FloorTile.tileBaseX, | |
| 362 | + (higey - basey) * FloorTile.tileBaseY, | |
| 363 | + FloorTile.tileBaseX, FloorTile.tileBaseY, this); | |
| 355 | 364 | } |
| 356 | 365 | // |
| 357 | 366 | nowdraw = false; |
| @@ -1210,8 +1219,8 @@ | ||
| 1210 | 1219 | } |
| 1211 | 1220 | } else if ((e.getModifiers() & (MouseEvent.BUTTON2_MASK |
| 1212 | 1221 | | MouseEvent.BUTTON3_MASK)) != 0) { |
| 1213 | - int x = dungeon.get_basex() + e.getX() / 16; | |
| 1214 | - int y = dungeon.get_basey() + e.getY() / 16; | |
| 1222 | + int x = dungeon.get_basex() + e.getX() / FloorTile.tileBaseX; | |
| 1223 | + int y = dungeon.get_basey() + e.getY() / FloorTile.tileBaseY; | |
| 1215 | 1224 | if (e.isShiftDown() == true) { |
| 1216 | 1225 | dungeon.set_lockview(false); |
| 1217 | 1226 | dungeon.set_viewoke(x, y); |
| @@ -1218,8 +1227,8 @@ | ||
| 1218 | 1227 | } else { |
| 1219 | 1228 | Dimension winsize; |
| 1220 | 1229 | winsize = dungeon.getSize(); |
| 1221 | - x -= winsize.width / 16 / 2; | |
| 1222 | - y -= winsize.height / 16 / 2; | |
| 1230 | + x -= winsize.width / FloorTile.tileBaseX / 2; | |
| 1231 | + y -= winsize.height / FloorTile.tileBaseY / 2; | |
| 1223 | 1232 | dungeon.set_lockview(true); |
| 1224 | 1233 | dungeon.set_base(x, y); |
| 1225 | 1234 | } |
| @@ -1,6 +1,5 @@ | ||
| 1 | 1 | package CarnageHack; |
| 2 | 2 | |
| 3 | -import java.awt.Color; | |
| 4 | 3 | import java.awt.Component; |
| 5 | 4 | import java.awt.Graphics; |
| 6 | 5 | import java.awt.Image; |
| @@ -24,6 +23,8 @@ | ||
| 24 | 23 | static Image upstairs; |
| 25 | 24 | static Image downstairs; |
| 26 | 25 | static Image parts; |
| 26 | + static public int tileBaseX = 16; | |
| 27 | + static public int tileBaseY = 16; | |
| 27 | 28 | int id; |
| 28 | 29 | CHArrayList item; |
| 29 | 30 |
| @@ -62,32 +63,42 @@ | ||
| 62 | 63 | static public int startup_image(Graphics g, int x, int y, int cx, |
| 63 | 64 | ImageObserver obs) { |
| 64 | 65 | int n = 0; |
| 66 | + int basex = blank.getWidth(obs); | |
| 67 | + int basey = blank.getHeight(obs); | |
| 68 | + if (basex != -1) { | |
| 69 | + //取得できるはずだが念のため取得できた時にタイル幅を更新 | |
| 70 | + tileBaseX = basex; | |
| 71 | + } | |
| 72 | + if (basey != -1) { | |
| 73 | + //取得できるはずだが念のため取得できた時にタイル長を更新 | |
| 74 | + tileBaseY = basey; | |
| 75 | + } | |
| 65 | 76 | g.drawImage(blank, x, y, obs); |
| 66 | - x += 16; | |
| 77 | + x += tileBaseX; | |
| 67 | 78 | if (x >= cx) { |
| 68 | 79 | x = 0; |
| 69 | - y += 16; | |
| 80 | + y += tileBaseY; | |
| 70 | 81 | } |
| 71 | 82 | n++; |
| 72 | 83 | g.drawImage(wall, x, y, obs); |
| 73 | - x += 16; | |
| 84 | + x += tileBaseX; | |
| 74 | 85 | if (x >= cx) { |
| 75 | 86 | x = 0; |
| 76 | - y += 16; | |
| 87 | + y += tileBaseY; | |
| 77 | 88 | } |
| 78 | 89 | n++; |
| 79 | 90 | g.drawImage(upstairs, x, y, obs); |
| 80 | - x += 16; | |
| 91 | + x += tileBaseX; | |
| 81 | 92 | if (x >= cx) { |
| 82 | 93 | x = 0; |
| 83 | - y += 16; | |
| 94 | + y += tileBaseY; | |
| 84 | 95 | } |
| 85 | 96 | n++; |
| 86 | 97 | g.drawImage(downstairs, x, y, obs); |
| 87 | - x += 16; | |
| 98 | + x += tileBaseX; | |
| 88 | 99 | if (x >= cx) { |
| 89 | 100 | x = 0; |
| 90 | - y += 16; | |
| 101 | + y += tileBaseY; | |
| 91 | 102 | } |
| 92 | 103 | n++; |
| 93 | 104 | g.drawImage(parts, x, y, obs); |
| @@ -172,7 +183,8 @@ | ||
| 172 | 183 | } |
| 173 | 184 | } |
| 174 | 185 | if (icon != null) { |
| 175 | - g.drawImage(icon, x, y, compo); | |
| 186 | + g.drawImage(icon, x, y, FloorTile.tileBaseX, FloorTile.tileBaseY, | |
| 187 | + compo); | |
| 176 | 188 | } |
| 177 | 189 | } |
| 178 | 190 | } |