Type problem![minib3d] JETZT: kollisionen :/

Übersicht BlitzMax, BlitzMax NG Beginners-Corner

Neue Antwort erstellen

 

Cry_p_Tix

Betreff: Type problem![minib3d] JETZT: kollisionen :/

BeitragDo, Nov 24, 2011 2:16
Antworten mit Zitat
Benutzer-Profile anzeigen
Grüße!
Hab momentan ein problem mit types, folgende ausgangssituation:
Ich will mit der linken maustaste klicken, dann krieg ich ein halbdurchsichtiges haus an meinen cursor, und kanns frei mit der maus bewegen, noch ein linksklick und ich kann es fest platzieren, und es ist nicht mehr halb durchsichtig.

funktioniert soweit, aber sobald ich das zweite haus setze, verschwindet das erste, wenn ich das dritte haus setze, bleibt das zweite zwar, aber wird durchsichtig, und das setzt sich so fort, alle häuser bis auf das zuletzt gesetzte bleiben durchsichtig.. wo ist das problem?

edit:
code mit posten wär ne gute idee Wink

Code: [AUSKLAPPEN]
Function build()
CameraPick camera,MouseX(),MouseY()


If MouseHit(2)
If buildmode=1
buildmode=0
TurnEntity camera,-15,0,0
PositionEntity camera,oldcamx,oldcamy,oldcamz
Else
buildmode = 1
If buildmode=1
oldcamx=EntityX(camera)
oldcamy=EntityY(camera)
oldcamz=EntityZ(camera)
MoveEntity camera,0,0,-50
TurnEntity camera,15,0,0
MoveEntity camera,0,50,0


EndIf
EndIf
EndIf




If buildmode=1

If buildmode2=0

If MouseHit(1)
wohnhaus:building = New building
wohnhaus.mesh = LoadMesh("data/meshes/house2.b3d")
EntityAlpha wohnhaus.mesh,0.5
wohnhaus.id = id
EntityType wohnhaus.mesh,2
buildmode2=1
listBuildings.AddLast(wohnhaus)

EndIf

Else

For wohnhaus:building = EachIn listBuildings
If wohnhaus.id = id
CameraPick camera,MouseX(),MouseY()
PositionEntity wohnhaus.mesh,PickedX(),0,PickedZ()
EndIf


If MouseHit(1)
wohnhaus.x =PickedX()
wohnhaus.y= 0
wohnhaus.z = PickedZ()
id = id + 1
PositionEntity wohnhaus.mesh,wohnhaus.x,wohnhaus.y,wohnhaus.z
EntityAlpha wohnhaus.mesh,1
buildmode2 = 0
EndIf
Next
EndIf
EndIf


End Function



Ach, und was kann ich dagegen tun, dass wenn ich das erste haus setzen will, also wenn ich das erste mal links klicke, das programm erstmal kurz lädt? also bis die mesh im speicher is.
einfach quasi ne blindmesh am anfang des programmes laden? damit die b3d im speicher is?
  • Zuletzt bearbeitet von Cry_p_Tix am Do, Nov 24, 2011 14:49, insgesamt 2-mal bearbeitet
 

Cry_p_Tix

BeitragDo, Nov 24, 2011 2:30
Antworten mit Zitat
Benutzer-Profile anzeigen
Okay.. habs selbst gelöst gekriegt Smile

Code: [AUSKLAPPEN]

Function build()
CameraPick camera,MouseX(),MouseY()


If MouseHit(2)
If buildmode=1
buildmode=0
TurnEntity camera,-15,0,0
PositionEntity camera,oldcamx,oldcamy,oldcamz
Else
buildmode = 1
If buildmode=1
oldcamx=EntityX(camera)
oldcamy=EntityY(camera)
oldcamz=EntityZ(camera)
MoveEntity camera,0,0,-50
TurnEntity camera,15,0,0
MoveEntity camera,0,50,0


EndIf
EndIf
EndIf




If buildmode=1

If buildmode2=0

