Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
b7a53bdb43 | |||
7700d4fdb0 | |||
1ebdd68873 | |||
ab4ddaf365 |
12
.drone.yml
12
.drone.yml
@@ -7,12 +7,16 @@ steps:
|
|||||||
image: alpine
|
image: alpine
|
||||||
#install make and gcc
|
#install make and gcc
|
||||||
commands:
|
commands:
|
||||||
- apk add build-base ncurses-dev
|
- apk add build-base ncurses-dev ncurses ncurses-terminfo ncurses-static g++
|
||||||
- mkdir build
|
- mkdir build
|
||||||
- gcc -o build/main main.c -lncurses
|
- gcc -static -o build/main_static_alpine main.c -l:libncurses.so
|
||||||
|
- gcc -o build/main_dynamic main.c -lncurses
|
||||||
artifacts:
|
artifacts:
|
||||||
- name: compiled
|
- name: compiled_static
|
||||||
path: main
|
path: build/main_static_alpine
|
||||||
|
type: file
|
||||||
|
- name: compiled_dynamic
|
||||||
|
path: build/main_dynamic
|
||||||
type: file
|
type: file
|
||||||
- name: gitea_release
|
- name: gitea_release
|
||||||
image: plugins/gitea-release
|
image: plugins/gitea-release
|
||||||
|
4
.vscode/tasks.json
vendored
4
.vscode/tasks.json
vendored
@@ -13,13 +13,15 @@
|
|||||||
],
|
],
|
||||||
"command": "/usr/bin/gcc",
|
"command": "/usr/bin/gcc",
|
||||||
"args": [
|
"args": [
|
||||||
|
"-static",
|
||||||
"-fdiagnostics-color=always",
|
"-fdiagnostics-color=always",
|
||||||
"-g",
|
"-g",
|
||||||
"${workspaceFolder}/main.c",
|
"${workspaceFolder}/main.c",
|
||||||
"-o",
|
"-o",
|
||||||
//include ncurses
|
//include ncurses
|
||||||
"${fileDirname}/${fileBasenameNoExtension}",
|
"${fileDirname}/${fileBasenameNoExtension}",
|
||||||
"-lncurses"
|
"-lncurses",
|
||||||
|
"-ltinfo"
|
||||||
],
|
],
|
||||||
"options": {
|
"options": {
|
||||||
"cwd": "${fileDirname}"
|
"cwd": "${fileDirname}"
|
||||||
|
14
main.c
14
main.c
@@ -20,15 +20,12 @@ char blank_char = 32;
|
|||||||
char wall_char = 35;
|
char wall_char = 35;
|
||||||
char goal_char = 71;
|
char goal_char = 71;
|
||||||
char player_char = 80;
|
char player_char = 80;
|
||||||
char bullet_char = 120;
|
|
||||||
char inchar = ' ';
|
char inchar = ' ';
|
||||||
uint16_t blank_color = 0;
|
uint16_t blank_color = 0;
|
||||||
uint16_t wall_color = 1;
|
uint16_t wall_color = 1;
|
||||||
uint16_t goal_color = 2;
|
uint16_t goal_color = 2;
|
||||||
uint16_t player_color = 3;
|
uint16_t player_color = 3;
|
||||||
uint16_t border_color = 4;
|
uint16_t border_color = 4;
|
||||||
uint16_t bullet1_color = 5;
|
|
||||||
uint16_t bullet2_color = 5;
|
|
||||||
char letter = ' ';
|
char letter = ' ';
|
||||||
struct Object {
|
struct Object {
|
||||||
uint16_t x;
|
uint16_t x;
|
||||||
@@ -37,13 +34,6 @@ struct Object {
|
|||||||
uint16_t color;
|
uint16_t color;
|
||||||
uint8_t dir;
|
uint8_t dir;
|
||||||
};
|
};
|
||||||
struct Bullet {
|
|
||||||
uint16_t x;
|
|
||||||
uint16_t y;
|
|
||||||
uint8_t dir;
|
|
||||||
uint8_t color;
|
|
||||||
};
|
|
||||||
uint16_t bulletptr = 0;
|
|
||||||
uint16_t player_x = 0;
|
uint16_t player_x = 0;
|
||||||
uint16_t player_y = 0;
|
uint16_t player_y = 0;
|
||||||
uint16_t goal_x = 0;
|
uint16_t goal_x = 0;
|
||||||
@@ -52,7 +42,6 @@ uint16_t rng_tmp = 0;
|
|||||||
uint16_t orient = 0;
|
uint16_t orient = 0;
|
||||||
uint16_t inputs_tmp = 0;
|
uint16_t inputs_tmp = 0;
|
||||||
struct Object * rendered;
|
struct Object * rendered;
|
||||||
struct Bullet * bullets;
|
|
||||||
char * playfield;
|
char * playfield;
|
||||||
int randomInt(int lower, int upper) {
|
int randomInt(int lower, int upper) {
|
||||||
return rand() % (upper - lower + 1) + lower;
|
return rand() % (upper - lower + 1) + lower;
|
||||||
@@ -163,7 +152,6 @@ void init() {
|
|||||||
getmaxyx(stdscr, SCR_Y, SCR_X);
|
getmaxyx(stdscr, SCR_Y, SCR_X);
|
||||||
playfield = malloc(sizeof(char) * SCR_Y * SCR_X);
|
playfield = malloc(sizeof(char) * SCR_Y * SCR_X);
|
||||||
rendered = malloc(sizeof(struct Object) * (SCR_X) * (SCR_Y));
|
rendered = malloc(sizeof(struct Object) * (SCR_X) * (SCR_Y));
|
||||||
bullets = malloc(sizeof(struct Bullet) * (SCR_X) * (SCR_Y));
|
|
||||||
noecho();
|
noecho();
|
||||||
nodelay(stdscr, TRUE);
|
nodelay(stdscr, TRUE);
|
||||||
start_color();
|
start_color();
|
||||||
@@ -172,8 +160,6 @@ void init() {
|
|||||||
init_pair(goal_color, COLOR_BLACK, COLOR_GREEN);
|
init_pair(goal_color, COLOR_BLACK, COLOR_GREEN);
|
||||||
init_pair(player_color, COLOR_BLACK, COLOR_YELLOW);
|
init_pair(player_color, COLOR_BLACK, COLOR_YELLOW);
|
||||||
init_pair(border_color, COLOR_WHITE, COLOR_BLUE);
|
init_pair(border_color, COLOR_WHITE, COLOR_BLUE);
|
||||||
init_pair(bullet1_color, COLOR_BLACK, COLOR_YELLOW);
|
|
||||||
init_pair(bullet2_color, COLOR_BLACK, COLOR_GREEN);
|
|
||||||
attron(COLOR_PAIR(blank_color));
|
attron(COLOR_PAIR(blank_color));
|
||||||
clear();
|
clear();
|
||||||
srand(time(NULL));
|
srand(time(NULL));
|
||||||
|
Reference in New Issue
Block a user