more sound effects

This commit is contained in:
2024-04-15 16:42:33 +02:00
parent 2404910870
commit 010c493b90
3 changed files with 31 additions and 17 deletions

View File

@ -60,22 +60,27 @@ void buttonsExec(void *handle) {
if (buttonsMoveLeftPressed()) { if (buttonsMoveLeftPressed()) {
stoneMoveLeft(); stoneMoveLeft();
soundCtrl(e_SOUND_STONE_MOVE_LEFT);
buttonPressed = 1; buttonPressed = 1;
} }
if (buttonsMoveRightPressed()) { if (buttonsMoveRightPressed()) {
stoneMoveRight(); stoneMoveRight();
soundCtrl(e_SOUND_STONE_MOVE_RIGHT);
buttonPressed = 1; buttonPressed = 1;
} }
if (buttonsRotateLeftPressed()) { if (buttonsRotateLeftPressed()) {
stoneRotateLeft(); stoneRotateLeft();
soundCtrl(e_SOUND_STONE_ROTATE_LEFT);
buttonPressed = 1; buttonPressed = 1;
} }
if (buttonsRotateRightPressed()) { if (buttonsRotateRightPressed()) {
stoneRotateRight(); stoneRotateRight();
soundCtrl(e_SOUND_STONE_ROTATE_RIGHT);
buttonPressed = 1; buttonPressed = 1;
} }
if (buttonsMoveDownPressed()) { if (buttonsMoveDownPressed()) {
stoneMoveDown(); stoneMoveDown();
soundCtrl(e_SOUND_STONE_MOVE_DOWN);
buttonPressed = 1; buttonPressed = 1;
} }

View File

@ -7,6 +7,7 @@
#include "canvas.h" #include "canvas.h"
#include "../rgb-driver/colors.h" #include "../rgb-driver/colors.h"
#include "display.h" #include "display.h"
#include "sound.h"
#define GAME_CYCLE_TIME 100 #define GAME_CYCLE_TIME 100
@ -40,6 +41,7 @@ void gameExec(void *handle) {
// --- phase: game -------------------------------------------------------- // --- phase: game --------------------------------------------------------
case e_Start: case e_Start:
canvasClear(); canvasClear();
soundCtrl(e_SOUND_START_BACKGROUND);
level = 1; level = 1;
score = 0; score = 0;
displaySetValue(score); displaySetValue(score);
@ -71,6 +73,7 @@ void gameExec(void *handle) {
case e_Down: case e_Down:
if (! stoneMoveDown()) { if (! stoneMoveDown()) {
soundCtrl(e_SOUND_STONE_LOCKED);
state = e_NewStone; state = e_NewStone;
} else { } else {
proceedDelay = delayFactor(level); proceedDelay = delayFactor(level);
@ -80,6 +83,8 @@ void gameExec(void *handle) {
// --- phase: game over --------------------------------------------------- // --- phase: game over ---------------------------------------------------
case e_GameOver: case e_GameOver:
soundCtrl(e_SOUND_STOP_BACKGROUND);
soundCtrl(e_SOUND_START_GAMEOVER);
rowIndex = CANVAS_HEIGHT; rowIndex = CANVAS_HEIGHT;
phase = e_Phase_GameOver; phase = e_Phase_GameOver;
state = e_GameOverFill; state = e_GameOverFill;
@ -105,6 +110,7 @@ void gameExec(void *handle) {
case e_GameOverDelay: case e_GameOverDelay:
gameOverDelay--; gameOverDelay--;
if (gameOverDelay == 0) { if (gameOverDelay == 0) {
soundCtrl(e_SOUND_STOP_GAMEOVER);
state = e_Start; state = e_Start;
} }
break; break;
@ -113,14 +119,17 @@ void gameExec(void *handle) {
canvasShow(); canvasShow();
if (phase == e_Phase_Game) { if (phase == e_Phase_Game) {
uint8_t wipeCnt = 0;
for (uint8_t r = 0; r < CANVAS_HEIGHT; r++) { for (uint8_t r = 0; r < CANVAS_HEIGHT; r++) {
if (canvasIsRowFilled(r)) { if (canvasIsRowFilled(r)) {
score += level; score += level;
displaySetValue(score); displaySetValue(score);
canvasWipeRow(r); canvasWipeRow(r);
canvasShow(); canvasShow();
wipeCnt += 1;
} }
} }
soundCtrl(e_SOUND_FANFARE_BASE + wipeCnt);
} }
} }

View File

@ -6,23 +6,23 @@
typedef enum { typedef enum {
e_SOUND_IDLE = 0, e_SOUND_IDLE = 0,
e_SOUND_MUTE = 1, e_SOUND_MUTE = 1,
e_SOUND_UNMUTE = 2, e_SOUND_UNMUTE,
e_SOUND_START_BACKGROUND = 3, e_SOUND_START_BACKGROUND,
e_SOUND_STOP_BACKGROUND = 4, e_SOUND_STOP_BACKGROUND,
e_SOUND_START_GAMEOVER = 5, e_SOUND_START_GAMEOVER,
e_SOUND_STOP GAMEOVER = 6, e_SOUND_STOP GAMEOVER,
e_SOUND_SPEED_UP = 7, e_SOUND_SPEED_UP,
e_SOUND_FANFARE_1 = 8, e_SOUND_FANFARE_BASE,
e_SOUND_FANFARE_2 = 9, e_SOUND_FANFARE_1,
e_SOUND_FANFARE_3 = 10, e_SOUND_FANFARE_2,
e_SOUND_FANFARE_4 = 11, e_SOUND_FANFARE_3,
e_SOUND_STONE_LOCKED = 12, e_SOUND_FANFARE_4,
e_SOUND_STONE_MOVE_LEFT = 13, e_SOUND_STONE_LOCKED,
e_SOUND_STONE_MOVE_RIGHT = 14, e_SOUND_STONE_MOVE_LEFT,
e_SOUND_STONE_ROTATE_LEFT = 15, e_SOUND_STONE_MOVE_RIGHT,
e_SOUND_STONE_ROTATE_RIGHT = 16, e_SOUND_STONE_ROTATE_LEFT,
e_SOUND_DROPPING_START = 17, e_SOUND_STONE_ROTATE_RIGHT,
e_SOUND_DROPPING_STOP = 18, e_SOUND_STONE_MOVE_DOWN,
} t_SoundCmd; } t_SoundCmd;
void soundInit(); void soundInit();