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