Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | ** EPITECH PROJECT, 2024 | ||
3 | ** zappy | ||
4 | ** File description: | ||
5 | ** eggs.c | ||
6 | */ | ||
7 | |||
8 | #include "server.h" | ||
9 | |||
10 | 10 | egg_t *init_egg(int width, int height) | |
11 | { | ||
12 | static int id = 0; | ||
13 | 10 | egg_t *egg = malloc(sizeof(egg_t)); | |
14 | |||
15 | 10 | if (egg == NULL) | |
16 | return NULL; | ||
17 | 10 | egg->x = width == 0 ? 0 : rand() % width; | |
18 | 10 | egg->y = height == 0 ? 0 : rand() % height; | |
19 | 10 | egg->id = id; | |
20 | 10 | id++; | |
21 | 10 | return egg; | |
22 | } | ||
23 |