More actions
imported>Unknown No edit summary |
(Repair batch-0007 pages from live compare) |
||
| Line 32: | Line 32: | ||
void main() | void main() | ||
{ | { | ||
int screenArray | int screenArray[SCREEN_HEIGHT][SCREEN_WIDTH] = {0,}; | ||
int x, y; | int x, y; | ||
while(1) | while(1) | ||
| Line 40: | Line 40: | ||
for (int j = 0; j < SCREEN_WIDTH; ++j) | for (int j = 0; j < SCREEN_WIDTH; ++j) | ||
{ | { | ||
if (ID_BLOCK == screenArray | if (ID_BLOCK == screenArray[i][j]) | ||
printf("■"); | printf("■"); | ||
else | else | ||
| Line 49: | Line 49: | ||
scanf("%d %d", &x, &y); | scanf("%d %d", &x, &y); | ||
system("CLS"); | system("CLS"); | ||
screenArray | screenArray[y][x] = ID_BLOCK; | ||
} | } | ||
} | } | ||
---- | ---- | ||
[[테트리스만들기2006]] | [[테트리스만들기2006]] | ||
Latest revision as of 01:32, 27 March 2026
테트리스만들기2006/예제1
=== 오늘할일 ===
사각형만 내려오는 테트리스를 만든다. 계속 내려오기만 하면 되며 끝까지 쌓이면 프로그램이 종료된다. 가로와 세로의 크기는 임의로 정한다.
=== 참고할 예제소스 ===
==== 1초마다 숫자를 1 증가시키는 소스 ====
#include <stdio.h>
#include <stdlib.h>
#include <Windows.h>
void main()
{
int number = 0;
while(1)
{
system("CLS");
printf("%d", number);
++number;
Sleep(1000);
}
}
==== 발로짠 원하는 위치에 점찍는 소스 ====
#include <stdio.h>
#include <stdlib.h>
#define SCREEN_WIDTH 17
#define SCREEN_HEIGHT 9
#define ID_BLOCK 1
void main()
{
int screenArray[SCREEN_HEIGHT][SCREEN_WIDTH] = {0,};
int x, y;
while(1)
{
for(int i = 0; i < SCREEN_HEIGHT; ++i)
{
for (int j = 0; j < SCREEN_WIDTH; ++j)
{
if (ID_BLOCK == screenArray[i][j])
printf("■");
else
printf(" ");
}
printf("\n");
}
scanf("%d %d", &x, &y);
system("CLS");
screenArray[y][x] = ID_BLOCK;
}
}