If MouseHit(1)
wohnhaus:building = New building
wohnhaus.mesh = LoadMesh("data/meshes/house2.b3d")
EntityAlpha wohnhaus.mesh,0.5
wohnhaus.id = id
EntityType wohnhaus.mesh,2
buildmode2=1
listBuildings.AddLast(wohnhaus)

EndIf

Else

For wohnhaus:building = EachIn listBuildings
If wohnhaus.id = id
CameraPick camera,MouseX(),MouseY()
RotateEntity wohnhaus.mesh,0,EntityYaw(wohnhaus.mesh)+(MouseZSpeed()*5),0
PositionEntity wohnhaus.mesh,PickedX(),0,PickedZ()
EndIf [b]
Next[/b]

If MouseHit(1) [b]
For wohnhaus:building = EachIn listBuildings[/b]
If wohnhaus.id = id
wohnhaus.x =PickedX()
wohnhaus.y= 0
wohnhaus.z = PickedZ()
id = id + 1
PositionEntity wohnhaus.mesh,wohnhaus.x,wohnhaus.y,wohnhaus.z
EntityAlpha wohnhaus.mesh,1
buildmode2 = 0
EndIf
[b]Next[/b]
EndIf

EndIf
EndIf
 

Cry_p_Tix

BeitragDo, Nov 24, 2011 2:56
Antworten mit Zitat
Benutzer-Profile anzeigen
Schon offenbart sich mir das nächste Problem.. jetzt funktioniert die Collision zwischen Spieler und Haus nicht, zwischen Spieler und map jedoch schon, obwohl sowohl map als auch haus die selben EntityType typen haben.. hoffe jemand kann mir helfen..
Neutral

main.bmx

Code: [AUSKLAPPEN]

Import "../minib3d.bmx"
AppTitle= "3D Funktionalitätstest"
Include "functions.bmx"

graphics3d 1024,768,16,2

'Umgebung erstellen, angefangen mit Kamera und Licht

Global camera:TCamera=CreateCamera()
Local light2:TLight=createlight()
RotateEntity light2,0,90,0
LightRange light2,10000

CameraRange camera,0.1,10000
MoveEntity camera,0,24,0
TurnEntity camera,25,0,0
EntityType camera,1

Global oldcamx
Global oldcamy
Global oldcamz

' Welt Mesh Laden
Global welt:TMesh = LoadMesh("data/meshes/world.b3d")
MoveEntity welt,0,-20,0
EntityType welt,2
EntityPickMode welt,2

'Spieler erstellen

Global body:TMesh = LoadAnimMesh("data/meshes/zombie.b3d")

EntityAlpha body, 0.9 ' Spieler durchscheinen lassen
MoveEntity body,0,-15,30 ' Spieler positionieren ######################################### TEMPORÄR!
EntityRadius body, 5 ' Kollisionsradius des Spielers
TurnEntity body,0,180,0 ' Drehen
EntityType body,1 ' Kollisionstyp 1 für Spieler
EntityRadius body,1
EntityParent camera,body ' Camera dem Spieler zuordnen
moveentity body,0,30,0
ScaleEntity body,2.5,2.5,2.5
Int run_anim:Int = ExtractAnimSeq(body,2,20)
Int idle_anim:Int = ExtractAnimSeq(body,137,200)

body.Animate(1,.25,run_anim)


Global running = 0 'Laufen ? Nein!
Global backwards = 0 'Rückwärts laufen? nein!
Global buildmode = 0 ' Baumodus an?
Global buildmode2 = 0 'Item gesetzt?
Global build_item = 0 ' Noch tote variable(comming soon!)
Global id = 0
Global listBuildings:TList = New TList
'Playerlight
Local light:Tlight=createlight(2)
EntityParent light,camera
Lightrange light,3000

