source: abuse/trunk/src/view.h

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

core: rename vec2i to ivec2 and update matrix.h from Lol Engine.

  • Property svn:keywords set to Id
File size: 4.1 KB
RevLine 
[56]1/*
2 *  Abuse - dark 2D side-scrolling platform game
3 *  Copyright (c) 1995 Crack dot Com
[494]4 *  Copyright (c) 2005-2011 Sam Hocevar <sam@hocevar.net>
[56]5 *
6 *  This software was released into the Public Domain. As with most public
[555]7 *  domain software, no warranty is made or implied by Crack dot Com, by
8 *  Jonathan Clark, or by Sam Hocevar.
[56]9 */
10
[2]11#ifndef _VIEW_HPP_
12#define _VIEW_HPP_
13
[481]14#include "light.h"
15#include "jwindow.h"
[2]16
17
18class object_node;
19class game_object;
20class area_controller;
21
22struct suggest_struct
23{
[676]24    int32_t cx1,cy1,cx2,cy2,pan_x,pan_y;
[682]25    ivec2 shift;
[676]26    int32_t new_weapon;
27    uint8_t send_view,send_weapon_change;
28};
[2]29
30
31class view;
32
33
34class view
35{
[674]36public:
37    view(game_object *Focus, view *Next, int number);
38    ~view();
39
[676]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)); }
[2]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;
[126]50  int _tint, _team;
[124]51
[2]52  int draw_solid;                         // -1 if don't draw solid
53
[16]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;
[2]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
[126]71
[676]72  int32_t pan_x,pan_y,no_xleft,no_xright,no_ytop,no_ybottom, view_percent;
[2]73
[16]74  int32_t last_left,last_right,last_up,last_down,   // how many frames ago were these pressed (<=0)
[2]75       last_b1,last_b2,last_b3,last_b4,last_hp,last_ammo,last_type;
[16]76  int32_t secrets,kills,tsecrets,tkills;
[2]77
78  void draw_character_damage();           // draws the characters 'status' on the viewer
79
[16]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();
[2]86  int drawable();                        // network viewables are not drawable
87  int local_player();                    //  just in case I ever need non-viewable local players.
88
[124]89  view *next;                             // next viewable player (singly linked list)
[2]90  void get_input();
[17]91  int process_input(char cmd, uint8_t *&pk);
[2]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();
[643]100  int handle_event(Event &ev);
[2]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();
[676]113  int receive_failed() { return m_focus==NULL; }
[16]114  int32_t get_view_var_value(int num);
115  int32_t set_view_var_value(int num, int32_t x);
[2]116  void configure_for_area(area_controller *a);
117
[126]118  void set_tint(int);
119  int get_tint();
120  void set_team(int);
121  int get_team();
[674]122
[682]123    ivec2 m_aa, m_bb; // view area to show
124    ivec2 m_shift; // shift of view
125    ivec2 m_lastpos, m_lastlastpos;
[674]126
[676]127    game_object *m_focus; // object we are focusing on (player)
128
[674]129private:
[676]130    uint8_t m_keymap[512 / 8];
131    char m_chat_buf[60];
[126]132};
133
[2]134extern view *player_list;
135void set_local_players(int total);
136int total_local_players();
137void recalc_local_view_space();
138
[17]139void process_packet_commands(uint8_t *pk, int size);
[2]140
141object_node *make_player_onodes(int player_num=-1);
142int total_view_vars();
[39]143char const *get_view_var_name(int num);
[555]144uint16_t make_sync();
[2]145
146#endif
147
148
149
150
151
Note: See TracBrowser for help on using the repository browser.