You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
566 B
Plaintext
32 lines
566 B
Plaintext
ring_add :: (using r : *ring, next: Vector2) {
|
|
data[start] = next;
|
|
start += 1;
|
|
start %= data.count;
|
|
}
|
|
|
|
ring_avg :: (using r : *ring) -> Vector2 {
|
|
sum : Vector2;
|
|
for data {
|
|
sum += it;
|
|
}
|
|
return sum / cast(float) data.count;
|
|
}
|
|
|
|
ring_reset :: (using r : *ring) {
|
|
memset(data.data, 0, data.count * size_of(Vector2));
|
|
}
|
|
|
|
new_ring :: (num_items: s64 = 5) -> ring {
|
|
r : ring;
|
|
r.data = NewArray(num_items, Vector2);
|
|
return r;
|
|
}
|
|
|
|
ring :: struct {
|
|
start : s64;
|
|
data : []Vector2;
|
|
}
|
|
|
|
#import "Math";
|
|
#import "Basic";
|