November 25, 2020, 08:20:04 AM

### Author Topic: [bb] Player Movement: Round vs Square by GIB3D [ 1+ years ago ]  (Read 536 times)

#### BlitzBot

• Jr. Member
• Posts: 1
##### [bb] Player Movement: Round vs Square by GIB3D [ 1+ years ago ]
« on: June 29, 2017, 12:28:42 AM »
Title : Player Movement: Round vs Square
Author : GIB3D
Posted : 1+ years ago

Description : The problem with using Square controls is that players can give themselves extra unintended speed

For example let's say you make a moat between land and a castle... the player couldn't normally jump over it by pressing just forward. But if the player holds forward+right they might be able to jump the gap.

Code :
Code: BlitzBasic
1. ;The problem with using Square controls is that players can
2. ;give themselves extra unintended speed
3.
4. ;For example let's say you make a moat between land and a castle...
5. ;the player couldn't normally jump over it by pressing just forward.
6. ;But if the player holds forward+right they might be able to jump the gap.
7.
8. Graphics3D 800,600,32,2
9. SetBuffer BackBuffer()
10. SeedRnd MilliSecs()
11.
12. AmbientLight 20,20,20
13. Global Light = CreateLight():RotateEntity Light,65,0,0
14.
15. Global Camera = CreateCamera()
16.         PositionEntity Camera,0,50,0
17.         CameraProjMode Camera,2
18.         CameraZoom Camera,.1
19.
20. Global Cube = CreateCube()
21.         PointEntity Camera,Cube
22.
23. Local Key[1],MoveX#,MoveY#,Angle#
24. Local Toggle
25.
26. ;[Block] Used to calculate where to put the 2D stuff on the screen
27. Local X,Y,Width,Height
28. CameraProject Camera,-1,0,1
29. X = ProjectedX()
30. Y = ProjectedY()
31. CameraProject Camera,1,0,-1
32. Width = ProjectedX()-X
33. Height = ProjectedY()-Y
34. ;[End]
35.
36. While Not KeyDown(1)
37.         If KeyHit(57) Toggle = Not Toggle
38.
39.         Key[0] = KeyDown(30)-KeyDown(32) ; X
40.         Key[1] = KeyDown(31)-KeyDown(17) ; Y
41.
42.         Select Toggle
43.                 Case True ; Round Controls
44.
45.                         Angle = VectorYaw(Key[0],0,Key[1])
46.
47.                         If Key[0] Or Key[1]
48.                                 MoveX = AngleX(Angle)
49.                                 MoveY = AngleY(Angle)
50.                         Else
51.                                 MoveX=0
52.                                 MoveY=0
53.                         EndIf
54.
55.                         PositionEntity Cube,MoveX,0,MoveY
56.
57.                 Case False ; Square Controls
58.
59.                         PositionEntity Cube,-Key[0],0,-Key[1]
60.
61.         End Select
62.
63.         UpdateWorld
64.         RenderWorld
65.
66.         Color 255,255,255
67.         Text GraphicsWidth()*.5,0,"Controls: WASD and Space to toggle input",1
68.
69.         Select Toggle
70.                 Case True ; Round Controls
71.                         Color 255,0,0
72.                         Oval X,Y,Width,Height,0
73.
74.                         Color 255,255,255
75.                         Text GraphicsWidth()*.5,20,"These are more circular controls",1
76.                         Text GraphicsWidth()*.5,ProjectedY()-160,"X("+AngleX(Angle)+")",1
77.                         Text GraphicsWidth()*.5,ProjectedY()-140,"Y("+AngleY(Angle)+")",1
78.                 Case False ; Square Controls
79.                         Color 255,0,0
80.                         Rect X,Y,Width,Height,0
81.
82.                         Color 255,255,255
83.                         Text GraphicsWidth()*.5,20,"These are the basic kind of controls mostly used by First Person Shooter games",1
84.                         Text GraphicsWidth()*.5,ProjectedY()-160,"X("+Key[0]+")",1
85.                         Text GraphicsWidth()*.5,ProjectedY()-140,"Y("+Key[1]+")",1
86.         End Select
87.
88.         Flip
89.
90. Wend
91. End
92.
93. Function AngleX#(angle#)
94.         Return Cos(angle-90)
95. End Function
96.
97. Function AngleY#(angle#)
98.         Return Sin(angle-90)
99. End Function

Serpent(Posted 1+ years ago)

Good demonstration.If anyone has played/seen 'The World's Hardest Game' you'll understand the problems of 'square' movement if FPS games...

_PJ_(Posted 1+ years ago)

Is this a result of moving, say: FORWARDS 1 unit AND SIDEWARDS 1 unittotalling 2 Units of movement in 1 'turn'?

Serpent(Posted 1+ years ago)

Well, technically 1.4 units (Sqare root of 2)  but basically your purpose in the game is to make use of diagonal movement because it does make a considerable difference.  If you can travel 40% faster in a game by moving diagonally and the developer hasn't accounted for this, there will definitely be inherent problems...

xlsior(Posted 1+ years ago)

<div class="quote"> there will definitely be inheren problems... </div>...or 'feature' -- in the Descent games you can sometimes outrun someone who's chasing you by flying forward and strafing sideways at the same time. A bit trickier to stear that way, but you do get a speedboost that can help you escape.

_PJ_(Posted 1+ years ago)

<div class="quote"> Well, technically 1.4 units (Sqare root of 2) but basically your purpose in the game is to make use of diagonal movement because it does make a considerable difference. If you can travel 40% faster in a game by moving diagonally and the developer hasn't accounted for this, there will definitely be inherent problems...  </div>Sorry, yeah that's what I meant...