-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathshapes_basic_shapes.php
89 lines (72 loc) · 3.15 KB
/
shapes_basic_shapes.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
declare(strict_types=1);
use Nawarian\Raylib\Types\{Color, Vector2};
use function Nawarian\Raylib\{
BeginDrawing,
ClearBackground,
CloseWindow,
DrawCircle,
DrawCircleGradient,
DrawCircleLines,
DrawLine,
DrawPoly,
DrawRectangle,
DrawRectangleGradientH,
DrawRectangleLines,
DrawText,
DrawTriangle,
DrawTriangleLines,
EndDrawing,
InitWindow,
SetTargetFPS,
WindowShouldClose
};
require_once __DIR__ . '/../../vendor/autoload.php';
// Initialization
//--------------------------------------------------------------------------------------
$screenWidth = 800;
$screenHeight = 450;
InitWindow($screenWidth, $screenHeight, 'raylib [shapes] example - basic shapes drawing');
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) { // Detect window close button or ESC key
// Update
//----------------------------------------------------------------------------------
// TODO: Update your variables here
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color::rayWhite());
DrawText('some basic shapes available on raylib', 20, 20, 20, Color::darkGray());
DrawCircle((int) ($screenWidth / 4), 120, 35, Color::darkBlue());
DrawRectangle((int) ($screenWidth / 4 * 2 - 60), 100, 120, 60, Color::red());
// NOTE: Uses QUADS internally, not lines
DrawRectangleLines((int) ($screenWidth / 4 * 2 - 40), 320, 80, 60, Color::orange());
DrawRectangleGradientH((int) ($screenWidth / 4 * 2 - 90), 170, 180, 130, Color::maroon(), Color::gold());
DrawTriangle(
new Vector2($screenWidth / 4 * 3, 80),
new Vector2($screenWidth / 4 * 3 - 60, 150),
new Vector2($screenWidth / 4 * 3 + 60, 150),
Color::violet()
);
DrawPoly(new Vector2($screenWidth / 4 * 3, 320), 6, 80, 0, Color::brown());
DrawCircleGradient((int) ($screenWidth / 4), 220, 60, Color::green(), Color::skyBlue());
// NOTE: We draw all LINES based shapes together to optimize internal drawing,
// this way, all LINES are rendered in a single draw pass
DrawLine(18, 42, $screenWidth - 18, 42, Color::black());
DrawCircleLines((int) ($screenWidth / 4), 340, 80, Color::darkBlue());
DrawTriangleLines(
new Vector2((int) ($screenWidth / 4 * 3), 160),
new Vector2((int) ($screenWidth / 4 * 3 - 20), 230),
new Vector2((int) ($screenWidth / 4 * 3 + 20), 230),
Color::darkBlue()
);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------