Positions Problem

Übersicht BlitzBasic Blitz3D

Neue Antwort erstellen

AMY

Betreff: Positions Problem

BeitragMo, Jul 16, 2007 11:08
Antworten mit Zitat
Benutzer-Profile anzeigen
Ich habe ein Problem mit der Position von Entitys. Egal mit welchem Befehl ich diese verschiebe oder positioniere, sie sind immer an der falschen stelle.
Immer wenn die Bomben den Boden erreicht haben sollen sie wieder zurückgesetzt werden, oder gelöscht und neu erstellt werden.
Kann mir da jemand weiterhelfen?

Hier mal der Code:
Code: [AUSKLAPPEN]

;Benchmark
Graphics3D(800,600,32,2)
camera=CreateCamera()
PositionEntity camera,-9500,0,300
MoveMouse 400,300
RotateEntity camera,0,270,90
camlight=CreateLight(2,camera)
CameraRange camera,0.1,30000
BigLight=CreateLight(2)
PositionEntity bigLight,-6000,2000,5000
LightRange biglight,5000
LightColor biglight,252,235,114
Ships=9
Dim HitSound(Ships,1),Blast(Ships,1),Mothership(Ships,1),Bomb(Ships,1),BombLocked(Ships,1),DetonationCount(Ships,1),ShipCoors(9);ShipNr,BombNr
SeedRnd MilliSecs()
For I=0 To Ships
   nr=Rnd(0,1)
   If nr=0 Then
      HitSound(I,0)=LoadSound("Biggun.wav")
      HitSound(I,1)=LoadSound("Biggun.wav")
   Else
      HitSound(I,0)=LoadSound("bullet1.wav")
      HitSound(I,1)=LoadSound("bullet1.wav")
   EndIf
Next
For I=0 To Ships
   nr=Rnd(0,1)
   If nr=0 Then
      Blast(I,0)=LoadSprite("crash1.bmp")
      Blast(I,1)=LoadSprite("crash1.bmp")
   Else
      Blast(I,0)=LoadSprite("crash2.bmp")
      Blast(I,1)=LoadSprite("crash2.bmp")
   EndIf
   PositionEntity Blast(I,0),-9000,0,-100
   PositionEntity Blast(I,1),-9000,0,-100
   ScaleSprite Blast(I,0),100,100
   ScaleSprite Blast(I,1),100,100
Next

plane=CreateCube()
EntityType plane,1
planetexture=LoadTexture("tex1.jpg")
EntityTexture plane,planetexture
ScaleEntity plane,10000,10000,1

For MS=0 To Ships
   Mothership(MS,0)=CreateSphere(100):Mothership(MS,1)=CreateCube()
   ScaleMesh Mothership(MS,0),30,10,10:ScaleMesh Mothership(MS,1),5,2,2
   Bomb(MS,0)=CreateSphere(100):EntityType Bomb(MS,0),2:BombLocked(MS,0)=1
   Bomb(MS,1)=CreateSphere(100):EntityType Bomb(MS,1),2:BombLocked(MS,1)=1
Next
For I=16 To 241 Step 25 ; How to do?
   EntityColor Mothership(counter,0),I,I,I
   EntityColor Mothership(counter,1),Rnd(255),Rnd(255),Rnd(255)
   counter=counter+1
Next
For I=0 To Ships
RNDX=Rnd(-300,300)
RNDY=Rnd(-600,600)
RNDZ=Rnd(150,350)
For J=0 To I
   If RNDY<ShipCoors(J) Then DifY=ShipCoors(J)-RNDY Else DifY=RNDY-ShipCoors(J)
   If Dify<25 Then RNDX=Rnd(-300,300):RNDY=Rnd(-600,600):RNDZ=Rnd(150,350):J=-1
Next
ShipCoors(I)=RNDY
PositionMesh Mothership(I,0),-9000+(RNDX),RNDY,RNDZ
PositionMesh Mothership(I,1),-9000+(RNDX),RNDY,RNDZ-10
PositionEntity Bomb(I,0),-9000+(RNDX),RNDY,RNDZ
PositionEntity Bomb(I,1),-9000+(RNDX),RNDY,RNDZ
Next

LRBL=5000
FlushMouse
Repeat
   For I=0 To Ships
      MoveEntity Mothership(I,0),0.3,0,0
      MoveEntity Mothership(I,1),0.3,0,0
      If BombLocked(I,0)=1 Then MoveEntity Bomb(I,0),0.3,0,0 Else MoveEntity Bomb(I,0),0,0,-0.6
      If BombLocked(I,1)=1 Then MoveEntity Bomb(I,1),0.3,0,0 Else MoveEntity Bomb(I,1),0,0,-0.6
      If DetonationCount(I,0)>0 Then MoveEntity Blast(I,0),0,0,-0.2:DetonationCount(I,0)=DetonationCount(I,0)-1
      If DetonationCount(I,1)>0 Then MoveEntity Blast(I,1),0,0,-0.2:DetonationCount(I,1)=DetonationCount(I,1)-1
      If CountCollisions(Bomb(I,0))<>0 Then
         PositionEntity Blast(I,0),EntityX(Bomb(I,0)),EntityY(Bomb(I,0)),EntityZ(Bomb(I,0))+10
         PlaySound(HitSound(I,0))
         BombLocked(I,0)=1
         BX=EntityX(Bomb(I,0))
         BZ=EntityZ(Bomb(I,0))
         FreeEntity Bomb(I,0)
         Bomb(I,0)=CreateSphere(100)
