source: abuse/trunk/src/view.h @ 676

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

game: prefix a few class members with m_ to avoid confusion.

  • Property svn:keywords set to Id
File size: 4.1 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 _VIEW_HPP_
12#define _VIEW_HPP_
13
14#include "light.h"
15#include "jwindow.h"
16
17
18class object_node;
19class game_object;
20class area_controller;
21
22struct suggest_struct
23{
24    int32_t cx1,cy1,cx2,cy2,pan_x,pan_y;
25    vec2i shift;
26    int32_t new_weapon;
27    uint8_t send_view,send_weapon_change;
28};
29
30
31class view;
32
33
34class view
35{
36public:
37    view(game_object *Focus, view *Next, int number);
38    ~view();
39
40  int key_down(int key) { return m_keymap[key/8]&(1<<(key%8)); }
41  void set_key_down(int key, int x) { if (x) m_keymap[key/8]|=(1<<(key%8)); else m_keymap[key/8]&=~(1<<(key%8)); }
42  void reset_keymap() { memset(m_keymap,0,sizeof(m_keymap)); }
43  void add_chat_key(int key);
44
45  char name[100];
46  struct suggest_struct suggest;
47
48  int god;                                // :) if you believe in such things
49  int player_number;
50  int _tint, _team;
51
52  int draw_solid;                         // -1 if don't draw solid
53
54  int32_t *weapons;                          // [0..total_weapons-1]
55  int32_t *last_weapons;                     // last history of above array (for updating statbar)
56  int32_t current_weapon;
57
58
59  int x_suggestion,                      // input from the player at the current time
60      y_suggestion,
61      b1_suggestion,
62      b2_suggestion,
63      b3_suggestion,
64      b4_suggestion,
65      pointer_x,
66      pointer_y,
67      freeze_time;
68
69
70  short ambient;                        // ambient lighting setting, used by draw
71
72  int32_t pan_x,pan_y,no_xleft,no_xright,no_ytop,no_ybottom, view_percent;
73
74  int32_t last_left,last_right,last_up,last_down,   // how many frames ago were these pressed (<=0)
75       last_b1,last_b2,last_b3,last_b4,last_hp,last_ammo,last_type;
76  int32_t secrets,kills,tsecrets,tkills;
77
78  void draw_character_damage();           // draws the characters 'status' on the viewer
79
80  int32_t x_center();                        // center of attention
81  int32_t y_center();
82  int32_t xoff();                            // top left and right corner of the screen
83  int32_t interpolated_xoff();
84  int32_t yoff();
85  int32_t interpolated_yoff();
86  int drawable();                        // network viewables are not drawable
87  int local_player();                    //  just in case I ever need non-viewable local players.
88
89  view *next;                             // next viewable player (singly linked list)
90  void get_input();
91  int process_input(char cmd, uint8_t *&pk);
92
93  void add_ammo   (int weapon_type, int total);
94  int has_weapon  (int weapon_type) { return god || (weapons[weapon_type]!=-1); }
95  void give_weapon(int weapontype);
96  int weapon_total(int weapon_type);
97
98  void note_upkey();
99  void note_downkey();
100  int handle_event(Event &ev);
101  void update_scroll();
102  void draw_hp();
103  void draw_ammo();
104  void draw_logo();
105  void set_input(int cx, int cy, int b1, int b2, int b3, int b4, int px, int py);
106  int view_changed() { return suggest.send_view; }
107  int weapon_changed() { return suggest.send_weapon_change; }
108
109  void next_weapon();
110  void last_weapon();
111
112  void reset_player();
113  int receive_failed() { return m_focus==NULL; }
114  int32_t get_view_var_value(int num);
115  int32_t set_view_var_value(int num, int32_t x);
116  void configure_for_area(area_controller *a);
117
118  void set_tint(int);
119  int get_tint();
120  void set_team(int);
121  int get_team();
122
123    vec2i m_aa, m_bb; // view area to show
124    vec2i m_shift; // shift of view
125    vec2i m_lastpos, m_lastlastpos;
126
127    game_object *m_focus; // object we are focusing on (player)
128
129private:
130    uint8_t m_keymap[512 / 8];
131    char m_chat_buf[60];
132};
133
134extern view *player_list;
135void set_local_players(int total);
136int total_local_players();
137void recalc_local_view_space();
138
139void process_packet_commands(uint8_t *pk, int size);
140
141object_node *make_player_onodes(int player_num=-1);
142int total_view_vars();
143char const *get_view_var_name(int num);
144uint16_t make_sync();
145
146#endif
147
148
149
150
151
Note: See TracBrowser for help on using the repository browser.