OMOK in Win Form Win Form GDI Graphics
- Slides: 27
OMOK in Win. Form
오목 Win. Form GDI+ Graphics class g. Draw. Line(), g. Fill. Ellipse() Pen class, Brush class Rectangle(), Point(), Size() 구조체 On. Paint() 메뉴 : Menu. Strip 19개의 가로 세로 줄 화점 9개 흰돌, 검은돌, 바둑판 enum STONE {none, black, white}; STONE[, ] 바둑판 = new STONE[19, 19]; 메뉴를 사용하므로, 좌표계산을 쉽게 하기 위해 Panel을 부모에 도킹 화점위치 : 3, 9, 16 3
바둑판 그리기 // 폼의 크기 조정 Client. Size = new Size(20+18*눈size, 20+18*눈size + menu. Strip 1. Height); g = panel 1. Create. Graphics(); // 가로줄 for(int i=0; i<19; i++) { g. Draw. Line(pen, new Point(margin, margin + 눈Size * i), new Point(margin + 18 * 눈Size, margin + 눈Size * i)); } // 세로줄 for(int i=0; i<19; i++) { g. Draw. Line(pen, new Point(margin + 눈Size * i, margin), new Point(margin + 눈Size * i, margin + 눈Size * 18)); }
화점 그리기 (3, 9, 15) 위치에 점을 그린다 g. Draw. Ellipse(pen, new Rectangle()) g. Fill. Ellipse(b. Brush, new Rectangle()) for(int i=3; i<=15; i+=6) for(int j=3; j<=15; j+=6) g. Fill. Ellipse(b. Brush, new Rectangle(margin + i * 눈Size - 화점Size/2, margin + j * 눈Size - 화점Size/2, 화점Size)); 7
화점의 위치 이동(돌도 같은 방법) Rectangle(x, y, 화점Size) (x, y) 화점Size Rectangle(x-화점Size/2, y-화점Size/2, 화점Size)
3. Image 사용법 흑돌과 백돌을 Fill. Ellipse()로 그리는 방법 대신, 이미지를 사용하는 방법 솔루션 탐색기에서 프로젝트 밑에 이미지를 저장할 폴더를 만들고 이곳에 이미지 파일을 저장함 if (turn == false) // 검은 돌 { // g. Fill. Ellipse(b. Brush, r); Bitmap bmp = new Bitmap(". . /images/black. png"); g. Draw. Image(bmp, r); 바둑판[x, y] = STONE. black; } else { //g. Fill. Ellipse(w. Brush, r); Bitmap bmp = new Bitmap(". . /images/white. png"); g. Draw. Image(bmp, r); 바둑판[x, y] = STONE. white; }
Draw. Image() vs Fill. Ellipse()
이것을 menu에 추가 여기에서도 flag를 하나 사용하자 image. Flag = true; // Draw. Image() image. Flag = false; // Draw. Ellipase()
수정한 부분 // On. Paint() 함수 protected override void On. Paint(Paint. Event. Args e) { base. On. Paint(e); draw바둑판(); draw돌들(); } // 자료구조에서 돌들을 읽어서 다시 그려줌 private void draw돌들() { for (int i = 0; i < 19; i++) for (int j = 0; j < 19; j++) if (바둑판[i, j] != STONE. none) draw. AStone(i, j); panel 1_Mouse. Down() 함수에서 } 돌 하나 그리는 부분을 추출하여 함수로 만든다
7. 오목 진행 사항 저장(복기) 오목게임의 복기 public class Bokki { public int X { get; set; } public int Y { get; set; } public char Stone { set; get; } 돌이 놓인 순서대로 저장하여야 함 List<T> 클래스를 사용 여기서 <T> 는 x, y, 흑/백을 나타내는 class를 만들어서 사용 using System. Collections. Generic; // 생성자 List<Bokki> list = new List<Bokki>(); public Bokki(int x, int y, char stone) private void 복기Tool. Strip. Menu. Item_Click(object sender, Event. Args e) { Print. List(); } // 테스트를 위해 List<Bokki> list를 출력 private void Print. List() { string s = ""; foreach(Bokki su in list) { s += su. X + ", " + su. Y + ": " + su. Stone + "n"; } Message. Box. Show(s); } { X = x; Y = y; Stone = stone; } }
- Deduction practice pictures
- Graphics device interface
- Habit 4 think win win examples
- Win win win lose lose lose
- Win win situacija
- Gdi nrw
- Gdi grab
- Gdi net
- Tableau tolérance alésage
- Expanding the pie negotiation
- Winwin hesap
- Example of a win win situation
- Covey win win
- Win-win conflict resolution
- Win win strategies
- Habit 4 summary
- Win win nacin placanja
- Habit 4 think win win summary
- Graphics monitors in computer graphics
- 3d viewing devices in computer graphics ppt
- Negative form present continuous
- Wintr 55
- Win tr55
- Win tr 20
- 3 reasons why william won the battle of hastings
- Win pond
- Tutorial
- Sometimes you win some