Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed mbed-rtos 4DGL-uLCD-SE
Revision 1:4af874b42e33, committed 2020-04-29
- Comitter:
- jsmith687
- Date:
- Wed Apr 29 03:35:48 2020 +0000
- Parent:
- 0:d9dcc0c3cd64
- Commit message:
- Cleaned up
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Apr 28 01:18:23 2020 +0000
+++ b/main.cpp Wed Apr 29 03:35:48 2020 +0000
@@ -1,40 +1,3 @@
-
-/*
-
-desired functionality (not priority)
------------------------------------
- - 2 player
- - check for moves so that if you try to move into check it displays an error
- - highlight previous move and new position in movePiece() function
- - display possible moves as yellow
- - audio needs done in separate thread or with short clips so that it doesn't freeze program
- - alternating color tiles
-
-program flow
------------------------------------
- - game initializes
- - a startup screen displays (or start on menu?)
- - timer begins on first move
- - timer changes every time a move is made
- - loop for new button inputs
- - when select button is hit is when the real checks run
- - if selecting a piece, simply update x and y coordinates of selected piece
- - if moving a selected piece, check if the move is valid and then update the board, switch current player
- - if menu button is hit, it takes priority
- - menu contains settings
- - if timer runs out or your king is taken you lose (display game end screen)
- - make sure gameend resets all variables to original values (or just use the initialize() function)
-
-TODO
-----------------------------------
- - game settings menu
- - en passant
- - castling
- - timer
- - images for pieces
- - need to handle input better, with debounced timer or on deasserted or something
- - restart button
-*/
#include "mbed.h"
#include "rtos.h"
@@ -123,7 +86,7 @@
{BISHOP, PAWN, NONE, NONE, NONE, NONE, PAWN, BISHOP},
{KNIGHT, PAWN, NONE, NONE, NONE, NONE, PAWN, KNIGHT},
{ROOK, PAWN, NONE, NONE, NONE, NONE, PAWN, ROOK}
-};//not sure if i did this right, also check x and y
+};
bool color[8][8] = {
{white, white, white, white, white, white, black, black},
@@ -690,7 +653,6 @@
//check it's on the lines
//check it's on diagonal
//make sure no pieces are in the way
- if (board[x][y] != NONE) return false;
if (x == selectedX) {
//check y direction in a line
if (selectedY < y) {
@@ -838,7 +800,7 @@
return true;
}
else {
- return true;
+ return false;
}
case PAWN:
//check en passant
@@ -912,7 +874,7 @@
timerBlack.stop();
timerWhite.start();
}
- speakerOut.PlayNote(2000, .1, .25);
+ if (playSound) speakerOut.PlayNote(2000, .1, .25);
currentPlayer = !currentPlayer;
}
@@ -943,7 +905,7 @@
if (direction == LEFT) {
positionX--;
}
- speakerOut.PlayNote(500, .1, .25);
+ if (playSound) speakerOut.PlayNote(500, .1, .25);
drawSelectionBox(positionX, positionY, GREEN);
}