This repository has been archived on 2024-01-06. You can view files and clone it, but cannot push or open issues or pull requests.
justhomework/MCU/MCU_REAL _FINAL/block.c

89 lines
1.2 KiB
C
Raw Normal View History

#include "block.h"
Group *base;
Group *piece;
void blockInit()
{
base=(Group*)calloc(1,sizeof(Group));
groupInit(*base,64);
}
void genPiece()
{
unsigned char i=2+rand()%3;
piece=(Group*)calloc(1,sizeof(Group));
groupInit(*piece,i);
}
void genShape(Group g)
{
//<2F><>Ҫһ<D2AA><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int random=rand()%4;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if(g.len==2)
{
if(random%2==0)
{
g.list[0].x=4; //
g.list[0].y=8; //
g.list[1].x=4;
g.list[1].y=9;
}
else
{
g.list[0].x=4; ////
g.list[0].y=8;
g.list[1].x=5;
g.list[1].y=8;
}
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if(g.len==3)
{
if(random%2==0)
{
g.list[0].x=4; //
g.list[0].y=8; //
g.list[1].x=4; //
g.list[1].y=9;
g.list[2].x=4;
g.list[2].y=10;
}
else
{
g.list[0].x=4; //////
g.list[0].y=8;
g.list[1].x=5;
g.list[1].y=8;
g.list[2].x=4;
g.list[2].y=9;
}
}
//<2F><><EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if(g.len==3)
{
if(random==0)
{
g.list[0].x=4; //
g.list[0].y=8; //
g.list[1].x=4; ////
g.list[1].y=9;
g.list[2].x=4;
g.list[2].y=10;
g.list[3].x=5;
g.list[3].y=8;
}
else
{
g.list[0].x=4;
g.list[0].y=8;
g.list[1].x=5;
g.list[1].y=8;
g.list[2].x=4;
g.list[2].y=9;
}
}
}