Well I've tried and it wont work, otherwise i wont be posting this thread. The thing is i don't know how to make it to print inside the box that i have made. im quite new to programming c thats why I have a lot that i dont know.
what i have done so far.
Code:
#include <stdio.h>
#include <stdlib.h>
#define ROW 15
#define COLUMN 15
void gameboard(char b[ROW][COLUMN])
{
int r, c;
for(r = -1; r <= ROW; r++)
{
for(c = -1; c <= COLUMN; c++)
{
if(r == -1 || r == ROW || c == -1 || c == COLUMN)
putchar('*');
else
putchar(b[r][c]);
}
putchar('\n');
}
}
void assignblocks(char b[ROW][COLUMN])
{
int rol,col;
srand( (unsigned) time(NULL));
for (rol = 7;rol<10;rol++)
{
b[rol][0] = rand()%2;
if (b[rol][0] == 1)
{
b[rol][0]= 'X';
printf("%c",b[rol][0]);
}
}
printf("\n");
for (rol = 7;rol<10;rol++)
{
b[rol][1] = rand()%2;
if (b[rol][1] == 1)
{
b[rol][1]= 'X';
printf("%c",b[rol][1]);
}
}
printf("\n");
for (rol = 7;rol<10;rol++)
{
b[rol][2] = rand()%2;
if (b[rol][2] == 1)
{
b[rol][2]= 'X';
printf("%c",b[rol][2]);
}
}
}
int main(void)
{
char box[ROW][COLUMN];
char name[20] ="AAA" ;
int x,y;
printf("*************Tetris Game*************\n");
printf("Please Enter Player Name: ");
scanf("%s", &name);
printf("Player Name:%s\n", name);
for(x=0; x<15; x++)
{
for(y=0; y<15; y++)
{
box[x][y] = ' ';
}
}
gameboard(box);
assignblocks(box);
return 0;
}