@ -1,15 +1,12 @@
# include <structs.h>
# include <stdlib.h>
# include <string.h>
# include <ncurses.h>
# include <world.h>
# include <screen.h>
# include <getPos.h>
void initializeWorld ( ) {
struct Entity player = { . type = " player " , . symbol = ' @ ' , . curYpos = 1 , . curXpos = 1 , . nextYpos = 1 , . nextXpos = 1 , . isAlive = 1 } ;
struct Weapon pistol = { . type = " Pistol " , . isAlive = 1 , . range = 3 , . maxCapacity = 12 , . curCapacity = 12 , . symbols = " - \\ |/- \\ |/ " } ;
srand ( time ( NULL ) ) ;
initscr ( ) ;
curs_set ( 0 ) ;
@ -17,10 +14,26 @@ void initializeWorld() {
nodelay ( stdscr , TRUE ) ;
keypad ( stdscr , TRUE ) ;
noecho ( ) ;
getmaxyx ( stdscr , scrRows , scrCols ) ;
viewportWin = newwin ( scrRows - 10 , scrCols , 0 , 0 ) ;
getmaxyx ( viewportWin , viewportWinRows , viewportWinCols ) ;
scoreWin = newwin ( 10 , scrCols , scrRows - 10 , 0 ) ;
struct Entity player = { . type = " player " , . symbol = ' @ ' , . curYpos = 1 , . curXpos = 1 , . nextYpos = 1 , . nextXpos = 1 , . isAlive = 1 } ;
struct Weapon pistol = { . type = " Pistol " , . isAlive = 1 , . range = 3 , . maxCapacity = 12 , . curCapacity = 12 , . symbols = " - \\ |/- \\ |/ " } ;
viewportWinRows = 21 ;
viewportWinCols = 87 ;
scoreWinRows = 7 ;
scoreWinCols = 87 ;
getmaxyx ( stdscr , stdscrRows , stdscrCols ) ;
if ( stdscrRows < viewportWinRows + scoreWinRows | | stdscrCols < viewportWinCols ) {
endwin ( ) ;
printf ( " ERROR: Terminal too small \n " ) ;
printf ( " Minimum size is: %dx%d \n " , viewportWinRows + scoreWinRows , viewportWinCols ) ;
printf ( " Terminal size is: %dx%d \n " , stdscrRows , stdscrCols ) ;
exit ( 0 ) ;
}
viewportWin = newwin ( viewportWinRows , viewportWinCols , 0 , 0 ) ;
scoreWin = newwin ( scoreWinRows , scoreWinCols , viewportWinRows , 0 ) ;
allEntities [ 0 ] = player ;
allEntities [ 0 ] . curYpos = viewportWinRows / 2 ;