;         PositionEntity Bomb(I,0),EntityX(Mothership(I,0)),EntityY(Mothership(I,0)),EntityZ(Mothership(I,0))
         EntityType Bomb(I,0),2
         TranslateEntity Bomb(I,0),-(EntityX(Mothership(I,0))-BX),0,EntityZ(Mothership(I,0))-BZ
         ClearCollisions
         DetonationCount(I,0)=500
      EndIf
      If CountCollisions(Bomb(I,1))<>0 Then
         PositionEntity Blast(I,1),EntityX(Bomb(I,1)),EntityY(Bomb(I,1)),EntityZ(Bomb(I,1))+10
         PlaySound(HitSound(I,1))
         BombLocked(I,1)=1
         BX=EntityX(Bomb(I,1))
         BZ=EntityZ(Bomb(I,1))
         FreeEntity Bomb(I,1)
         Bomb(I,1)=CreateSphere(100)
;         PositionEntity Bomb(I,1),EntityX(Mothership(I,1)),EntityY(Mothership(I,1)),EntityZ(Mothership(I,1))
         EntityType Bomb(I,1),2
         TranslateEntity Bomb(I,1),-(EntityX(Mothership(I,1))-BX),0,EntityZ(Mothership(I,1))-BZ
         ClearCollisions
         DetonationCount(I,1)=500
      EndIf
   Next
   BombTimer=MilliSecs()
   If BombTimer-BombTimerOld>5000 Then
      D=Rnd(0,Ships)
      B=Rnd(0,1)
      If BombLocked(D,B)=1 Then BombLocked(D,B)=0
      BombTimerOld=BombTimer
   EndIf
   framecounter=framecounter+1
   msecsnew=MilliSecs()
   If msecsnew-msecsold=>1000 Then
      msecsold=msecsnew
      Frames=framecounter
      framecounter=0
   End If
   If KeyDown(78) Then LRBL=LRBL+1000:LightRange BigLight,LRBL;Num+
   If KeyDown(74) Then LRBL=LRBL-1000:LightRange BigLight,LRBL;Num-
   If KeyDown(73) Then LRCL=LRCL+100:LightRange camLight,LRCL;Num9
   If KeyDown(77) Then LRCL=LRCL-100:LightRange camLight,LRCL;Num6
   If KeyHit(59) Then Stop
   If KeyHit(66) Then FlipMode=1-FlipMode
   If KeyHit(67) Then WFMode=1-WFMode
   Movement(camera)
WireFrame WFMode
Collisions 2,1,2,1
UpdateWorld
RenderWorld
Text 0,0,"Frames: "+Frames
Text 0,13,"Tris Rendered:"+TrisRendered()
Text 0,26,"xyz: "+EntityX(camera)+","+EntityY(camera)+","+EntityZ(camera)
Text 0,78,"LightRange BigLight: "+LRBL

Text 0,100,"Press F8 to switch FrameLimiter"
Text 0,113,"Press F9 to Switch WireFrame Mode"
Text 0,126,"Press +/- on NumPad to in-/decrease LightRange"
Text 0,139,"Press F1 to Stop (Debug)"
Flip FlipMode
Until KeyHit(1)
End

Function Movement(camera)
  mspeedx=MouseXSpeed()
  mspeedy=MouseYSpeed()
  msensivityX#=mspeedx/2
  msensivityY#=mspeedy/2
If mspeedy<>0 Then TurnEntity camera,msensivityy,0 ,0
If mspeedx<>0 Then TurnEntity camera,0,-msensivityX,0
  If KeyDown(54) Then movespeed#=3 Else movespeed=5
  If KeyDown(32)=True Then MoveEntity camera, movespeed, 0, 0;205
  If KeyDown(30)=True Then MoveEntity camera,-movespeed, 0, 0;203
  If KeyDown(201)=True Then MoveEntity camera, 0, movespeed, 0;201
  If KeyDown(209)=True Then MoveEntity camera, 0,-movespeed, 0;209
  If KeyDown(31)=True Then MoveEntity camera, 0, 0,-movespeed;208
  If KeyDown(17)=True Then MoveEntity camera, 0, 0, movespeed;200
  MoveMouse 512,384
End Function



Achso die Dateien könnt ihr hier herunterladen:
http://www.beepworld.de/member...kfiles.zip
Projekte: www.amyscbi.de
I never comment my sourcecode. What's HARD to write must be HARD to read!
 

Omenaton_2

BeitragMo, Jul 16, 2007 13:27
Antworten mit Zitat
Benutzer-Profile anzeigen
Ich kenne die Antwort nicht, aber ich möchte dich daran erinnern, daß man bei PositionEntity auch noch einen Flag angeben kann, um zu bestimmten, ob die Koordinaten relativ sein sollen oder absolut Werte. Oft wird das übersehen und das kann dann zu falschen Ergebnissen führen. Check einfach mal deinen Code auf diese Fehlermöglichkeit hin !

NightPhoenix

BeitragMo, Jul 16, 2007 14:36
Antworten mit Zitat
Benutzer-Profile anzeigen
Collisions deaktivieren
PositionEntity
Collisions aktivieren

auch bei Positionentity greift die Kollision Wink
MfG.

AMY

BeitragMo, Jul 16, 2007 14:56
Antworten mit Zitat
Benutzer-Profile anzeigen
Ich hab den Fehler doch noch gefunden. Als ich die Welt erstellt habe habe ich PositionMesh für einige Objekte benutzt. Jetzt benutze ich PositionEntity und es funktioniert. aber warum kann man eigentlich keine MeshBefehle mehr nach entitybefehlen ausführen? Worin besteht der genaue unterschied außer das nur die Punkte neu berechnet werden und nicht der Körper verschoben?
Projekte: www.amyscbi.de
I never comment my sourcecode. What's HARD to write must be HARD to read!

Neue Antwort erstellen


Übersicht BlitzBasic Blitz3D

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group