-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmenu.php
44 lines (36 loc) · 894 Bytes
/
menu.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
<?php
declare(strict_types=1);
/**
* Unused.
* */
class Menu
{
public $titleTexture;
public $titleRect;
public function __construct()
{
$this->titleRect = new SDL_Rect;
$this->titleRect->x = 300;
$this->titleRect->y = 300;
}
public function __destruct()
{
SDL_DestroyTexture($this->titleTexture);
}
public function loadTexture(string $titlePath, $windowSurface, $renderer)
{
$image = SDL_LoadBMP($titlePath);
if ($image === null) {
exit("Cannot load title image.");
}
SDL_SetColorKey($image, true, SDL_MapRGB($windowSurface->format, 0, 255, 0));
$this->titleTexture = SDL_CreateTextureFromSurface($renderer, $image);
$this->titleRect->w = $image->clip_rect->w;
$this->titleRect->h = $image->clip_rect->h;
SDL_FreeSurface($image);
}
public function draw($renderer)
{
SDL_RenderCopy($renderer, $this->titleTexture, null, $this->titleRect);
}
}