Wieder einmal schussproblem -.-

Übersicht BlitzBasic Blitz3D

Neue Antwort erstellen

 

Honesch

Betreff: Wieder einmal schussproblem -.-

BeitragFr, Aug 01, 2008 17:24
Antworten mit Zitat
Benutzer-Profile anzeigen
ich weiß, dass es zu diesem thema schon viele threads gibt, doch bin ich noch immer zu keiner Lösung gekommen Confused
mein problem ist, dass ich einen schuss erstelle, dieser sich auch in die gewünschte richtung bewegt, aber sobald ich einen neuen schuss abfeuere, der alte in der luft stehn bleibt ?! hier einmal der codeausschnitt
Code: [AUSKLAPPEN]

Type shot
   Field x
   Field y
   Field z
End Type

If MouseHit(1) Then
      schuss_count=schuss_count+1
   If schuss_count=100
      schuss_count=0
   EndIf
   fire.shot=New shot
   fire\x=EntityX(player)
   fire\y=EntityY(player)+140
   fire\z=EntityZ(player)
   shot_cone=CreateCone(10)
   EntityType shot_cone,typ_shot
   ScaleEntity shot_cone,10,10,10
   PositionEntity shot_cone,fire\x,fire\y,fire\z
   TurnEntity shot_cone,EntityPitch(camera),EntityYaw(player),0
   EntityColor shot_cone,0,255,0
EndIf

For fire.shot=Each shot
      MoveEntity shot_cone,0,0,shot_speed#
      If EntityCollided (shot_cone,typ_welt) Then
      Delete fire
      EndIf     
Next    
Das Leben ist wie ein Computerspiel. Scheiß Handlung aber geile Grafik !
 

Omenaton_2

BeitragFr, Aug 01, 2008 17:33
Antworten mit Zitat
Benutzer-Profile anzeigen
Mach den Shot_Cone (Entity) auch zum Teil des Types !

Type shot
Field x
Field y
Field z
Field Shot_Cone
End Type

Ersetze überall Shot-Cone mit fire\Shot_Cone.
Dann bist du erstmal ein Stück weiter.
 

Honesch

BeitragFr, Aug 01, 2008 18:56
Antworten mit Zitat
Benutzer-Profile anzeigen
es funzt ! danke Laughing Laughing Laughing Very Happy Smile Very Happy
Das Leben ist wie ein Computerspiel. Scheiß Handlung aber geile Grafik !
 

Honesch

BeitragSa, Aug 02, 2008 8:58
Antworten mit Zitat
Benutzer-Profile anzeigen
und kann ich das machen dass der schuss nach einer gewissen zeit verschwindet ? ich hab versucht ihm eine variable lifetime mitzugeben, wenn diese 0 ist, dass soll er verschwinden, damit sie nicht ewig in der welt herumfliegt und den speicher füllt...mein code sieht so aus:
Code: [AUSKLAPPEN]

Type shot
   Field x
   Field y
   Field z
   Field shot_cone
   Field birthtime
   Field shotspeed_cone
End Type

schuss_count=schuss_count+1
      If schuss_count=100
         schuss_count=0
      EndIf
      fire.shot=New shot
      fire\x=EntityX(player)
      fire\y=EntityY(player)+140
      fire\z=EntityZ(player)
      fire\shot_cone=CreateCone(10)
      fire\birthtime=0

      schuss_count=schuss_count+1
      If schuss_count=100
         schuss_count=0
      EndIf
      fire.shot=New shot
      fire\x=EntityX(player)
      fire\y=EntityY(player)+140
      fire\z=EntityZ(player)
      fire\shot_cone=CreateCone(10)
      fire\birthtime=0
      EntityType fire\shot_cone,typ_shot
      ScaleEntity fire\shot_cone,10,10,10
      PositionEntity fire\shot_cone,fire\x,fire\y,fire\z
      TurnEntity fire\shot_cone,EntityPitch(camera),EntityYaw(player),0
      EntityColor fire\shot_cone,0,255,0


For fire.shot=Each shot
            fire\birthtime=fire\birthtime+1
   MoveEntity fire\shot_cone,0,0,shot_speed#
   If EntityCollided (fire\shot_cone,typ_welt) Or fire\birthtime=100   
   FreeEntity fire\shot_cone
   Delete fire
   EndIf 
Next    
Das Leben ist wie ein Computerspiel. Scheiß Handlung aber geile Grafik !

Xeres

Moderator

BeitragSa, Aug 02, 2008 15:48
Antworten mit Zitat
Benutzer-Profile anzeigen
Du kannst nach der erstellung des Types die Zeit in einer Variable ablegen...
fire\birthtime= millisecs() + X, Wobei X die Zeit ist, die es existieren soll.
Sobald Millisecs > fire\birthtime, ist die Zeit abgelaufen - so gehe ich meist vor.
Win10 Prof.(x64)/Ubuntu 16.04|CPU 4x3Ghz (Intel i5-4590S)|RAM 8 GB|GeForce GTX 960
Wie man Fragen richtig stellt || "Es geht nicht" || Video-Tutorial: Sinus & Cosinus
T
HERE IS NO FAIR. THERE IS NO JUSTICE. THERE IS JUST ME. (Death, Discworld)

Neue Antwort erstellen


Übersicht BlitzBasic Blitz3D

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group