-
-
Notifications
You must be signed in to change notification settings - Fork 177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Controller support #416
base: master
Are you sure you want to change the base?
Controller support #416
Changes from 1 commit
f34a14b
29c3904
78dabad
dfd54b8
0effb6d
78cc4f5
748da8a
f3bc168
6206403
70b757e
f10a3fc
6b04ff8
696f78f
30f4e99
c135992
56ac855
001b79b
b518ba0
b9914b3
12e50c2
a2af537
0ffd77c
03137c5
b0ccbdb
fd2cc74
b6e0f25
82dfef6
b6778db
03487ae
3551e18
f91d79f
6ef7f6d
76135f5
d8032c5
6885cea
6d768a6
6b8b15d
fe8d3c8
40f01e4
c072ba8
4215c58
8b62d3b
a2b1f7d
a135d94
c9bfde5
3a1754a
ff4057b
2d706a4
15e9c52
60cf8cd
5433661
f381a85
341ac6d
0c76016
d1f8545
6bbad7d
e7bc76c
3961d46
dc278cf
4a992b1
3999993
4e9fe5a
fe53996
fbdcc3e
92e2021
6e795c9
a3caa6d
0f034d0
ea8cc50
7010659
3c2fc70
9e56a86
f9e05f8
f589075
04c0327
4248002
385cec2
3a40470
b5539c4
c2f658b
8df2b89
af06e4f
41c47eb
cce48f5
4126c5f
5d4ef1f
3a75147
189c768
6ec0bdd
c69fe4f
c32c525
309207c
0852e1f
178b87d
647bbbe
6866ed8
4fe212b
2c63fa3
d31c66f
bdf9fff
36994b5
7dd94c6
3fa7d68
679f304
f9d3d0f
312dd15
f3843af
10889a9
ce9467b
3f513c6
ea897b3
b7487de
0f16dfe
e067544
98353a3
aac088f
b05e0a8
a761c9c
4e45aed
8a87b93
51a72e4
0b07176
68ef674
c4ed157
958464e
4692bbe
e4d9283
ecd447b
b356404
6a17063
0f32443
e92459f
237aef7
a78467f
2e3f3cc
bc90cf3
cf163d2
054dc4e
22d338c
59c5a3e
279f048
2ac278b
572e937
476c1e1
53f0a79
2e917b3
78ab8d4
4801959
eece62e
47d503d
b3099f9
532e516
46cd930
3de4f1d
dd87211
b1257c8
11f165c
c93bab3
59226af
2668afc
7265f15
6596485
b35a40e
581136e
4f10bc6
b0bb315
2c1a6f6
5d63191
57c5e6f
173123e
bdc7d40
a050657
36bdcd1
9fe1acb
cf75d4b
4c8eb34
f512dbe
f1eefc3
e0f27a6
51aacae
62561d1
5f768ee
a784ba7
c630af1
81b19c1
9765e3a
6dc7113
c7d5f4c
50af449
e477e08
99e4147
ad7dffc
3b23d33
a9e130d
860702d
9747639
6872515
7e3d43f
883eff6
7945d09
36cd907
f9571b7
4ccca28
0c9b6ad
1c5ca40
1401c6b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ import { ItemType, type ItemDefinition } from "@common/utils/objectDefinitions"; | |
import { Vec } from "@common/utils/vector"; | ||
import $ from "jquery"; | ||
import nipplejs, { type JoystickOutputData } from "nipplejs"; | ||
import * as PIXI from "pixi.js"; | ||
import { Ticker } from "pixi.js"; | ||
import { isMobile } from "pixi.js"; | ||
import { getTranslatedString } from "../../translations"; | ||
import { type Game } from "../game"; | ||
|
@@ -343,8 +343,7 @@ export class InputManager { | |
shootOnRelease = false; | ||
}); | ||
} | ||
const ticker = new PIXI.Ticker(); | ||
ticker.stop(); | ||
const ticker = new Ticker(); | ||
ticker.add(() => { | ||
const gamepads = navigator.getGamepads(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if you use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do you really need to call this method every frame, is it required? |
||
if (gamepads[0]) { | ||
Arman-AIi marked this conversation as resolved.
Show resolved
Hide resolved
Arman-AIi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
@@ -360,13 +359,12 @@ export class InputManager { | |
if (!rightJoystickMoving) { | ||
this.rotation = movementAngle; | ||
this.turning = true; | ||
const activePlayer = game.activePlayer; | ||
if (game.console.getBuiltInCVar("cv_responsive_rotation") && !game.gameOver && game.activePlayer) { | ||
game.activePlayer.container.rotation = this.rotation; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. isn't there a better way to do this in the |
||
this.turning = true; | ||
} | ||
if (!activePlayer) return; | ||
activePlayer.images.aimTrail.alpha = 0; | ||
if (!game.activePlayer) return; | ||
game.activePlayer.images.aimTrail.alpha = 0; | ||
} | ||
} else { | ||
this.movement.moving = false; | ||
|
@@ -375,14 +373,11 @@ export class InputManager { | |
if (rightJoystickMoving) { | ||
this.rotation = Math.atan2(gamepads[0].axes[3], gamepads[0].axes[2]); | ||
this.turning = true; | ||
const activePlayer = game.activePlayer; | ||
|
||
if (game.console.getBuiltInCVar("cv_responsive_rotation") && !game.gameOver && activePlayer) { | ||
if (game.console.getBuiltInCVar("cv_responsive_rotation") && !game.gameOver && game.activePlayer) { | ||
game.activePlayer.container.rotation = this.rotation; | ||
game.activePlayer.images.aimTrail.alpha = 1; | ||
} | ||
|
||
if (!activePlayer) return; | ||
activePlayer.images.aimTrail.alpha = 1; | ||
} | ||
} | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is still wrong, use the
Game
update method