Hi All,
I've been playing with the Blitz collision system to see how it works and have come up with the little snippet you see below. My question is, does the collision and sliding in this feel correct for a platform style game?
I haven't added any time dependent code so it will run at different speeds on different machines. I'm not really concerned with the camera following, just the collision of the cylinder against the rest of the world. I'm just curious what others think. Thanks for your comments.
left alt key = jump
arrow keys = move
Ken
I've been playing with the Blitz collision system to see how it works and have come up with the little snippet you see below. My question is, does the collision and sliding in this feel correct for a platform style game?
I haven't added any time dependent code so it will run at different speeds on different machines. I'm not really concerned with the camera following, just the collision of the cylinder against the rest of the world. I'm just curious what others think. Thanks for your comments.
left alt key = jump
arrow keys = move
Ken
; platformer collision test ; Kenneth "Physt" Lemieux ; kenlem@... ; No Rights Reserved ;left alt key = jump ;arrow keys = move Global gravity# = -0.02 Global speed# = 0.09 Global x# = 10 Global y# = 50 Global z# = 10 Global platvel# = .025 Graphics3D 640, 480 GameLoop() Function GameLoop() frametimer = CreateTimer(60) light=CreateLight() RotateEntity light,45,45,0 camera=CreateCamera() PositionEntity camera, 10, 10, 10 player = CreateCylinder(32) FitMesh player, -1, -1, -1, 2, 2, 2, False level = CreateCube() grid=CreateTexture(64,64,9) SetBuffer TextureBuffer(grid) Color 32,64,128 Rect 0, 0, 64,64, 1 Color 255,255,255 Rect 0, 0, 64,64, 0 SetBuffer BackBuffer() ScaleTexture grid, .1, .1 EntityTexture level, grid FitMesh level, -40, -40, -40, 80, 80, 80, True FlipMesh(level) platform1 = CreateCube() FitMesh platform1, -10, -25, -10, 10, 1, 10, False EntityTexture platform1, grid platform2 = CreateCube() FitMesh platform2 , -10, -30, 10, 10, 1, 10, False EntityTexture platform2 , grid platform3 = CreateCube() FitMesh platform3 , -15, -35, 10, 10, 1, 10, False EntityTexture platform3 , grid platform4 = CreateCube() FitMesh platform4 , -16, -20, 7, 10, 1, 10, False EntityTexture platform4 , grid EntityType player,1 EntityType level, 2 EntityType platform1, 2 EntityType platform2, 2 EntityType platform3, 2 EntityType platform4, 2 Collisions 1, 2, 2, 2 While Not KeyDown(1) ; left If KeyDown(203) Then TurnEntity player, 0, 3, 0 End If ; right If KeyDown(205) Then TurnEntity player, 0, -3, 0 End If ; down If KeyDown(208) Then TFormVector 0, 0, 1, player, 0 xvel# = xvel# - (TFormedX() * speed#) yvel# = yvel# - (TFormedY() * speed#) zvel# = zvel# - (TFormedZ() * speed#) End If ; up arrow forward If KeyDown(200) Then TFormVector 0, 0, 1, player, 0 xvel# = xvel# + (TFormedX() * speed#) yvel# = yvel# + (TFormedY() * speed#) zvel# = zvel# + (TFormedZ() * speed#) End If collide = CountCollisions (player) If collide > 0 Then For i = 1 To collide NY# = CollisionNY(player, i) If NY# > 0 Then yvel# = yvel# - gravity# If KeyDown(29) Then yvel# = yvel# + .60 If yvel# < .4 Then yvel# = 0 End If End If Else If NY#=-1 Then ;yvel# = -yvel# * .5 yvel# = 0 End If Next End If yvel# = yvel# + gravity# x# = x# + xvel# y# = y# + yvel# z# = z# + zvel# xvel# = xvel# * .7 zvel# = zvel# * .7 PositionEntity player, x#, y#, z# UpdateWorld() PositionEntity camera, EntityX(player), EntityY(player)+2, EntityZ(player) RotateEntity camera ,EntityPitch(player), EntityYaw(player)+4, EntityRoll(player) MoveEntity camera, 0, 0, -5 PointEntity camera, player x# = EntityX(player) y# = EntityY(player) z# = EntityZ(player) RenderWorld() Flip Wend End Function