Get skater to move

Blitz3D Forums/Blitz3D Programming/Get skater to move

clownhunter(Posted 2004) [#1]
How do I get the skater to move? The source is:

;choose the gender of the character
Graphics3D 400,400,32,2
AppTitle"Clown Hunter: Pro Skater"
SetBuffer BackBuffer()

;load the images
Global boy = LoadImage("Clown Hunter Pro Skater/male.jpg")
Global girl = LoadImage("Clown Hunter Pro Skater/female.jpg")
Global selecterimage = LoadImage("Clown Hunter Pro Skater/select.jpg")

Type selecter
Field x,y
End Type

selecter.selecter = New selecter

selecter\x = 40
selecter\y = 140

Global gender

While gender = 0
Cls

If KeyHit (205) And selecter\x = 40
selecter\x = selecter\x + 200
EndIf

If KeyHit (203) And selecter\x = 240
selecter\x = selecter\x - 200
EndIf

If KeyHit(28)
If selecter\x = 40
gender = 1
EndIf
If selecter\x = 240
gender = 2
EndIf
EndIf

Text 10,10,"Choose your Skater:"

DrawImage selecterimage,selecter\x,selecter\y
DrawImage boy,0,200
DrawImage girl,200,200

Flip
Wend

;choose the course
Graphics3D 400,400,32,2
AppTitle"Clown Hunter: Pro Skater"
SetBuffer BackBuffer()

Global courseer = LoadImage("Clown Hunter Pro Skater/course.jpg")
Global selecter2image = LoadImage("Clown Hunter Pro Skater/select.jpg")

Type selecter2
Field x,y
End Type

selecter2.selecter2 = New selecter2

selecter2\x = 40
selecter2\y = 140

Global course

While course = 0
Cls

If KeyHit (205) And selecter2\x = 40
selecter2\x = selecter2\x + 200
EndIf

If KeyHit (203) And selecter2\x = 240
selecter2\x = selecter2\x - 200
EndIf

If KeyHit(28)
If selecter2\x = 40
course = 1
EndIf
If selecter2\x = 240
course = 2
EndIf
EndIf

DrawImage courseer,0,0
DrawImage selecter2image,selecter2\x,selecter2\y

Flip
Wend

;*********************************************************
;*********************************************************
;*********************************************************
;**********************the real game**********************
;*********************************************************
;*********************************************************
;*********************************************************
Graphics3D 400,400,32,2
AppTitle"Clown Hunter: Pro Skater"
SetBuffer BackBuffer()

;all of that camera stuff
camera_pivot = CreatePivot()
EntityRadius camera_pivot,1.4
camera = CreateCamera(camera_pivot)
CameraViewport camera,0,0,GraphicsWidth(),GraphicsHeight()
CameraClsColor camera,0,0,255

;lights
AmbientLight 200,200,200
Global light = CreateLight()
RotateEntity light,90,0,0

;if you are a boy, load the boy model
If gender = 1
person = LoadMesh("Clown Hunter Pro Skater/boy on skateboard.3ds",camera_pivot)
ScaleEntity person,.1,.1,.1
MoveEntity person,0,-1.5,2
RotateEntity person,0,90,0
EndIf

;if you are a girl, load the girl model
If gender = 2
person = LoadMesh("Clown Hunter Pro Skater/girl on skateboard.3ds",camera_pivot)
ScaleEntity person,.1,.1,.1
MoveEntity person,0,-1.5,2
RotateEntity person,0,90,0
EndIf

;if you chose track1
If course = 1
track = LoadMesh("Clown Hunter Pro Skater/track1.3ds")
track2 = LoadMesh("Clown Hunter Pro Skater/track3.3ds",track)
track1 = LoadMesh("Clown Hunter Pro Skater/track1-2.3ds",track)
PositionEntity track,0,-7.1,3
ScaleEntity track,3,3,3
EntityColor track1,255,255,0
testtex = LoadTexture("Clown Hunter Pro Skater/testtex4.jpg")
EntityTexture track,testtex
EntityTexture track2,testtex
EndIf

;if you chose track1
If course = 2
track = LoadMesh("Clown Hunter Pro Skater/track2.3ds")
track2 = LoadMesh("Clown Hunter Pro Skater/track3.3ds")
track1 = LoadMesh("Clown Hunter Pro Skater/track2-2.3ds",track)
PositionEntity track,0,-1.9,0
ScaleEntity track,3,3,3
testtex = LoadTexture("Clown Hunter Pro Skater/testtex4.jpg")
EntityTexture track,testtex
EntityTexture track2,testtex
EndIf

;speed,acceleration,and that stuff
speed = 0
tfspeed = 1
tbspeed = -.5

;the main loop
While Not KeyDown(1)
Cls

MoveEntity camera_pivot,0,0,speed

If KeyDown(200) = False
If KeyDown(208) = False
If speed < 0
speed = speed + .1
EndIf
If speed > 0
speed = speed - 1
EndIf
EndIf
EndIf

;movement
If KeyDown(200)
speed = speed + .1

If KeyDown(203)
TurnEntity camera_pivot,0,2,0
EndIf

If KeyDown(205)
TurnEntity camera_pivot,0,-2,0
EndIf
EndIf

If KeyDown(208)
speed = speed - .1

If KeyDown(203)
TurnEntity camera_pivot,0,-1,0
EndIf

If KeyDown(205)
TurnEntity camera_pivot,0,1,0
EndIf
EndIf

If KeyDown(30)
MoveEntity track,0,.3,0
EndIf

If KeyDown(44)
MoveEntity track,0,-.3,0
EndIf

;all of that crud that goes at the end
UpdateWorld
RenderWorld

Text 0,0,EntityY(track)

Flip
Wend
End


Matty(Posted 2004) [#2]
"Speed" is an integer, specify it as Speed# the first time it is used to declare it as a float. Otherwise when you add 0.1 or -0.1 to an integer it rounds it back to zero.


clownhunter(Posted 2004) [#3]
How do you get collisions for it as well. I can't get any to work.


clownhunter(Posted 2004) [#4]
Thanks for your help Matty. Also, how do you get collisions for it. I can't get any to work.


Matty(Posted 2004) [#5]
Have a look at the example in the Blitz3d documentation. More specifically look up the "Collisions" command under 3D-Category, Global.