1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Java】二次元配列でドット絵を作ってみた

Posted at

##作ろうと思ったきっかけ

→for文の演習問題中
→以下を実行せよ
▼▲▼
▼▲

→これ応用したらドット絵作れるんじゃね?

##ドット絵を作ってみました

kkk02.png
星のカービィ© Nintendo / HAL Laboratory, Inc.

inu.png
UNDERTALE©Toby Fox 2015-2021.

##開発環境
Windows10(32bit)
eclipse(4.9.0)
コマンドプロンプトで実行

Dot_pic.java
class Dot_pic {
	public static void main(String[] args) {
		int[][] dotPic =
            {{0,0,0,0,0,0,1,1,1,1,1,0,1,1,0,0},
             {0,0,0,0,1,1,0,0,0,0,0,1,0,0,1,0},
             {0,0,0,1,0,0,0,1,0,1,0,0,1,0,0,1},
        /*------------------省略------------------*/
             {0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
             {0,0,0,1,1,1,0,0,0,1,1,1,1,1,1,0}};

        for (int[] line : dotPic) {
            for (int dot : line) {
                if (dot == 1) {
                    System.out.print("■");
                } else {
                    System.out.print(" ");
                }
            }
            System.out.println("");
		}
	}
}

二次元配列でキャンバスを作り、ドットにしたいところを1にします。
ドット絵を表示する - Java入門編 - Paiza より引用

###ちなみに初期ドット絵はこちら
↓ ↓ ↓
kkk.png

for文を使って自力でただひたすらに試行錯誤→微調整の繰り返し・・
0→1を頑張らずに、先人の知恵はとことん活用させて頂くことが賢明だと学びました。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?