-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
58 lines (45 loc) · 1.91 KB
/
main.cpp
File metadata and controls
58 lines (45 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <iostream>
#include "miosix.h"
#include <time.h>
#include <stdlib.h>
#include <fcntl.h>
#include "terminal/terminal.h"
#include "render_object/menu/menu.h"
#include "terminal/input_manager.h"
using namespace std;
using namespace miosix;
int main()
{
srand (time(NULL));
int row = 0, col = 0;
InputManager inputManager;
Terminal terminal(&inputManager);
terminal.getPos(&row,&col);
if(row<ROW_TETRIS || col<COL_TETRIS){
printf("The terminal size is not enough, exiting.\n");
return -1;
}
RenderObject * actualRenderObject = new Menu(&inputManager, &terminal);
while (!isDone)
{
//TODO check the condition if a signal handler can be used.
RenderObject * returnedRenderObject = actualRenderObject->drawFrame();
if(returnedRenderObject!=NULL){
delete actualRenderObject;
actualRenderObject = returnedRenderObject;
}
Thread::sleep(500);
}
// printf("(%d,%d)\n",col,row);
//TODO: follow example in https://solarianprogrammer.com/2019/04/08/c-programming-ansi-escape-codes-windows-macos-linux-terminals/
//TODO: use another thread to read the input from keyboard and not displaying it in some way and then add a queue in which puts the input, that is read in the other part by some class that is mainting a state used to draw the frame
//TODO: use instead the main loop in order to draw frames
//TODO: use external file to draw each object, and pass the content to this file at a function like drawObject() that move the cursor where to write on screen for represents this object and takes also the color of them and where to leave the cursor at the end
//TODO: set the screen dimension fixed to a 50x50 and then center it in other cases?
delete actualRenderObject;
terminal.resetScreen();
return 0;
}