Changeset 400
- Timestamp:
- 07/21/08 17:19:03 (4 months ago)
- Files:
-
- trunk/qd/SDL_ttf.d (modified) (1 diff)
- trunk/qd/dsss.conf (modified) (1 diff)
- trunk/qd/gone.d (modified) (4 diffs)
- trunk/qd/qd.d (modified) (8 diffs)
- trunk/qd/test2.d (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/qd/SDL_ttf.d
r369 r400 16 16 17 17 TTF_FontClass[int] standard; 18 void initFont(int size = 14, string name="Vera.ttf") { 19 standard[size] = new TTF_FontClass(read(name), size); 18 void initFont(int size = 14, string name="") { 19 void[] data; 20 if (name.length) data = name.read(); 21 else data = import("Vera.ttf"); 22 standard[size] = new TTF_FontClass(data, size); 20 23 } 21 24 trunk/qd/dsss.conf
r373 r400 2 2 [qd.d] 3 3 type=library 4 # [dt/main.d]5 # buildflags=-L-lSDL -L-lSDL_ttf -g -O6 4 [test.d] 7 5 buildflags=-L-lSDL -g 8 [test2.d]9 buildflags=-L-lSDL -L-lSDL_ttf -g6 # [test2.d] 7 # buildflags=-L-lSDL -L-lSDL_ttf -g 10 8 [cellular.d] 11 buildflags=-L-lSDL -g -J. -O -release -inline -q,-march=nocona 12 # buildflags=-L-lSDL -g -J. 9 buildflags=-L-lSDL -g -J. -O -release -inline 13 10 [SDL_ttf.d] 14 11 type=library 12 buildflags=-J. 15 13 [primes.d] 16 14 buildflags=-L-lSDL 17 # [ff.d]18 # buildflags=-L-lSDL19 15 [pingtest.d] 20 16 buildflags=-g -L-lSDL -L-lSDL_ttf 21 17 [dgram.d] 22 18 buildflags=-L-lSDL 23 # [tetris.d]24 # buildflags=-L-lSDL25 19 [test11.d] 26 20 buildflags=-L-lSDL -L-lSDL_ttf -g 27 # [test12.d]28 # buildflags=-L-lSDL -L-lSDL_ttf -g29 21 [ff.d] 30 22 buildflags=-L-lSDL -L-lSDL_ttf -O 31 # [test13.d]32 # buildflags=-L-lSDL -L-lSDL_ttf -O -release -inline33 23 [snake.d] 34 24 buildflags=-L-lSDL trunk/qd/gone.d
r97 r400 57 57 auto res=new SuperGoBoard(turn); 58 58 foreach (id, value; this.tupleof) 59 static if (is Array!(typeof(value))) res.tupleof[id]=value.dup;59 static if (is(typeof(value.dup))) res.tupleof[id]=value.dup; 60 60 else res.tupleof[id]=value; 61 61 res.conns=conns.dup; … … 143 143 if (e) line(px-2, py, px-2, py+5); 144 144 if (f) line(px+2, py, px+2, py+5); 145 if (g) line(px -2, py+5, px+2, py+5);145 if (g) line(px+2, py+5, px-2, py+5); 146 146 } 147 147 const y=true; … … 196 196 if (i) { 197 197 if (cond(j)) board.connect(newPos, columns[dir*i][j]); 198 if (cond(j) && (j + 2) in columns[dir*i]) 199 board.connect(newPos, columns[dir*i][j+2]); 198 200 // connect outsides 199 201 /*if (j==i-size-1) board.connect(newPos, columns[dir*i][j-1]); … … 235 237 fill=fill~(fill~overlay); 236 238 circle(x, y, 10, Red, Fill=fill); 237 //drawNumber(x, y, id); 239 if (board[id]) drawNumber(x, y, board.freedoms(board.group(id))); 240 // drawNumber(x, y, id); 238 241 } 239 242 trunk/qd/qd.d
r373 r400 1 1 module qd; 2 2 import std.c.string, std.math, std.traits: ParameterTypeTuple; 3 4 uint delegate() qd_rand;5 import std.random;6 static this() { qd_rand = { return rand(); }; }7 3 8 4 import tools.base; … … 119 115 int SDL_Init(uint flags); 120 116 } 121 static this() { SDL_Init(SDL_INIT_VIDEO); } 117 uint delegate() qd_rand; 118 import std.random; 119 static this() { qd_rand = { return rand(); }; SDL_Init(SDL_INIT_VIDEO); } 122 120 123 121 import std.string: toStringz; … … 389 387 static if (steep) { 390 388 if (countUp) { 391 putpixel(var2 , var1, color.values, 255-alpha);392 if (var2 < display.width) putpixel(var2 +1, var1, color.values, alpha);389 putpixel(var2-1, var1, color.values, 255-alpha); 390 if (var2 < display.width) putpixel(var2, var1, color.values, alpha); 393 391 } else { 394 putpixel(var2 , var1, color.values, alpha);395 if (var2 > 0) putpixel(var2 -1, var1, color.values, 255-alpha);392 putpixel(var2+1, var1, color.values, alpha); 393 if (var2 > 0) putpixel(var2, var1, color.values, 255-alpha); 396 394 } 397 395 } else { … … 400 398 if (var2 < display.height) putpixel(var1, var2+1, color.values, alpha); 401 399 } else { 402 putpixel(var1, var2 , color.values, alpha);403 if (var2 > 0) putpixel(var1, var2 -1, color.values, 255-alpha);400 putpixel(var1, var2+1, color.values, alpha); 401 if (var2 > 0) putpixel(var1, var2, color.values, 255-alpha); 404 402 } 405 403 } … … 504 502 auto stopy="~(first?"0":"x2square*radius")~"; 505 503 while (stopx"~(first?">=":"<=")~"stopy) { 506 putpixel(c x+x, cy+y, col);507 putpixel(c x+x, cy-y, col);508 putpixel(c x-x, cy+y, col);509 putpixel(c x-x, cy-y, col);504 putpixel(cast(int) (cx+x), cast(int) (cy+y), col); 505 putpixel(cast(int) (cx+x), cast(int) (cy-y), col); 506 putpixel(cast(int) (cx-x), cast(int) (cy+y), col); 507 putpixel(cast(int) (cx-x), cast(int) (cy-y), col); 510 508 "~yx~"++; 511 509 stop"~yx~"+="~xy~"2square; … … 540 538 import std.stdio; 541 539 void circle(T...)(T t) { 542 static assert(T.length!<3, "Circle: Needs x, y and radius");543 int cx=cast(int)t[0], cy=cast(int)t[1]; float radius=cast(float)t[2];544 SDL_LockSurface(display.surface);545 scope(exit) { SDL_UnlockSurface(display.surface); if (doFlip) flip; }546 execParams(t[3..$]);547 if (radius!>0) return;548 static if (T.length>3 && is(T[3]: int)) yradius=t[3];549 static if (Select!(back_rgb, T) != -1) {550 auto back_sdl=SDL_MapRGBA(display.surface.format, back.values[0], back.values[1], back.values[2], 0);551 for (int i=0; i<=radius; ++i) {552 ushort j=cast(ushort)(sqrt(cast(real)(radius*radius-i*i)));553 hline(cx-j, cy+i, 2*j, back_sdl);554 if (i) hline(cx-j, cy-i, 2*j, back_sdl);555 }556 }557 static if (Select!(back_rgb, T) == -1 || Select!(rgb, T) != -1) {558 auto x2square=2*radius*radius, y2square=x2square;559 uint col=SDL_MapRGBA(display.surface.format, color.values[0], color.values[1], color.values[2], 0);560 { mixin(circle_bresenham_pass!(true).str); }561 { mixin(circle_bresenham_pass!(false).str); }562 }563 }564 565 void circle_aa(T...)(T t) {566 540 static assert(T.length!<3, "Circle: Needs x, y and radius"); 567 541 int cx=cast(int)t[0], cy=cast(int)t[1]; float radius=cast(float)t[2]; … … 637 611 } 638 612 613 bool opengl_mode; 639 614 640 615 struct screen { … … 647 622 } 648 623 void resize(int w, int h, bool osc = false) { 624 if (opengl_mode && !offscreen) { display.width = w; display.height = h; return; } 649 625 if (display && display.surface && offscreen) SDL_FreeSurface(display.surface); 650 626 offscreen = osc; trunk/qd/test2.d
r369 r400 444 444 445 445 list!(Window) windows; 446 <<<<<<< .mine447 this() { mouse_sched~=stackthread=&mousethr; }448 =======449 446 // this() { mouse.sched~=stackthread=&mousethr; } 450 >>>>>>> .r368451 447 void draw() { windows.each((Window w) { w.draw(); }); } 452 <<<<<<< .mine453 void mousethr(proc yield) {454 assert(mouse_sched.runsMe);455 =======456 448 /*void mousethr(proc yield) { 457 449 // assert(mouse.sched.runsMe); 458 >>>>>>> .r368459 450 enum State { start, title_inside, title_dragging, resize_inside, resize_dragging } 460 451 pt lastpos;
