Skip to content

Commit

Permalink
adds touch controls for android and ios devices
Browse files Browse the repository at this point in the history
  • Loading branch information
ericoporto committed Jan 27, 2019
1 parent 42e7f9f commit 9221f9a
Show file tree
Hide file tree
Showing 27 changed files with 177 additions and 6 deletions.
4 changes: 3 additions & 1 deletion AltKeyboardMovement.asc
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,9 @@ void on_mouse_click(MouseButton button) {
}



static void KeyboardMovement::FakeKeyPres(eKeyCode k) {
on_key_press(k);
}



Expand Down
3 changes: 3 additions & 0 deletions AltKeyboardMovement.ash
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ struct KeyboardMovement {
import static void Disable();
import static bool IsEnabled();
import static void StopMoving();

//fake keys
import static void FakeKeyPres(eKeyCode k);
};


Expand Down
113 changes: 112 additions & 1 deletion Game.agf
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,69 @@
</GUIButton>
</Controls>
</GUIMain>
<GUIMain>
<NormalGUI>
<OnClick />
<Height>40</Height>
<Width>224</Width>
<Left>0</Left>
<Top>280</Top>
<Clickable>True</Clickable>
<Visibility>NormalButInitiallyOff</Visibility>
<PopupYPos>0</PopupYPos>
<ZOrder>0</ZOrder>
<BorderColor>0</BorderColor>
<Transparency>0</Transparency>
<BackgroundColor>0</BackgroundColor>
<BackgroundImage>0</BackgroundImage>
<ID>10</ID>
<Name>gBottomGui</Name>
</NormalGUI>
<Controls>
<GUIButton>
<OnClick>button_left_OnClick</OnClick>
<ClickAction>RunScript</ClickAction>
<NewModeNumber>0</NewModeNumber>
<ClipImage>False</ClipImage>
<TextAlignment>TopMiddle</TextAlignment>
<TextColor>0</TextColor>
<Font>0</Font>
<PushedImage>0</PushedImage>
<MouseoverImage>0</MouseoverImage>
<Image>154</Image>
<Text />
<Height>40</Height>
<Locked>False</Locked>
<Width>80</Width>
<Left>16</Left>
<Top>0</Top>
<ZOrder>0</ZOrder>
<ID>0</ID>
<Name>button_left</Name>
</GUIButton>
<GUIButton>
<OnClick>button_right_OnClick</OnClick>
<ClickAction>RunScript</ClickAction>
<NewModeNumber>0</NewModeNumber>
<ClipImage>False</ClipImage>
<TextAlignment>TopMiddle</TextAlignment>
<TextColor>0</TextColor>
<Font>0</Font>
<PushedImage>0</PushedImage>
<MouseoverImage>0</MouseoverImage>
<Image>155</Image>
<Text />
<Height>40</Height>
<Locked>False</Locked>
<Width>80</Width>
<Left>128</Left>
<Top>0</Top>
<ZOrder>1</ZOrder>
<ID>1</ID>
<Name>button_right</Name>
</GUIButton>
</Controls>
</GUIMain>
</GUIs>
</GUIFolder>
</GUIs>
Expand Down Expand Up @@ -3777,6 +3840,26 @@
<FileName>img/gui/reset_room.png</FileName>
</Source>
</Sprite>
<Sprite Slot="154" Width="80" Height="40" ColorDepth="32" Resolution="LowRes" AlphaChannel="True">
<Source>
<FileName>img/gui/left_button.png</FileName>
</Source>
</Sprite>
<Sprite Slot="155" Width="80" Height="40" ColorDepth="32" Resolution="LowRes" AlphaChannel="True">
<Source>
<FileName>img/gui/right_button.png</FileName>
</Source>
</Sprite>
<Sprite Slot="156" Width="80" Height="40" ColorDepth="32" Resolution="LowRes" AlphaChannel="True">
<Source>
<FileName>img/gui/left_button_hold.png</FileName>
</Source>
</Sprite>
<Sprite Slot="157" Width="80" Height="40" ColorDepth="32" Resolution="LowRes" AlphaChannel="True">
<Source>
<FileName>img/gui/right_button_hold.png</FileName>
</Source>
</Sprite>
</Sprites>
</SpriteFolder>
</SubFolders>
Expand Down Expand Up @@ -9197,7 +9280,7 @@
<DefaultVolume>-1</DefaultVolume>
<DefaultPriority>Inherit</DefaultPriority>
<DefaultRepeat>Inherit</DefaultRepeat>
<FileLastModifiedDate>2019-01-27 16:15:39Z</FileLastModifiedDate>
<FileLastModifiedDate>2019-01-27 15:49:27Z</FileLastModifiedDate>
</AudioClip>
<AudioClip>
<ScriptName>aDog_from_hell_3</ScriptName>
Expand Down Expand Up @@ -9374,6 +9457,34 @@
<Component Name="AudioNew" />
<Component Name="GlobalVariables" />
<Component Name="Scripts" />
<Component Name="SpeechCenter">
<SpeechCenter Version="2.1.0.0">
<Document Version="2.0.0.0">
<Settings>
<CustomFunctions />
<VoiceActorScripts NewParagraph="PER_FUNCTION">
<Format>
<Styles>
<CSSStyle CSSName="body" FontFamily="Cambria" Color="" FontStyle="inherit" FontWeight="inherit" />
<CSSStyle CSSName=".currentCharacter" FontFamily="" Color="" FontStyle="inherit" FontWeight="inherit" />
<CSSStyle CSSName=".otherCharacter" FontFamily="" Color="LightGray" FontStyle="inherit" FontWeight="inherit" />
<CSSStyle CSSName=".lineNumber" FontFamily="" Color="Firebrick" FontStyle="inherit" FontWeight="inherit" />
<CSSStyle CSSName=".duplicate" FontFamily="" Color="Thistle" FontStyle="inherit" FontWeight="inherit" />
<CSSStyle CSSName=".speechCorrect" FontFamily="" Color="MediumBlue" FontStyle="inherit" FontWeight="inherit" />
<CSSStyle CSSName=".speechIncorrect" FontFamily="" Color="Red" FontStyle="inherit" FontWeight="inherit" />
<CSSStyle CSSName=".filtered" FontFamily="" Color="LightSlateGray" FontStyle="italic" FontWeight="inherit" />
</Styles>
</Format>
</VoiceActorScripts>
<Translations EnableEditing="false" />
<Edit ShowWarning="true" ExitEditModeAfterSave="true" RefreshProjectAfterSave="Any" />
<DialogParsing ShowAllOoptionText="false" />
</Settings>
<SpeechLines />
<Translations />
</Document>
</SpeechCenter>
</Component>
<Component Name="Plugins" />
<Component Name="Rooms" />
<Component Name="Translations" />
Expand Down
38 changes: 35 additions & 3 deletions GlobalScript.asc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function game_start()
cLetter9.ChangeRoom(TRASH);
cLetter10.ChangeRoom(TRASH);
cLetter11.ChangeRoom(TRASH);
gBottomGui.Transparency = 30;
}

