Skip to content

Touch controls - #87

Open
motcodes wants to merge 25 commits into
pmndrs:mainfrom
motcodes:touch-controls
Open

Touch controls#87
motcodes wants to merge 25 commits into
pmndrs:mainfrom
motcodes:touch-controls

Conversation

@motcodes

@motcodes motcodes commented Jun 8, 2021

Copy link
Copy Markdown

I added some simple touch-based controls:

  • Forward
  • Backward
  • Left
  • Right
  • Boost
  • Reset

I moved the speedometer and controls menu to the top when using a touch-enabled device.
And after clicking "click to continue" I unmount the start menu to prevent text selection.

@vercel

vercel Bot commented Jun 8, 2021

Copy link
Copy Markdown

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/pmndrs/racing-game/CGa3wYGcYyCpovMmzojxEx3v2Jj4
✅ Preview: https://racing-game-git-fork-motcodes-touch-controls-pmndrs.vercel.app

[Deployment for 0c37f76 failed]

@drcmda

drcmda commented Jun 8, 2021

Copy link
Copy Markdown
Member

beautiful! can we make the minimap a little smaller? i also think the on screen hints have to go, it's too little space for that.

@Gusted

Gusted commented Jun 8, 2021

Copy link
Copy Markdown
Contributor

I ain't sure, but this is targeted for portrait mode? I think the game is better played on landscape mode then portrait mode as the car itself will already take half of your screen. But good begin!

@motcodes

motcodes commented Jun 8, 2021

Copy link
Copy Markdown
Author

beautiful! can we make the minimap a little smaller? i also think the on screen hints have to go, it's too little space for that.

I actually would prefer to disable the minimap on mobile as well.

I ain't sure, but this is targeted for portrait mode? I think the game is better played on landscape mode then portrait mode as the car itself will already take half of your screen. But good begin!

One option would be to move the camera back a little more on mobile.

@motcodes motcodes mentioned this pull request Jun 8, 2021
@Gusted

Gusted commented Jun 8, 2021

Copy link
Copy Markdown
Contributor

One option would be to move the camera back a little more on mobile.

Yeah that seems good to me.

@drcmda

drcmda commented Jun 8, 2021

Copy link
Copy Markdown
Member

right, lets remove the minimap, makes no sense on a small screen.

Comment thread src/styles.css Outdated
}
.mobile-controls .left-turn,
.mobile-controls .right-turn {
-webkit-user-select: none;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are all redundancy, user-select should cover all cases. It isn't like we should have to cover browsers from a decade ago(Luckily)

Comment thread src/ui/Help.jsx Outdated
Comment thread src/ui/MobileControls.jsx Outdated
Comment thread src/styles.css Outdated
}
}

@media (hover: hover) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm we are now going to rely into media queries to detect, touch devices? Well I have no experience with this specific media query and don't know the reliability of this. It should be hold in mind that it could break with edge cases.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thereby a detect if any keys are pressed(mobiles/tablets with keyboards) that we could add a non-touch class into the html and then as well hide these.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest we use a package to handle this: https://github.com/duskload/react-device-detect

so we don't have to worry about the edge cases

Comment thread src/controls/Mobile.js Outdated
useEffect(() => {
const downHandler = (e) => {
if (target.indexOf(e.target.value) !== -1) {
const isRepeating = !!pressed[e.target.value]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value of this array is already a boolean or null no need to have the !! in check as in the if statement the browser will already check it for truthiness.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The controls have changed since this PR has been opened

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have all of the controls changed or specific controls that can get updated?
please list them.

How can we set this pr up for success? @njm222 , thanks

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I remember this is good to go, it just needs to be merged with main and resolve conflicts.

I would rebase onto main or force push a new branch since a lot has changed since this PR was opened.

motcodes and others added 2 commits June 8, 2021 23:12
Co-authored-by: Gusted <williamzijl7@hotmail.com>
@drcmda

drcmda commented Jun 9, 2021

Copy link
Copy Markdown
Member

is this ready to go?

@njm222

njm222 commented Jun 9, 2021

Copy link
Copy Markdown
Member

I don't think so

@njm222
njm222 marked this pull request as draft June 9, 2021 07:45
@motcodes
motcodes marked this pull request as ready for review June 9, 2021 11:46
Comment thread src/controls/Mobile.js Outdated
Comment thread src/lib/useOrientationChange.js Outdated
Comment thread src/lib/useOrientationChange.js Outdated

@Gusted Gusted left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No more issues raised for me other then that little comment.

Comment thread src/lib/useOrientationChange.js Outdated
Comment thread src/App.jsx Outdated
<Help />
<KeyboardControls />
<HideMouse />
{isMobile && <MobileControls />}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{isMobile && <MobileControls />}
{isMobile ? <MobileControls /> : <KeyboardControls />}

Comment thread src/controls/Keyboard.js Outdated
Comment on lines +31 to +34
useKeys()
if (isMobile) {
useTouch()
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
useKeys()
if (isMobile) {
useTouch()
}
if (isMobile) {
useTouch()
return
}
useKeys()

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would leave it like this so you can use both the touch and keyboard control on an iPad.

@vercel

vercel Bot commented Jun 10, 2021

Copy link
Copy Markdown

@motcodes is attempting to deploy a commit to the Poimandres Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants