source: abuse/trunk/src/extend.cpp @ 124

Last change on this file since 124 was 124, checked in by Sam Hocevar, 11 years ago
  • Get rid of ugly tabs and trailing spaces everywhere.
File size: 2.9 KB
Line 
1/*
2 *  Abuse - dark 2D side-scrolling platform game
3 *  Copyright (c) 1995 Crack dot Com
4 *
5 *  This software was released into the Public Domain. As with most public
6 *  domain software, no warranty is made or implied by Crack dot Com or
7 *  Jonathan Clark.
8 */
9
10#include "config.h"
11
12#include "extend.hpp"
13#include "view.hpp"
14#include "objects.hpp"
15#include "lisp.hpp"
16
17/*
18
19
20
21  Simple object             (power ups, non-moving objects)
22    int32_t x,y;
23    int8_t direction;
24    uint16_t otype,state
25    uint16_t current_frame;
26    extension *
27
28
29  Moving object             (simple lisp controlled characters)
30     uint8_t flags;
31     int32_t xvel,yvel,xacel,yacel;
32     uint8_t fx,fy,fxvel,fyvel,fxacel,fyacel,aitype;
33     uint16_t aistate,aistate_time;
34     uint16_t hp,mp,
35     extension *
36
37
38  Complex objects          (can controll lights, other characters, and have a neural net ai)
39    uint8_t tobjs,tlights;
40    object_list *
41    light_list *
42    nnet_info *
43    int8_t fade_dir, frame_dir;
44    uint8_t fade_count,fade_max;
45    morph_char *morph_status;
46
47
48*/
49
50void simple_object::add_light(light_source *ls)
51{
52  if (!ls) return ;
53  ls->known=1;
54  for (int i=0;i<tlights;i++) if (lights[i]==ls) return;
55  tlights++;
56  lights=(light_source **)jrealloc(lights,sizeof(light_source *)*tlights,"Light list");
57  lights[tlights-1]=ls;
58}
59
60void simple_object::add_object(game_object *o)
61{
62  if (!o) return ;
63  for (int i=0;i<tobjs;i++) if (objs[i]==o) return;
64  o->set_flags(o->flags()|KNOWN_FLAG);
65  tobjs++;
66  objs=(game_object **)jrealloc(objs,sizeof(game_object *)*tobjs,"Object list");
67  objs[tobjs-1]=o;
68}
69
70
71void simple_object::remove_light(light_source *ls)
72{
73  for (int i=0;i<tlights;i++)
74  {
75    if (lights[i]==ls)
76    {
77      tlights--;
78      for (int j=i;j<tlights;j++)     // don't even think about it :)
79        lights[j]=lights[j+1];
80      lights=(light_source **)jrealloc(lights,sizeof(light_source *)*tlights,"object's lights");
81      return ;
82    }
83  }
84}
85
86void simple_object::remove_object(game_object *o)
87{
88  for (int i=0;i<tobjs;i++)
89  {
90    if (objs[i]==o)
91    {
92      tobjs--;
93      for (int j=i;j<tobjs;j++)     // don't even think about it :)
94        objs[j]=objs[j+1];
95      objs=(game_object **)jrealloc(objs,sizeof(game_object *)*tobjs,"object's lights");
96      return ;
97    }
98  }
99}
100
101
102simple_object::simple_object()
103{
104
105  x=y=0;
106  direction=1;
107  otype=0;
108  state=stopped;
109  current_frame=0;
110
111  Fade_dir=0;
112  Fade_count=0;
113  Fade_max=16;
114
115
116  tobjs=tlights=0;
117  objs=NULL;
118  lights=NULL;
119  Frame_dir=1;
120  mc=NULL;
121  Controller=NULL;
122
123  Flags=0;
124  Xvel=Yvel=Xacel=Yacel=0;
125  Fx=Fy=Fxvel=Fyvel=Fxacel=Fyacel=Aitype=0;
126  Aistate=Aistate_time=0;
127  Hp=Mp=Fmp=0;
128  grav_on=1;
129  targetable_on=1;
130}
131
132
133
134void simple_object::set_morph_status(morph_char *Mc)
135{
136  mc=Mc;
137}
138
139void simple_object::clean_up()
140{
141  if (tlights) jfree(lights);
142  if (tobjs)   jfree(objs);
143  if (Controller)
144    Controller->focus=NULL;
145}
146
147
148simple_object default_simple;
149
150
Note: See TracBrowser for help on using the repository browser.