function help
Blitz3D Forums/Blitz3D Beginners Area/function help
| ||
quick question am i placing the function in the right place it not working right. sorry for sounding like a pain asking a lot of question Graphics3D 800,600,2 Global max_life = 6 Global heart_container = 1 Global rupy = 0 Global key = 0 Global bomb = 0 Global red_rupy = 1 Global blue_rupy = 5 Const cube_col = 1 Const sphere_col = 1 SetBuffer BackBuffer() camera=CreateCamera() CameraViewport camera,0,0,800,600 PositionEntity camera,0,0,-5 light= CreateLight() cube=CreateCube() PositionEntity cube,-5,0,5 EntityColor cube,70,80,190 EntityType cube,cube_col sphere=CreateSphere(12) PositionEntity sphere,5,0,5 EntityColor sphere,170,80,90 EntityType sphere,sphere_col Collisions sphere_col,cube_col,3,1 While Not KeyDown(1) gui() If KeyDown(200) Then MoveEntity sphere,0,.1,0 EndIf If KeyDown(208) Then MoveEntity sphere,0,-.1,0 EndIf If KeyDown(205) Then MoveEntity sphere,.1,0,0 EndIf If KeyDown(203) Then MoveEntity sphere,-.1,0,0 EndIf UpdateWorld RenderWorld gui() Flip Wend Function gui() Text 540,10, "- LIFE -" Text 450,10, "B A" Text 400,10, + rupy Text 400,40, + key Text 400,60, + bomb If max_life = 0 Text 350,290," Game Over!" End Function End |
| ||
Its sort of in the right place, but you're calling it twice in your main loop. Also, three of the six text commands (rupy, key, bomb) have the wrong syntax - there should either be something before the +, or the + shouldn't be there at all. |
| ||
i can put empty quotations in front of them "" also the qui() that doesn't have the function should be before the update world then. |
| ||
You seem to have forgotten 'End If'If max_life = 0 Text 350,290," Game Over!" End If |
| ||
i notes there an other problem now the new function i put in is also giving me problems as well. i'm trying to get it so that if i collide to the cube that it losses 1 life point Graphics3D 800,600,2 Global max_life = 6 Global heart_container = 1 Global rupy = 0 Global key = 0 Global bomb = 0 Global red_rupy = 1 Global blue_rupy = 5 Const cube_col = 1 Const sphere_col = 1 SetBuffer BackBuffer() camera=CreateCamera() CameraViewport camera,0,0,800,600 PositionEntity camera,0,0,-5 light= CreateLight() cube=CreateCube() PositionEntity cube,-5,0,5 EntityColor cube,70,80,190 EntityType cube,cube_col sphere=CreateSphere(12) PositionEntity sphere,5,0,5 EntityColor sphere,170,80,90 EntityType sphere,sphere_col Collisions sphere_col,cube_col,3,1 While Not KeyDown(1) If KeyDown(200) Then MoveEntity sphere,0,.1,0 EndIf If KeyDown(208) Then MoveEntity sphere,0,-.1,0 EndIf If KeyDown(205) Then MoveEntity sphere,.1,0,0 EndIf If KeyDown(203) Then MoveEntity sphere,-.1,0,0 EndIf UpdateWorld RenderWorld death_cube() gui() Flip Wend Function gui() Text 540,10, "- LIFE -" Text 450,10, "B A" Text 400,10, + rupy Text 400,40, + key Text 400,60, + bomb If max_life = 0 Text 350,290," Game Over!" End If End Function Function death_cube() If EntityCollided(sphere,cube_col) Then max_life = max_life -1 End If End Function End |
| ||
"Sphere" isn't visible within "death_cube", as it's a local in the main program's scope. You need to either declare it as a global, making it visible everywhere (bad), or add a parameter to "death_cube" which you use to pass the value in, and use that parameter to refer to the sphere in question. e.g. ... death_cube(sphere) ... Function death_cube(sp) If EntityCollided(sp, cube_col) Then max_life = max_life -1 End If End Function |