aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar jonas <himself@jonasgunz.de> 2018-12-07 13:10:00 +0100
committerGravatar jonas <himself@jonasgunz.de> 2018-12-07 13:10:00 +0100
commitc7ee3d48002585362505b68aabd1093a2877e1cc (patch)
tree1e84a4a7290eb7c984683980c260658a85a91f5d
parent8c81604b5a22a72885ff5d6270a251172fa90319 (diff)
downloadtermgl-c7ee3d48002585362505b68aabd1093a2877e1cc.tar.gz
cRender ported to Linux.
Functional
-rw-r--r--AmpelJonas/Makefile12
-rw-r--r--AmpelJonas/cRender.cpp10
-rw-r--r--AmpelJonas/cRender.h2
-rw-r--r--AmpelJonas/main.cpp2
4 files changed, 16 insertions, 10 deletions
diff --git a/AmpelJonas/Makefile b/AmpelJonas/Makefile
index a581b30..32709e2 100644
--- a/AmpelJonas/Makefile
+++ b/AmpelJonas/Makefile
@@ -1,11 +1,17 @@
CC = /usr/bin/g++
CFLAGS = -Wall -g
-LDFLAGS = -lm -lpthread
+LDFLAGS = -lm -lpthread -lcurses
+OUTPUT = Kreuzung
-OBJ = main.o cCar.o cCrossroad.o cObject.o cObjectHandler.o cPeasant.o cPeasantTrafficLight.o cRender.o cTrafficLight.o
+OBJ = main.o cCar.o cCrossroad.o cObject.o cObjectHandler.o cPeasant.o cPeasantTrafficLight.o cRender.o cTrafficLight.o
prog: $(OBJ)
- $(CC) $(CFLAGS) -o prog $(OBJ) $(LDFLAGS)
+ $(CC) $(CFLAGS) -o $(OUTPUT) $(OBJ) $(LDFLAGS)
%.o: %.cpp
$(CC) $(CFLAGS) -c $<
+
+.PHONY: clean
+
+clean:
+ rm -f $(OUTPUT) *.o
diff --git a/AmpelJonas/cRender.cpp b/AmpelJonas/cRender.cpp
index 4f18df5..61d4843 100644
--- a/AmpelJonas/cRender.cpp
+++ b/AmpelJonas/cRender.cpp
@@ -13,8 +13,8 @@ cRender::cRender(char _backound, WORD _color, int _sx, int _sy)
struct winsize w;
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
- sizeX = w.ws_row;
- sizeY = w.ws_col;
+ sizeX = w.ws_col;
+ sizeY = w.ws_row - 1;
if(sizeX < _sx || sizeY < _sy) //Notify Program tha screen is too small for desired Size
iLastError = _ERR_SCREEN_TOO_SMALL_;
@@ -38,11 +38,11 @@ cRender::cRender(char _backound, WORD _color, int _sx, int _sy)
//Initialize 2D array
cScreen = (char**)malloc(sizeof *cScreen * sizeX);
- for (int i = 0; i < _sx; i++)
+ for (int i = 0; i < sizeX; i++)
cScreen[i] = (char*)malloc(sizeof *cScreen[i] * sizeY);
wColor = (WORD**)malloc(sizeof *wColor * sizeX);
- for (int i = 0; i < _sx; i++)
+ for (int i = 0; i < sizeX; i++)
wColor[i] = (WORD*)malloc(sizeof *wColor[i] * sizeY);
clear(); //Init backround array
@@ -150,7 +150,7 @@ int cRender::render(void)
SetConsoleTextAttribute(hstdout, wColor[o][i] | _COL_INTENSITY);
cout << cScreen[o][i];
#elif __linux__
- cout << "\033["<< wColor[o][i] <<"m"<< cScreen[o][i] <<"\033[0m";
+ cout << "\033["<< wColor[o][i] <<"m"<< cScreen[o][i];
#endif
}
cout << endl; //New Line Feed
diff --git a/AmpelJonas/cRender.h b/AmpelJonas/cRender.h
index 1ff3416..848619d 100644
--- a/AmpelJonas/cRender.h
+++ b/AmpelJonas/cRender.h
@@ -9,7 +9,7 @@
#include <term.h>
#include <sys/ioctl.h>
- typedef char WORD;
+ typedef int WORD;
#elif _WIN32
#include <Windows.h>
#else
diff --git a/AmpelJonas/main.cpp b/AmpelJonas/main.cpp
index 1b463c1..47a214b 100644
--- a/AmpelJonas/main.cpp
+++ b/AmpelJonas/main.cpp
@@ -11,4 +11,4 @@ int main()
cin.get();
return 0;
-} \ No newline at end of file
+}