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 | #ifndef _VIEW_HPP_ |
---|
11 | #define _VIEW_HPP_ |
---|
12 | |
---|
13 | #include "light.hpp" |
---|
14 | #include "jwindow.hpp" |
---|
15 | |
---|
16 | |
---|
17 | class object_node; |
---|
18 | class game_object; |
---|
19 | class area_controller; |
---|
20 | |
---|
21 | struct suggest_struct |
---|
22 | { |
---|
23 | int32_t cx1,cy1,cx2,cy2,shift_down,shift_right,pan_x,pan_y; |
---|
24 | int32_t new_weapon; |
---|
25 | uint8_t send_view,send_weapon_change; |
---|
26 | } ; |
---|
27 | |
---|
28 | |
---|
29 | class view; |
---|
30 | |
---|
31 | |
---|
32 | class view |
---|
33 | { |
---|
34 | uint8_t keymap[512/8]; |
---|
35 | char chat_buf[60]; |
---|
36 | public : |
---|
37 | int key_down(int key) { return keymap[key/8]&(1<<(key%8)); } |
---|
38 | void set_key_down(int key, int x) { if (x) keymap[key/8]|=(1<<(key%8)); else keymap[key/8]&=~(1<<(key%8)); } |
---|
39 | void reset_keymap() { memset(keymap,0,sizeof(keymap)); } |
---|
40 | void add_chat_key(int key); |
---|
41 | |
---|
42 | char name[100]; |
---|
43 | struct suggest_struct suggest; |
---|
44 | int32_t cx1,cy1,cx2,cy2, // view area to show |
---|
45 | shift_down,shift_right; // shift of view |
---|
46 | |
---|
47 | int god; // :) if you believe in such things |
---|
48 | int player_number; |
---|
49 | |
---|
50 | int draw_solid; // -1 if don't draw solid |
---|
51 | |
---|
52 | int32_t *weapons; // [0..total_weapons-1] |
---|
53 | int32_t *last_weapons; // last history of above array (for updating statbar) |
---|
54 | int32_t current_weapon; |
---|
55 | |
---|
56 | |
---|
57 | game_object *focus; // object we are focusing on (player) |
---|
58 | int x_suggestion, // input from the player at the current time |
---|
59 | y_suggestion, |
---|
60 | b1_suggestion, |
---|
61 | b2_suggestion, |
---|
62 | b3_suggestion, |
---|
63 | b4_suggestion, |
---|
64 | pointer_x, |
---|
65 | pointer_y, |
---|
66 | freeze_time; |
---|
67 | |
---|
68 | |
---|
69 | short ambient; // ambient lighting setting, used by draw |
---|
70 | int32_t pan_x,pan_y,no_xleft,no_xright,no_ytop,no_ybottom, |
---|
71 | last_x,last_y,last_last_x,last_last_y,view_percent; |
---|
72 | |
---|
73 | int32_t last_left,last_right,last_up,last_down, // how many frames ago were these pressed (<=0) |
---|
74 | last_b1,last_b2,last_b3,last_b4,last_hp,last_ammo,last_type; |
---|
75 | int32_t secrets,kills,tsecrets,tkills; |
---|
76 | |
---|
77 | view(game_object *Focus, view *Next, int number); |
---|
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 resize_view(int32_t Cx1, int32_t Cy1, int32_t Cx2, int32_t Cy2); |
---|
106 | void set_input(int cx, int cy, int b1, int b2, int b3, int b4, int px, int py); |
---|
107 | int view_changed() { return suggest.send_view; } |
---|
108 | int weapon_changed() { return suggest.send_weapon_change; } |
---|
109 | |
---|
110 | void next_weapon(); |
---|
111 | void last_weapon(); |
---|
112 | |
---|
113 | void reset_player(); |
---|
114 | int receive_failed() { return focus==NULL; } |
---|
115 | int32_t get_view_var_value(int num); |
---|
116 | int32_t set_view_var_value(int num, int32_t x); |
---|
117 | void configure_for_area(area_controller *a); |
---|
118 | ~view(); |
---|
119 | } ; |
---|
120 | |
---|
121 | extern view *player_list; |
---|
122 | void set_local_players(int total); |
---|
123 | int total_local_players(); |
---|
124 | void recalc_local_view_space(); |
---|
125 | |
---|
126 | void process_packet_commands(uint8_t *pk, int size); |
---|
127 | |
---|
128 | object_node *make_player_onodes(int player_num=-1); |
---|
129 | int total_view_vars(); |
---|
130 | char const *get_view_var_name(int num); |
---|
131 | ushort make_sync(); |
---|
132 | |
---|
133 | #endif |
---|
134 | |
---|
135 | |
---|
136 | |
---|
137 | |
---|
138 | |
---|