MCPcopy Create free account
hub / github.com/RobLoach/raylib-cpp / Bunny

Class Bunny

examples/textures/textures_bunnymark.cpp:20–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18#define MAX_BATCH_ELEMENTS 8192
19
20class Bunny {
21 public:
22 Bunny() {
23 position = GetMousePosition();
24 speed.x = static_cast<float>(GetRandomValue(-250, 250)) / 60.0f;
25 speed.y = static_cast<float>(GetRandomValue(-250, 250)) / 60.0f;
26 color = raylib::Color(
27 GetRandomValue(50, 240),
28 GetRandomValue(80, 240),
29 GetRandomValue(100, 240));
30 }
31
32 void Update(const raylib::Texture2D& texBunny) {
33 position.x += speed.x;
34 position.y += speed.y;
35
36 if (((position.x + texBunny.width/2) > GetScreenWidth()) ||
37 ((position.x + texBunny.width/2) < 0)) speed.x *= -1;
38 if (((position.y + texBunny.height/2) > GetScreenHeight()) ||
39 ((position.y + texBunny.height/2 - 40) < 0)) speed.y *= -1;
40 }
41
42 Vector2 position;
43 Vector2 speed;
44 Color color;
45};
46
47int main(void)
48{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected