Compare commits
No commits in common. "a9fc1c3a74b5961ad3a308fa3b177d0afbb9d6bb" and "8b2a969f6d1770b9738eafa04cff32e82c4d68c6" have entirely different histories.
a9fc1c3a74
...
8b2a969f6d
16
.clang-tidy
16
.clang-tidy
@ -1,16 +0,0 @@
|
|||||||
# https://clang.llvm.org/extra/clang-tidy/checks/list.html
|
|
||||||
Checks: '-*,
|
|
||||||
bugprone-*,
|
|
||||||
cert-*,
|
|
||||||
misc-*,
|
|
||||||
concurrency-*,
|
|
||||||
performance-*,
|
|
||||||
portability-*,
|
|
||||||
readability-*,
|
|
||||||
clang-analyzer-*,
|
|
||||||
'
|
|
||||||
# CheckOptions:
|
|
||||||
|
|
||||||
WarningsAsErrors: '*'
|
|
||||||
HeaderFilterRegex: '.'
|
|
||||||
FormatStyle: 'file'
|
|
||||||
@ -1,24 +0,0 @@
|
|||||||
# SPDX-License-Identifier: MIT
|
|
||||||
#
|
|
||||||
# SPDX-FileCopyrightText: Copyright (c) 2019-2023 Lars Melchior and contributors
|
|
||||||
|
|
||||||
set(CPM_DOWNLOAD_VERSION 0.40.8)
|
|
||||||
set(CPM_HASH_SUM "78ba32abdf798bc616bab7c73aac32a17bbd7b06ad9e26a6add69de8f3ae4791")
|
|
||||||
|
|
||||||
if(CPM_SOURCE_CACHE)
|
|
||||||
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
|
|
||||||
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
|
|
||||||
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
|
|
||||||
else()
|
|
||||||
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Expand relative path. This is important if the provided path contains a tilde (~)
|
|
||||||
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)
|
|
||||||
|
|
||||||
file(DOWNLOAD
|
|
||||||
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
|
|
||||||
${CPM_DOWNLOAD_LOCATION} EXPECTED_HASH SHA256=${CPM_HASH_SUM}
|
|
||||||
)
|
|
||||||
|
|
||||||
include(${CPM_DOWNLOAD_LOCATION})
|
|
||||||
16
.gitignore
vendored
16
.gitignore
vendored
@ -1,13 +1,4 @@
|
|||||||
#
|
|
||||||
# Project
|
|
||||||
#
|
|
||||||
|
|
||||||
.build/
|
|
||||||
|
|
||||||
#
|
|
||||||
# ---> C
|
# ---> C
|
||||||
#
|
|
||||||
|
|
||||||
# Prerequisites
|
# Prerequisites
|
||||||
*.d
|
*.d
|
||||||
|
|
||||||
@ -61,10 +52,7 @@ Module.symvers
|
|||||||
Mkfile.old
|
Mkfile.old
|
||||||
dkms.conf
|
dkms.conf
|
||||||
|
|
||||||
#
|
|
||||||
# ---> C++
|
# ---> C++
|
||||||
#
|
|
||||||
|
|
||||||
# Prerequisites
|
# Prerequisites
|
||||||
*.d
|
*.d
|
||||||
|
|
||||||
@ -98,10 +86,7 @@ dkms.conf
|
|||||||
*.out
|
*.out
|
||||||
*.app
|
*.app
|
||||||
|
|
||||||
#
|
|
||||||
# ---> CMake
|
# ---> CMake
|
||||||
#
|
|
||||||
|
|
||||||
CMakeLists.txt.user
|
CMakeLists.txt.user
|
||||||
CMakeCache.txt
|
CMakeCache.txt
|
||||||
CMakeFiles
|
CMakeFiles
|
||||||
@ -114,3 +99,4 @@ compile_commands.json
|
|||||||
CTestTestfile.cmake
|
CTestTestfile.cmake
|
||||||
_deps
|
_deps
|
||||||
CMakeUserPresets.json
|
CMakeUserPresets.json
|
||||||
|
|
||||||
|
|||||||
@ -1,22 +0,0 @@
|
|||||||
|
|
||||||
cmake_minimum_required(VERSION 3.12)
|
|
||||||
|
|
||||||
project("C Rogue Game" VERSION "1.0.0" LANGUAGES "C"
|
|
||||||
DESCRIPTION "A rogue-like game written in C99")
|
|
||||||
|
|
||||||
include(.cmake/get_cpm.cmake)
|
|
||||||
CPMAddPackage("gh:robertefry/RockHopperStandards@1.3.6")
|
|
||||||
|
|
||||||
set(BINARY_NAME "c_rogue")
|
|
||||||
add_executable(${BINARY_NAME} "")
|
|
||||||
target_compile_features(${BINARY_NAME} PUBLIC c_std_99)
|
|
||||||
|
|
||||||
target_rockhopper_standards(${BINARY_NAME})
|
|
||||||
|
|
||||||
target_link_libraries(${BINARY_NAME} PUBLIC "ncurses")
|
|
||||||
|
|
||||||
file(GLOB_RECURSE BINARY_HEADERS "include/*.h")
|
|
||||||
file(GLOB_RECURSE BINARY_SOURCES "src/*.c" "src/*.h")
|
|
||||||
target_sources(${BINARY_NAME} PUBLIC ${BINARY_HEADERS} PRIVATE ${BINARY_SOURCES})
|
|
||||||
|
|
||||||
message(STATUS "CMAKE_CXX_COMPILER_ID: ${CMAKE_CXX_COMPILER_ID}")
|
|
||||||
95
src/main.c
95
src/main.c
@ -1,95 +0,0 @@
|
|||||||
|
|
||||||
// https://www.youtube.com/playlist?list=PLkTXsX7igf8erbWGYT4iSAhpnJLJ0Nk5G
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <ncurses.h>
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int pos_x;
|
|
||||||
int pos_y;
|
|
||||||
} player_t;
|
|
||||||
|
|
||||||
player_t *player_malloc(void);
|
|
||||||
void player_free(player_t *player);
|
|
||||||
|
|
||||||
int screen_setup(void);
|
|
||||||
int screen_teardown(void);
|
|
||||||
|
|
||||||
int draw_map(void);
|
|
||||||
int draw_player(player_t *player);
|
|
||||||
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
player_t *player = player_malloc();
|
|
||||||
|
|
||||||
screen_setup();
|
|
||||||
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
draw_map();
|
|
||||||
draw_player(player);
|
|
||||||
refresh();
|
|
||||||
|
|
||||||
char key_pressed = getch();
|
|
||||||
|
|
||||||
if (key_pressed == 'q') {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
screen_teardown();
|
|
||||||
|
|
||||||
player_free(player);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int screen_setup(void)
|
|
||||||
{
|
|
||||||
initscr();
|
|
||||||
noecho();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int screen_teardown(void)
|
|
||||||
{
|
|
||||||
endwin();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int draw_map(void)
|
|
||||||
{
|
|
||||||
int const pos_x = 0;
|
|
||||||
int const pos_y = 0;
|
|
||||||
|
|
||||||
mvprintw(pos_y+0, pos_x, "--------");
|
|
||||||
mvprintw(pos_y+1, pos_x, "|......|");
|
|
||||||
mvprintw(pos_y+2, pos_x, "|......|");
|
|
||||||
mvprintw(pos_y+3, pos_x, "|......|");
|
|
||||||
mvprintw(pos_y+4, pos_x, "--------");
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
player_t *player_malloc(void)
|
|
||||||
{
|
|
||||||
int const player_x = 1;
|
|
||||||
int const player_y = 1;
|
|
||||||
|
|
||||||
player_t *player = (player_t*)malloc(sizeof(player_t));
|
|
||||||
player->pos_x = player_x;
|
|
||||||
player->pos_y = player_y;
|
|
||||||
return player;
|
|
||||||
}
|
|
||||||
|
|
||||||
void player_free(player_t *player)
|
|
||||||
{
|
|
||||||
free(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
int draw_player(player_t *player)
|
|
||||||
{
|
|
||||||
mvprintw(player->pos_y, player->pos_x, "@");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user