Probleme mit Kolisionen

Übersicht BlitzBasic Blitz3D

Gehe zu Seite 1, 2  Weiter

Neue Antwort erstellen

ewok1

Betreff: Probleme mit Kolisionen

BeitragSo, Mai 15, 2011 17:11
Antworten mit Zitat
Benutzer-Profile anzeigen
Hi
ich will einen Ego shooter programieren doch ich habe ka wie ich machen soll das der spieler nicht durch die wand läuft. Hier der Quelltext:
Code: [AUSKLAPPEN]

AppTitle "ego shooter"
Graphics3D 640, 480, 16,2
SetBuffer BackBuffer()



Print "Laden..."
If KeyDown(1) Then End


Cls

Ton = LoadSound ("C:\Users\Patrick\Music\mp5.wav")

camera = CreateCamera()
PositionEntity camera, 0, 1, 0             ;Kamera
CameraZoom camera, 2.5

light = CreateLight()
RotateEntity light, 640, 0, 0            ;Licht
AmbientLight 255,200,200



terrain = CreateTerrain(64)               ;Terrain
EntityAlpha terrain, 0.99
                                        
      cone = CreateCube()                ;objekte
      PositionEntity cone, 45, 3, 20
      ScaleEntity cone, 10,3,10
      EntityType cone, 2
      EntityBox cone, 45, 3, 20, 10, 3, 10
      EntityColor cone, 255,255,255
      test1 = LoadTexture("C:\Users\Patrick\Documents\BlitzBasic\help\commands\grafik\textureConcrete.bmp")

      EntityTexture cone,test1
   

   
      cone3 = CreateCube()
      PositionEntity cone3, 15,5, 20
      ScaleEntity cone3, 10,3,10   
      test2 = LoadTexture("C:\Users\Patrick\Documents\BlitzBasic\help\commands\grafik\textureHouse1.bmp")
      EntityTexture cone3,test2
      
      coneo = CreateCube()
      PositionEntity coneo, 15,0, 20
      ScaleEntity coneo, 10,3,10   
      testo = LoadTexture("C:\Users\Patrick\Documents\BlitzBasic\help\commands\grafik\Plastic.bmp")
      EntityTexture coneo,testo
   
      sphere = CreateSphere(100)
      PositionEntity sphere, 31,32,32
      ScaleEntity sphere, 10,10,10
      EntityColor sphere, 0, 0, 255
   
      cylinder = CreateCylinder(100)
      PositionEntity cylinder, 31,0,32
      ScaleEntity cylinder, 1,25,1
      EntityColor cylinder, 255, 255, 0
   
      cone4 = CreateCube()
      PositionEntity cone4, 40,1,40
      ScaleEntity cone4, 2,3,2
      EntityColor cone4, 0, 255, 255
   
      cone4 = CreateCube()
      PositionEntity cone4, 13.25,1,48
      ScaleEntity cone4, 1,1,1
      test = LoadTexture("C:\Users\Patrick\Documents\BlitzBasic\help\commands\grafik\texture5.bmp")
      EntityTexture cone4,test

      cone5 = CreateCube()
      PositionEntity cone5, 12,1,48
      ScaleEntity cone5, 2,5,2
      texture = LoadTexture("C:\Users\Patrick\Documents\BlitzBasic\help\commands\grafik\textureConcreted.bmp")
      EntityTexture cone5,texture

      
      M4 = LoadMesh("C:\Users\Patrick\documents\M4 fl red dot.3ds")
      PositionEntity M4, 0, 0, 0

      
grass_tex = LoadTexture("C:\Users\Patrick\Documents\BlitzBasic\help\commands\grafik\WaterTex.bmp")
EntityTexture terrain,grass_tex

