Compare commits

..

No commits in common. "3af2f2fd21f4b9a08e093a6d27f55c78f7eb6760" and "97aac296262d6ffddd75d6a993c4f57c1eb2e9aa" have entirely different histories.

5 changed files with 68 additions and 88 deletions

View file

@ -5,6 +5,5 @@ project('playergame', 'c',
] ]
) )
cursesdep = dependency('curses') cursesdep = dependency('curses')
#pdcursesdep = [dependency('pdcurses'), dependency('SDL')]
executable('playergame', 'src/main.c', dependencies: cursesdep) executable('playergame', 'src/main.c', dependencies: cursesdep)

View file

@ -3,68 +3,25 @@
#include "linux.h" //TODO make this detect and change depending on os #include "linux.h" //TODO make this detect and change depending on os
#include "maptest.h" #include "maptest.h"
#include "map.h" #include "map.h"
//######################################################
//######################################################
//######################################################
//HOLY FUCK MOVE THIS NOW!!! TODO
//HOLY FUCK MOVE THIS NOW!!! TODO
//HOLY FUCK MOVE THIS NOW!!! TODO
//HOLY FUCK MOVE THIS NOW!!! TODO
//HOLY FUCK MOVE THIS NOW!!! TODO
//HOLY FUCK MOVE THIS NOW!!! TODO
//HOLY FUCK MOVE THIS NOW!!! TODO
//HOLY FUCK MOVE THIS NOW!!! TODO
//HOLY FUCK MOVE THIS NOW!!! TODO
struct entity {
int x;
int y;
int xold; //i kinda dont like tbid xold yold shit
int yold;
char under_char; //the char that is under the entity so when it moves off of it it wont be erased
char under_charold;
}
player = {0, 0, 0, 0, ' ', ' '},
enemy = {24, 16, 0, 0, ' ', ' '},
debugent_x = {0, 0, 0, 0, ' ', ' '},
debugent_y = {0, 0, 0, 0, ' ', ' '};
//HOLY FUCK MOVE THIS NOW!!! TODO
//HOLY FUCK MOVE THIS NOW!!! TODO
//HOLY FUCK MOVE THIS NOW!!! TODO
//HOLY FUCK MOVE THIS NOW!!! TODO
//HOLY FUCK MOVE THIS NOW!!! TODO
//HOLY FUCK MOVE THIS NOW!!! TODO
//HOLY FUCK MOVE THIS NOW!!! TODO
//HOLY FUCK MOVE THIS NOW!!! TODO
//HOLY FUCK MOVE THIS NOW!!! TODO
//HOLY FUCK MOVE THIS NOW!!! TODO
//HOLY FUCK MOVE THIS NOW!!! TODO
//HOLY FUCK MOVE THIS NOW!!! TODO
//HOLY FUCK MOVE THIS NOW!!! TODO
//######################################################
//######################################################
//######################################################
//######################################################
#include "movement.h" #include "movement.h"
int scrwidth = 80; int scrwidth = 80;
int scrheight = 40; int scrheight = 40;
int render_border (int width, int height) { int render_border (int width, int height) {
// width++; width++;
// height--; height++;
// int widthold = width; // int widthold = width;
int heightold = height; int heightold = height;
while(height >= 0){ while(height > 0){
zom_putcharat(width, height, '&'); zom_putcharat(width, height, '&');
height--; height--;
} }
height = heightold; height = heightold;
while(width >= 0){ while(width > 0){
zom_putcharat(width, height, '&'); zom_putcharat(width, height, '&');
width--; width--;
} }
@ -82,6 +39,19 @@ int main( int argc, char *argv[] ) { //yoinked from the internet argc is number
//here it js being stolen from curses //here it js being stolen from curses
bool gamerun = true; bool gamerun = true;
struct entity {
int x;
int y;
int xold; //i kinda dont like tbid xold yold shit
int yold;
char under_char; //the char that is under the entity so when it moves off of it it wont be erased
char under_charold;
}
player = {0, 0, 0, 0, ' ', ' '},
enemy = {24, 16, 0, 0, ' ', ' '},
debugent_x = {0, 0, 0, 0, ' ', ' '},
debugent_y = {0, 0, 0, 0, ' ', ' '};
zom_scrinit(); zom_scrinit();
@ -107,19 +77,31 @@ int main( int argc, char *argv[] ) { //yoinked from the internet argc is number
switch (zom_getch()) { switch (zom_getch()) {
case 'a': case 'a':
attempt_move(&player, 1, 2); if (attempt_move(player.x, player.y, 1, 2) == 1) {
player.x--;
player.under_char = readmap(player.x, player.y);
}
break; break;
case 'w': case 'w':
attempt_move(&player, 1, 1); if (attempt_move(player.x, player.y, 1, 1) == 1) {
player.y--;
player.under_char = readmap(player.x, player.y);
}
break; break;
case 'd': case 'd':
attempt_move(&player, 1, 0); if (attempt_move(player.x, player.y, 1, 0) == 1) {
player.x++;
player.under_char = readmap(player.x, player.y);
}
break; break;
case 's': case 's':
attempt_move(&player, 1, 3); if (attempt_move(player.x, player.y, 1, 3) == 1) {
player.y++;
player.under_char = readmap(player.x, player.y);
}
break; break;
case 'q': case 'q':
@ -131,9 +113,8 @@ int main( int argc, char *argv[] ) { //yoinked from the internet argc is number
break; break;
//debug case //debug case
case 'l': case 'l':
// debugent_x.x++; debugent_x.x++;
debugent_y.y++; debugent_y.y++;
all_entity(&debugent_x);
break; break;
} }
//game logic not kb dependent //game logic not kb dependent
@ -152,6 +133,31 @@ int main( int argc, char *argv[] ) { //yoinked from the internet argc is number
} else {enemy.y++;} } else {enemy.y++;}
} }
/*
TODO clean this shit up
this should apply to everything not just the player
it should also be generalized to all entitys using a for loop or somthing
*/
//anti go off screen
if (player.x < 0) {
player.x = 0;
}
if (player.x > 80) {
player.x = 80;
}
if (player.y < 0) {
player.y = 0;
}
if (player.y > 40) {
player.y = 40;
}
prevtime = currenttime; prevtime = currenttime;
} }