// put anything you want to happen every game cycle in here
Expand Down Expand Up @@ -52,6 +53,18 @@ function repeatedly_execute_always()
if(FakeSprite != null && FakeScreen.isEnabled()){
gGameScr.BackgroundGraphic = FakeSprite.Graphic;
}

if(KeyboardMovement.Moving()) {
if(button_left.NormalGraphic!= 156) {
button_left.NormalGraphic = 156;
button_right.NormalGraphic = 157;
}
} else {
if(button_left.NormalGraphic != 154){
button_left.NormalGraphic = 154;
button_right.NormalGraphic = 155;
}
}
}

// called when a key is pressed. keycode holds the key's ASCII code
Expand Down Expand Up @@ -90,7 +103,26 @@ function dialog_request(int param) {

function ResetRoomButton_OnClick(GUIControl *control, MouseButton button)
{
room_to_go_back = player.Room;
resetRoom = true;
player.ChangeRoom(7);
RestoreGameSlot(2);
}


function button_left_OnClick(GUIControl *control, MouseButton button)
{
if(KeyboardMovement.GetMode() == eKMModePressing){
KeyboardMovement.SetMode(eKeyboardMovement_Tapping);
}

KeyboardMovement.FakeKeyPres(eKeyLeftArrow);
}

function button_right_OnClick(GUIControl *control, MouseButton button)
{
if(KeyboardMovement.GetMode() == eKMModePressing){
KeyboardMovement.SetMode(eKeyboardMovement_Tapping);
}

KeyboardMovement.FakeKeyPres(eKeyRightArrow);
}


Binary file modified acsprset.spr
Binary file not shown.
Binary file added img/gui/left_button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/gui/left_button_hold.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/gui/right_button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/gui/right_button_hold.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions room1.asc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ function room_AfterFadeIn()
init_enemy1(cEnemy1_4);
FakeScreen.Enable();
CustomTransition_FadeIn(0.4, eNoBlockTween);
SaveGameSlot(2, "autosave");
}