'Häuser Initialisieren
Type building
Field mesh:TMesh
Field x
Field y
Field z
Field id
Field Bid
End Type
'''''''''''''''''''''


'Skybox
Local sky:TMesh = CreateSphere()
ScaleEntity sky,100,100,100
PositionEntity sky, EntityX(camera),EntityY(camera),EntityZ(camera)
EntityParent sky,camera
EntityTexture sky, LoadTexture("data/textures/wolken.jpg")
FlipMesh sky
EntityOrder sky,1


Local lightsky:TLight=createlight(2,sky)
LightRange lightsky,10000
'Skybox Ende

Collisions 1,2,2,2


Rem
################ MAIN ###############
################ LOOP ###############
End Rem



While Not KeyDown(KEY_ESCAPE)
build
Movement
Animate_Player(run_anim,idle_anim)


UpdateWorld
RenderWorld
Print running
Flip
Wend

End














functions.bmx
Code: [AUSKLAPPEN]

Function Animate_Player(run_anim,idle_anim)

If backwards = 1
Animate body,1,0.3,run_anim
backwards =2
EndIf

If backwards =2
If Not KeyDown(KEY_S) Then backwards = 0
EndIf

If backwards =0

Animate body,1,0.2,idle_anim
backwards = 3
EndIf


;
If running = 1
Animate body,1,0.5,run_anim
running=2
EndIf

If running=2
If Not KeyDown(KEY_W) Then running = 0
EndIf

If running =0

Animate body,1,0.2,idle_anim
running = 3
EndIf




End Function


Function Movement()
moveentity body,0,-1.5,0 ' Gravity
If KeyDown( KEY_D )=True Then TurnEntity body,0,-3,0
If KeyDown( KEY_A )=True Then TurnEntity body,0,3,0

If KeyDown( KEY_S )=True
MoveEntity body,0,0,1.0
If backwards = 3 Or 0
backwards = 1
EndIf
EndIf

If KeyDown( KEY_W )=True
MoveEntity body,0,0,-2.4
If running = 3 Or 0
running = 1
EndIf
EndIf

End Function



Function build()
CameraPick camera,MouseX(),MouseY()
If MouseHit(2)
If buildmode=1
buildmode=0
TurnEntity camera,-15,0,0
PositionEntity camera,oldcamx,oldcamy,oldcamz
Else
buildmode = 1
If buildmode=1
oldcamx=EntityX(camera)
oldcamy=EntityY(camera)
oldcamz=EntityZ(camera)
MoveEntity camera,0,0,-50
TurnEntity camera,15,0,0
MoveEntity camera,0,50,0


EndIf
EndIf
EndIf




If buildmode=1

If buildmode2=0

If MouseHit(1)
wohnhaus:building = New building
wohnhaus.mesh = LoadMesh("data/meshes/house2.b3d")
EntityAlpha wohnhaus.mesh,0.5
wohnhaus.id = id
EntityType wohnhaus.mesh,2
buildmode2=1
listBuildings.AddLast(wohnhaus)

EndIf

Else

For wohnhaus:building = EachIn listBuildings
If wohnhaus.id = id
CameraPick camera,MouseX(),MouseY()
RotateEntity wohnhaus.mesh,0,EntityYaw(wohnhaus.mesh)+(MouseZSpeed()*5),0
PositionEntity wohnhaus.mesh,PickedX(),0,PickedZ()
EndIf
Next

If MouseHit(1)
For wohnhaus:building = EachIn listBuildings
If wohnhaus.id = id
EntityType wohnhaus.mesh,2
wohnhaus.x =PickedX()
wohnhaus.y= 0
wohnhaus.z = PickedZ()
id = id + 1
PositionEntity wohnhaus.mesh,wohnhaus.x,wohnhaus.y,wohnhaus.z


buildmode2 = 0
EndIf
Next
EndIf

EndIf
EndIf


End Function

Xeres

Moderator

BeitragDo, Nov 24, 2011 3:21
Antworten mit Zitat
Benutzer-Profile anzeigen
Cry_p_Tix, Doppelpost sind nicht gern gesehen und Trippel schon gar nicht. Wenn du was hin zu zu fügen hast, benutze doch bitte den Edit Button.
Es wäre auch nett, deutlich auf die Module hin zu weisen, die du benutzt, sofern sie vom Standard abweichen.
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)
 

Cry_p_Tix

BeitragDo, Nov 24, 2011 3:21
Antworten mit Zitat
Benutzer-Profile anzeigen
Also das Problem ist anscheinend dass vom Type buildings das field mesh ein int ist, statt ein TMesh, aber warum? habs doch eigentlich deklariert..


Edit: Okay, sorry.


Also das type problem hab ich hinbekommen..

allerdings hab ich ein neues >.<

undzwar funktionieren jetzt die collisionen nicht so wie ich das will..
also wenn ich das gebäude über den spieler ziehe, soll das spiel beendet werden,
klappt aber nich, nur wenn ich statt
If EntityCollided(wohnhaus.mesh,1) Then End
If EntityCollided(body,3) Then End
mache.
und das auch nur wenn der spieler genau auf gebäude zuläuft und ich dabei das gebäude "still halte"

in der main.bmx steht
Collisions 1,3,2,2

hier die functions.bmx
Code: [AUSKLAPPEN]
Function Animate_Player(run_anim,idle_anim)

If backwards = 1
Animate body,1,0.3,run_anim
backwards =2
EndIf

If backwards =2
If Not KeyDown(KEY_S) Then backwards = 0
EndIf

If backwards =0

Animate body,1,0.2,idle_anim
backwards = 3
EndIf


;
If running = 1
Animate body,1,0.5,run_anim
running=2
EndIf

If running=2
If Not KeyDown(KEY_W) Then running = 0
EndIf

If running =0

Animate body,1,0.2,idle_anim
running = 3
EndIf




End Function


Function Movement()
MoveEntity body,0,-1.5,0 ' Gravity
If KeyDown( KEY_D )=True Then TurnEntity body,0,-3,0
If KeyDown( KEY_A )=True Then TurnEntity body,0,3,0

If KeyDown( KEY_S )=True
MoveEntity body,0,0,1.0
If backwards = 3 Or 0
backwards = 1
EndIf
EndIf

If KeyDown( KEY_W )=True
MoveEntity body,0,0,-2.4
If running = 3 Or 0
running = 1
EndIf
EndIf

End Function



Function build()
CameraPick camera,MouseX(),MouseY()
If MouseHit(2)
If buildmode=1
buildmode=0
TurnEntity camera,-15,0,0
PositionEntity camera,oldcamx,oldcamy,oldcamz
Else
buildmode = 1
If buildmode=1
oldcamx=EntityX(camera)
oldcamy=EntityY(camera)
oldcamz=EntityZ(camera)
MoveEntity camera,0,0,-50
TurnEntity camera,15,0,0
MoveEntity camera,0,50,0


EndIf
EndIf
EndIf




If buildmode=1

If buildmode2=0

If MouseHit(1)
wohnhaus:building = New building
wohnhaus.mesh = LoadMesh("data/meshes/house2.b3d")
EntityAlpha wohnhaus.mesh,0.5

wohnhaus.id = id
EntityType wohnhaus.mesh,3
buildmode2=1
listBuildings.AddLast(wohnhaus)
EndIf

Else

For wohnhaus:building = EachIn listBuildings
If wohnhaus.id = id
CameraPick camera,MouseX(),MouseY()

RotateEntity wohnhaus.mesh,0,EntityYaw(wohnhaus.mesh)+(MouseZSpeed()*5),0
PositionEntity wohnhaus.mesh,PickedX(),-20,PickedZ()

If EntityCollided(body,3) Then End
EndIf
Next


If MouseHit(1)
For wohnhaus:building = EachIn listBuildings
If wohnhaus.id = id



EntityAlpha wohnhaus.mesh,1
wohnhaus.x =PickedX()
wohnhaus.y= -20
wohnhaus.z = PickedZ()
id = id + 1
PositionEntity wohnhaus.mesh,wohnhaus.x,wohnhaus.y,wohnhaus.z


buildmode2 = 0
EndIf
Next
EndIf

EndIf
EndIf


End Function

Neue Antwort erstellen


Übersicht BlitzMax, BlitzMax NG Beginners-Corner

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group