Top Banner

Click here to load reader

of 38

G+ Summer C Study 20130718(8일차)

Jan 24, 2015

Download

Education

Jake Yoon

8일차 20130718

7월18일 스터디에 대한 PPT 자료입니다.
C언어 프로그래밍의 꽃 테트리스를
배웠던 기술들을 활용하여 제작하는 수업을 진행하였습니다.
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • 1. G+ Summer C Programming Study 1 2013. 07. 17 19:00 G-Lab
  • 2. 2 For
  • 3. 3
  • 4. 4
  • 5. 5 ?
  • 6. 6 TODO BOOL ProcessKey(); // void PrintBrick(BOOL Show); // int GetAround(int x,int y,int b,int r); // BOOL MoveDown(); // 1 , TestFull void TestFull(); //
  • 7. 7
  • 8. 8 . 4 . nx, ny, brick, rot . x , y , , . BOOL ProcessKey();
  • 9. 9 main for(;1;) . brick=rand()%(sizeof(Shape)/sizeof(Shape[0])); nx = BW/2; ny = 3; ? . BOOL ProcessKey();
  • 10. 10 . brick=rand()%(sizeof(Shape)/sizeof(Shape[0])); // 7 1 . nx = BW/2; // . ny = 3; // 3 . BOOL ProcessKey();
  • 11. 11 ProcessKey() . lib.c kbhit() . 1 0 . , if( kbhit() ) { printf( ); else { printf( ); } BOOL ProcessKey();
  • 12. 12 , getch() . LEFT RIGHT UP DOWN SPACE . BOOL ProcessKey();
  • 13. 13 #define LEFT 68 #define RIGHT 67 #define UP 65 #define DOWN 66 #define SPACE 32 #define int LEFT = 68; . BOOL ProcessKey();
  • 14. 14 ? BOOL ProcessKey() { char ch; if(kbhit()) { ch = getch(); if ( ch == LEFT ) { // return TRUE; } BOOL ProcessKey();
  • 15. 15 ? BOOL ProcessKey() { char ch; if(kbhit()) { ch = getch(); if ( ch == LEFT ) { // return TRUE; } BOOL ProcessKey();
  • 16. 16 (LEFT,RIGHT etc) . . BOOL ProcessKey();
  • 17. 17 ? ?!?!!!?!?! BOOL ProcessKey();
  • 18. 18 , . ?! . ? BOOL ProcessKey();
  • 19. 19 Move ?! , . , . ( ) BOOL ProcessKey();
  • 20. 20 PrintBrick() . , . BOOL ProcessKey();
  • 21. 21 DrawBoard() ? for . nx, ny, brick, rot ? x , y , , . void PrintBrick(BOOL Show);
  • 22. 22 brick nx, ny, rot . BX+(Shape[brick][rot][0].x+nx)*2, BY+Shape[brick][rot][0].y+ny BX+(Shape[brick][rot][1].x+nx)*2, BY+Shape[brick][rot][1].y+ny BX+(Shape[brick][rot][2].x+nx)*2, BY+Shape[brick][rot][2].y+ny BX+(Shape[brick][rot][3].x+nx)*2, BY+Shape[brick][rot][3].y+ny void PrintBrick(BOOL Show);
  • 23. 23 BX+(Shape[brick][rot][0].x+nx)*2 BX = brick = rot = 0 = x = *2 = 2 *2 nx = x ( BW/2, ) void PrintBrick(BOOL Show);
  • 24. 24 , . . void PrintBrick(BOOL Show) { int i, x, y; for (i=0;i