master
orange 12 years ago
parent 53f90ed803
commit 697f7dfd27

@ -25,7 +25,7 @@ struct cb {
int start; int start;
int end; int end;
elem_t * elems; elem_t *elems;
}; };
typedef struct cb cb_t; typedef struct cb cb_t;
@ -45,7 +45,7 @@ void cb_init(cb_t * cb, int size) {
cb->start = 0; cb->start = 0;
cb->elems = malloc(sizeof(elem_t)*size); cb->elems = malloc(sizeof(elem_t) * size);
if (!cb->elems) if (!cb->elems)
dienomem(); dienomem();
} }

@ -17,7 +17,7 @@ void xy2rc(float x, float y, int *r, int *c) {
} }
float lerp(float from, float to, float t) { float lerp(float from, float to, float t) {
return from + t * (to-from); return from + t * (to - from);
} }
float ball_x = 0.0; float ball_x = 0.0;
@ -36,7 +36,7 @@ void paint_ball() {
void paint_paddles() { void paint_paddles() {
int r, c; int r, c;
xy2rc( 0, pad_l, &r, &c); xy2rc(0, pad_l, &r, &c);
mvaddch(r, c, ACS_VLINE); mvaddch(r, c, ACS_VLINE);
xy2rc(MAX_X, pad_r, &r, &c); xy2rc(MAX_X, pad_r, &r, &c);
@ -56,14 +56,14 @@ int main() {
initscr(); /* Start curses mode */ initscr(); /* Start curses mode */
curs_set(0); /* Disable cursor */ curs_set(0); /* Disable cursor */
while(true) { while (true) {
ball_x += dir_x; ball_x += dir_x;
ball_y += dir_y; ball_y += dir_y;
if (ball_x>MAX_X || ball_x<0) { if (ball_x > MAX_X || ball_x < 0) {
dir_x = -dir_x; dir_x = -dir_x;
} }
if (ball_y>MAX_Y || ball_y<0) { if (ball_y > MAX_Y || ball_y < 0) {
dir_y = -dir_y; dir_y = -dir_y;
} }

@ -5,7 +5,7 @@ struct test {
}; };
typedef struct test test_t; typedef struct test test_t;
int main(int argc, char * argv[]) { int main(int argc, char *argv[]) {
test_t a = { 23 }; test_t a = { 23 };
test_t b = { 42 }; test_t b = { 42 };

Loading…
Cancel
Save