Overview
SHA1 Hash: | b59ee91407b7ab7505e76c4e324ca5db2d517618 |
---|---|
Date: | 2012-07-13 23:16:22 |
User: | kinaba |
Comment: | GUI version. |
Timelines: | family | ancestors | descendants | both | trunk |
Diffs: | redesign |
Downloads: | Tarball | ZIP archive |
Other Links: | files | file ages | manifest |
Tags And Properties
- branch=trunk inherited from [16f0b5784f]
- sym-trunk inherited from [16f0b5784f]
Changes
Modified test.d from [53cab87f74c4871d] to [b27a6df805fe9112].
1 import std.algorithm; 1 import std.algorithm; 2 import std.array; 2 import std.array; 3 import std.conv; 3 import std.conv; 4 import std.stdio; 4 import std.stdio; 5 import std.string; 5 import std.string; > 6 import dfl.all; 6 7 7 class Map 8 class Map 8 { 9 { 9 private char[][] data; 10 private char[][] data; 10 11 11 this(File input) 12 this(File input) 12 { 13 { ................................................................................................................................................................................ 106 next[y][x] = 'O'; 107 next[y][x] = 'O'; 107 } 108 } 108 } 109 } 109 data = next; 110 data = next; 110 } 111 } 111 } 112 } 112 113 113 void main(string[] args) | 114 class MyForm : Form 114 { 115 { 115 Map m = new Map(File(args[1])); | 116 Map m; 116 for(;;) { | 117 this(Map m) 117 writeln(m); < > 118 { 118 write("> "); | 119 noMessageFilter(); 119 string s = readln(); | 120 this.m = m; 120 if(s.length == 0) | 121 this.text = "Dark Integers"; > 122 this.keyDown ~= &myKey; > 123 } > 124 override void onResize(EventArgs ev) { > 125 invalidate(); > 126 } > 127 override void onPaint(PaintEventArgs ev) > 128 { > 129 int Z = min(this.clientSize.width, this.clientSize.height) / max > 130 Font font = new Font("MS Gothic", Z-4); > 131 Graphics g = ev.graphics; > 132 for(int y=1; y+1<m.H; ++y) > 133 for(int x=1; x+1<m.W; ++x) { > 134 if(m.data[y][x]=='*') { > 135 g.drawText("岩", font, Color(0,0,0), Rect((x-1)*Z > 136 } > 137 if(m.data[y][x]=='\\') { > 138 g.drawText("λ", font, Color(0,255,0), Rect((x-1) > 139 } > 140 if(m.data[y][x]=='R') { > 141 g.drawText("R", font, Color(128,128,0), Rect((x- > 142 } > 143 if(m.data[y][x]=='L') { > 144 g.drawText("L", font, Color(255,255,0), Rect((x- > 145 } > 146 if(m.data[y][x]=='O') { > 147 g.drawText("O", font, Color(255,255,0), Rect((x- > 148 } > 149 if(m.data[y][x]=='#') { > 150 g.drawText("#", font, Color(0,0,0), Rect((x-1)*Z > 151 } > 152 if(m.data[y][x]=='.') { > 153 g.drawText("・", font, Color(128,40,0), Rect((x-1 > 154 } > 155 } > 156 } > 157 void myKey(Control c, KeyEventArgs ev) > 158 { > 159 switch(ev.keyCode) > 160 { > 161 case Keys.DOWN: > 162 m.command_D(); > 163 break; > 164 case Keys.UP: > 165 m.command_U(); > 166 break; > 167 case Keys.LEFT: > 168 m.command_L(); > 169 break; > 170 case Keys.RIGHT: > 171 m.command_R(); > 172 break; > 173 case Keys.W: > 174 m.wait(); > 175 break; > 176 default: 121 break; 177 break; 122 s = s.chomp().toUpper(); < > 178 } 123 if(s=="R")m.command_R(); | 179 invalidate(); 124 if(s=="L")m.command_L(); < 125 if(s=="U")m.command_U(); < 126 if(s=="D")m.command_D(); < 127 if(s=="W")m.wait(); < 128 } 180 } > 181 } 129 182 > 183 void main(string[] args) > 184 { > 185 Form myForm = new MyForm(new Map(File(args[1]))); > 186 Application.run(myForm); 130 } 187 }