While Not KeyHit(1)
   If MouseX() <340 Then TurnEntity camera, 0, 1, 0
   If MouseX() >300 Then TurnEntity camera, 0, -1, 0

   If MouseX() <440 Then TurnEntity camera, 0, 2, 0
   If MouseX() >200 Then TurnEntity camera, 0, -2, 0

   If KeyDown(17) = 1 Then MoveEntity camera, 0, 0, 0.1
   If KeyDown(31) = 1 Then MoveEntity camera, 0, 0, -0.1
   If KeyDown(30) = 1 Then MoveEntity camera, -0.05, 0, 0
   If KeyDown(32) = 1 Then MoveEntity camera, 0.05, 0, 0

   If MouseX() <340 Then TurnEntity M4, 0, 1, 0
   If MouseX() >300 = 1 Then TurnEntity M4, 0, -1, 0

   If MouseX() <440 Then TurnEntity M4, 0, 2, 0
   If MouseX() >200 = 1 Then TurnEntity M4, 0, -2, 0

   If KeyDown(17) = 1 Then MoveEntity M4, 0, 0, 0.1
   If KeyDown(31) = 1 Then MoveEntity M4, 0, 0, -0.1
   If KeyDown(30) = 1 Then MoveEntity M4, -0.05, 0, 0
   If KeyDown(32) = 1 Then MoveEntity M4, 0.05, 0, 0



   If KeyDown(25) Then Text 320,240, "Pause" WaitKey
   
   If MouseDown(1) = 1 Then PlaySound ton Delay 100

   If KeyDown(28) = 1 Then Text 0,20, CameraProject ,camera

   RenderWorld
Bild = LoadImage ("C:\Users\Patrick\Documents\zielvisier.bmp")
DrawImage Bild, 0, 0

   Flip
Cls
Wend
End


Wäre sehr nett wenn mir das jemand erklären könnte

blackgecko

BeitragSo, Mai 15, 2011 17:39
Antworten mit Zitat
Benutzer-Profile anzeigen
Du weist dem Spieler und der "Wand" Kollisionstypen zu. Das sind einfach Zahlenwerte. Siehe EntityType.
Dann setzt du eventuell Kollisionsradien - mit EntityRadius und / oder EntityBox.
Dann aktivierst du die Kollisionsprüfung zwischen den Objekten - mit Collisions.
Alle diese Befehle vor der Hauptschleife verwenden!
So long and thanks for all the fish.
Fedora 17 | Windows 7 || BlitzPlus | BlitzMax
Rechtschreibflame GO!!! Deppenapostroph | SeidSeit | Deppenakzent | DassDas | Deppenleerzeichen | TodTot | enzigste.info - Ja, ich sammel die.

ewok1

BeitragSo, Mai 15, 2011 17:44
Antworten mit Zitat
Benutzer-Profile anzeigen
Danke ich versuchs mal

ewok1

BeitragSo, Mai 15, 2011 17:55
Antworten mit Zitat
Benutzer-Profile anzeigen
Hat leider nich funktioniert Sad wüsstest du wie einbauen? (M4 spieler)

Xeres

Moderator

BeitragSo, Mai 15, 2011 18:49
Antworten mit Zitat
Benutzer-Profile anzeigen
Wenn du Hilfe willst, solltest du etwas genauer als "funktioniert nicht" werden.
Aktueller Code, Fehlermeldungen + Zeile, usw.
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)

ewok1

BeitragSo, Mai 15, 2011 18:53
Antworten mit Zitat
Benutzer-Profile anzeigen
OK
Die Fehlermeldung lautet Memory access violation

und zwar ist diese Zeile das Problem:

M4 = LoadMesh("C:\Users\Patrick\documents\M4 fl red dot.3ds")
PositionEntity M4, 0, 0, 0
EntityType M4, 2

EntityBox cone, 45, 3, 20, 10,3,10
EntityBox M4, 0, 0, 0, 1,1,1

Collisions M4, cone, 2, 1


grass_tex = LoadTexture("C:\Users\Patrick\Documents\BlitzBasic\help\commands\grafik\WaterTex.bmp")
EntityTexture terrain,grass_tex

Xeres

Moderator

BeitragSo, Mai 15, 2011 18:55
Antworten mit Zitat
Benutzer-Profile anzeigen
Wird daran liegen, dass der Mesh nicht geladen wurde, was daran liegen kann, dass der Pfad nicht richtig ist... Teste das einfach:
Code: [AUSKLAPPEN]
M4 = LoadMesh [...]
If M4=0 then RuntimeError("M4 nicht geladen!")
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)

ewok1

BeitragSo, Mai 15, 2011 18:57
Antworten mit Zitat
Benutzer-Profile anzeigen
ohne collisions funktioniert es also liegt es nicht am pfad

Xeres

Moderator

BeitragSo, Mai 15, 2011 19:07
Antworten mit Zitat
Benutzer-Profile anzeigen
Solange du nicht auf das Objekt zugreifst, gibt es auch keinen Fehler Rolling Eyes
Edit: Lies dir Collisions nochmal durch - du gibst statt eines Kollisionstyps Entitys an.
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)

ewok1

