Issues with the great purple googler.

Blitz3D Forums/Blitz3D Beginners Area/Issues with the great purple googler.

zortzblatz(Posted 2005) [#1]
I can't figure out why the googler/bullet bullet/googler collisions aren't working also boom doesn't work correctly but my biggest question is is there any way to cause something to happen on collisions like a decrease in health ect and how do you do it? here is the source to what I've been making::
;basically pointless
Graphics3D 800,600
SetBuffer BackBuffer()
;health
Global health = 100
Global googlerpower = 25
;fired?
Global fired = False
Global speed = 5
;lighting
Global light = CreateLight()
RotateEntity light,90,0,0
LightColor light,0,0,0
;collision stuff
Global door = 3
Global player = 2
Global scene = 1
Global enemy = 4
Global projectile = 5
;pivot stuff
Global pivot = CreatePivot()
EntityRadius pivot,1.5
;camera
Global camera = CreateCamera(pivot)
CameraRange camera,1,1000
CameraFogMode camera,1
CameraFogRange camera,60,200
EntityType pivot,player
;weapon
	;left barrel
Global barrel1= CreateCylinder(32)
RotateEntity barrel1,90,0,0
EntityColor barrel1,128,128,128
PositionEntity barrel1,1.5,-1,2.5
EntityParent barrel1,pivot
ScaleEntity barrel1,0.2,2,0.2
EntityType barrel1,scene
EntityOrder barrel1,-2
	;right barrel
Global barrel2 = CreateCylinder(32)
RotateEntity barrel2,90,0,0
EntityColor barrel2,128,128,128
PositionEntity barrel2,2,-1,2.5
EntityParent barrel2,pivot
ScaleEntity barrel2,0.2,2,0.2
EntityType barrel2,scene
EntityOrder barrel2,-1
;the sky
Global sky = CreateSphere(16,pivot)
FlipMesh sky
ScaleEntity sky,100,100,100
PositionEntity sky,0,50,0
EntityColor sky,0,0,255
;terrain
Global terrain = CreatePlane()
ScaleEntity terrain,3,15,3
PositionEntity terrain,0,0,-530
EntityRadius terrain,0.2
EntityColor terrain,0,255,0
EntityType terrain,scene
PositionEntity pivot,0,5,0
;trees?
stump = CreateCylinder() 
ScaleEntity stump,1,7,1
PositionEntity stump,0,-1,30
EntityColor stump,128,64,0
EntityRadius stump,1
tree = CreateSphere(32)
EntityColor tree,0,100,0
ScaleEntity tree,3,4,3
PositionEntity tree,0,8,30
EntityType tree,scene
EntityRadius tree,3
stump2 = CreateCylinder() 
ScaleEntity stump2,1,7,1
PositionEntity stump2,10,-1,30
EntityColor stump2,128,64,0
EntityRadius stump2,1
tree2 = CreateSphere(32)
EntityColor tree2,0,100,0
ScaleEntity tree2,3,4,3
PositionEntity tree2,10,8,30
EntityType tree2,scene
EntityRadius tree2,3
stump3 = CreateCylinder() 
ScaleEntity stump3,1,7,1
PositionEntity stump3,-10,-1,30
EntityColor stump3,128,64,0
EntityRadius stump3,1
tree3 = CreateSphere(32)
EntityColor tree3,0,100,0
ScaleEntity tree3,3,4,3
PositionEntity tree3,-10,8,30
EntityType tree3,scene
EntityRadius tree3,3
;building?
bricks = CreateCube()
ScaleEntity bricks,19,9,9
PositionEntity bricks,0,9,50
EntityColor bricks,255,0,0
EntityType bricks,scene
	;eves
eve = CreateCylinder(3)
RotateEntity eve,30,0,90
ScaleEntity eve,13,20,13
PositionEntity eve,0,23,50
EntityColor eve,145,72,0 
	;door
door = CreateCube()
ScaleEntity door,3,5,3
PositionEntity door,-6.5,5,43,7
EntityColor door,170,85,0
	;knob of door
knob = CreateSphere()
ScaleEntity knob,0.8,0.8,0.8
PositionEntity knob,-5,5,40
EntityColor knob,255,255,0
;the great purple googler!
googler = CreateSphere(32)
ScaleEntity googler,4,4,4
PositionEntity googler,30,5,10
EntityColor googler,128,0,255
EntityType googler,enemy
EntityRadius googler,4
EntityAlpha googler,0.7
;ammunition
bullet = CreateSphere()
ScaleEntity bullet,0.2,0.2,0.2
PositionEntity bullet,7,5,2
RotateEntity bullet,EntityPitch(pivot),EntityYaw(pivot),EntityRoll(pivot)
HideEntity bullet
EntityRadius bullet,1
EntityType bullet,projectile
;explode
boom = CreateSphere()
EntityColor boom,255,0,0
EntityAlpha boom,0.5
HideEntity boom
;collisions
Collisions player,scene,2,1
Collisions enemy,scene,2,1
Collisions enemy,projectile,2,2
Collisions projectile,enemy,2,2
Collisions enemy,player,1,1
Collisions player,enemy,2,1
Collisions projectile,scene,5,1
;loopieness
While Not KeyHit(1)
If KeyDown(200) MoveEntity pivot,0,0,1
If KeyDown(208) MoveEntity pivot,0,0,-1
If KeyDown(203) TurnEntity pivot,0,2,0
If KeyDown(205) TurnEntity pivot,0,-2,0
If EntityCollided(pivot,googler)
health = health - 10
EndIf
;shooting now!
If KeyDown(57)
If Not fired
fired = True
PositionEntity bullet,EntityX(pivot) ,EntityY(pivot)-.5 ,EntityZ(pivot) 
RotateEntity bullet,EntityPitch(pivot),EntityYaw(pivot),EntityRoll(pivot) 
ShowEntity bullet
End If 
End If 
If fired
MoveEntity bullet,0,0,speed
boomx# = EntityX(bullet,1)
boomy# = EntityY(bullet,1)
boomz# = EntityZ(bullet,1)
HideEntity boom
ShowEntity bullet
PositionEntity boom,boomx,boomy,boomz
End If 
If EntityDistance(bullet,pivot) >100
HideEntity bullet
fired = False
End If
;googler movement
MoveEntity googler,0,0,0.8
TurnEntity googler,0,3.2,0
If health = 0 Then lose
UpdateWorld
RenderWorld
Print "your health is " + health
Flip
Wend
End

Function lose()
ClearWorld
Cls
Print "YOU LOSE"
End Function



RiK(Posted 2005) [#2]
O.O Try sticking that in a code box!


zortzblatz(Posted 2005) [#3]
how do you make a code box?


Rubiks14(Posted 2005) [#4]
put code in [] at beggining and /code in [] at end

yes there is a way to make health decrease. like this

this is just an example i'm sure you can make it work into your code
Global health = 100 doesnt have to be 100

if entitycollided(bullet,player)
health = health - 5 or whatever number you want
endif


now what this does is create a variable for the health and then it checks if the player is hit and then decreases health by 5

hope that helps


zortzblatz(Posted 2005) [#5]
I just updated the code and the life value still doesnt work


Rubiks14(Posted 2005) [#6]
ok i c your problem change
 If EntityCollided(barrel1,googler) 

to this
 if entitycollided(pivot,enemy) 

also you need to put that if statement inside your loop not before it

EDIT: i also found that you need to make a check for if the health is lower than or equal to 0 and then call your lose function. one more thing how in the crap can you stand to play that with it jumping all around like that


zortzblatz(Posted 2005) [#7]
I made the corrections you pointed out but they didn't work (does it jump on your computer? It doesn't on mine and I've never had that complaint before.)