-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUasteroide.pas
61 lines (49 loc) · 1.12 KB
/
Uasteroide.pas
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
unit UAsteroide;
interface
Uses Graphics, System.Types;
Type
Asteroid = Class
Private
Public
angulo: integer;
velocidad: integer;
Radio : Integer;
Cx,Cy : Integer;
constructor Create(x,y,radio, angulo:Integer);
Procedure Draw(Pantalla : TCanvas);
Procedure Move;
procedure setRadio( radio: integer );
End;
implementation
constructor Asteroid.Create(x, y, radio, angulo: Integer);
begin
Cx:=x;
Cy:=y;
setRadio(radio);
Self.angulo := angulo;
randomize;
velocidad := random(5)+5;
end;
procedure Asteroid.Draw(Pantalla: TCanvas);
begin
Pantalla.pen.Color:=clWhite;
Pantalla.Pen.Width := 4;
Pantalla.Ellipse(Cx-radio,Cy-radio,Cx+radio,Cy+radio);
end;
procedure Asteroid.Move;
var dx, dy: integer;
begin
dx := trunc(velocidad * sin(angulo*pi/180));
dy := -trunc(velocidad * cos(angulo*pi/180));
Cx:=Cx+dx;
Cy:=Cy+dy;
end;
procedure Asteroid.setRadio( radio: integer );
begin
case radio of
1: Self.radio := 20;
2: Self.radio := 50;
3: Self.radio := 150;
end;
end;
end.