View file

@ -1,22 +1,10 @@
char readmap(int x, int y) { char readmap(int x, int y) {
if (x > (mapwidth - 1)) {
return '&';
}
if (y > (mapheight - 1)) {
return '&';
}
if (x < 0) {
return '&';
}
if (y < 0) {
return '&';
}
return maptest[y][x]; //TODO make it be able to rrad feom multiple maps but idk how to do that return maptest[y][x]; //TODO make it be able to rrad feom multiple maps but idk how to do that
} }
int render_map(void) { int render_map(void) {
int x; int x;
int y; int y;
//I think this is broken but maybe with with the border code idk TODO fix
for(y = 0; y < 40; y++) { for(y = 0; y < 40; y++) {
for(x = 0; x < 80; x++) { for(x = 0; x < 80; x++) {
zom_putcharat(x, y, readmap(x, y)); zom_putcharat(x, y, readmap(x, y));

View file

@ -1,6 +1,4 @@
//TODO make this read from a file instead of from this array pile //TODO make this read from a file instead of from this array pile
int mapwidth = 80;
int mapheight = 40;
char maptest[40][80] = { char maptest[40][80] = {
{'1', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '2'}, {'1', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '2'},
{'2', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '2'}, {'2', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '2'},

View file

@ -1,53 +1,42 @@
//TODO fix this bug //TODO fix this bug
//there is a bug with the units arg //there is a bug with the units arg
//it doesnt check weather EVERY spot in its path is vaiid so it allows the possibity of going thru walls if units is more than 1 //it doesnt check weather EVERY spot in its path is vaiid so it allows the possibity of going thru walls if units is more than 1
int attempt_move(struct entity *fuck, int units, int direction) { int attempt_move(int x, int y, int units, int direction) {
int xfuture = fuck->x; int xfuture = x;
int yfuture = fuck->y; int yfuture = y;
switch (direction) { switch (direction) {
case 0: // right case 0: // right
xfuture = xfuture + units; xfuture = xfuture + units;
if (readmap(xfuture, fuck->y) == '&') { if (readmap(xfuture, y) == '&') {
return 0; return 0;
} }
else { else {
fuck->x++;
fuck->under_char = readmap(fuck->x, fuck->y);
return 1; return 1;
} }
case 1: // up case 1: // up
yfuture = yfuture - units; // we subtract because moving up yfuture = yfuture - units; // we subtract because moving up
if (readmap(fuck->x, yfuture) == '&') { if (readmap(x, yfuture) == '&') {
return 0; return 0;
} }
else { else {
fuck->y--;
fuck->under_char = readmap(fuck->x, fuck->y);
return 1; return 1;
} }
case 2: // left case 2: // left
xfuture = xfuture - units; xfuture = xfuture - units;
if (readmap(xfuture, fuck->y) == '&') { if (readmap(xfuture, y) == '&') {
return 0; return 0;
} }
else { else {
fuck->x--;
fuck->under_char = readmap(fuck->x, fuck->y);
return 1; return 1;
} }
case 3: // down case 3: // down
yfuture = yfuture + units; yfuture = yfuture + units;
if (readmap(fuck->x, yfuture) == '&') { if (readmap(x, yfuture) == '&') {
return 0; return 0;
} }
else { else {
fuck->y++;
fuck->under_char = readmap(fuck->x, fuck->y);
return 1; return 1;
} }
} }
return 0; return 0;
} }
void all_entity(struct entity *fuck) {
fuck->x++;
}