move and rotate of i

This commit is contained in:
2024-03-14 14:46:31 +01:00
parent 1959a3f578
commit a7ea698f9b
11 changed files with 376 additions and 35 deletions

91
game-ctrl/buttons.c Normal file
View File

@ -0,0 +1,91 @@
#include "stddef.h"
#include "stdint.h"
#include "buttons.h"
#include "PontCoopScheduler.h"
#include "shapes.h"
#include "canvas.h"
#include "led.h"
// TEST CODE
uint16_t counter;
static uint8_t buttonsMoveLeftPressed() {
// -----------------------
// TEST CODE
if (counter == 25) {
ledGreenToggle();
return 1;
}
// -----------------------
return 0;
}
static uint8_t buttonsMoveRightPressed() {
return 0;
}
static uint8_t buttonsRotateLeftPressed() {
return 0;
}
static uint8_t buttonsRotateRightPressed() {
// -----------------------
// TEST CODE
if (counter == 40) {
ledGreenToggle();
return 1;
}
// -----------------------
// -----------------------
// TEST CODE
if (counter == 80) {
ledGreenToggle();
return 1;
}
// -----------------------
return 0;
}
void buttonsExec(void *handle) {
if (stone.shape == e_ShapeInvalid) {
// don't do anything, the stone has not been initialized
return;
}
// TEST CODE
counter++;
uint8_t buttonPressed = 0;
if (buttonsMoveLeftPressed()) {
stoneMoveLeft();
buttonPressed = 1;
}
if (buttonsMoveRightPressed()) {
stoneMoveRight();
buttonPressed = 1;
}
if (buttonsRotateLeftPressed()) {
stoneRotateLeft();
buttonPressed = 1;
}
if (buttonsRotateRightPressed()) {
stoneRotateRight();
buttonPressed = 1;
}
if (buttonPressed == 1) {
canvasShow();
}
}
void buttonsInit() {
// TEST CODE
counter = 0;
schAdd(buttonsExec, NULL, 0, 100);
}