function room_Leave()
Expand All @@ -43,5 +44,8 @@ function room_Leave()
function room_Load()
{
gTopGui.Visible = true;
if(System.OperatingSystem == eOSAndroid || System.OperatingSystem == eOSiOS || System.OperatingSystem == eOSPSP || System.OperatingSystem == eOSLinux){
gBottomGui.Visible = true;
}
cBonePile.ChangeRoom(1, 21, 285);
}
Binary file modified room1.crm
Binary file not shown.
4 changes: 4 additions & 0 deletions room2.asc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ function room_AfterFadeIn()
init_enemy1(cEnemy1_3);
FakeScreen.Enable();
CustomTransition_FadeIn(0.4, eNoBlockTween);
SaveGameSlot(2, "autosave");
}

function room_Leave()
Expand All @@ -45,5 +46,8 @@ function room_Leave()
function room_Load()
{
gTopGui.Visible = true;
if(System.OperatingSystem == eOSAndroid || System.OperatingSystem == eOSiOS || System.OperatingSystem == eOSPSP || System.OperatingSystem == eOSLinux){
gBottomGui.Visible = true;
}
cBonePile.ChangeRoom(2, 21, 285);
}
Binary file modified room2.crm
Binary file not shown.
4 changes: 4 additions & 0 deletions room3.asc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ function room_AfterFadeIn()
init_enemy1(cEnemy1_5);
FakeScreen.Enable();
CustomTransition_FadeIn(0.4, eNoBlockTween);
SaveGameSlot(2, "autosave");
}

function room_Leave()
Expand All @@ -43,5 +44,8 @@ function room_Leave()
function room_Load()
{
gTopGui.Visible = true;
if(System.OperatingSystem == eOSAndroid || System.OperatingSystem == eOSiOS || System.OperatingSystem == eOSPSP || System.OperatingSystem == eOSLinux){
gBottomGui.Visible = true;
}
cBonePile.ChangeRoom(3, 21, 285);
}
Binary file modified room3.crm
Binary file not shown.
4 changes: 4 additions & 0 deletions room4.asc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ function room_AfterFadeIn()
init_enemy3(cEnemy3_1);
FakeScreen.Enable();
CustomTransition_FadeIn(0.4, eNoBlockTween);
SaveGameSlot(2, "autosave");
}

function room_Leave()
Expand All @@ -43,5 +44,8 @@ function room_Leave()
function room_Load()
{
gTopGui.Visible = true;
if(System.OperatingSystem == eOSAndroid || System.OperatingSystem == eOSiOS || System.OperatingSystem == eOSPSP || System.OperatingSystem == eOSLinux){
gBottomGui.Visible = true;
}
cBonePile.ChangeRoom(4, 21, 285);
}
Binary file modified room4.crm
Binary file not shown.
4 changes: 4 additions & 0 deletions room5.asc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ function room_AfterFadeIn()
init_enemy3(cEnemy3_2);
FakeScreen.Enable();
CustomTransition_FadeIn(0.4, eNoBlockTween);
SaveGameSlot(2, "autosave");
}

function room_Leave()
Expand All @@ -43,5 +44,8 @@ function room_Leave()
function room_Load()
{
gTopGui.Visible = true;
if(System.OperatingSystem == eOSAndroid || System.OperatingSystem == eOSiOS || System.OperatingSystem == eOSPSP || System.OperatingSystem == eOSLinux){
gBottomGui.Visible = true;
}
cBonePile.ChangeRoom(5, 21, 285);
}
Binary file modified room5.crm
Binary file not shown.
Binary file modified room6.crm
Binary file not shown.
1 change: 1 addition & 0 deletions room7.asc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

function room_Load()
{
gBottomGui.Visible = false;
gTopGui.Visible = false;
CustomTransition_IntantFadeIn();
aDog_from_hell_3.Play(eAudioPriorityHigh, eRepeat);
Expand Down
Binary file modified room7.crm
Binary file not shown.
1 change: 1 addition & 0 deletions room8.asc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ function room_AfterFadeIn()

function room_Load()
{
gBottomGui.Visible = false;
gTopGui.Visible = false;

}
Expand Down
Binary file modified room8.crm
Binary file not shown.
3 changes: 2 additions & 1 deletion room9.asc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

function room_Load()
{
gBottomGui.Visible = false;
gTopGui.Visible = false;
CustomTransition_IntantFadeIn();
aDog_from_hell.Play(eAudioPriorityHigh, eRepeat);
Expand All @@ -12,7 +13,7 @@ function room_AfterFadeIn()
{
Wait(SecondsToLoops(3.0));
CustomTransition_FadeOut(1.6, eBlockTween);
player.ChangeRoom(7, 30, 284, eDirectionRight);
RestartGame();
}

function room_Leave()
Expand Down
Binary file modified room9.crm
Binary file not shown.
Binary file modified sprindex.dat
Binary file not shown.

0 comments on commit 9221f9a

Please sign in to comment.