Autor Beitrag
Girgl
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 281


D6 Enterprise
BeitragVerfasst: So 11.07.04 15:08 
Servus,kann mir bitte jemand helfen.Ich möcht eine Grafik mittels DXInput bewegen.Und zwar hab ich mir eine procedure MovePlayer geschrieben,die jedesmal in nem timer aufgerufen wird und da wird dann geprüft,ob eine taste zum bewegen der grafik gedrückt wurde.Aber es bewegt sich nix.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.MovePayer;
begin
 If isUP in DXInput.States Then
  Bild.Y:=Bild.Y+2
...


Und dann im onTimer - Ereignis
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
begin
 DXInput.Update;
 MovePlayer;
 {Grafik zeichnen}
end;


Hoffe es kann wer helfen
Blitz.XP
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 26



BeitragVerfasst: So 11.07.04 15:12 
Also als erstes hoffe ich mal, dass du das ganze in DXTimer1.OnTimer und nicht in OnActivate geschriben hast (das passiertt, wenn man nen Doppelklick auf den DXTimer machst) und sonst fälltt mir auch nix verdächtiges auf.
Das DXINput heist hoffentlich auch wirklich so un dnicht DXINput1.
Girgl Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 281


D6 Enterprise
BeitragVerfasst: So 11.07.04 15:31 
ja,is alles richtig benannt und
Zitat:
Und dann im onTimer - Ereignis
:wink:
Blitz.XP
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 26



BeitragVerfasst: So 11.07.04 16:08 
Ich mein es kann gut sein dass man sich mal vertut.
Wird da überhaupt was gezeichnet oder nicht? Wäre warscheinlcih am besten, wenn du die Zeichenroutine auch postest, weil in den paar Codeschnipsel is (meine ansicht nach) schonmal nix falsch.
Girgl Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 281


D6 Enterprise
BeitragVerfasst: So 11.07.04 20:14 
also,hier ist der ganze Code fürs Programm
Was ihr noch wissen müsst.Ich hab mir ne Klasse TSpieler gemacht und DrawPlayer und MovePlayer sind die zugehörigen Methoden der Klasse.
ausblenden volle Höhe Delphi-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:
procedure TSpieler.DrawPlayer;
begin
 With Form1 do
  begin
   If not DXDraw.CanDraw Then Exit;
   DXDraw.Surface.Fill(0);
   DXImageList.Items[0].Draw(DXDraw.Surface,0,0,0);
   DXDraw.Flip;
  end;
end;

procedure TSpieler.MovePlayer;
begin
 With Form1 do
  begin
   If isUP in DXInput.States Then Inc(Spieler.Y,2);
   If isDown in DXInput.States Then Dec(Spieler.Y,2);
   If isRight in DXInput.States Then Inc(Spieler.X,2);
   If isLeft in DXInput.States Then Dec(Spieler.X,2);
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
 Spieler:=TSpieler.Create;
 Spieler.X:=0;
 Spieler.Y:=0;
end;

procedure TForm1.DXTimer1Timer(Sender: TObject; LagCount: Integer);
begin
 DXInput.Update; 
 Spieler.DrawPlayer;
 Spieler.MovePlayer;
end;
umpani
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 389



BeitragVerfasst: Mo 12.07.04 02:58 
Ich bin jetzt gerade nicht an einem Delphi-rechner, aber ich glaube mich daran erinnern zu können, dass man die tasteneingabe vor jeder Abfrage noch mal auslesen muß.

Irgendetwas im Sinne von dxinput.refresh

Der richtige Befehl lautet:

ausblenden Delphi-Quelltext
1:
dxinput.Update;					


vor den if-Abfragen


Gruß Umpani

_________________
Lernen, ohne zu denken, ist eitel; denken, ohne zu lernen, ist gefährlich. Konfuzius
Girgl Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 281


D6 Enterprise
BeitragVerfasst: Fr 16.07.04 17:54 
sorry,konnte net antworten,war im auf studienfahrt.
Also ich hab das DXInput.Refresh jetz vor die ganzen if - Abfragen in der Methode MovePlayer eingebaut,aber leider funktioniert es immer noch nicht.Das Interval des Timers hab ich auf 1 gestellt.Hat jemand noch ne andre Idee?
umpani
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 389



BeitragVerfasst: Fr 16.07.04 21:03 
Hallo,

das mit dem refresh war doch nur ein Tipp ins blaueb.

Am selben Tag haatte ich in meiner Antwort (zwei Zeilen darunter) die richtige Lösung geschrieben.

Zitat:
Der richtige Befehl lautet:

ausblenden Delphi-Quelltext
1:
dxinput.Update;					



vor den if-Abfragen


Gruß Umpani

_________________
Lernen, ohne zu denken, ist eitel; denken, ohne zu lernen, ist gefährlich. Konfuzius
Girgl Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 281


D6 Enterprise
BeitragVerfasst: Sa 17.07.04 14:08 
es geht jetz,hab vergessen,bei Draw die Koordinaten des Spielers zu übergeben...