--- a/hedgewars/hwengine.pas Sat Oct 24 13:50:31 2009 +0000
+++ b/hedgewars/hwengine.pas Sun Oct 25 09:02:17 2009 +0000
@@ -165,11 +165,9 @@
event: TSDL_Event;
{$IFDEF IPHONEOS}
type TDirection = (nodir, left, right);
-var mouseState: byte;
- x, y: LongInt;
- oldy: LongInt = 240;
- oldJoy: LongInt =0;
- dir: TDirection = nodir;
+var x, y: LongInt;
+ oldy_zoom: LongInt = -1;
+ oldy_aim: LongInt = -1;
{$ENDIF}
begin
PrevTime:= SDL_GetTicks;
@@ -189,56 +187,81 @@
{*MoveCamera is in uWord.pas -- conflicts with other commands*}
{*Keys are in uKeys.pas*}
SDL_MOUSEBUTTONDOWN: begin
- AddFileLog('********************************************* touch down');
+ AddFileLog('********************************************* touch down');
- mouseState:= SDL_GetMouseState(0, @x, @y);
+ SDL_GetMouseState(0, @x, @y);
- if x <= 50 then
+ {* zoom slider *}
+ if (x <= 50) and (y <= 430) then
begin
{$IFDEF DEBUGFILE}
AddFileLog('Wheel -- x: ' + inttostr(x) + ' y: ' + inttostr(y));
{$ENDIF}
- {* sliding *}
- if oldy - y > 0 then uKeys.wheelUp:= true
- else uKeys.wheelDown:= true;
- {* update value only if movement is consistent *}
- // if (y > oldy - 10 ) or (y > oldy + 10 ) then oldy:= y
- // oldy:= y;
+ if oldy_zoom = -1 then oldy_zoom:= y
+ else
+ begin
+ if oldy_zoom - y > 10 then uKeys.wheelUp:= true
+ else if oldy_zoom -y < -10 then uKeys.wheelDown:= true;
+ {* update value only if movement is consistent *}
+ if (y > oldy_zoom + 20 ) or (y < oldy_zoom - 20 ) then oldy_zoom:= y
+ end;
+ end;
+ {* reset zoom *}
+ if (x <= 50) and (y > 430) then
+ begin
+{$IFDEF DEBUGFILE}
+ AddFileLog('Middle Click -- x: ' + inttostr(x) + ' y: ' + inttostr(y));
+{$ENDIF}
+ uKeys.middleClick:= true;
end;
-
- {* keys *}
- {* if (x > 50) then
+ {* aim slider *}
+ if (x > 230) and (y <= 430) then
begin
- AddFileLog('Arrow Key -- x: ' + inttostr(x) + ' y: ' + inttostr(y));
-
- if (y <= 50) and (x > 135) and (x <= 185) then uKeys.upKey:= true;
- if (y > 430) and (x > 135) and (x <= 185) then uKeys.downKey:= true;
- if (x > 270) and (y > 215) and (y > 265) then uKeys.rightClick:= true;
- if (x <= 100) and (y > 215) and (y > 265) then uKeys.leftClick:= true;
- end;*}
-
+{$IFDEF DEBUGFILE}
+ AddFileLog('Up&Down -- x: ' + inttostr(x) + ' y: ' + inttostr(y));
+{$ENDIF}
+ if oldy_aim = -1 then oldy_aim:= y
+ else
+ begin
+ if oldy_aim - y > 10 then uKeys.upKey:= true
+ else if oldy_aim -y < -10 then uKeys.downKey:= true;
+ {* update value only if movement is consistent *}
+ if (y > oldy_aim + 20 ) or (y < oldy_aim - 20 ) then oldy_aim:= y
+ end;
+ end;
+ {* reset zoom *}
+ if (x <= 50) and (y > 430) then
+ begin
+{$IFDEF DEBUGFILE}
+ AddFileLog('Middle Click -- x: ' + inttostr(x) + ' y: ' + inttostr(y));
+{$ENDIF}
+ uKeys.middleClick:= true;
+ end;
+ {* long jump *}
if (y > 430) and (x > 50) and (x <= 135) then
begin
{$IFDEF DEBUGFILE}
AddFileLog('Enter -- x: ' + inttostr(x) + ' y: ' + inttostr(y));
{$ENDIF}
- uKeys.enterKey:=true;
+ uKeys.enterKey:= true;
end;
+ {* high jump *}
if (y > 430) and (x > 185) and (x <= 270) then
begin
{$IFDEF DEBUGFILE}
AddFileLog('Backspace -- x: ' + inttostr(x) + ' y: ' + inttostr(y));
{$ENDIF}
- uKeys.backspaceKey:=true;
+ uKeys.backspaceKey:= true;
end;
+ {* attack *}
if (y <= 50) and (x > 50) and (x <= 270) then
begin
{$IFDEF DEBUGFILE}
AddFileLog('Space DOWN -- x: ' + inttostr(x) + ' y: ' + inttostr(y));
{$ENDIF}
- uKeys.spaceKey:= true;
- uKeys.isAttacking:= true;
+ uKeys.spaceKey:= true;
+ uKeys.isAttacking:= true;
end
else
begin
@@ -247,11 +270,11 @@
end;
end;
SDL_MOUSEBUTTONUP: begin
- AddFileLog('********************************************* touch up');
+ AddFileLog('********************************************* touch up');
- if bShowAmmoMenu = true then ParseCommand('/put', true);
+ if bShowAmmoMenu = true then uKeys.leftClick:= true;
- mouseState:= SDL_GetMouseState(0, @x, @y);
+ SDL_GetMouseState(0, @x, @y);
{* open ammo menu *}
if (y > 430) and (x > 270) then
begin
@@ -260,44 +283,29 @@
{$ENDIF}
uKeys.rightClick:= true;
end;
- {* reset zoom *}
- if (x > 270) and (y <= 50) then
- begin
-{$IFDEF DEBUGFILE}
- AddFileLog('Middle Click -- x: ' + inttostr(x) + ' y: ' + inttostr(y));
-{$ENDIF}
- uKeys.middleClick:= true;
- end;
end;
SDL_JOYAXIS: begin
- {axis 2 = back and forth; axis 1 = up and down; axis 0 = left and right}
- //AddFileLog('which: ' + inttostr(event.jaxis.which) + ' axis: ' + inttostr(event.jaxis.axis) + ' value: ' + inttostr(event.jaxis.value));
+ {* axis 0 = left and right;
+ axis 1 = up and down;
+ axis 2 = back and forth; *}
if (event.jaxis.axis = 0) and (CurrentTeam <> nil) then
begin
- if (modulo(event.jaxis.value) > (oldJoy + 400)) or (modulo(event.jaxis.value) < (oldJoy - 400)) then
+ if event.jaxis.value > 1500 then
begin
- if event.jaxis.value > 1500 then
- begin
- if dir <> right then ParseCommand('-left', true);
- ParseCommand('+right', true);
- dir:= right;
+ uKeys.rightKey:= true;
+ uKeys.isWalking:= true;
+ end
+ else
+ if event.jaxis.value <= -1500 then
+ begin
+ uKeys.leftKey:= true;
+ uKeys.isWalking:= true;
end
else
- if event.jaxis.value <= -1500 then
- begin
- if dir <> left then ParseCommand('-right', true);
- ParseCommand('+left', true);
- dir:= left;
- end
- else
- if (event.jaxis.value > 0) and (event.jaxis.value <= 1500) then ParseCommand('-right', true)
- else
- if (event.jaxis.value <= 0) and (event.jaxis.value > -1500) then ParseCommand('-left', true);
+ if (event.jaxis.value > -1500) and (event.jaxis.value <= 1500) then uKeys.isWalking:= false;
{$IFDEF DEBUGFILE}
- AddFileLog('Joystick value: ' + inttostr(event.jaxis.value) + ' oldJoy: ' + inttostr(oldJoy));
+ AddFileLog('Joystick value: ' + inttostr(event.jaxis.value));
{$ENDIF}
- oldJoy:= modulo(event.jaxis.value);
- end;
end;
end;
--- a/hedgewars/uAI.pas Sat Oct 24 13:50:31 2009 +0000
+++ b/hedgewars/uAI.pas Sun Oct 25 09:02:17 2009 +0000
@@ -237,7 +237,7 @@
begin
BestActions:= Actions;
BestRate:= Rate;
- Me^.State:= Me^.State or gstAttacked // we have better place, go there and don't use ammo
+ Me^.State:= Me^.State or gstAttacked // we have better place, go there and do not use ammo
end
else if Rate < BestRate then break;
if ((Me^.State and gstAttacked) = 0)
--- a/hedgewars/uKeys.pas Sat Oct 24 13:50:31 2009 +0000
+++ b/hedgewars/uKeys.pas Sun Oct 25 09:02:17 2009 +0000
@@ -55,7 +55,9 @@
backspaceKey: boolean = false;
spaceKey: boolean = false;
enterKey: boolean = false;
-isAttacking:boolean = false;
+
+isAttacking: boolean = false;
+isWalking: boolean = false;
{$ENDIF}
ControllerNumControllers: Integer;
@@ -136,11 +138,10 @@
middleClick:= false;
rightClick:= false;
-//sdl1.3 for these keys is messed up
-//tkbdn[MYCONST]:= ord(upKey);
-//tkbdn[MYCONST + 1]:= ord(downKey);
-//tkbdn[MYCONST + 2]:= ord(rightKey);
-//tkbdn[MYCONST + 3]:= ord(leftKey);
+tkbdn[23]:= ord(upKey);
+tkbdn[24]:= ord(downKey);
+tkbdn[25]:= ord(leftKey);
+tkbdn[26]:= ord(rightKey);
tkbdn[ 8]:= ord(backspaceKey);
tkbdn[13]:= ord(enterKey);
@@ -148,8 +149,8 @@
upKey:= false;
downKey:= false;
-rightKey:= false;
-leftKey:= false;
+if isWalking = false then rightKey:= false;
+if isWalking = false then leftKey:= false;
if isAttacking = false then spaceKey:= false;
enterKey:= false;
@@ -242,11 +243,10 @@
middleClick:= false;
rightClick:= false;
-//sdl1.3 for these keys is messed up
-//tkbdn[MYCONST]:= ord(upKey);
-//tkbdn[MYCONST + 1]:= ord(downKey);
-//tkbdn[MYCONST + 2]:= ord(rightKey);
-//tkbdn[MYCONST + 3]:= ord(leftKey);
+tkbdn[23]:= ord(upKey);
+tkbdn[24]:= ord(downKey);
+tkbdn[25]:= ord(leftKey);
+tkbdn[26]:= ord(rightKey);
tkbdn[ 8]:= ord(backspaceKey);
tkbdn[13]:= ord(enterKey);
@@ -254,8 +254,8 @@
upKey:= false;
downKey:= false;
-rightKey:= false;
-leftKey:= false;
+if isWalking = false then rightKey:= false;
+if isWalking = false then leftKey:= false;
if isAttacking = false then spaceKey:= false;
enterKey:= false;
@@ -344,12 +344,16 @@
end;
end;
{$IFDEF IPHONEOS}
-
+DefaultBinds[ 1]:= '/put';
DefaultBinds[ 3]:= 'ammomenu';
DefaultBinds[ 8]:= 'hjump';
DefaultBinds[ 13]:= 'ljump';
DefaultBinds[ 32]:= '+attack';
+DefaultBinds[ 23]:= '+up';
+DefaultBinds[ 24]:= '+down';
+DefaultBinds[ 25]:= '+left';
+DefaultBinds[ 26]:= '+right';
{$ENDIF}
DefaultBinds[ 27]:= 'quit';
--- a/hedgewars/uStore.pas Sat Oct 24 13:50:31 2009 +0000
+++ b/hedgewars/uStore.pas Sun Oct 25 09:02:17 2009 +0000
@@ -963,10 +963,10 @@
function glLoadExtension(extension : string) : boolean;
begin
-{$IFNDEF IPHONEOS}
+{$IFDEF IPHONEOS}
+ glLoadExtension:= false;
+{$ELSE}
glLoadExtension:= glext_LoadExtension(extension);
-{$ELSE}
- glLoadExtension:= false;
{$ENDIF}
{$IFDEF DEBUGFILE}
if not glLoadExtension then
--- a/hedgewars/uWorld.pas Sat Oct 24 13:50:31 2009 +0000
+++ b/hedgewars/uWorld.pas Sun Oct 25 09:02:17 2009 +0000
@@ -345,7 +345,7 @@
{$IFDEF IPHONEOS}
{* see the code in MainLoop *}
SDL_GetMouseState(0, @x, @y);
-if ((x > 100) and (x <= 220) and (y > 200) and (y <= 280)) and bShowAmmoMenu <> false then
+//if ((x > 100) and (x <= 220) and (y > 200) and (y <= 280)) and bShowAmmoMenu <> false then
{$ENDIF}
if not isPaused then MoveCamera;