Compare commits
No commits in common. "a7ec60390cd8ec777c63fff83e99ce776de4e483" and "e1e330265346d305c44fce459169372bd3c4d831" have entirely different histories.
a7ec60390c
...
e1e3302653
2 changed files with 28 additions and 45 deletions
23
src/linux.h
23
src/linux.h
|
@ -1,23 +0,0 @@
|
||||||
#include <curses.h>
|
|
||||||
|
|
||||||
int fuck(void) {
|
|
||||||
return 69;
|
|
||||||
}
|
|
||||||
int zom_scrinit(void) {
|
|
||||||
initscr();
|
|
||||||
nodelay(stdscr, true);//cbreak would wait for you to press a key this doesnt
|
|
||||||
noecho();
|
|
||||||
clear();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
int zom_screxit(void) {
|
|
||||||
endwin();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
int zom_putcharat(int x, int y, char chara){
|
|
||||||
mvaddch(y, x, chara); //flipped to match screen coords
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
char zom_getch(void){
|
|
||||||
return getch();
|
|
||||||
}
|
|
50
src/main.c
50
src/main.c
|
@ -1,6 +1,6 @@
|
||||||
#include <stdio.h> //printf and shit
|
#include <stdio.h> //printf and shit
|
||||||
|
#include <curses.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "linux.h"
|
|
||||||
|
|
||||||
|
|
||||||
int main( int argc, char *argv[] ) { //yoinked from the internet argc is number of args and argv is a "array of arguments"
|
int main( int argc, char *argv[] ) { //yoinked from the internet argc is number of args and argv is a "array of arguments"
|
||||||
|
@ -24,7 +24,12 @@ int main( int argc, char *argv[] ) { //yoinked from the internet argc is number
|
||||||
debugent_x = {0, 0, 0, 0},
|
debugent_x = {0, 0, 0, 0},
|
||||||
debugent_y = {0, 0, 0, 0};
|
debugent_y = {0, 0, 0, 0};
|
||||||
|
|
||||||
zom_scrinit();
|
initscr();
|
||||||
|
//cbreak();
|
||||||
|
nodelay(stdscr, true);//cbreak would wait for you to press a key this doesnt
|
||||||
|
noecho();
|
||||||
|
|
||||||
|
clear();
|
||||||
|
|
||||||
while(gamerun) {
|
while(gamerun) {
|
||||||
currenttime = clock();
|
currenttime = clock();
|
||||||
|
@ -39,21 +44,21 @@ int main( int argc, char *argv[] ) { //yoinked from the internet argc is number
|
||||||
debugent_y.xold = debugent_y.x;
|
debugent_y.xold = debugent_y.x;
|
||||||
debugent_y.yold = debugent_y.y;
|
debugent_y.yold = debugent_y.y;
|
||||||
|
|
||||||
switch (zom_getch()) {
|
switch (getch()) {
|
||||||
case 'a':
|
case 'a':
|
||||||
player.x--;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'w':
|
|
||||||
player.y--;
|
player.y--;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'w':
|
||||||
|
player.x--;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'd':
|
case 'd':
|
||||||
player.x++;
|
player.y++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 's':
|
case 's':
|
||||||
player.y++;
|
player.x++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'q':
|
case 'q':
|
||||||
|
@ -71,7 +76,7 @@ int main( int argc, char *argv[] ) { //yoinked from the internet argc is number
|
||||||
}
|
}
|
||||||
//game logic not kb dependent
|
//game logic not kb dependent
|
||||||
if ((enemy.x == player.x) && (enemy.y == player.y)){
|
if ((enemy.x == player.x) && (enemy.y == player.y)){
|
||||||
zom_screxit();
|
endwin();
|
||||||
puts("you lose :(");
|
puts("you lose :(");
|
||||||
return 0; //TODO fix this this should not be here...
|
return 0; //TODO fix this this should not be here...
|
||||||
}
|
}
|
||||||
|
@ -87,32 +92,33 @@ int main( int argc, char *argv[] ) { //yoinked from the internet argc is number
|
||||||
prevtime = currenttime;
|
prevtime = currenttime;
|
||||||
}
|
}
|
||||||
//entity rendering
|
//entity rendering
|
||||||
zom_putcharat(enemy.xold, enemy.yold, ' ');
|
mvaddch(enemy.xold, enemy.yold, ' ');
|
||||||
switch (dosspin) {
|
switch (dosspin) {
|
||||||
case 0:
|
case 0:
|
||||||
zom_putcharat(enemy.x, enemy.y, '-');
|
mvaddch(enemy.x, enemy.y, '-');
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
zom_putcharat(enemy.x, enemy.y, '/');
|
mvaddch(enemy.x, enemy.y, '/');
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
zom_putcharat(enemy.x, enemy.y, '|');
|
mvaddch(enemy.x, enemy.y, '|');
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
zom_putcharat(enemy.x, enemy.y, '\\');
|
mvaddch(enemy.x, enemy.y, '\\');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
zom_putcharat(player.xold, player.yold, ' ');
|
mvaddch(player.xold, player.yold, ' ');
|
||||||
zom_putcharat(player.x, player.y, '#');
|
mvaddch(player.x, player.y, '#');
|
||||||
zom_putcharat(debugent_x.xold, debugent_x.yold, ' ');
|
mvaddch(debugent_x.xold, debugent_x.yold, ' ');
|
||||||
zom_putcharat(debugent_x.x, debugent_x.y, 'X');
|
mvaddch(debugent_x.x, debugent_x.y, 'X');
|
||||||
zom_putcharat(debugent_y.xold, debugent_y.yold, ' ');
|
mvaddch(debugent_y.xold, debugent_y.yold, ' ');
|
||||||
zom_putcharat(debugent_y.x, debugent_y.y, 'Y');
|
mvaddch(debugent_y.x, debugent_y.y, 'Y');
|
||||||
}
|
}
|
||||||
|
|
||||||
//cleanup
|
//cleanup
|
||||||
zom_screxit();
|
endwin();
|
||||||
|
|
||||||
printf("Args %d",argc); //anti Wall Werror Wextra
|
printf("Args %d",argc); //anti Wall Werror Wextra
|
||||||
|
|
||||||
puts(argv[0]);//anti Wall Werror Wextra
|
puts(argv[0]);//anti Wall Werror Wextra
|
||||||
|
|
Loading…
Reference in a new issue