Also ich hab mir ein programm gesschrieben in dem man die Vertex und Edge zeichnen kann.
Damit man das speichern kann bediene ich mich der Exportphysics Funktion
in einem anderen Spiel bzw kleiner Anfang (reibungs Beispiel) versuche ich es zu laden
nur fliegt das geladene Entity einfach nach unten obwohl ich es im Editor auf locked gestellt habe
weiß jemand was ich falsch mache
Code Beispiel
Danke im vorraus
Code Editor
BlitzBasic: [AUSKLAPPEN] [EINKLAPPEN] .Start Cls Graphics 800, 600, 0, 2 SetBuffer BackBuffer() Zeiter = CreateTimer(50) Include "NooNooPhysics.bb"
NNP_CreatePhysics 512, 1024, 1024
NNP_SetGravity 0, 0.5
Strecke.TEntity = NNP_CreateEntity( 1 ) Strecke\Locked = True
Global genauigkeit = 2 Global abstand Global help = 1 Global Maustaste Global Modus = 1 Global Mousehitcount Global Mouse_old_X Global Mouse_old_Y Global Mouse_old_Fokus Global Mouse_Fokus
Type ob End Type
Type ob2 End Type
Repeat Cls Showhelp() Maus() If Modus = 1 If Maustaste=1 ob.TVertex = NNP_CreateVertex( Strecke, MouseX(), MouseY() ) EndIf EndIf
For ob.TVertex = Each TVertex abstand = Sqr((MouseX()-ob.TVertex\X#)^2+(MouseY()-ob.TVertex\Y#)^2) If abstand < genauigkeit Color 255,0,0 Oval ob.TVertex\X#-3,ob.TVertex\Y#-3,6,6,1 Color 255,255,255 If Modus = 2 If Mousehitcount = 1 And Maustaste = 1 Mousehitcount = 0 Mouse_Fokus = Handle (ob.TVertex) ob2.TEdge = NNP_CreateEdge(Strecke,Object.TVertex (Mouse_old_Fokus),Object.TVertex (Mouse_Fokus),1,1) Mouse_Fokus = 0 Mouse_old_Fokus = 0 EndIf If Maustaste = 1 Mousehitcount = 1 Mouse_old_X = MouseX() Mouse_old_Y = MouseY() Mouse_old_Fokus = Handle (ob.TVertex) EndIf EndIf EndIf If Modus = 4 And Maustaste=1 If abstand < genauigkeit NNP_DeleteVertex( ob.TVertex) EndIf EndIf Next For ob.TVertex = Each TVertex Next If Modus = 5 NNP_ExportPhysics("strecke.dat") RuntimeError "wurde als bab .dat im selben ordner gespeichert" EndIf NNP_UpdateForces NNP_UpdatePhysics NNP_DebugRender DEBUG_EDGES + DEBUG_VERTICES Flip WaitTimer (Zeiter) Until KeyDown (1)
Function Showhelp() If KeyHit(59) Select help Case 0 help = 1 Case 1 help = 0 End Select EndIf If help = 1 Color 255,255,255 Text 20,20,"1 => Vertex Zeichnen" Text 20,40,"2 => Edge Zeichnen" Text 20,60,"3 => Edge Loeschen" Text 20,80,"4 => Vertex Loeschen" Text 20,100,"5 => Physic Speichern" Text 20,140,"Derzeit Modus " + Modus EndIf End Function
Function Maus() Maustaste=0 If MouseHit(1) Maustaste = 1 EndIf If MouseHit(2) Maustaste=2 EndIf If MouseHit(3) Maustaste=3 EndIf If KeyHit(2) Modus = 1 EndIf If KeyHit(3) Modus = 2 EndIf If KeyHit(4) Modus = 3 EndIf If KeyHit(5) Modus = 4 EndIf If KeyHit(6) Modus = 5 EndIf End Function
Code Beispiel
BlitzBasic: [AUSKLAPPEN] [EINKLAPPEN] Graphics3D 800, 600, 0, 2 SetBuffer BackBuffer()
Include "NooNooPhysics.bb"
NNP_CreatePhysics 512, 1024, 1024 NNP_SetGravity 0, 0.5 NNP_ImportPhysics("bab.dat")
Global scroll_x Global scroll_y
Global Wheel.TEntity = NNP_CreateCircle( 400, 300, 60, 60, 1 )
CreateLevel()
Timer = CreateTimer( 60 )
While Not KeyHit( 1 ) Cls dreh# = KeyDown( 205 ) - KeyDown( 203 ) NNP_TurnEntity Wheel,dreh#, Wheel\CenterX#, Wheel\CenterY#, False scroll_x=1024/2-Wheel\CenterX# scroll_y=768/2-Wheel\CenterY# NNP_UpdateForces NNP_UpdatePhysics NNP_DebugRender DEBUG_EDGES + DEBUG_VERTICES Color 255, 255, 255 Text 400, 0, "Pfeiltasten links/rechts, um das Rad zu drehen", True
Flip 0 WaitTimer Timer Wend End
Function Sprite_positionieren(entity,x,y,angle#) PositionEntity entity,((0)*2)-800+x,-((0)*2)+600+y,800 TurnEntity entity, 0, 0, angle# End Function
Function CreateLevel() WallBottom.TEntity = NNP_CreateBox( 400, 600, 800, 10, 1 ) WallLeft.TEntity = NNP_CreateBox( 0, 300, 10, 600, 1 ) WallRight.TEntity = NNP_CreateBox( 800, 300, 10, 600, 1 ) WallBottom\Locked = True WallLeft\Locked = True WallRight\Locked = True WallBottom\CollisionGroup = -1 WallLeft\CollisionGroup = -1 WallRight\CollisionGroup = -1 Ramp.TEntity = NNP_CreateEntity( 1 ) Ramp\Locked = True Ramp\CollisionGroup = -1 V1.TVertex = NNP_CreateVertex( Ramp, 300, 600 ) V2.TVertex = NNP_CreateVertex( Ramp, 600, 400 ) V3.TVertex = NNP_CreateVertex( Ramp, 800, 600 ) NNP_CreateEdge Ramp, V1, V2 NNP_CreateEdge Ramp, V2, V3 NNP_CreateEdge Ramp, V3, V1 End Function
Function UserInput() End Function
|