blob: e01325278e9d0c49e2fdd72c89acd7146a5063b4 (
plain)
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
59
60
61
62
63
64
|
#include <ncurses.h>
#include <stdlib.h>
#include <time.h>
#include "GameWorld.hpp"
#include "Vehicle.hpp"
#include "models.hpp"
#include "veh_models.hpp"
int main(int argc, char *argv[])
{
int total_rows, total_cols;
initscr();
noecho();
curs_set(0);
srand(time(0));
getmaxyx(stdscr, total_rows, total_cols);
struct timespec my_timer;
my_timer.tv_sec = 0;
my_timer.tv_nsec = 50000000; // 100000000
GameWorld *world = new GameWorld(total_rows, total_cols);
Vehicle *car = 0;
struct ll_vehicle *ptr_first = new struct ll_vehicle(0, 0);
struct ll_vehicle *ptr;
int wait_move = 0;
for(;;) {
ptr = ptr_first;
while(ptr)
{
car = ptr->data;
if(!car) {
if(wait_move > 0)
break;
int type = rand() % veh_types_max;
ptr->data = new Vehicle(type, total_rows-1, -veh_store[type].length);
car = ptr->data;
wait_move = veh_store[type].length + 3 + rand() % 10;
ptr->next = new struct ll_vehicle(0, 0);
}
if(!car->MoveRight(world)) {
ptr = ptr->next;
delete car;
delete ptr_first;
ptr_first = ptr;
continue;
}
ptr = ptr->next;
}
wait_move--;
world->Update();
nanosleep(&my_timer, NULL);
}
endwin();
return 0;
}
|