Skip to content

GraphicEngine

HunSeokJeong edited this page Jun 20, 2021 · 3 revisions

GraphicEngine

GraphicEngine contains fuctions to help Console display and making image Matrix for Object.

Operation It use tmp_screen_buffer to save screen’s temporary image like moving balls. It use screen_buffer to save screen’s lasting image like back ground. By using setTmpBufScreen(), screen_buffer’s data is copying to tmp_screen_buffer, By using update(), tmp_screen_buffer’s data display in the console.

Draw functions

By draw functions, images are pushed in screen_buffer.

void draw(int x, int y, short c, short col);

It allows you to push ascii c with color in position (x, y).

void drawCircle(int x, int y, int r, short c, short col);

It allows you to push circle composed with ascii c and col color whose center position is (x, y).

void drawLine(int x1, int y1, int x2, int y2, short c, short col);

It allows you to push Line start from position(x1,y1) to position(x2,y2).

void drawTriangle(int x1, int y1, int x2, int y2, int x3, int y3, short c, short col)

It allows you to push hollow traingle whose vertices are (x1,y1),(x2,y2),(x3,y3)

void drawSquare(int x, int y, int width, int height, short c, short col);

It allows you to push filled Square with certain width and height whose Top left position is (x,y)

void drawObject(Object obj, short col = 0x000F)

It allows you to push Object to screen_buffer. It use Object’s position (x,y) as top left position and use image Matrix in it.

DrawTmp functions

By drawTmp functions, images are pushed in tmp_screen_buffer.

void drawTmp(int x, int y, short c, short col)

It allows you to push ascii c with color in position (x, y).

void drawTmpObject(Object obj, short col = 0x000F);

It allows you to push Object to tmp_screen_buffer.

Make functions

Make fuction allows you to make certain shape of image matrix easily.

Matrix makeCircle(int r, short c);

It allows you to make Circle image Matrix.

Matrix makeSquare(int width, int height, short c)

It allows you to make filled Square image Matrix.

Matrix makeTriangle(int x1, int y1, int x2, int y2, int x3, int y3, short c, short col);

It allows you to make Traingle image Matrix.

Matrix makeFile2Matrix(const char* filename);

It allows you to make image Matrix from Ascii Painter(oss) file.

Update function

void update();

Update() displays tmp_buffer_screen to console.

void setTmpBufScreen();

setTmpBufScreen() set tmp_buf_screen by coping data in buf_screen