Kugel sinkt halb in Würfel ein.

Übersicht BlitzBasic Blitz3D

Neue Antwort erstellen

canny771

Betreff: Kugel sinkt halb in Würfel ein.

BeitragDi, Nov 16, 2010 17:55
Antworten mit Zitat
Benutzer-Profile anzeigen
Hey Leute,

Ich hab ein dummes und wahrscheinlich auch einfaches Problem. Momentan versuche ich nämlich eine kugel einfach nur durch die Gegend hüpfen zu lassen. Außerdem soll sie auf auf Würfeln stehen können.
Leider sinkt die Kugel bei mir immer zur hälfte ein, wenn ich auf einen Würfel springe. Ansonsten fällt sie zurück zum Boden. Wie verhindere ich das einsinken?! Kollision ist beim Würfel natürlich aktiviert.
Vielen dank schon mal für die Hilfe. Code: [AUSKLAPPEN]
Graphics3D 800,600,32,1
SetBuffer BackBuffer()
SeedRnd MilliSecs()

;Images and Objekts
Global floorc=LoadTexture ("Floor.bmp")
Global skyc=LoadTexture ("Cloud.bmp",2)
Global aimer=LoadImage ("aimer.bmp")
Global mauer=LoadTexture ("Mauersave.bmp")
Global Lisa=LoadTexture ("Lisa2.bmp",1)
Global sunc=LoadTexture ("Sun.bmp")

;Variables
Global JumpUp=0


;World and BB-Objekts
Global sun=CreateSphere()
Global Kugel=CreateSphere()
Global Quadrat=CreateCube()
Global Floor1=CreatePlane(10)
Global Cam=CreateCamera(Kugel)
Global Light=CreateLight()
Global sky=CreateSphere(32,Kugel)


;Details
ScaleTexture floorc,5,5
ScaleEntity sky,500,500,500
ScaleEntity sun,50,50,50
EntityTexture floor1,floorc
EntityTexture quadrat,mauer
EntityTexture Kugel,Lisa
EntityTexture Sky,Skyc
EntityTexture Sun,Sunc
PositionEntity Cam,0,1,-10
PositionEntity Kugel,0,1,0
PositionEntity quadrat,10,1,10
PositionEntity light,0,100,0
PositionEntity sun,-500,320,500
MoveMouse 400,300
EntityType kugel,1
EntityType quadrat,2
FlipMesh Sky
CameraRange cam,1,1000
AmbientLight 200,200,200
CameraClsColor cam,0,255,255
LightMesh sky,0,0,0
UpdateNormals sky
EntityFX sun,1
EntityShininess kugel,1

;Before

Repeat
   RenderWorld()
   UpdateWorld()
   Collisions 1,2,3,2
   physik()
   MoveKugel()
   aimer()
   Flip
   Cls
Until KeyDown (1)

End

Function MoveKugel()
   If KeyDown (17)
      MoveEntity Kugel,0,0,.1
   EndIf
   If KeyDown (32)
      MoveEntity Kugel,.1,0,0
   EndIf
   If KeyDown (31)
      MoveEntity Kugel,0,0,-.1
   EndIf
   If KeyDown (30)
      MoveEntity Kugel,-.1,0,0
   EndIf
   If KeyDown (57) And JumpUp=0
      JumpUp=2
   EndIf
   If JumpUp=2
      If EntityY (Kugel)<=5
         MoveEntity Kugel,0,.5,0
      Else
         JumpUp=1
      EndIf
   EndIf
End Function

Function aimer()
   DrawImage aimer,MouseX(),MouseY()
   If MouseX()<50
      TurnEntity Kugel,0,1,0
      TurnEntity sky,0,-1,0
   EndIf
   If MouseX()>750
      TurnEntity Kugel,0,-1,0
      TurnEntity sky,0,1,0
   EndIf
End Function

Function CreateSky()
   tex=LoadTexture( "cloud.bmp",3 )
   ScaleTexture tex,1000,1000
   p=CreatePlane()
   EntityTexture p,tex
   EntityFX p,1
   PositionEntity p,0,100,0
   p=CopyEntity( p )
   RotateEntity p,0,0,180
   
End Function

Function Physik()
   If JumpUp=1
      For x=1 To 10
         If EntityY (kugel)>1
            MoveEntity kugel,0,-.1,0
         Else
            JumpUp=0
         EndIf
      Next
   EndIf
End Function

blackgecko

BeitragDi, Nov 16, 2010 18:52
Antworten mit Zitat
Benutzer-Profile anzeigen
1. Collisions gehört nicht in die Hauptschleife, sondern irgendwo davor hin!
2. Code: [AUSKLAPPEN]
Global aimer=LoadImage ("aimer.bmp")
[...]
Function aimer()

Es ist unsauber, einer Variablen und einer Funktion den selben Namen zu geben.

3. Zum Einsinken: Ich glaube du suchst EntityRadius.
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.

canny771

BeitragDi, Nov 16, 2010 23:17
Antworten mit Zitat
Benutzer-Profile anzeigen
Danke für die Schnelle Hilfe.
Ich probiere es direkt aus.

Neue Antwort erstellen


Übersicht BlitzBasic Blitz3D

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group