hedgewars/uLandUtils.pas
branchtransitional_engine
changeset 16062 1860852892c0
parent 16055 ce4b50823a95
equal deleted inserted replaced
16061:31cc1e450273 16062:1860852892c0
     2 interface
     2 interface
     3 uses SDLh;
     3 uses SDLh;
     4 
     4 
     5 procedure GenerateOutlineTemplatedLand(featureSize: Longword; seed, templateType: shortstring; dataPath: ansistring);
     5 procedure GenerateOutlineTemplatedLand(featureSize: Longword; seed, templateType: shortstring; dataPath: ansistring);
     6 procedure GenerateWfcTemplatedLand(featureSize: Longword; seed, templateType: shortstring; dataPath: ansistring);
     6 procedure GenerateWfcTemplatedLand(featureSize: Longword; seed, templateType: shortstring; dataPath: ansistring);
       
     7 procedure GenerateMazeLand(featureSize: Longword; seed, templateType: shortstring; dataPath: ansistring);
     7 procedure ResizeLand(width, height: LongWord);
     8 procedure ResizeLand(width, height: LongWord);
     8 procedure DisposeLand();
     9 procedure DisposeLand();
     9 procedure InitWorldEdges();
    10 procedure InitWorldEdges();
    10 
    11 
    11 function  LandGet(y, x: LongInt): Word;
    12 function  LandGet(y, x: LongInt): Word;
    36 procedure land_pixel_set(game_field: pointer; x, y: LongInt; value: Longword); cdecl; external;
    37 procedure land_pixel_set(game_field: pointer; x, y: LongInt; value: Longword); cdecl; external;
    37 function  land_pixel_row(game_field: pointer; row: LongInt): PLongwordArray; cdecl; external;
    38 function  land_pixel_row(game_field: pointer; row: LongInt): PLongwordArray; cdecl; external;
    38 
    39 
    39 function  generate_outline_templated_game_field(feature_size: Longword; seed, template_type, data_path: PChar): pointer; cdecl; external;
    40 function  generate_outline_templated_game_field(feature_size: Longword; seed, template_type, data_path: PChar): pointer; cdecl; external;
    40 function  generate_wfc_templated_game_field(feature_size: Longword; seed, template_type, data_path: PChar): pointer; cdecl; external;
    41 function  generate_wfc_templated_game_field(feature_size: Longword; seed, template_type, data_path: PChar): pointer; cdecl; external;
       
    42 function  generate_maze_game_field(feature_size: Longword; seed, template_type, data_path: PChar): pointer; cdecl; external;
    41 procedure apply_theme(game_field: pointer; data_path, theme_name: PChar); cdecl; external;
    43 procedure apply_theme(game_field: pointer; data_path, theme_name: PChar); cdecl; external;
    42 
    44 
    43 var gameField: pointer;
    45 var gameField: pointer;
    44 
    46 
    45 function  LandGet(y, x: LongInt): Word;
    47 function  LandGet(y, x: LongInt): Word;
   106 begin
   108 begin
   107     seed[byte(seed[0]) + 1]:= #0;
   109     seed[byte(seed[0]) + 1]:= #0;
   108     templateType[byte(templateType[0]) + 1]:= #0;
   110     templateType[byte(templateType[0]) + 1]:= #0;
   109 
   111 
   110     gameField:= generate_wfc_templated_game_field(featureSize, @seed[1], @templateType[1], PChar(dataPath));
   112     gameField:= generate_wfc_templated_game_field(featureSize, @seed[1], @templateType[1], PChar(dataPath));
       
   113     get_game_field_parameters(gameField, LAND_WIDTH, LAND_HEIGHT, playWidth, playHeight);
       
   114 
       
   115     MaxHedgehogs:= 32;
       
   116     hasGirders:= true;
       
   117 
       
   118     leftX:= (LAND_WIDTH - playWidth) div 2;
       
   119     rightX:= Pred(leftX + playWidth);
       
   120     topY:= LAND_HEIGHT - playHeight;
       
   121     cWaterLine:= LAND_HEIGHT;
       
   122 
       
   123     // let's assume those are powers of two
       
   124     LAND_WIDTH_MASK:= not(LAND_WIDTH-1);
       
   125     LAND_HEIGHT_MASK:= not(LAND_HEIGHT-1);
       
   126 
       
   127     SetLength(LandDirty, (LAND_HEIGHT div 32), (LAND_WIDTH div 32));
       
   128 
       
   129     initScreenSpaceVars();
       
   130 end;
       
   131 
       
   132 procedure GenerateMazeLand(featureSize: Longword; seed, templateType: shortstring; dataPath: ansistring);
       
   133 begin
       
   134     seed[byte(seed[0]) + 1]:= #0;
       
   135     templateType[byte(templateType[0]) + 1]:= #0;
       
   136 
       
   137     gameField:= generate_maze_game_field(featureSize, @seed[1], @templateType[1], PChar(dataPath));
   111     get_game_field_parameters(gameField, LAND_WIDTH, LAND_HEIGHT, playWidth, playHeight);
   138     get_game_field_parameters(gameField, LAND_WIDTH, LAND_HEIGHT, playWidth, playHeight);
   112 
   139 
   113     MaxHedgehogs:= 32;
   140     MaxHedgehogs:= 32;
   114     hasGirders:= true;
   141     hasGirders:= true;
   115 
   142