blob: 9aa42a2567124cf373e10b6ddeca473bd8e27972 (
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
|
#include "ball.h"
void move_ball(ball_t *ball, f32 dt, i32 width)
{
if (ball->stuck)
return;
ball->o.pos = add_v2(ball->o.pos, scale_v2(ball->o.vel, dt));
if (ball->o.pos.x < 0.0f) {
ball->o.vel.x = -ball->o.vel.x;
ball->o.pos.x = 0.0f;
}
if (ball->o.pos.x + ball->o.size.x > width) {
ball->o.vel.x = -ball->o.vel.x;
ball->o.pos.x = width - ball->o.size.x;
}
if (ball->o.pos.y < 0.0f) {
ball->o.vel.y = -ball->o.vel.y;
ball->o.pos.y = 0.0f;
}
}
void reset_ball(ball_t *ball, v2 pos, v2 vel)
{
}
|