Joined: Sun Apr 21, 2013 8:40 am Posts: 4
|
Oh Blitz3d - my first language! I don't have it installed on this PC anymore so I can't test what I'd advise you - but try this: Code: ; 1st project, Jumping Cone
;------------------------------
Local camdistance=10 Graphics3D 1024, 768, 0, 1 SetBuffer BackBuffer()
;types Local type_player=1 Local type_ground=2
;camera camera=CreateCamera() RotateEntity camera, 45,0,0
;light light=CreateLight()
;plane/texture grid_tex=CreateTexture(32,32,8) ScaleTexture grid_tex,10,10 SetBuffer TextureBuffer (grid_tex) Color 0,0,64:Rect 0,0,32,32 Color 0,0,255:Rect 0,0,32,32,False SetBuffer BackBuffer() grid_plane=CreatePlane() EntityTexture grid_plane,grid_tex EntityBlend grid_plane,1 EntityAlpha grid_plane,.6 EntityFX grid_plane,1 EntityType grid_plane,type_ground
;mirror mirror = CreateMirror()
;cone cone=CreateCone(64) EntityType cone,type_player PositionEntity cone, 0, 1, 5 ScaleEntity cone, .4,.4,.4 EntityRadius cone, 0.5 Texture=CreateTexture(16,16):SetBuffer TextureBuffer(texture) ClsColor 256,6,256 Cls Color 12,126,256 Rect 0,0,8,8,1 Rect 8,8,8,8,1 ScaleTexture Texture,.2,.2 SetBuffer BackBuffer() ;run
Local y# = 0 Local velocity# = 0 Local xvelocity# = 0 While Not KeyDown(1) y=0
If KeyDown(208) Then velocity=velocity-0.001 If KeyDown(200) Then velocity=velocity+0.001 If KeyDown(31) Then velocity=0 xvelocity = 0 EndIf If KeyDown(203) Then xvelocity=xvelocity-0.001 If KeyDown(205) Then xvelocity=xvelocity+0.001 If KeyDown(57) Then y=y+0.5
MoveEntity cone,xvelocity,y,velocity TranslateEntity cone, 0,-0.1,0 PositionEntity camera, EntityX(cone),0,EntityZ(cone)-5 Collisions type_player,type_ground,2,2 Collisions type_ground,type_player,2,2
UpdateWorld()
RenderWorld() Flip
Wend
End I don't see any really "good result", so I decided to write a little something(installed blitz3d): Code: ; 1st project, Jumping Cone
;------------------------------ Local random_seed = 8 SeedRnd random_seed
Local screen_width = 1024 Local screen_height = 768
Graphics3D screen_width, screen_height, 0, 1 SetBuffer BackBuffer()
;types Local type_player=1 Local type_ground=2
Local cam_distance# = 7
;player init cone=CreateCone(8) EntityType cone,type_player PositionEntity cone, 0, 5, 0 ScaleEntity cone, .4,.4,.4 EntityRadius cone, 0.5
piv = CreatePivot(cone)
Local fog_near = 10 Local fog_far = 50 camera = CreateCamera(piv) CameraFogMode camera, 1 CameraFogRange camera, fog_near, fog_far CameraFogColor camera, 0, 0, 0 PositionEntity camera, EntityX(cone), EntityY(cone)+.2, EntityZ(cone)-cam_distance
;world init plane = CreatePlane() EntityType plane, type_ground EntityColor plane, 100, 100, 200 EntityAlpha plane,.5
mirror = CreateMirror()
Local elements_num = 50 Local counter = 0 Local element_type = 0 Local element = 0 ;wrap: Local wrap_min_x = -64 Local wrap_min_z = -64 Local wrap_max_x = 64 Local wrap_max_z = 64
For counter = 1 To elements_num
element_type = Rand(1,4) Select element_type Case 1 element = CreateCube() Case 2 element = CreateCylinder() Case 3 element = CreateCone() Case 4 element = CreateSphere() End Select
PositionEntity element, Rnd(wrap_min_x+10, wrap_max_z-10), Rnd(2, 5), Rnd(wrap_min_z+10, wrap_max_z-10) EntityColor element, Rand(0,255), Rand(0, 255), Rand(0, 255) ScaleEntity element, Rnd(.5, 2), Rnd(.5, 2), Rnd(.5, 2) EntityType element, type_ground
Next
pivot = CreatePivot(); the point around which the camera will revolve
;light light=CreateLight(1, pivot) MoveEntity light,0,0, -20
;Player: Local player = cone Local speed_z# = .3 Local strafe# = .2 Local air_speed_z# = speed_z/2 Local speed_x# = .5 Local jump_strength# = .8 Local y_change# = 0 Local touch_ground = 0
;World: Local gravity# = .02 Local light_revol# = .5 Local wireframe_state = 0
Collisions type_player,type_ground,2,2 Collisions type_ground,type_player,2,2 PointEntity camera, player While Not KeyDown(1)
;Input If EntityCollided(player, type_ground) Then touch_ground = 1 y_change = 0 EndIf
If touch_ground Then
If KeyDown(31) Then MoveEntity player, 0, 0, -speed_z EndIf
If KeyDown(17) Then MoveEntity player, 0, 0, speed_z EndIf
If KeyDown(30) Then MoveEntity player, -strafe, 0, 0 EndIf
If KeyDown(32) Then MoveEntity player, strafe, 0, 0 EndIf
If KeyHit(57) Then y_change = jump_strength touch_ground = 0 EndIf
Else
y_change = y_change - gravity MoveEntity player,0 , y_change, 0
If KeyDown(31) Then MoveEntity player, 0, 0, -air_speed_z EndIf
If KeyDown(17) Then MoveEntity player, 0, 0, air_speed_z EndIf
EndIf
TurnEntity player, 0, -speed_x*MouseXSpeed(), 0 TurnEntity piv, speed_x*MouseYSpeed(), 0, 0 MoveMouse screen_width/2, screen_height/2 TurnEntity pivot, light_revol, 0, 0 PointEntity light, pivot
If KeyHit(28) Then wireframe_state = 1-wireframe_state WireFrame wireframe_state EndIf
;World wrap
If EntityX(player) > wrap_max_x Then PositionEntity player, wrap_min_x, EntityY(player), EntityZ(player) EndIf
If EntityX(player) < wrap_min_x Then PositionEntity player, wrap_max_x, EntityY(player), EntityZ(player) EndIf
If EntityZ(player) < wrap_min_z Then PositionEntity player, EntityX(player), EntityY(player), wrap_max_z EndIf
If EntityZ(player) > wrap_max_z Then PositionEntity player, EntityX(player), EntityY(player), wrap_min_z EndIf
UpdateWorld()
touch_ground = 0
RenderWorld()
Text 0,0, "Player X: " + EntityX(player) + ", Y: " + EntityY(player) + ", Z: " + EntityZ(player) Flip
Wend
End
Btw here's an image - try the code and tell me what you think about it, I haven't coded in B3D for ages, so I'd be happy to see what you make out of it. Btw here's a nice IDE for B3d too: http://www.fungamesfactory.com/index.htmlBtw the end of line error is usually when you forget a comma, or some parameter for a function
|
|