1 /*------------------------------------------------------------------
4 XINVADERS 3D - 3d Shoot'em up
5 Copyright (C) 2000 Don Llopis
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 ------------------------------------------------------------------*/
24 #include <sys/types.h>
30 /*================================================================*/
32 void Objlist_clear ( OBJLIST
*lst
)
39 /*================================================================*/
41 void Objlist_add ( OBJLIST
*lst
, OBJECT
*obj
)
48 lst
->tail
->next
= obj
;
49 /* move tail forward */
50 lst
->tail
= lst
->tail
->next
;
51 lst
->tail
->prev
= tmp
;
52 lst
->tail
->next
= NULL
;
54 /* empty list so initialize head and tail */
57 lst
->head
= lst
->tail
= obj
;
58 lst
->head
->prev
= lst
->tail
->prev
= NULL
;
59 lst
->head
->next
= lst
->tail
->next
= NULL
;
65 /*================================================================*/
67 void Objlist_del ( OBJLIST
*lst
, OBJECT
*obj
)
71 /* is the object at the head of the list */
72 if ( obj
->prev
== NULL
)
74 /* is object both at head and tail */
75 if ( obj
->next
== NULL
)
77 lst
->head
= lst
->tail
= NULL
;
78 obj
->next
= obj
->prev
= NULL
;
82 lst
->head
= obj
->next
;
83 lst
->head
->prev
= NULL
;
86 /* is the object at the end of the list */
87 else if ( obj
->next
== NULL
)
89 lst
->tail
= obj
->prev
;
90 lst
->tail
->next
= NULL
;
92 /* otherwise object somewhere in the list */
95 obj
->prev
->next
= obj
->next
;
96 obj
->next
->prev
= obj
->prev
;
99 obj
->next
= obj
->prev
= NULL
;
104 /*================================================================*/
106 int Objlist_count ( OBJLIST
*lst
)
108 return lst
->obj_count
;
111 /*================================================================*/
112 OBJECT
* Object_new ( void )
116 obj
= ( OBJECT
* ) malloc ( sizeof ( OBJECT
) );
120 /*================================================================*/
122 void Object_delete ( OBJECT
*obj
)
128 /*================================================================*/
130 void Object_init ( OBJECT
*obj
)
140 Vector_init ( obj
->pos
);
141 Vector_init ( obj
->old_pos
);
142 Vector_init ( obj
->dir
);
143 Vector_init ( obj
->thrust
);
145 obj
->actionfn
= NULL
;
152 /*================================================================*/
154 void Object_set_actionfn ( OBJECT
*obj
, PFV1 actionfn
)
156 obj
->actionfn
= actionfn
;
159 /*================================================================*/
161 void Object_set_drawfn ( OBJECT
*obj
, PFV2 drawfn
)
163 obj
->drawfn
= drawfn
;
166 /*================================================================*/
168 void Object_set_model ( OBJECT
*obj
, MODEL
*model
)
173 /*================================================================*/
175 void Object_set_pos ( OBJECT
*obj
, VECTOR4 pos
)
177 Vector_copy ( pos
, obj
->pos
);
180 /*================================================================*/
181 void Object_get_pos ( OBJECT
*obj
, VECTOR4 pos
)
183 Vector_copy ( obj
->pos
, pos
);
186 /*================================================================*/
187 void Object_set_dir ( OBJECT
*obj
, VECTOR4 dir
)
189 Vector_copy ( dir
, obj
->dir
);
192 /*================================================================*/
193 void Object_get_dir ( OBJECT
*obj
, VECTOR4 dir
)
195 Vector_copy ( obj
->dir
, dir
);
198 /*================================================================*/
200 void Object_draw ( OBJECT
*obj
)
204 /*================================================================*/