Skip to content

Commit

Permalink
shmup web control improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
ZacharyPatten committed Sep 30, 2023
1 parent 532c3af commit ba26a76
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
14 changes: 14 additions & 0 deletions Projects/Website/Games/Shmup/Shmup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ public class Shmup

internal static bool spacebar_down = false;

internal static bool ui_u_down = false;
internal static bool ui_d_down = false;
internal static bool ui_l_down = false;
internal static bool ui_r_down = false;

internal static bool ui_shoot_down = false;

public async Task Run()
{
if (OperatingSystem.IsWindows() && (consoleWidth < intendedMinConsoleWidth || consoleHeight < intendedMinConsoleHeight))
Expand Down Expand Up @@ -149,8 +156,15 @@ async Task Update()
d = d || downarrow_down;
r = r || rightarrow_down;

u = u || ui_u_down;
l = l || ui_l_down;
d = d || ui_d_down;
r = r || ui_r_down;

shoot = shoot || spacebar_down;

shoot = shoot || ui_shoot_down;

if (waitingForInput)
{
waitingForInput = !(u || d || l || r || shoot);
Expand Down
16 changes: 6 additions & 10 deletions Projects/Website/Pages/Shmup.razor
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,12 @@
</pre>
</div>
<div>
<button class="btn btn-primary" @onclick="() => Console.EnqueueInput(ConsoleKey.W) ">w</button>
<button class="btn btn-primary" @onclick="() => Console.EnqueueInput(ConsoleKey.A) ">a</button>
<button class="btn btn-primary" @onclick="() => Console.EnqueueInput(ConsoleKey.S) ">s</button>
<button class="btn btn-primary" @onclick="() => Console.EnqueueInput(ConsoleKey.D) ">d</button>
<button class="btn btn-primary" @onclick="() => Console.EnqueueInput(ConsoleKey.UpArrow) ">↑</button>
<button class="btn btn-primary" @onclick="() => Console.EnqueueInput(ConsoleKey.DownArrow) ">↓</button>
<button class="btn btn-primary" @onclick="() => Console.EnqueueInput(ConsoleKey.LeftArrow) ">←</button>
<button class="btn btn-primary" @onclick="() => Console.EnqueueInput(ConsoleKey.RightArrow)">→</button>
<button class="btn btn-primary" @onclick="() => Console.EnqueueInput(ConsoleKey.Enter) ">enter</button>
<button class="btn btn-primary" @onclick="() => Console.EnqueueInput(ConsoleKey.Escape) ">escape</button>
<button class="btn btn-primary" @onmousedown="() => Games.Shmup.Shmup.ui_u_down = true" @onmouseup="() => Games.Shmup.Shmup.ui_u_down = false">↑</button>
<button class="btn btn-primary" @onmousedown="() => Games.Shmup.Shmup.ui_d_down = true" @onmouseup="() => Games.Shmup.Shmup.ui_d_down = false">↓</button>
<button class="btn btn-primary" @onmousedown="() => Games.Shmup.Shmup.ui_l_down = true" @onmouseup="() => Games.Shmup.Shmup.ui_l_down = false">←</button>
<button class="btn btn-primary" @onmousedown="() => Games.Shmup.Shmup.ui_r_down = true" @onmouseup="() => Games.Shmup.Shmup.ui_r_down = false">→</button>
<button class="btn btn-primary" @onmousedown="() => Games.Shmup.Shmup.ui_shoot_down = true" @onmouseup="() => Games.Shmup.Shmup.ui_shoot_down = false">shoot</button>
<button class="btn btn-primary" @onclick="() => Console.EnqueueInput(ConsoleKey.Enter)">enter</button>
</div>
</div>

Expand Down

0 comments on commit ba26a76

Please sign in to comment.