I'm trying to make my first game in Blitz3d. The entitycollided statement doesn't work for the dimonds. Here is the code. Its kinda long.
The update dimonds function spins the dimonds and is supposed to make them rise into the air and disappear when you hit them.
Does anyone have any suggestions?
Graphics3D 800,600,0,2 AppTitle "Ballbot" SetBuffer BackBuffer() ;load textures Global sand_tex = LoadTexture("sand_tex.png") timeball_tex = LoadTexture("timebot_tex.png") water_tex = LoadTexture("water_tex.jpg") sky_tex = LoadTexture("sky1.jpg") ;create player Global ball=CreateSphere(32) RotateTexture timeball_tex,90 EntityTexture ball,timeball_tex EntityType ball,1 ScaleEntity ball,.5,.5,.5 EntityRadius ball,.5 pivot = CreatePivot() camera=CreateCamera(pivot) light=CreateLight() RotateEntity light,100,0,10 ;create sky-sphere sky = CreateSphere(64) FlipMesh sky RotateTexture sky_tex,180 EntityTexture sky,sky_tex ScaleMesh sky,400,400,400 ;create water reflection waterreflect = CreateMirror() PositionEntity waterreflect,0,-4,0 ;create water ScaleTexture water_tex,4,4 water = CreatePlane() EntityTexture water,water_tex PositionEntity water,0,-5,0 EntityAlpha water,.5 ;create die cube diecube = CreateCube(camera) EntityColor diecube,0,0,0 EntityAlpha diecube,0 ;variables Local wx = 0 Local wz = 0 Global col_type_ball = 1 Global col_type_ground = 2 Global col_type_dimond = 3 Global plyface# = 0 Global plx# = 0 Global ply# = 7 Global plz# = 0 Global pldz# = .1 Global plxface# = 0 Global plzface# = 0 Global plxspeed# = 0 Global Level = 1 Global lives = 3 Global dimonds_left = 0 Global fall = 0 Global collision_count = 0 Global pldie = 0 Global dcubealpha# = 0 Collisions col_type_ball,col_type_ground,2,2 Collisions col_type_dimond,col_type_ball,2,2 ;TYPES Type block Field x#,y#,z#,typ,x1#,y1#,z1#,x2#,y2#,z2#,ent End Type readlevels() Type dimonds Field x#,y#,z#,pic,tim End Type RotateEntity ball,plrot,plface,90 PositionEntity ball,plx,plz,ply MoveEntity camera,-plx,-plz+3,-ply-2 ScaleEntity diecube,2,2,2 FlipMesh diecube MoveEntity diecube,0,0,-.9 ;main loop While Not KeyDown( 1 ) Cls wx = wx + 1 wz = wz + 1 PositionEntity water,Sin(wx)*.6,Cos(wz)/10-3.7,Sin(wx)*.8 PositionEntity waterreflect,Sin(wx)*.6,Cos(wz)/10-3.7,Sin(wx)*.8 If pldie = 0 Then gravity() testkeys() hitwater() EndIf playerdie() update_dimonds() RotateEntity ball,plxface,plyface,90+plzface PositionEntity pivot,plx,plz-1,ply+5 PositionEntity ball,plx,plz,ply EntityAlpha diecube,dcubealpha UpdateWorld If plz < -3.6 Then fall = 1 RenderWorld ;Text 1,1,"Alpha: "+dcubealpha+" fall: "+fall+" playerz: "+plz Flip Wend End Function readlevels() Select level Case 1 file = ReadFile("level1.mp") End Select box = CreateCube() ScaleEntity box,.501,.501,.501 PositionEntity box,0,-3.5,7 TurnEntity box,0,0,0 EntityTexture box,sand_tex dimond = LoadMesh("dimond.3ds") EntityAlpha dimond,.9 EntityShininess dimond,1 ScaleEntity dimond,.1,.1,.1 PositionEntity dimond,0,0,0 x = ReadInt(file) y = ReadInt(file) For a = 1 To y For b = 1 To x typ = ReadInt(file) If typ = 3 Then movx# = b movy# = a EndIf If typ = 2 Then t.dimonds = New dimonds t\x# = b t\y# = -a t\z# = -3 t\pic = CopyEntity(dimond) PositionEntity t\pic,t\x,t\z,t\y EndIf If typ = 1 Or typ = 2 Or typ = 3 Or typ = 4 Then c.block = New block c\x# = b c\y# = -a c\z# = -3.5 c\typ = typ c\ent = CopyEntity(box) PositionEntity c\ent,c\x,c\z,c\y EndIf Next Next FreeEntity(box) FreeEntity(dimond) dimonds_left = ReadInt(file) For d.block = Each block d\x = d\x - movx# d\y = d\y + movy#+7 PositionEntity d\ent,d\x,d\z,d\y EntityType d\ent,2 Next For q.dimonds = Each dimonds q\x = q\x - movx# q\y = q\y + movy# + 7 PositionEntity q\pic,q\x,q\z,q\y EntityType q\pic,3 EntityRadius q\pic,.3 Next End Function Function gravity() temp = 0 If fall = 1 Then pldz# = pldz# - .004 plz = plz + pldz temp = 1 EndIf If Not EntityCollided(ball,2) Then If temp = 0 Then pldz# = pldz# - .004 plz = plz + pldz EndIf EndIf If fall = 0 And EntityCollided(ball,2) Then pldz = 0 EndIf End Function Function testkeys() If KeyDown(203) plyface = plyface + 2 EndIf If KeyDown(205) plyface = plyface - 2 EndIf If KeyDown(200) plxspeed = plxspeed + .3 EndIf If plxspeed > 0 Then plxspeed = plxspeed -.02 EndIf If plxspeed < 0 Then plxspeed = 0 EndIf If plxspeed > 2 Then plxspeed = 2 plxface = plxface + plxspeed plx = plx - (Cos(plyface-90)*plxspeed)/55 ply = ply - (Sin(plyface-90)*plxspeed)/55 End Function Function hitwater() If plz < -3.5 Then plz = -3.5 pldz = 0 pldie = 1 EndIf End Function Function playerdie() If pldie = 1 Then plz = plz - .001 dcubealpha = dcubealpha +.01 If dcubealpha > 1 Then dcubealpha = 1 EndIf End Function Function update_dimonds() For d.dimonds = Each dimonds TurnEntity d\pic,0,-2,0 ;dist# = Sqr((plx-EntityX(d\pic))^2+(ply-EntityY(d\pic))^2) If EntityCollided(d\pic,1) Then d\tim = 1 ;This part doesn't work!!! If d\tim => 1 Then MoveEntity d\pic,0,.01,0 d\tim = d\tim + 1 EndIf If d\tim > 50 Then FreeEntity(d\pic) Delete d.dimonds EndIf Next End Function
The update dimonds function spins the dimonds and is supposed to make them rise into the air and disappear when you hit them.
Does anyone have any suggestions?