BeitragSo, Mai 15, 2011 19:43
Antworten mit Zitat
Benutzer-Profile anzeigen
ich verstehe nicht ganz Question also statt
Code: [AUSKLAPPEN]
Collisions  M4, cone,2, 1

Code: [AUSKLAPPEN]
Collisions 2, 1,M4, cone

Question

Xeres

Moderator

BeitragSo, Mai 15, 2011 19:50
Antworten mit Zitat
Benutzer-Profile anzeigen
Nein.
Nochmal: Lies dir Collisions durch. Wenn du es nicht verstehst such im Forum nach Erklärung / Tutorials zum Thema.
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)

ewok1

BeitragSo, Mai 15, 2011 19:58
Antworten mit Zitat
Benutzer-Profile anzeigen
habs gecheckt das man keine variabelnn setztn muss geht trotzdem nicht -.- zeigt jedoch keine fehlermeldung an

BladeRunner

Moderator

BeitragSo, Mai 15, 2011 20:09
Antworten mit Zitat
Benutzer-Profile anzeigen
Und ohne deinen aktuellen Code können wir nicht helfen.
Zu Diensten, Bürger.
Intel T2300, 2.5GB DDR 533, Mobility Radeon X1600 Win XP Home SP3
Intel T8400, 4GB DDR3, Nvidia GF9700M GTS Win 7/64
B3D BMax MaxGUI

Stolzer Gewinner des BAC#48, #52 & #92

ewok1

BeitragSo, Mai 15, 2011 20:11
Antworten mit Zitat
Benutzer-Profile anzeigen
ok das ist er:

Code: [AUSKLAPPEN]
AppTitle "ego shooter"
Graphics3D 640, 480, 16,2
SetBuffer BackBuffer()



Print "Laden..."
If KeyDown(1) Then End


Cls

Ton = LoadSound ("C:\Users\Patrick\Music\mp5.wav")

camera = CreateCamera()
PositionEntity camera, 0, 1, 0             ;Kamera
CameraZoom camera, 2.5

light = CreateLight()
RotateEntity light, 640, 0, 0            ;Licht
AmbientLight 255,200,200



terrain = CreateTerrain(64)               ;Terrain
EntityAlpha terrain, 0.99


                                        
      cone = CreateCube()                ;objekte
      PositionEntity cone, 45, 1, 20
      ScaleEntity cone, 10,3,10
      EntityType cone, 2
      EntityBox cone, 45, 3, 20, 10, 3, 10
      EntityColor cone, 255,255,255
      test1 = LoadTexture("C:\Users\Patrick\Documents\BlitzBasic\help\commands\grafik\textureConcrete.bmp")
      EntityTexture cone,test1
      EntityType cone, 2
   

   
      cone3 = CreateCube()
      PositionEntity cone3, 15,5, 20
      ScaleEntity cone3, 10,3,10   
      test2 = LoadTexture("C:\Users\Patrick\Documents\BlitzBasic\help\commands\grafik\textureHouse1.bmp")
      EntityTexture cone3,test2
      
      coneo = CreateCube()
      PositionEntity coneo, 15,0, 20
      ScaleEntity coneo, 10,3,10   
      testo = LoadTexture("C:\Users\Patrick\Documents\BlitzBasic\help\commands\grafik\Plastic.bmp")
      EntityTexture coneo,testo
      EntityBox coneo, 0, 0, 0, 1,1,1
      
   
      sphere = CreateSphere(100)
      PositionEntity sphere, 31,32,32
      ScaleEntity sphere, 10,10,10
      EntityColor sphere, 0, 0, 255
   
      cylinder = CreateCylinder(100)
      PositionEntity cylinder, 31,0,32
      ScaleEntity cylinder, 1,25,1
      EntityColor cylinder, 255, 255, 0
   
      cone4 = CreateCube()
      PositionEntity cone4, 40,1,40
      ScaleEntity cone4, 2,3,2
      EntityColor cone4, 0, 255, 255
   
      cone4 = CreateCube()
      PositionEntity cone4, 13.25,1,48
      ScaleEntity cone4, 1,1,1
      test = LoadTexture("C:\Users\Patrick\Documents\BlitzBasic\help\commands\grafik\texture5.bmp")
      EntityTexture cone4,test

      cone5 = CreateCube()
      PositionEntity cone5, 12,1,48
      ScaleEntity cone5, 2,5,2
      texture = LoadTexture("C:\Users\Patrick\Documents\BlitzBasic\help\commands\grafik\textureConcreted.bmp")
      EntityTexture cone5,texture

      
      M4 = LoadMesh("C:\Users\Patrick\documents\M4 fl red dot.3ds")
      PositionEntity M4, 0, 0, 0
      EntityType M4, 2
      
      EntityBox cone, 45, 3, 20, 10,3,10
      EntityBox M4, 0, 0, 0, 1,1,1      
      
         Collisions M4,cone, 2, 2
