Bug fixes and fixing build system to be more reliable

This commit is contained in:
Daniel Weber 2024-02-19 20:44:33 -05:00
parent 63fa9d8eab
commit 3819294f57
13 changed files with 29 additions and 189 deletions

View File

@ -1,23 +0,0 @@
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"C:\\Users\\Daniel\\Documents\\Projects\\i686-w64-mingw32\\include\\SDL2"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.14393.0",
"compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "msvc-x64"
}
],
"version": 4
}

28
.vscode/launch.json vendored
View File

@ -1,28 +0,0 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/Chess.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\Program Files (x86)\\mingw-w64\\i686-7.2.0-posix-dwarf-rt_v5-rev1\\mingw32\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}

View File

@ -1,5 +0,0 @@
{
"files.associations": {
"stack": "cpp"
}
}

32
.vscode/tasks.json vendored
View File

@ -1,32 +0,0 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "Build Ouptup",
"command": "g++",
"args": [
"*.cpp",
"-IC:\\Users\\Daniel\\Documents\\Projects\\i686-w64-mingw32\\include\\SDL2",
"-LC:\\Users\\Daniel\\Documents\\Projects\\i686-w64-mingw32\\lib",
"-w",
"-Wl,-subsystem,windows",
"-lmingw32",
"-lSDL2main",
"-lSDL2",
"-static-libstdc++",
"-o",
"Chess"
],
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
}
},
]
}

21
CMakeLists.txt Normal file
View File

@ -0,0 +1,21 @@
cmake_minimum_required(VERSION 3.8)
set(This Chess)
project(${This} C CXX)
enable_language(CXX)
# set(SDL2_INCLUDE_DIR /usr/include/SDL2)
# set(SDL2_LIBRARY /usr/lib/x86_64-linux-gnu/libSDL2.so)
# list(APPEND CMAKE_MODULE_PATH SDL2_INCLUDE_DIR)
# list(APPEND CMAKE_MODULE_PATH SDL2_LIBRARY)
#list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/sdl2)
find_package(SDL2 REQUIRED)
file(GLOB FILES
src/*.cpp)
add_executable(${This} ${FILES})
include_directories(${SDL2_INCLUDE_DIRS})
target_link_libraries(${This} ${SDL2_LIBRARIES})

View File

@ -1,12 +0,0 @@
task "configure" do
check_cxx_compiler "g++"
check_lib "SDL2"
check_lib "SDL2main"
end
task "build" do
env do |env|
env.Program("Chess", glob("src/*.cpp"))
end
end

46
rscons

File diff suppressed because one or more lines are too long

View File

@ -1,9 +1,7 @@
#include "chess_board.h"
#include "stdio.h"
#include <stack>
#include <string.h>
#include "pieces.hpp"
#include <SDL2/SDL.h>
static uint8_t Board_State[12][8] = {{0}};
@ -78,12 +76,12 @@ bool square_is_safe(uint8_t row, uint8_t column)
int8_t temp = row + (White_Turn ? -1 : 1);
/* first check if pawns can take us */
if ((White_Turn ? PAWN_BLACK : PAWN_WHITE) == Board_State[temp][column - 1u])
if ((column > 0) && ((White_Turn ? PAWN_BLACK : PAWN_WHITE) == Board_State[temp][column - 1u]))
{
//can be eaten by a pawn, not safe.
return false;
}
if ((White_Turn ? PAWN_BLACK : PAWN_WHITE) == Board_State[temp][column + 1u])
if ((column < 7) && ((White_Turn ? PAWN_BLACK : PAWN_WHITE) == Board_State[temp][column + 1u]))
{
//can be eaten by a pawn, not safe.
return false;
@ -662,11 +660,11 @@ bool Check_If_Player_Can_Move(bool white)
{
if((white_team(Board_State[row][column]) == white))
{
SDL_Log("move: Row:%d, Col:%d", row, column);
// SDL_Log("move: Row:%d, Col:%d", row, column);
if(Mark_Potential_Moves(Board_State[row][column], column, row))
{
SDL_Log("Player Can still move: Row:%d, Col:%d", row, column);
// SDL_Log("Player Can still move: Row:%d, Col:%d", row, column);
clear_lights();
return true;
}
@ -675,7 +673,7 @@ bool Check_If_Player_Can_Move(bool white)
}
clear_lights();
SDL_Log("Player cant move");
// SDL_Log("Player cant move");
return false;
}

View File

@ -1,4 +1,4 @@
#include <cstdint>
#include "stdint.h"
#define LIGHT_OFF 0u
#define POTENTIAL_MOVE 1u

View File

@ -49,7 +49,6 @@ int begin_game(SDL_Renderer *renderer, SDL_Window *win)
ui_click(renderer, event.button.x, event.button.y);
end_time = clock();
SDL_RenderPresent(renderer);
clock_t t = end_time - start_time;
SDL_Log("No. of clicks %ld clicks (%f seconds) to process the incoming click.\n", t, ((float)t) / CLOCKS_PER_SEC);
}
@ -107,4 +106,4 @@ int begin_game(SDL_Renderer *renderer, SDL_Window *win)
//g++ main.cpp -o blah `sdl2-config --cflags --libs`
/*
g++ main.cpp -IC:\Users\Daniel\Documents\Projects\i686-w64-mingw32\include\SDL2 -LC:\Users\Daniel\Documents\Projects\i686-w64-mingw32\lib -w -Wl,-subsystem,windows -lmingw32 -lSDL2main -lSDL2 -o SDLMain
*/
*/

View File

@ -1,12 +0,0 @@
#include "pieces.hpp"
pieces::pieces(uint8_t row, uint8_t column)
{
my_position.row = row;
my_position.column = column;
}
pieces::~pieces()
{
}

View File

@ -1,19 +0,0 @@
#include <stdint.h>
#define UNINIT 0xFFu
struct position
{
uint8_t row;
uint8_t column;
};
class pieces
{
private:
position my_position;
public:
pieces(uint8_t row, uint8_t column);
~pieces();
};

View File

@ -1,6 +1,5 @@
#include "user_interface_abstraction.h"
#include "chess_board.h"
#include <stack>
#include <string.h>
#define MARGIN 300