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

Last change on this file since 674 was 674, checked in by Sam Hocevar, 11 years ago

game: convert a few View members to vec2i.

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