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

Last change on this file since 126 was 126, checked in by Sam Hocevar, 14 years ago
  • Implement game_object::set_tint, get_tint, set_team and get_team, as well as the corresponding set_object_tint, get_object_tint, set_object_team and get_object_team LISP functions. They'll be useful for CTF mode.

Inspired by Abuse Win32 changelog from February 18, 2001:

  • Changed lisp function (set_player_color x) to

(set_object_tint x)

  • Added lisp function (get_object_tint)

Inspired by Abuse Win32 changelog from February 17, 2001:

  • Added lisp function (set_player_color x) to switch player

to color number x
see chat.lsp for details

File size: 3.0 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  if(_team != -1)
66    o->set_team(_team);
67  if(_tint != -1)
68    o->set_tint(_tint);
69  tobjs++;
70  objs=(game_object **)jrealloc(objs,sizeof(game_object *)*tobjs,"Object list");
71  objs[tobjs-1]=o;
72}
73
74
75void simple_object::remove_light(light_source *ls)
76{
77  for (int i=0;i<tlights;i++)
78  {
79    if (lights[i]==ls)
80    {
81      tlights--;
82      for (int j=i;j<tlights;j++)     // don't even think about it :)
83        lights[j]=lights[j+1];
84      lights=(light_source **)jrealloc(lights,sizeof(light_source *)*tlights,"object's lights");
85      return ;
86    }
87  }
88}
89
90void simple_object::remove_object(game_object *o)
91{
92  for (int i=0;i<tobjs;i++)
93  {
94    if (objs[i]==o)
95    {
96      tobjs--;
97      for (int j=i;j<tobjs;j++)     // don't even think about it :)
98        objs[j]=objs[j+1];
99      objs=(game_object **)jrealloc(objs,sizeof(game_object *)*tobjs,"object's lights");
100      return ;
101    }
102  }
103}
104
105
106simple_object::simple_object()
107{
108
109  x=y=0;
110  direction=1;
111  otype=0;
112  state=stopped;
113  current_frame=0;
114
115  Fade_dir=0;
116  Fade_count=0;
117  Fade_max=16;
118
119
120  tobjs=tlights=0;
121  objs=NULL;
122  lights=NULL;
123  Frame_dir=1;
124  mc=NULL;
125  Controller=NULL;
126
127  Flags=0;
128  Xvel=Yvel=Xacel=Yacel=0;
129  Fx=Fy=Fxvel=Fyvel=Fxacel=Fyacel=Aitype=0;
130  Aistate=Aistate_time=0;
131  Hp=Mp=Fmp=0;
132  _tint = -1;
133  _team = -1;
134  grav_on=1;
135  targetable_on=1;
136}
137
138
139
140void simple_object::set_morph_status(morph_char *Mc)
141{
142  mc=Mc;
143}
144
145void simple_object::clean_up()
146{
147  if (tlights) jfree(lights);
148  if (tobjs)   jfree(objs);
149  if (Controller)
150    Controller->focus=NULL;
151}
152
153
154simple_object default_simple;
155
156
Note: See TracBrowser for help on using the repository browser.