Compare commits

...

5 Commits

Author SHA1 Message Date
f99024bb75 add testing
All checks were successful
continuous-integration/drone/push Build is passing
2022-05-29 19:35:57 +02:00
b7a53bdb43 fix stuff
All checks were successful
continuous-integration/drone/push Build is passing
2022-05-29 11:22:38 +02:00
7700d4fdb0 fix stic compile
All checks were successful
continuous-integration/drone/push Build is passing
2022-05-29 11:10:12 +02:00
1ebdd68873 compile statically
Some checks failed
continuous-integration/drone/push Build is failing
2022-05-29 10:58:43 +02:00
ab4ddaf365 clean up bullets
All checks were successful
continuous-integration/drone/push Build is passing
2022-05-29 10:43:50 +02:00
5 changed files with 69 additions and 24 deletions

@ -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

@ -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}"

BIN
main

Binary file not shown.

49
main.c

@ -12,23 +12,23 @@
#include <math.h> #include <math.h>
#include <string.h>
uint16_t Hole_Div = 40; uint16_t Hole_Div = 40;
uint16_t SCR_X; uint16_t SCR_X;
uint16_t SCR_Y; uint16_t SCR_Y;
#define FPS (60) uint16_t FPS = 60;
char blank_char = 32; 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 Quit_on_pass = 0;
uint16_t bullet2_color = 5;
char letter = ' '; char letter = ' ';
struct Object { struct Object {
uint16_t x; uint16_t x;
@ -37,13 +37,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 +45,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 +155,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 +163,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));
@ -250,9 +239,26 @@ int main(int argc, char * argv[]) {
SCR_Y = atoi(argv[2]); SCR_Y = atoi(argv[2]);
Hole_Div = atoi(argv[3]); Hole_Div = atoi(argv[3]);
} }
if(argc == 5){
SCR_X = atoi(argv[1]);
SCR_Y = atoi(argv[2]);
Hole_Div = atoi(argv[3]);
FPS = atoi(argv[4]);
}
if (argc == 6){
SCR_X = atoi(argv[1]);
SCR_Y = atoi(argv[2]);
Hole_Div = atoi(argv[3]);
FPS = atoi(argv[4]);
if(strcmp(argv[5],"-n") == 0){
Quit_on_pass = 1;
}
}
generate_maze(); generate_maze();
render_maze(); if(Quit_on_pass == 0){
draw_maze(); render_maze();
draw_maze();
}
while (1) { while (1) {
inputs_tmp = keyinput(); inputs_tmp = keyinput();
if (inputs_tmp == 1) { if (inputs_tmp == 1) {
@ -264,10 +270,15 @@ int main(int argc, char * argv[]) {
} else { } else {
orient = 0; orient = 0;
} }
if(Quit_on_pass == 1){
return 4;
}
generate_maze(); generate_maze();
} }
render_maze(); if(Quit_on_pass == 0){
draw_maze(); render_maze();
draw_maze();
}
usleep(round(1000000 / FPS)); usleep(round(1000000 / FPS));
} }
endwin(); endwin();

28
test.sh Normal file

@ -0,0 +1,28 @@
#!/bin/bash
RANDOM=$$$(date +%s)
X=""
CNT=0
CNTX=0
CNTA=0
CNTB=0
CNTXB=0
CNTAB=0
while [ $CNTX -lt 50 ]; do
let CNT=0
while [ $CNT -lt 162 ]; do
X+="wd"
let CNT=CNT+1
done
let CNTA=0
while [ $CNTA -lt 162 ]; do
X+="wa"
let CNTA=CNTA+1
done
let CNTX=CNTX+1
done
X+="q"
echo $X