grass_tex = LoadTexture("C:\Users\Patrick\Documents\BlitzBasic\help\commands\grafik\WaterTex.bmp")
EntityTexture terrain,grass_tex

While Not KeyHit(1)

   If MouseX() <340 Then TurnEntity camera, 0, 1, 0
   If MouseX() >300 Then TurnEntity camera, 0, -1, 0

   If MouseX() <440 Then TurnEntity camera, 0, 2, 0
   If MouseX() >200 Then TurnEntity camera, 0, -2, 0

   If KeyDown(17) = 1 Then MoveEntity camera, 0, 0, 0.1
   If KeyDown(31) = 1 Then MoveEntity camera, 0, 0, -0.1
   If KeyDown(30) = 1 Then MoveEntity camera, -0.05, 0, 0
   If KeyDown(32) = 1 Then MoveEntity camera, 0.05, 0, 0

   If MouseX() <340 Then TurnEntity M4, 0, 1, 0
   If MouseX() >300 = 1 Then TurnEntity M4, 0, -1, 0

   If MouseX() <440 Then TurnEntity M4, 0, 2, 0
   If MouseX() >200 = 1 Then TurnEntity M4, 0, -2, 0

   If KeyDown(17) = 1 Then MoveEntity M4, 0, 0, 0.1
   If KeyDown(31) = 1 Then MoveEntity M4, 0, 0, -0.1
   If KeyDown(30) = 1 Then MoveEntity M4, -0.05, 0, 0
   If KeyDown(32) = 1 Then MoveEntity M4, 0.05, 0, 0



   If KeyDown(25) Then Text 320,240, "Pause" WaitKey
   
   If MouseDown(1) = 1 Then PlaySound ton Delay 100

   If KeyDown(28) = 1 Then Text 0,20, CameraProject ,camera

   RenderWorld
Bild = LoadImage ("C:\Users\Patrick\Documents\zielvisier.bmp")
DrawImage Bild, 0, 0

   Flip
Cls
Wend
End

BladeRunner

Moderator

BeitragSo, Mai 15, 2011 20:16
Antworten mit Zitat
Benutzer-Profile anzeigen
und was genau funktioniert nicht? läuft das Programm?
Zu Diensten, Bürger.
Intel T2300, 2.5GB DDR 533, Mobility Radeon X1600 Win XP Home SP3
Intel T8400, 4GB DDR3, Nvidia GF9700M GTS Win 7/64
B3D BMax MaxGUI

Stolzer Gewinner des BAC#48, #52 & #92

ewok1

BeitragSo, Mai 15, 2011 20:19
Antworten mit Zitat
Benutzer-Profile anzeigen
zeigt die fehlermeldung memory access violation und das bei der collisions zeile

skey-z

BeitragSo, Mai 15, 2011 20:27
Antworten mit Zitat
Benutzer-Profile anzeigen
Weil cone und M4 Entities sind und keine Kollissionstypen
Awards:
Coffee's Monatswettbewerb Feb. 08: 1. Platz
BAC#57: 2. Platz
Twitter

ewok1

BeitragSo, Mai 15, 2011 20:36
Antworten mit Zitat
Benutzer-Profile anzeigen
wie soll ichs dann lösen ? ohne variabeln?

skey-z

BeitragSo, Mai 15, 2011 20:37
Antworten mit Zitat
Benutzer-Profile anzeigen
Xeres hat Folgendes geschrieben:

Nochmal: Lies dir Collisions durch. Wenn du es nicht verstehst such im Forum nach Erklärung / Tutorials zum Thema.
Awards:
Coffee's Monatswettbewerb Feb. 08: 1. Platz
BAC#57: 2. Platz
Twitter

Xeres

Moderator

BeitragSo, Mai 15, 2011 20:50
Antworten mit Zitat
Benutzer-Profile anzeigen
blackgecko hat ganz zu Anfang schon alle wichtigen Befehle aufgezählt - Lesen & Verstehen kann man dir nicht wirklich abnehmen.
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)

Gehe zu Seite 1, 2  Weiter

Neue Antwort erstellen


Übersicht BlitzBasic Blitz3D

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group