Compare commits
2 Commits
configmode
...
1beb7ef04a
Author | SHA1 | Date | |
---|---|---|---|
1beb7ef04a | |||
70467cf2a7 |
@ -354,14 +354,18 @@ const orientation_t nextOrientation[5][4] = { // 5 = number of directions to mov
|
|||||||
stone_t stone;
|
stone_t stone;
|
||||||
shape_t nextShape;
|
shape_t nextShape;
|
||||||
|
|
||||||
|
static shape_t randomNextShape() {
|
||||||
|
return ((shape_t[]){ e_I, e_O, e_T, e_Z, e_S, e_L, e_J })[myRandGet() % e_ShapeInvalid];
|
||||||
|
}
|
||||||
|
|
||||||
void shapesInit() {
|
void shapesInit() {
|
||||||
stone.shape = e_ShapeInvalid;
|
stone.shape = e_ShapeInvalid;
|
||||||
nextShape = e_Z;
|
nextShape = randomNextShape();
|
||||||
}
|
}
|
||||||
|
|
||||||
void stoneCreate() {
|
void stoneCreate() {
|
||||||
stone.shape = nextShape;
|
stone.shape = nextShape;
|
||||||
nextShape = ((shape_t[]){ e_I, e_O, e_T, e_Z, e_S, e_L, e_J })[myRandGet() % e_ShapeInvalid];
|
nextShape = randomNextShape();
|
||||||
stone.orientation = e_0;
|
stone.orientation = e_0;
|
||||||
stone.x = 4;
|
stone.x = 4;
|
||||||
stone.y = 0;
|
stone.y = 0;
|
||||||
@ -452,6 +456,21 @@ void nextStoneDraw() {
|
|||||||
motions[nextShape].color);
|
motions[nextShape].color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void stoneJustDraw(uint8_t x, uint8_t y, shape_t shape) {
|
||||||
|
canvasSetPixel(x + motions[shape].draw[0].x,
|
||||||
|
y + motions[shape].draw[0].y,
|
||||||
|
motions[shape].color);
|
||||||
|
canvasSetPixel(x + motions[shape].draw[1].x,
|
||||||
|
y + motions[shape].draw[1].y,
|
||||||
|
motions[shape].color);
|
||||||
|
canvasSetPixel(x + motions[shape].draw[2].x,
|
||||||
|
y + motions[shape].draw[2].y,
|
||||||
|
motions[shape].color);
|
||||||
|
canvasSetPixel(x + motions[shape].draw[3].x,
|
||||||
|
y + motions[shape].draw[3].y,
|
||||||
|
motions[shape].color);
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t stoneDraw() {
|
uint8_t stoneDraw() {
|
||||||
nextStoneDraw();
|
nextStoneDraw();
|
||||||
|
|
||||||
@ -466,38 +485,12 @@ uint8_t stoneDraw() {
|
|||||||
canvasIsPixelFree(stone.x + motions[stone.shape].draw[3].x,
|
canvasIsPixelFree(stone.x + motions[stone.shape].draw[3].x,
|
||||||
stone.y + motions[stone.shape].draw[3].y)) {
|
stone.y + motions[stone.shape].draw[3].y)) {
|
||||||
// if so, draw the shape
|
// if so, draw the shape
|
||||||
canvasSetPixel(stone.x + motions[stone.shape].draw[0].x,
|
stoneJustDraw(stone.x, stone.y, stone.shape);
|
||||||
stone.y + motions[stone.shape].draw[0].y,
|
|
||||||
motions[stone.shape].color);
|
|
||||||
canvasSetPixel(stone.x + motions[stone.shape].draw[1].x,
|
|
||||||
stone.y + motions[stone.shape].draw[1].y,
|
|
||||||
motions[stone.shape].color);
|
|
||||||
canvasSetPixel(stone.x + motions[stone.shape].draw[2].x,
|
|
||||||
stone.y + motions[stone.shape].draw[2].y,
|
|
||||||
motions[stone.shape].color);
|
|
||||||
canvasSetPixel(stone.x + motions[stone.shape].draw[3].x,
|
|
||||||
stone.y + motions[stone.shape].draw[3].y,
|
|
||||||
motions[stone.shape].color);
|
|
||||||
res = 1;
|
res = 1;
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void stoneJustDraw(uint8_t x, uint8_t y, shape_t shape) {
|
|
||||||
canvasSetPixel(x + motions[shape].draw[0].x,
|
|
||||||
y + motions[shape].draw[0].y,
|
|
||||||
motions[shape].color);
|
|
||||||
canvasSetPixel(x + motions[shape].draw[1].x,
|
|
||||||
y + motions[shape].draw[1].y,
|
|
||||||
motions[shape].color);
|
|
||||||
canvasSetPixel(x + motions[shape].draw[2].x,
|
|
||||||
y + motions[shape].draw[2].y,
|
|
||||||
motions[shape].color);
|
|
||||||
canvasSetPixel(x + motions[shape].draw[3].x,
|
|
||||||
y + motions[shape].draw[3].y,
|
|
||||||
motions[shape].color);
|
|
||||||
}
|
|
||||||
|
|
||||||
void stoneDrawConfigPattern() {
|
void stoneDrawConfigPattern() {
|
||||||
stoneJustDraw(1, 0, e_I);
|
stoneJustDraw(1, 0, e_I);
|
||||||
stoneJustDraw(3, 4, e_O);
|
stoneJustDraw(3, 4, e_O);
|
||||||
|
Reference in New Issue
Block a user