Okay, (just taking a brief moment during half-time) -
It all depends on what you are trying to do, in terms of how you go about solving this problem.
I'll give you a way which is similar to how I do it in my current games.
In the example I give I will try to use obviously named variables and will avoid using types/arrays and other code that beginners can struggle with at first (I'm assuming you are a beginner - I apologise if I'm wrong):
It all depends on what you are trying to do, in terms of how you go about solving this problem.
I'll give you a way which is similar to how I do it in my current games.
In the example I give I will try to use obviously named variables and will avoid using types/arrays and other code that beginners can struggle with at first (I'm assuming you are a beginner - I apologise if I'm wrong):
;Outside of your main loop, when you load your level, place doors etc you might set a variable like this: DoorState = 0 ; 0 = closed, 1 = opening, 2 = open, 3 = closing DoorAngle# = 0.0 ;door swings between an angle of 90 degrees about a pivot point you would place at the door hinge. DoorTimeToRemainOpen = 3000 ;milliseconds ; then inside your main loop REPEAT ;game loop Moveyourcamera, and everything else.....here SELECT DoorState ;if you have multiple doors you are going to need to store each door's doorstate, and other properties somehow, the easiest way is with TYPEs - when you get used to them, CASE 0 ;closed IF 'collided with door' THEN DoorState = 1;your current collision method seems fine so use that... ;okay we've collided with a closed door, so it is time to set it to 'opening' CASE 1 ;opening TURNENTITY DoorEnt,0,1,0 DoorAngle=ENTITYYAW(DoorEnt) IF DoorAngle >= 90 then ROTATEENTITY DoorEnt,0,90,0 :DoorState = 2:ENTITYTYPE DoorEnt,0:DoorClosingTime=Millisecs()+DoorTimetoRemainOpen CASE 2 ;open If Millisecs() > DoorClosingtime then DoorState = 3 CASE 3 ;closing TurnEntity DoorEnt,0,-1,0 DoorAngle=EntityYaw(DoorEnt) If DoorAngle <=0 then RotateEntity DoorEnt,0,0,0:DoorState=0:EntityType DoorEnt,DOORTYPE ;whatever you have set your door collision type number to END-SELECT updateworld renderworld flip UNTIL KEYDOWN(1) ;end of game loop