Autor Beitrag
AlA
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 30



BeitragVerfasst: So 02.03.03 17:37 
Ich werd wahnsinnig!!! Ich habe eine Tastensteuerung für ein Spiel definiert.Es funktioniert über OnKeyDown, dabei werden für die einzelnen Tasten dann Variablen true. Bei OnKeyUp werden bei Loslassen der Tasten wieder die Variablen auf false gesetzt. Ich wollte die normalen Richtungstasten (vk_left....) und Buchstaben (Hex : 65 ...) als Tasten benutzen.
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
case key of
vk_left : begin taste1:=false; end;
vk_right : begin taste2:=false; end;
vk_down : begin taste3:=false; end;
vk_up : begin taste4:=false; end;
56 : begin taste5:=false; end;
47 : begin taste6:=false; end;
....

Der Compiler meldet zwar keinen Fehler, aber ich kann nur die vk_Tasten verwenden. Die Buchstaben werden nicht erkannt. Wie kann ich das beheben????

Moderiert von user profile iconTino: Absätze entfernt & Code-Tags hinzugefügt.

_________________
ala
derDoc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 623

Win Vista Prof
D2007 Prof
BeitragVerfasst: So 02.03.03 23:09 
Versuch mal
ausblenden Quelltext
1:
2:
case key of
$56: begin taste5 := false; end;

_________________
MfG derDoc
There are only 10 types of people: those who understand binary and those who don't.
Aya
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: So 02.03.03 23:52 
Hi,

das aller einfachste is das:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
var
  Keys: Array[0..255] of Boolean;

procedure OnKeyDown(...);
begin
  Keys[Key]:=true;
end;

procedure OnKeyUp(...);
begin
  Keys[Key]:=false;
end;


und dann um abzufragen ob z.B. die Leertaste gedrückt ist:
ausblenden Quelltext
1:
if Keys[VK_SPACE] then...					

oder für Pfeiltaste Links:
ausblenden Quelltext
1:
if Keys[VK_LEFT] then...					


Au'revoir,
Aya

_________________
Aya
I aim for my endless dreams and I know they will come true!
Andreas Pfau
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 997



BeitragVerfasst: Mo 03.03.03 12:01 
Buchstaben checken:
ausblenden Quelltext
1:
if Keys[Ord('A')] then...					

_________________
Life is a bad adventure, but the graphic is really good!
mimi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: Di 04.03.03 21:16 
oder:
ausblenden Quelltext
1:
if key = ord('a') then...					

_________________
MFG
Michael Springwald, "kann kein englisch...."