Cant get this to work

Blitz3D Forums/Blitz3D Programming/Cant get this to work

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

In your original code you have :

if speed > 2
dosomething1
elseif speed > 10
dosomething2
endif

"dosomething2" will never be done since a speed greater than 10 is also greater than 2. hence it will only do the "dosomething1" line

use this :

If EntityCollided(plane,Terrain) > 0
	If speed#>20
		status$="DEADLY COLLISION" 
		health=health-50
	ElseIf speed#>15
		status$="HARD COLLISION" 
		health=health-10
	ElseIf speed#>10
		status$="MEDIUM COLLISION" 
		health=health-5
	ElseIf speed#>2
		status$="SOFT COLLISION" 
		health=health-1 
	EndIf
EndIf


also define your global vars like so you dont have to add the type symbol everytime ("status$")

global Status$
...
status = "string"
...
text 10,10,status


and if you want to use lines like
If speed#>2 And EntityCollided(plane,TERRAIN) Then status$="SOFT COLLISION" : health=health-1 
If speed#>10 And EntityCollided(plane,TERRAIN) Then status$="MEDIUM COLLISION" : health=health-5
If speed#>15 And EntityCollided(plane,TERRAIN) Then status$="HARD COLLISION" : health=health-10
If speed#>20 And EntityCollided(plane,TERRAIN) Then status$="DEADLY COLLISION" : health=health-50


add ">0" to the EntityCollided() :

If speed#>2 And EntityCollided(plane,TERRAIN)>0 Then status$="SOFT COLLISION" : health=health-1 
If speed#>10 And EntityCollided(plane,TERRAIN)>0 Then status$="MEDIUM COLLISION" : health=health-5
If speed#>15 And EntityCollided(plane,TERRAIN)>0 Then status$="HARD COLLISION" : health=health-10
If speed#>20 And EntityCollided(plane,TERRAIN)>0 Then status$="DEADLY COLLISION" : health=health-50


Note that this method is still bad because when the speed is > 15 its also >10 and >2 so every lines will be done, hence giving 1 + 5 + 10 damage, instead of just 10.


Last note, you will also need to change your plane direction upon collision, because else it will keep collide at everyframe hence making it lose all life in a glimpse.