Autor Beitrag
F34r0fTh3D4rk Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5285
Erhaltene Danke: 29

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Fr 15.10.04 15:21 
ich bracuh ja schon 4 timer für die schläger bewegungen, mal gucken ob ich die auf 2
reduzieren kannn und die ki in den ball move timer einbaue, aber
dann ist da immer noch das problem, dass der ball zu lahm ist, wenn der sich
nur n pixel pro intervall bewegt, wenn der sich aber weiter bewegt, findet die
kollision nicht immer statt :?
Elite
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Fr 15.10.04 16:21 
F34r0fTh3D4rk hat folgendes geschrieben:
wenn der sich aber weiter bewegt, findet die
kollision nicht immer statt :?

Dann ist das auf jeden Fall ein Punkt, über den du nachdenken musst. Wie willst du denn bei einer derartigen Bewegung je eine andere Steigung als 1 oder -1 erreichen? Zum Beispiel Steigung 4/7 ?
Du musst die Kollisionsabfrage umprogrammieren.
F34r0fTh3D4rk Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5285
Erhaltene Danke: 29

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Sa 16.10.04 14:31 
so hab jetzt alles in einem Timer, nur liegt es weder an dem timer, noch an der
geschwindigkeit, weil ja alles gleichzeitig passiert, der ball wird bewegt und
gleichzeitig kommt die kollisionsabfrage, also muss irgendwo eine Lücke im programm sein. außerdem wenn man einen Punkt macht (also am gegener vorbeispielt) bekommt
man auf einmal nicht mehr einen punkt sonder ein paar hundert

hier der vollständige code des timers:
ausblenden volle Höhe Quelltext
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:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
var
  u:integer;
  d:integer;
  u2:integer;
  d2:integer;
  kollision:boolean;
  LHit:boolean;
  RHit:boolean;
  LP:integer;
  RP:integer;
begin
kollision:=false;
//Pad Control
if mup=true then begin
mdown:=false;
u:=0;
u:=u+speed;
l.top:=l.top-u;
if l.top<spielfeld.top + 6 then l.top:=spielfeld.top + 6;
end;
if mdown=true then begin
mup:=false;
d:=0;
d:=d+speed;
l.top:=l.top+d;
if l.top>spielfeld.height + Spielfeld.top - l.height - 6 then l.top:=spielfeld.height + spielfeld.top - l.height - 6;
end;
if mdown2=true then begin
mdown2:=false;
u2:=0;
u2:=u2+speed;
r.top:=r.top-u2;
if r.top<spielfeld.top + 6 then r.top:=spielfeld.top + 6;
end;
if mup2=true then begin
mup2:=false;
d2:=0;
d2:=d2+speed;
r.top:=r.top+d2;
if r.top>spielfeld.height + Spielfeld.top - r.height - 6 then r.top:=spielfeld.height + spielfeld.top - r.height - 6;
end;
//collide left and right
if ball.left < 6 then begin
xspeed:=-xspeed;
kollision:=true;
//Ball Hit the Left Goal
LHit:=true;
end;
if ball.left > spielfeld.left + spielfeld.width - ball.width - 6 then begin
xspeed:=-xspeed;
kollision:=true;
//Ball Hit the Right Goal
RHit:=true;
end;
//collide top and bottom
if ball.top < spielfeld.top + 6 then begin
yspeed:=-yspeed;
kollision:=true;
end;
if ball.top > spielfeld.height + Spielfeld.top - ball.height - 6 then begin
yspeed:=-yspeed;
kollision:=true;
end;
//collide with pads
//Left Pad
if ball.top > l.top - ball.height - 6 then begin
if ball.left < l.Left + l.width + 6 then begin
xspeed:=-xspeed;
end;
end;
if ball.top > l.height + l.top + 6 then begin
if ball.left < l.left + l.width + 6 then begin
xspeed:=-xspeed;
end;
end;
//Right Pad
if ball.top > r.top - ball.height - 6 then begin
if ball.left > r.left - ball.width - 6 then begin
xspeed:=-xspeed;
end;
end;
if ball.top > r.height + r.top + 6 then begin
if ball.left > r.left - ball.width - 6 then begin
xspeed:=-xspeed;
end;
end;
//movement
ball.left := ball.Left + xspeed;
ball.top := ball.top + yspeed;
//Points
if RHit = true then begin
LP:=LP+1;
edit1.text:=inttostr(lp);
RHit:=false;
end;
if LHit = true then begin
RP:=RP+1;
edit2.text:=inttostr(rp);
LHit:=false;
end;

//KI
//Tied
if lp = rp then begin
if (ball.top + ball.height) div 2 < (r.top + r.height) div 2 then mup2:=true;
if (ball.top + ball.height) div 2 > (r.top + r.height) div 2 then mdown2:=true;
end;
//Loosing
if lp < rp then begin
if xspeed > 0 then begin
if yspeed < 0 then mup2:=true;
if yspeed > 0 then mdown2:=true;
end;
end;
//Winning
if lp > rp then begin
if xspeed < 0 then begin
if r.top + r.height div 2 > spielfeld.top + spielfeld.Height div 2 then mup2:=true;
if r.top + r.height div 2 < spielfeld.top + spielfeld.Height div 2 then mdown2:=true;
if r.top + r.height div 2 = spielfeld.top + spielfeld.Height div 2 then begin
mup2:=false;
mdown2:=false;
end;
end;
if xspeed > 0 then begin
if xspeed > yspeed then begin
if ball.top + ball.height div 2 < spielfeld.top + spielfeld.height div 2 then mup2:=true;
if ball.top + ball.height div 2 > spielfeld.top + spielfeld.height div 2 then mdown2:=true;
end;

if xspeed < yspeed then begin
if yspeed < 0 then mup2:=true;
if yspeed > 0 then mdown2:=true;
end;

end;

end;
end;