source: abuse/trunk/src/objects.h @ 682

Last change on this file since 682 was 653, checked in by Sam Hocevar, 8 years ago

imlib: remove unused code and tag unused method arguments.

  • Property svn:keywords set to Id
File size: 6.0 KB
Line 
1/*
2 *  Abuse - dark 2D side-scrolling platform game
3 *  Copyright (c) 1995 Crack dot Com
4 *  Copyright (c) 2005-2011 Sam Hocevar <sam@hocevar.net>
5 *
6 *  This software was released into the Public Domain. As with most public
7 *  domain software, no warranty is made or implied by Crack dot Com, by
8 *  Jonathan Clark, or by Sam Hocevar.
9 */
10
11#ifndef _OBJECTS_HPP_
12#define _OBJECTS_HPP_
13#include "input.h"
14#include "chars.h"
15//#include "sound.h"
16#include "morpher.h"
17#include "loader2.h"
18#include "view.h"
19#include "extend.h"
20
21class view;
22
23extern char **object_names;
24extern int total_objects;
25
26#define NOT_BLOCKED 0
27#define BLOCKED_LEFT 1
28#define BLOCKED_RIGHT 2
29#define BLOCKED_UP 4
30#define BLOCKED_DOWN 8
31
32
33
34#define FIRST_ATTACK atk_fast
35#define LAST_ATTACK attack_special
36
37
38
39
40#define RC_8 0
41#define RC_16 1
42#define RC_32 2
43
44
45
46
47
48#define TOTAL_OBJECT_VARS 28
49struct obj_desc { char const *name; int type; } ;
50extern obj_desc object_descriptions[TOTAL_OBJECT_VARS];
51int RC_type_size(int type);
52//void init_object_offsets();
53
54
55class game_object : public simple_object
56{
57  sequence *current_sequence() { return figures[otype]->get_sequence(state); }
58public :
59  game_object *next,*next_active;
60  int32_t *lvars;
61
62  int size();
63  int decide();        // returns 0 if you want to be deleted
64  int type() { return otype; }
65  ifield *make_fields(int ystart, ifield *Next)
66  {
67    (void)ystart; (void)Next;
68    return NULL;
69  }
70  void gather_input(InputManager *inm) { (void)inm; }
71  int hurt_all() { return figures[otype]->get_cflag(CFLAG_HURT_ALL); }
72  int stoppable() { return figures[otype]->get_cflag(CFLAG_STOPPABLE); }
73  int can_block() { return figures[otype]->get_cflag(CFLAG_CAN_BLOCK); }
74
75  int hurtable() { return figures[otype]->get_cflag(CFLAG_HURTABLE); }
76  int pushable() { return figures[otype]->get_cflag(CFLAG_PUSHABLE); }
77
78  void draw();
79  void map_draw();
80  void draw_trans(int count, int max);
81  void draw_tint(int tint_id);
82  void draw_double_tint(int tint_id1, int tint_id2);
83  void draw_predator();
84
85
86  void drawer();
87  void draw_above(view *v);
88  void do_damage(int amount, game_object *from, int32_t hitx, int32_t hity, int32_t push_xvel, int32_t push_yvel);
89  void damage_fun(int amount, game_object *from, int32_t hitx, int32_t hity, int32_t push_xvel, int32_t push_yvel);
90
91
92  void note_attack(game_object *whom);
93  void receive_signal(long signal) { (void)signal; }
94  int push_range();
95  int can_hurt(game_object *who);     // collision checking will ask first to see if you
96                              // can hurt this person before calculating weither you actually do
97
98  void load(int type, bFILE *fp, unsigned char *state_remap);
99  int tick();  // should be called from decide, does the physics on the people, returns blocked status
100  void *float_tick();  // returns T or blocked structure =
101                       // (block_flags 'tile tilex tiley)
102                       // (block_flags 'object obj)
103
104  void next_sequence();
105
106  int facing_attacker(int attackerx);
107  void set_state(character_state s, int frame_direction=1);
108  int has_sequence(character_state s) { return figures[otype]->has_sequence(s); }
109
110  game_object *try_move(int32_t x, int32_t y, int32_t &xv, int32_t &yv, int checks);  // 1=down,2=up,3=both
111  game_object *bmove(int &whit, game_object *exclude);  // ballestic move, return hit object,
112                                                        // or NULL (whit is 1 if hit wall)
113  TransImage *picture() { return current_sequence()->get_frame(current_frame,direction); }
114
115  int next_picture();
116  int32_t x_center();
117  int32_t height();
118
119  void stop_acel() { set_xacel(0);  set_yacel(0); set_fxacel(0); set_fyacel(0); }
120  void stop_vel() {  set_xvel(0);   set_yvel(0); set_fxvel(0);  set_fyvel(0); }
121  void stop_x() {  set_xvel(0);  set_fxvel(0); set_xacel(0); set_fxacel(0); }
122  void stop()
123  { set_xvel(0);   set_yvel(0); set_fxvel(0);  set_fyvel(0);
124    set_xacel(0);  set_yacel(0); set_fxacel(0); set_fyacel(0);
125  }
126
127  int move(int cx, int cy, int button);  // return blocked status
128  int mover(int cx, int cy, int button);
129  figure *current_figure() { return current_sequence()->get_figure(current_frame); }
130  int total_frames() { return current_sequence()->length(); }
131  void picture_space(int32_t &x1, int32_t &y1,int32_t &x2, int32_t &y2);
132  int tx(int x) { if (direction>0) return x-x_center(); else return x_center()-x; }
133  int ty(int y) { return y-picture()->Size().y+1; }
134  void defaults();
135
136  game_object(int Type, int load=0);
137  ~game_object();
138
139  int is_playable() { return hurtable(); }
140  void add_power(int amount);
141  void add_hp(int amount);
142  int can_morph_into(int type);
143  void morph_into(int type, void (*stat_fun)(int), int anneal, int frames);
144  void do_flinch(game_object *from);
145  void set_aimemory(game_object *p) { add_object(p); p->set_flags(p->flags()|KNOWN_FLAG); }
146  int alive() { if (state==dead || hp()<=0) return 0; else return 1; }
147  void frame_advance();
148  object_node *make_not_list(object_node *first);
149  int reduced_state();
150  void reload_notify();
151
152  void change_type(int new_type);
153  int set_var_by_name(char *name, int32_t value);
154  int32_t get_var_by_name(char *name, int &error);
155  game_object *copy();
156  void change_aitype(int new_type);
157
158  int get_tint() { return _tint; }
159  void set_tint(int tint)
160  {
161    for(int i = 0; i < tobjs; i++)
162      get_object(i)->_tint = tint;
163    _tint = tint;
164  }
165  int get_team() { return _team; }
166  void set_team(int team)
167  {
168    for(int i = 0; i < tobjs; i++)
169      get_object(i)->_team = team;
170    _team = team;
171  }
172} ;
173
174class object_node  // used to create various list of objects
175{
176  public :
177  game_object *me;
178  object_node *next;
179  object_node(game_object *Me, object_node *Next) { me=Me; next=Next; }
180} ;
181
182extern game_object *current_object;
183extern view *current_view;
184game_object *create(int type, int32_t x, int32_t y, int skip_constructor=0, int aitype=0);
185int base_size();
186
187void delete_object_list(object_node *first);
188int          object_to_number_in_list(game_object *who, object_node *list);
189game_object *number_to_object_in_list(int32_t x, object_node *list);
190
191
192#endif
193
194
195
196
Note: See TracBrowser for help on using the repository browser.