Compare commits
No commits in common. "8b2a969f6d1770b9738eafa04cff32e82c4d68c6" and "a9fc1c3a74b5961ad3a308fa3b177d0afbb9d6bb" have entirely different histories.
8b2a969f6d
...
a9fc1c3a74
16
.clang-tidy
Normal file
16
.clang-tidy
Normal file
@ -0,0 +1,16 @@
|
||||
# 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'
|
||||
24
.cmake/get_cpm.cmake
Normal file
24
.cmake/get_cpm.cmake
Normal file
@ -0,0 +1,24 @@
|
||||
# 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,4 +1,13 @@
|
||||
#
|
||||
# Project
|
||||
#
|
||||
|
||||
.build/
|
||||
|
||||
#
|
||||
# ---> C
|
||||
#
|
||||
|
||||
# Prerequisites
|
||||
*.d
|
||||
|
||||
@ -52,7 +61,10 @@ Module.symvers
|
||||
Mkfile.old
|
||||
dkms.conf
|
||||
|
||||
#
|
||||
# ---> C++
|
||||
#
|
||||
|
||||
# Prerequisites
|
||||
*.d
|
||||
|
||||
@ -86,7 +98,10 @@ dkms.conf
|
||||
*.out
|
||||
*.app
|
||||
|
||||
#
|
||||
# ---> CMake
|
||||
#
|
||||
|
||||
CMakeLists.txt.user
|
||||
CMakeCache.txt
|
||||
CMakeFiles
|
||||
@ -99,4 +114,3 @@ compile_commands.json
|
||||
CTestTestfile.cmake
|
||||
_deps
|
||||
CMakeUserPresets.json
|
||||
|
||||
|
||||
22
CMakeLists.txt
Normal file
22
CMakeLists.txt
Normal file
@ -0,0 +1,22 @@
|
||||
|
||||
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
Normal file
95
src/main.c
Normal file
@ -0,0 +1,95 @@
|
||||
|
||||
// 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