-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodel.d
More file actions
45 lines (41 loc) · 1.58 KB
/
Copy pathmodel.d
File metadata and controls
45 lines (41 loc) · 1.58 KB
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
module model;
import sdl, view, control;
public struct ÇİZ {
SAHNE sahne; // view.d
TUŞLAR tuş; // control.d
bool başla(SDL_Surface* ekran, SDL_Rect* çerçeve) {
double HIZLAN = 0.0123456789;
double YAVAŞLA = 0.998754321;
double nXkonumu = sahne.genişliği /2;
double nYkonumu = sahne.yüksekliği/2;
double nXivmesi = 0;
double nYivmesi = 0;
while (true) {
if(tuş.sol) nXivmesi -= HIZLAN;
if(tuş.sağ) nXivmesi += HIZLAN;
if(tuş.üst) nYivmesi -= HIZLAN;
if(tuş.alt) nYivmesi += HIZLAN;
nXivmesi *= YAVAŞLA;
nYivmesi *= YAVAŞLA;
if(nXkonumu > cast(double)(sahne.genişliği - sahne.çerçeveKalınlığı) ||
(nXkonumu < cast(double)sahne.çerçeveKalınlığı)) {
nXkonumu -= nXivmesi;
nXivmesi = -nXivmesi * YAVAŞLA;
}
if(nYkonumu > cast(double)(sahne.yüksekliği - sahne.çerçeveKalınlığı) ||
(nYkonumu < cast(double)sahne.çerçeveKalınlığı)) {
nYkonumu -= nYivmesi;
nYivmesi = -nYivmesi * YAVAŞLA;
}
nXkonumu += nXivmesi;
nYkonumu += nYivmesi;
SDL_FillRect(ekran, çerçeve, SDL_MapRGB(ekran.format, 0xff, 0xff, 0xff));
if(sahne.circleFill(ekran, cast(int)nXkonumu,
cast(int)nYkonumu, sahne.yuvarlakÇapı, 0)) {
SDL_Flip(ekran);
}
if(tuş.kontroEt()) return false;
} // sonsuz döngü
return true;
}
}