Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int virtual_map[114]; //nine dmaps screen, x, y, left_bound, rightbound, topbound, bottombound* dmaps];
- const int DMAP1 = 0;
- const int DMAP_COLS = 12;
- //start ( dmap, start screen, screen_left, screen_right, screen_up, screen_down, dma_left, dmap_right, dmap_down, dmap_up, x, y ) * dmap count
- int virtualmap_dmap-connections[numdmaps];
- //Call in init script to set up all the boundaries, dest screens, and so forth.
- void SetMapBound(int ptr, int type, int screen, bool wrapdmap, int wrapto){
- //Set the screen that is the left most, and the screen on the right of the dmap to wrap into.
- //If we are wrapping to another dmap, we need to know it.
- if ( type == BOUND_LEFT ) {
- //We need to automatically set up wraps to dmaps using GetWrapDMap()
- ptr[FLF_MAP_BOUND_LEFT = screen; //the screen at which we start the wrap
- ptr[FLF_MAP_BOUND_LEFT_WRAPTO_SCREEN] = wrapto; //the screen at which we end the map
- if ( wrapdmap ) ptr[FLF_MAP_BOUND_LEFT_WRAPTO_DMAP] = GetWrapDMap(Game->GetCurDMap(DIR_LEFT); //the dmap on which we end the wrap.
- ptr[FLF_X] = 255; //We wrapped left from x=0, so we wrap to x = 255.
- }
- if ( type == BOUND_RIGHT ) {
- ptr[FLF_MAP_BOUND_RIGHT = screen; //the screen at which we start the wrap
- ptr[FLF_MAP_BOUND_RIGHT_WRAPTO_SCREEN] = wrapto; //the screen at which we end the map
- if ( wrapdmap ) ptr[FLF_MAP_BOUND_RIGHT_WRAPTO_DMAP] = GetWrapDMap(Game->GetCurDMap(DIR_RIGHT); //the dmap on which we end the wrap.
- ptr[FLF_X] = 0; //We wrapped left from x=255, so we wrap to x = 0.
- }
- if ( type == BOUND_UP ) {
- ptr[FLF_MAP_BOUND_UP = screen; //the screen at which we start the wrap
- ptr[FLF_MAP_BOUND_UP_WRAPTO_SCREEN] = wrapto; //the screen at which we end the map
- if ( wrapdmap != -1 ) ptr[FLF_MAP_BOUND_UP_WRAPTO_DMAP] = GetWrapDMap(Game->GetCurDMap(DIR_UP); //the dmap on which we end the wrap.
- ptr[FLF_Y] = 175; //We wrapped left from y=0, so we wrap to Y = 175.
- }
- if ( type == BOUND_DOWN ) {
- ptr[FLF_MAP_BOUND_DOWN = screen; //the screen at which we start the wrap
- ptr[FLF_MAP_BOUND_DOWN_WRAPTO_SCREEN] = wrapto; //the screen at which we end the map
- if ( wrapdmap != -1 ) ptr[FLF_MAP_BOUND_DOWN_WRAPTO_DMAP] = GetWrapDMap(Game->GetCurDMap(DIR_DOWN); //the dmap on which we end the wrap.
- ptr[FLF_Y] = 0; //We wrapped left from y=175, so we wrap to Y = 0.
- }
- }
- /*
- int WrapDMap(int dmap){
- int dmap = Game->GetCurDMap();
- //checck ths table to see if we are on the edge of a dmap and wrappinf to another one,
- //if so, return its value
- //otherwise, return the current dmap.
- int dmap1[128]={
- 0,0,0,0,0,0
- }
- */
- const int DMAP_COLS = 4; //Actual columns
- const int DMAP_ROWS = 4; //Actual rows
- int GetWrapDMap(int source, int dir){
- int virtual_dmaps[ (4_dirs +1 )* NumDMaps] {
- //Layout of the world by DMap IDs.
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- //Left position from each
- 3, 0, 1, 2,
- 7, 4, 5, 6,
- 11, 8, 9, 10,
- 15, 12, 13, 14,
- //Right position from each
- 1, 2, 3, 0,
- 5, 6, 7, 4,
- 9, 10, 11, 8,
- 13, 14, 15, 12,
- //Down position from each
- 4, 5, 6, 7,
- 8, 9, 10, 11,
- 12, 13, 14, 15,
- 0, 1, 2, 3,
- //Up position from each
- 12, 13, 14, 15,
- 0, 1, 2, 3,
- 8, 9, 10, 11,
- 7, 8, 9, 10,
- }
- if ( dir == DIR_LEFT ) return [virtual_dmaps[pos+((DMAP_COLS*DMAP_ROWS)*1)];
- if ( dir == DIR_RIGHT ) return [virtual_dmaps[pos+((DMAP_COLS*DMAP_ROWS)*2)];
- if ( dir == DIR_DOWN ) return [virtual_dmaps[pos+((DMAP_COLS*DMAP_ROWS)*3)];
- if ( dir == DIR_UP ) return [virtual_dmaps[pos+((DMAP_COLS*DMAP_ROWS)*4)];
- return -1;//Error
- }
- int Fortresses[27]; //tmer, dir, speed, x, y, dmap, screen
- const int FORTRESS_TIMER = 0;
- const int FORTRESS_DIR = 1;
- const int FORTRESS_SPEED = 2;
- const int FORTRESS_X = 3;
- const int FORTRESS_Y = 4;
- const int FORTRESS_DMAP_ID = 5;
- const int FORTRESS_SCREEN_ID = 6;
- const int FORTRESS_DMAP_OFFSET = 7; // Multiply this * Fortress ID, then add element.
- const int NUM_FORTRESSES = 9;
- const int FORTRESS_MOVE_TMER_MIN = 120;
- const int FORTRESS_MOVE_TMER_MAX = 400;
- const int FORTRESS_MOVE_DIST_MIN = 6;
- const int FORTRESS_MOVE_DIST_MAX = 14;
- void SetFortressTimers(int ptr){
- nt sz = SzeOfArray(ptr);
- for ( int q = 0; q < sz; q += NUM_FORTRESSES ) ptr[q] = Rand(FORTRESS_MOVE_TMER_MIN,FORTRESS_MOVE_TMER_MAX);
- }
- void DoFortressTmers(int ptr){
- int sz = SizeOfArray(ptr);
- for ( int q = 0; q < sz; q += NUM_FORTRESSES ) {
- if ( ptr[q] <= 0 ) { MoveFortress(q); ptr[q] = Rand(FORTRESS_MOVE_TMER_MIN,FORTRESS_MOVE_TMER_MAX); }
- else ptr[q]--;
- }
- }
- int MoveFortressDir(int ptr) {
- int dirs[4] = {UP, DOWN, LEFT, RIGHT};
- int dir = dirs[Rand(0,4)]; //What about angles?
- //
- }
- //If our DMap is square, this part is easier.
- int virtual_maps[]={ 0, 0x1F, 0, 0x1F,
- 0, 0x1F, 0, 0x1F,
- 0, 0x1F, 0, 0x1F,
- 0, 0x1F, 0, 0x1F,
- 0, 0x1F, 0, 0x1F,
- 0, 0x1F, 0, 0x1F,
- 0, 0x1F, 0, 0x1F,
- 0, 0x1F, 0, 0x1F,
- 0, 0x1F, 0, 0x1F,
- }; //Topleft, Topright, BottomLeft, BottomRight Screen IDs
- //! THis function is Not finished
- //Boundary Screen?
- bool FortressAtDMapBoundary(int fortress_id, int virtual_map, int offset){
- //Map out the screens of this DMap.
- int map[4];
- for ( int q = 0; q < 3; q++ ) {
- map[q] = virtual_map[(offset*4)+q];
- }
- int edges[4];
- if ( FortressScreen(fortress_id) % map[0] == 0 ) edges[0] = 1; //on left side of dmap. //Will this work of the DMap has an offset???
- //Decide which screens are dmap boundaries.
- //If the fortress is on one of these screens, return true.
- }
- //! Let's hardcode some DMAPS! Z
- const int FF_DMAP_SCREEN_VALID = 0;
- const int FF_DMAP_SCREEN_INVALID = -1;
- const int FF_DMAP_SCREEN_BOUNDARY = 1; //1 or higher is a screen boundary.
- //A virtual DMap. 0s are empty space, 1s are screens, 2s are boundaries.
- //Should each edge and corner be a unique value
- /*
- -1 empty space
- 0 has sceens on each side
- 1 cannot turn up
- 2 cannot turn down
- 4 cannot turn right
- 8 cannot turn up
- */
- const int NOT_VALID_SCREEN = -1;
- const int CANNOT_TURN_UP = 1;
- const int CANNOT_TURN_DOWN = 2;
- const int CANNOT_TURN_RIGHT = 4;
- const int CANNOT_TURN_LEFT = 8;
- //A virtual map with the edges marked.
- int virtual_map_1[]={
- 9,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,
- 8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,
- 8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,
- 8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,
- 8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,
- 8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,
- 8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,
- 10,2,2,2,2,2,2,2,2,2,2,2,2,2,2,6 }
- //Determines a random, legal directions, based on values on a vritual map.
- int FindLegalTurn(int virtual_map, int screen){
- if ( virtual_map[screen] == 1 ) { //cannot turn up
- return ( Choose(DIR_RIGHT, DIR_LEFT, DIR_DOWN) );
- }
- if ( virtual_map[screen] == 2 ) { //cannot tuen down
- return ( Choose(DIR_RIGHT, DIR_LEFT, DIR_UP) );
- }
- if ( virtual_map[screen] == 4 ) { //cannot turn right
- return ( Choose(DIR_LEFT, DIR_DOWN, DIR_UP) );
- }
- if ( virtual_map[screen] == 5 ) { //cannot turn up or right
- return ( Choose(DIR_DOWN, DIR_LEFT) );
- }
- if ( virtual_map[screen] == 6 ) { //cannot turn down or right
- return ( Choose(DIR_UP, DIR_LEFT) );
- }
- if ( virtual_map[screen] == 8 ) { //cannot turn left
- return ( Choose(DIR_RIGHT, DIR_DOWN, DIR_UP) );
- }
- if ( virtual_map[screen] == 9 ) { //cannot turn left or up
- return ( Choose(DIR_RIGHT, DIR_DOWN) );
- }
- if ( virtual_map[screen] == 10 ) { //cannot turn left or down
- return ( Choose(DIR_RIGHT, DIR_UP) );
- }
- return Rand(0,3); //Otherwise, return a random direction.
- }
- int virtual_map_0[]={
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
- //Edge of Boundary Screen
- bool FortressAtDMapEdge(int virtual_map){
- }
- const int FORTRESS_WIDTH = 8; //Sprite dimensions.
- const int FORTRESS_HEIGHT = 8;
- const int FORTRESS_Z_LOCATION = 100; //must match this Z to enter.
- bool FortressAtScreenEdge(int fortress_id, int dir){
- if ( dir == DIR_LEFT && FottressX(fortress_id) <= 0+FORTRESS_WIDTH ) return true;
- if ( dir == DIR_RIGHT && FortressX(fortress_id) >= 256 ) return true;
- if ( dir == DIR_UP && FortressY(fortress_id)+FORTRESS_HEIGHT < 0 ) return true;
- if ( dir == DIR_DOWN && FortrwessY(fortress_id) >= 176 ) return true;
- return false;
- }
- bool TurnFortress(int fortress_id) {
- if ( ( FortressAtScreenEdge(fortres_id), FortressDir(fortress_id) ) || FortressTimer(fortress_id) <= 0 ) {
- //Choose a direction other than the present diretion.
- int dir;
- do { //Pick a random direction that differs from this direction.
- dir = Rand(0,7);
- } while ( dir != FortressDir(fortress_id);
- FortressDir(fortress_id, dir); //Change the direction.
- }
- }
- int FortressX(int fort_id){ return Fortresses[(FORTRESS_DMAP_OFFSET*fort_id)+FORTRESS_X]; }
- int FortressY(int fort_id){ return Fortresses[(FORTRESS_DMAP_OFFSET*fort_id)+FORTRESS_Y]; }
- int FortressDir(int fort_id){ return Fortresses[(FORTRESS_DMAP_OFFSET*fort_id)+FORTRESS_DIR]; }
- int FortressSpeed(int fort_id){ return Fortresses[(FORTRESS_DMAP_OFFSET*fort_id)+FORTRESS_SPEED]; }
- int FortressDMap(int fort_id){ return Fortresses[(FORTRESS_DMAP_OFFSET*fort_id)+FORTRESS_DMAP_ID]; }
- int FortressScreen(int fort_id){ return Fortresses[(FORTRESS_DMAP_OFFSET*fort_id)+FORTRESS_SCREEN_ID]; }
- int FortressTimer(int fort_id){ return Fortresses[(FORTRESS_DMAP_OFFSET*fort_id)+FORTRESS_TIMER]; }
- void FortressX(int fort_id, int v){ return Fortresses[(FORTRESS_DMAP_OFFSET*fort_id)+FORTRESS_X] = VBound(v,0,255); }
- void FortressY(int fort_id, int v){ return Fortresses[(FORTRESS_DMAP_OFFSET*fort_id)+FORTRESS_Y] = VBound(v,0,175); }
- void FortressDir(int fort_id, int v){ Fortresses[(FORTRESS_DMAP_OFFSET*fort_id)+FORTRESS_DIR] = VBound(v,0,7); }
- void FortressSpeed(int fort_id, int v){ Fortresses[(FORTRESS_DMAP_OFFSET*fort_id)+FORTRESS_SPEED] = Abs(v); }
- void FortressDMap(int fort_id, int v){ Fortresses[(FORTRESS_DMAP_OFFSET*fort_id)+FORTRESS_DMAP_ID] = v; }
- void FortressScreen(int fort_id, int v){ Fortresses[(FORTRESS_DMAP_OFFSET*fort_id)+FORTRESS_SCREEN_ID] = VBound(v,0,255); }
- void FortressTimer(int fort_id, int v){ Fortresses[(FORTRESS_DMAP_OFFSET*fort_id)+FORTRESS_TIMER] = Abs(v); }
- //Set the turn timer.
- int FortressTime(int time_min, time_max, int frac_time, int frac_max){
- int t = Rand(time_min,time_max); int tt = (Rand(frac_time, frac_max) / 1000);
- Return (t+tt)*60;
- }
- int MoveForetressSpeed()
- void MoveFortress(int ptr){
- int distx = Rand(FORTRESS_MOVE_DIST_MIN, FORTRESS_MOVE_DIST_MAX);
- int disty = Rand(FORTRESS_MOVE_DIST_MIN, FORTRESS_MOVE_DIST_MAX);
- bool neg = RandB();
- if ( neg )
- //Avoid jiter somehow?
- }
- void MoveFortress(int id)}
- const int FLF_MAP_
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement