/* * Abuse - dark 2D side-scrolling platform game * Copyright (c) 1995 Crack dot Com * * This software was released into the Public Domain. As with most public * domain software, no warranty is made or implied by Crack dot Com or * Jonathan Clark. */ #ifndef __LEVEL_HPP_ #define __LEVEL_HPP_ #include "specs.hpp" #include "macs.hpp" #include "objects.hpp" #include "view.hpp" #include "id.hpp" #include #define ASPECT 4 // foreground scrolls 4 times faster than background // the following defines the area of activity for objects // when they are out of this are no processing occurs on them // region is specified from upper left corner of screen #define ACTIVE_LEFT 500 #define ACTIVE_RIGHT (280+500) #define ACTIVE_TOP 200 #define ACTIVE_BOTTOM (180+200) #define fgvalue(y) ((y) & 0x3fff) #define above_tile(y) ((y) & 0x4000) #define bgvalue(y) (y) class area_controller { public : int32_t x,y,w,h,active; int32_t ambient,view_xoff,view_yoff; int32_t ambient_speed, view_xoff_speed,view_yoff_speed; area_controller *next; area_controller(int32_t X, int32_t Y, int32_t W, int32_t H, area_controller *Next); } ; extern int32_t last_tile_hit_x,last_tile_hit_y; extern int dev; class level // contain map info and objects { uint16_t *map_fg, // just big 2d arrays *map_bg, bg_width,bg_height, fg_width,fg_height; char *Name,*first_name; int32_t total_objs; game_object *first,*first_active,*last; game_object **attack_list; // list of characters for tick which can attack someone int attack_list_size,attack_total; void add_attacker(game_object *who); game_object **target_list; // list of characters for tick which can be attacked int target_list_size,target_total; void add_target(game_object *who); game_object **block_list; // list of characters who can block a character int block_list_size,block_total; void add_block(game_object *who); void remove_block(game_object *who); void remove_all_block(game_object *who); game_object **all_block_list; // list of characters who can block a character or can be hurt int all_block_list_size,all_block_total; void add_all_block(game_object *who); uint32_t ctick; public : char *original_name() { if (first_name) return first_name; else return Name; } uint32_t tick_counter() { return ctick; } void set_tick_counter(uint32_t x); area_controller *area_list; void clear_active_list() { first_active=NULL; } char *name() { return Name; } game_object *attacker(game_object *who); int is_attacker(game_object *who); game_object *main_character(); game_object *first_object() { return first; } game_object *first_active_object() { return first_active; } uint16_t foreground_width() { return fg_width; } uint16_t foreground_height() { return fg_height; } uint16_t background_width() { return bg_width; } uint16_t background_height() { return bg_height; } int load_failed() { return map_fg==NULL; } level(spec_directory *sd, bFILE *fp, char const *lev_name); void load_fail(); level(int width, int height, char const *name); int save(char const *filename, int save_all); // save_all includes player and view information (1 = success) void set_name(char const *name) { Name=strcpy((char *)jrealloc(Name,strlen(name)+1,"map name"),name); } void set_size(int w, int h); void remove_light(light_source *which); void try_pushback(game_object *subject,game_object *target); ~level(); int fg_raised(int x, int y) { CHECK(x>=0 && y>=0 && x=0 && y>=0 && x=0 && y>=0 && x=0 && y=0 && y=0 && y>=0 && x=0 && y>=0 && x