SyntaxBomb - Indie Coders

Languages & Coding => Blitz Code Archives => User Input => Topic started by: BlitzBot on June 29, 2017, 00:28:42

Title: [bb] Player Movement: Round vs Square by GIB3D [ 1+ years ago ]
Post by: BlitzBot on June 29, 2017, 00:28:42
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) Select
;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.

Graphics3D 800,600,32,2
SetBuffer BackBuffer()
SeedRnd MilliSecs()

AmbientLight 20,20,20
Global Light = CreateLight():RotateEntity Light,65,0,0

Global Camera = CreateCamera()
PositionEntity Camera,0,50,0
CameraProjMode Camera,2
CameraZoom Camera,.1

Global Cube = CreateCube()
PointEntity Camera,Cube

Local Key[1],MoveX#,MoveY#,Angle#
Local Toggle

;[Block] Used to calculate where to put the 2D stuff on the screen
Local X,Y,Width,Height
CameraProject Camera,-1,0,1
X = ProjectedX()
Y = ProjectedY()
CameraProject Camera,1,0,-1
Width = ProjectedX()-X
Height = ProjectedY()-Y
;[End]

While Not KeyDown(1)
If KeyHit(57) Toggle = Not Toggle

Key[0] = KeyDown(30)-KeyDown(32) ; X
Key[1] = KeyDown(31)-KeyDown(17) ; Y

Select Toggle
Case True ; Round Controls

Angle = VectorYaw(Key[0],0,Key[1])

If Key[0] Or Key[1]
MoveX = AngleX(Angle)
MoveY = AngleY(Angle)
Else
MoveX=0
MoveY=0
EndIf

PositionEntity Cube,MoveX,0,MoveY

Case False ; Square Controls

PositionEntity Cube,-Key[0],0,-Key[1]

End Select

UpdateWorld
RenderWorld

Color 255,255,255
Text GraphicsWidth()*.5,0,"Controls: WASD and Space to toggle input",1

Select Toggle
Case True ; Round Controls
Color 255,0,0
Oval X,Y,Width,Height,0

Color 255,255,255
Text GraphicsWidth()*.5,20,"These are more circular controls",1
Text GraphicsWidth()*.5,ProjectedY()-160,"X("+AngleX(Angle)+")",1
Text GraphicsWidth()*.5,ProjectedY()-140,"Y("+AngleY(Angle)+")",1
Case False ; Square Controls
Color 255,0,0
Rect X,Y,Width,Height,0

Color 255,255,255
Text GraphicsWidth()*.5,20,"These are the basic kind of controls mostly used by First Person Shooter games",1
Text GraphicsWidth()*.5,ProjectedY()-160,"X("+Key[0]+")",1
Text GraphicsWidth()*.5,ProjectedY()-140,"Y("+Key[1]+")",1
End Select

Flip

Wend
End

Function AngleX#(angle#)
Return Cos(angle-90)
End Function

Function AngleY#(angle#)
Return Sin(angle-90)
End Function


Comments :


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...