]> git.cameronkatri.com Git - bsdgames-darwin.git/blob - warp/object.c
Add testpat(6) to games.
[bsdgames-darwin.git] / warp / object.c
1 /* Header: object.c,v 7.0 86/10/08 15:12:55 lwall Exp */
2
3 /* Log: object.c,v
4 * Revision 7.0 86/10/08 15:12:55 lwall
5 * Split into separate files. Added amoebas and pirates.
6 *
7 */
8
9 #include "EXTERN.h"
10 #include "warp.h"
11 #include "INTERN.h"
12 #include "object.h"
13
14 void
15 object_init(void)
16 {
17 ;
18 }
19
20 OBJECT *
21 make_object(char typ, char img, int px, int py, int vx, int vy, long energ,
22 long mas, OBJECT *where)
23 {
24 OBJECT *obj;
25
26 if (free_root.next == &free_root)
27 #ifndef lint
28 obj = (OBJECT *) malloc(sizeof root);
29 #else
30 obj = Null(OBJECT*);
31 #endif
32 else {
33 obj = free_root.next;
34 free_root.next = obj->next;
35 obj->next->prev = &free_root;
36 }
37 obj->type = typ;
38 obj->image = img;
39 obj->next = where;
40 obj->prev = where->prev;
41 where->prev = obj;
42 obj->prev->next = obj;
43 obj->velx = vx;
44 obj->vely = vy;
45 obj->contend = 0;
46 obj->strategy = 0;
47 obj->flags = 0;
48 obj->posx = px;
49 obj->posy = py;
50 if (typ != Torp && typ != Web) {
51 occupant[py][px] = obj;
52 }
53 obj->energy = energ;
54 obj->mass = mas;
55 return(obj);
56 }
57
58 void
59 unmake_object(OBJECT *curobj)
60 {
61 curobj->prev->next = curobj->next;
62 curobj->next->prev = curobj->prev;
63 if (curobj == movers) {
64 movers = curobj->next;
65 }
66 free_object(curobj);
67 }
68
69 void
70 free_object(OBJECT *curobj)
71 {
72 curobj->next = free_root.next;
73 curobj->prev = &free_root;
74 free_root.next->prev = curobj;
75 free_root.next = curobj;
76 }