92 lines
2.2 KiB
C
92 lines
2.2 KiB
C
/*
|
|
* PVVMUD a 3D MUD
|
|
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
*
|
|
*/
|
|
#include <stdio.h>
|
|
/*
|
|
#include "server.H"
|
|
#include "door.H"
|
|
|
|
CDoor::CDoor():CSrvObject(){
|
|
|
|
state = DOORSTATE_OPENED;
|
|
doorAngle = 45;
|
|
|
|
CGeometryObject * geometry = new CGeometryObject("Door",7);
|
|
geometry->setBBox( new CBBox(-0.4,-0.1,0,0.4,0.1,1.8) );
|
|
|
|
setGeometry(geometry);
|
|
|
|
setDirection( CDirection(0,-doorAngle,0) );
|
|
|
|
}
|
|
|
|
int CDoor::open(){
|
|
if (state == DOORSTATE_CLOSED) {
|
|
printf("Door: open!\n");
|
|
state = DOORSTATE_OPEN;
|
|
} else return FALSE;
|
|
return TRUE;
|
|
}
|
|
|
|
int CDoor::close(){
|
|
if (state == DOORSTATE_OPENED) {
|
|
printf("Door: close!\n");
|
|
state = DOORSTATE_CLOSE;
|
|
} else return FALSE;
|
|
return TRUE;
|
|
}
|
|
|
|
void CDoor::animate( double time ){
|
|
// printf("Door: animate( %f )\n",time );
|
|
switch (state) {
|
|
case DOORSTATE_OPENED:
|
|
case DOORSTATE_CLOSED:
|
|
return ;
|
|
break;
|
|
case DOORSTATE_OPEN:
|
|
doorAngle += DOORANGLE_SPEED*time;
|
|
if (doorAngle > 45.0){
|
|
doorAngle = 45.0;
|
|
state = DOORSTATE_OPENED;
|
|
doorOpened();
|
|
}
|
|
updateDirection( CDirection(0,-doorAngle,0) );
|
|
break;
|
|
case DOORSTATE_CLOSE:
|
|
doorAngle -= DOORANGLE_SPEED*time;
|
|
if (doorAngle < 0.0){
|
|
doorAngle = 0.0;
|
|
state = DOORSTATE_CLOSED;
|
|
doorClosed();
|
|
}
|
|
updateDirection( CDirection(0,-doorAngle,0) );
|
|
break;
|
|
}
|
|
}
|
|
|
|
void CDoor::doorOpened(){
|
|
printf("Door: doorOpened!\n");
|
|
}
|
|
|
|
void CDoor::doorClosed(){
|
|
printf("Door: doorClosed!\n");
|
|
}
|
|
|
|
*/
|