-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqueue.c
74 lines (57 loc) · 2.33 KB
/
queue.c
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
65
66
67
68
69
70
71
72
73
74
#include <math.h>
#include <stdlib.h>
#include "raylib.h"
#include "queue.h"
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
void Queue_Add(Queue* t, QueueItem tm){
t->items[t->next]=malloc(sizeof(QueueItem));
if (t->next>=QUEUE_SIZE) t->next=0;
t->items[t->next]->position = tm.position;
t->items[t->next]->color = tm.color;
t->items[t->next]->size = tm.size;
t->next++;
t->size=MAX(t->next, t->size);
}
void Queue_DrawF(Queue *Queue, Model *mark){
// smaller from now to previous
for (int i=0; i<Queue->size; i++){
int history_index = (Queue->next-i)-1;
if (history_index<0) history_index+=Queue->size;
if (Queue->items[history_index] == (QueueItem*)(NULL)) continue;
DrawModel(*mark,(Vector3){Queue->items[history_index]->position.x,\
0.2f,\
Queue->items[history_index]->position.z},\
Queue->items[history_index]->size*(QUEUE_SIZE-i)/QUEUE_SIZE,\
Queue->items[history_index]->color);
}
}
void Queue_Draw(Queue *Queue, Model *mark){
// no smaller from now to previous
for (int i=0; i<Queue->size; i++){
int history_index = (Queue->next-i)-1;
if (history_index<0) history_index+=Queue->size;
if (Queue->items[history_index] == (QueueItem*)(NULL)) continue;
DrawModel(*mark,(Vector3){Queue->items[history_index]->position.x,\
Queue->items[history_index]->position.y,\
Queue->items[history_index]->position.z},\
Queue->items[history_index]->size,\
Queue->items[history_index]->color);
}
}
void Queue_DrawEx(Queue *Queue, Model *mark){
// no smaller from now to previous
// random rotation phi
double delta_time = GetTime()-(int)GetTime();
for (int i=0; i<Queue->size; i++){
int history_index = (Queue->next-i)-1;
if (history_index<0) history_index+=Queue->size;
if (Queue->items[history_index] == (QueueItem*)(NULL)) continue;
DrawModelEx(*mark,(Vector3){Queue->items[history_index]->position.x,\
Queue->items[history_index]->position.y,\
Queue->items[history_index]->position.z}, \
(Vector3){1,1,1},\
delta_time*360,\
(Vector3){Queue->items[history_index]->size,Queue->items[history_index]->size,Queue->items[history_index]->size},\
Queue->items[history_index]->color);
}
}