Skip to content

Commit

Permalink
Day 3.
Browse files Browse the repository at this point in the history
  • Loading branch information
devapromix committed Mar 5, 2018
1 parent 6ca544d commit 50f600f
Show file tree
Hide file tree
Showing 18 changed files with 551 additions and 86 deletions.
3 changes: 2 additions & 1 deletion CLEAN.bat
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ del /s *.otares
del /s *.local
del /s *.cfg
del /s *.ddp
del /s *.o
del /s *.a
del /S *.*proj.local
del /S *.tvsconfig
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,31 @@
Simple roguelike game based on Disciples.

## Screenshots
### Day 1
### Day 1 [3.03.2018]

![screenshot](https://github.com/devapromix-roguelikes/disciplesrl/blob/master/screenshots/screenshot_day_1.png)

### Day 2
### Day 2 [4.03.2018]

![screenshot](https://github.com/devapromix-roguelikes/disciplesrl/blob/master/screenshots/screenshot_day_2.png)

### Day 3
### Day 3 [5.03.2018]

![screenshot](https://github.com/devapromix-roguelikes/disciplesrl/blob/master/screenshots/screenshot_day_3.png)

### Day 4
### Day 4 [6.03.2018]

![screenshot](https://github.com/devapromix-roguelikes/disciplesrl/blob/master/screenshots/screenshot_day_4.png)

### Day 5
### Day 5 [7.03.2018]

![screenshot](https://github.com/devapromix-roguelikes/disciplesrl/blob/master/screenshots/screenshot_day_5.png)

### Day 6
### Day 6 [8.03.2018]

![screenshot](https://github.com/devapromix-roguelikes/disciplesrl/blob/master/screenshots/screenshot_day_6.png)

### Day 7
### Day 7 [9.03.2018]

![screenshot](https://github.com/devapromix-roguelikes/disciplesrl/blob/master/screenshots/screenshot_day_7.png)

Expand Down
Binary file modified resources/chest.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/dirt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/mountain.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/screenshot_day_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
121 changes: 121 additions & 0 deletions sources/DisciplesRL.City.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
unit DisciplesRL.City;

interface

uses DisciplesRL.Party;

type
TCity = record
X, Y: Integer;
CurLevel: Integer;
MaxLevel: Integer;
Owner: TRaceEnum;
end;

var
City: array [0 .. 3] of TCity;

procedure Init;
function GetCityIndex(const AX, AY: Integer): Integer;
procedure UpdateRadius(const AID: Integer);
procedure Gen;

implementation

uses System.Math, DisciplesRL.Map, DisciplesRL.Resources, DisciplesRL.Utils, DisciplesRL.Player;

procedure Init;
var
I: Integer;
begin
for I := 0 to High(City) do
begin
City[I].X := 0;
City[I].Y := 0;
City[I].CurLevel := 0;
City[I].MaxLevel := 2;
City[I].Owner := reNeutrals;
end;
end;

function GetCityIndex(const AX, AY: Integer): Integer;
var
I: Integer;
begin
Result := -1;
for I := 0 to High(City) do
if ((City[I].X = AX) and (City[I].Y = AY)) then
begin
Result := I;
Break;
end;
end;

procedure UpdateRadius(const AID: Integer);
begin
DisciplesRL.Map.UpdateRadius(City[AID].X, City[AID].Y, City[AID].CurLevel, MapTile, reEmpireTerrain,
[reEmpireCity, reNeutralCity, reEmpireCapital]);
DisciplesRL.Map.UpdateRadius(City[AID].X, City[AID].Y, City[AID].CurLevel, MapDark, reNone);
City[AID].Owner := reTheEmpire;
end;

function ChCity(N: Integer): Boolean;
var
I: Integer;
begin
Result := True;
if (N = 0) then
Exit;
for I := 0 to N - 1 do
begin
if (GetDist(City[I].X, City[I].Y, City[N].X, City[N].Y) <= 6) then
begin
Result := False;
Exit;
end;
end;
end;

procedure ClearObj(const AX, AY: Integer);
var
X, Y: Integer;
begin
for X := AX - 2 to AX + 2 do
for Y := AY - 2 to AY + 2 do
if (X = AX - 2) or (X = AX + 2) or (Y = AY - 2) or (Y = AY + 2) then
begin
if (RandomRange(0, 5) = 0) then
MapObj[X, Y] := reNone
end
else
MapObj[X, Y] := reNone;
end;

procedure Gen;
var
I, X, Y: Integer;
begin
for I := 0 to High(City) do
begin
repeat
City[I].X := RandomRange(3, MapWidth - 3);
City[I].Y := RandomRange(3, MapHeight - 3);
until ChCity(I);
// Capital
if (I = 0) then
begin
Player.X := City[I].X;
Player.Y := City[I].Y;
MapTile[City[I].X, City[I].Y] := reEmpireCapital;
ClearObj(City[I].X, City[I].Y);
UpdateRadius(I);
Continue;
end;
// City
MapTile[City[I].X, City[I].Y] := reNeutralCity;
ClearObj(City[I].X, City[I].Y);
MapObj[City[I].X, City[I].Y] := reEnemies;
end;
end;

end.
6 changes: 4 additions & 2 deletions sources/DisciplesRL.MainForm.dfm
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
object MainForm: TMainForm
Left = 0
Top = 0
BorderIcons = [biSystemMenu, biMinimize]
BorderStyle = bsSingle
Caption = 'DisciplesRL'
ClientHeight = 492
ClientWidth = 1057
ClientHeight = 596
ClientWidth = 795
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Expand Down
7 changes: 6 additions & 1 deletion sources/DisciplesRL.MainForm.pas
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,18 @@ implementation

procedure TMainForm.FormCreate(Sender: TObject);
begin
Top := 0;
Left := 0;
Randomize;
DisciplesRL.Scenes.Init;
// Test
DisciplesRL.Resources.Init;
DisciplesRL.Map.Init;
DisciplesRL.Map.Gen;
DisciplesRL.Player.Init;
//
ClientWidth := MapWidth * TileSize;
ClientHeight := MapHeight * TileSize;
DisciplesRL.Scenes.Init;
end;

procedure TMainForm.FormPaint(Sender: TObject);
Expand Down
102 changes: 78 additions & 24 deletions sources/DisciplesRL.Map.pas
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,35 @@ interface
uses DisciplesRL.Resources;

var
MapWidth: Integer = 20;
MapHeight: Integer = 12;
MapWidth: Integer = 40;
MapHeight: Integer = 20;

const
TileSize = 32;

type
TLayerEnum = (lTile, lPath, lDark);
TLayerEnum = (lrTile, lrPath, lrDark, lrObj);

type
TMapLayer = array of array of TResEnum;
TIgnoreRes = set of TResEnum;

var
MapTile: array of array of TResEnum;
MapPath: array of array of TResEnum;
MapDark: array of array of TResEnum;
MapTile: TMapLayer;
MapPath: TMapLayer;
MapDark: TMapLayer;
MapObj: TMapLayer;

procedure Init;
procedure Clear(const L: TLayerEnum);
procedure Gen;
function InMap(X, Y: Integer): Boolean;
procedure UpdateRadius(const AX, AY, AR: Integer; var MapLayer: TMapLayer; const AResEnum: TResEnum;
IgnoreRes: TIgnoreRes = []);

implementation

uses System.Math, DisciplesRL.Player;
uses System.Math, DisciplesRL.Player, DisciplesRL.Utils, DisciplesRL.City, DisciplesRL.PathFind;

procedure Init;
var
Expand All @@ -35,8 +42,10 @@ procedure Init;
SetLength(MapTile, MapWidth, MapHeight);
SetLength(MapPath, MapWidth, MapHeight);
SetLength(MapDark, MapWidth, MapHeight);
SetLength(MapObj, MapWidth, MapHeight);
for L := Low(TLayerEnum) to High(TLayerEnum) do
Clear(L);
DisciplesRL.City.Init;
end;

procedure Clear(const L: TLayerEnum);
Expand All @@ -46,39 +55,84 @@ procedure Clear(const L: TLayerEnum);
for Y := 0 to MapHeight - 1 do
for X := 0 to MapWidth - 1 do
case L of
lTile:
lrTile:
MapTile[X, Y] := reNone;
lPath:
lrPath:
MapPath[X, Y] := reNone;
lDark:
lrDark:
MapDark[X, Y] := reDark;
lrObj:
MapObj[X, Y] := reNone;
end;
end;

function ChTile(X, Y: Integer): Boolean; stdcall;
begin
Result := True;
end;

procedure Gen;
var
X, Y: Integer;
X, Y, RX, RY, I: Integer;
begin
for Y := 0 to MapHeight - 1 do
for X := 0 to MapWidth - 1 do
MapTile[X, Y] := reGrass;
for X := 0 to 7 do
MapTile[RandomRange(0, MapWidth), RandomRange(0, MapHeight)] := reEnemies;
for X := 0 to 5 do
MapTile[RandomRange(0, MapWidth), RandomRange(0, MapHeight)] := reBag;
for X := 0 to 3 do
MapTile[RandomRange(0, MapWidth), RandomRange(0, MapHeight)] := reCity;
// Player
X := RandomRange(0, MapWidth);
Y := RandomRange(0, MapHeight);
MapTile[X, Y] := reCapital;
Player.X := X;
Player.Y := Y;
begin
MapTile[X, Y] := reNeutral;
MapObj[X, Y] := reMountain;
end;
// Bags
// for X := 0 to 5 do
// MapObj[RandomRange(0, MapWidth), RandomRange(0, MapHeight)] := reBag;
// Capital and Cities
DisciplesRL.City.Gen;
X := City[0].X;
Y := City[0].Y;
for I := 1 to High(City) do
repeat
if PathFind(X, Y, City[I].X, City[I].Y, ChTile, RX, RY) then
begin
// if (RandomRange(0, 2) = 0) then
begin
X := RX + RandomRange(-1, 2);
Y := RY + RandomRange(-1, 2);
if MapObj[X, Y] = reMountain then
MapObj[X, Y] := reNone;
end;
X := RX;
Y := RY;
if MapObj[X, Y] = reMountain then
MapObj[X, Y] := reNone;
end;
until ((X = City[I].X) and (Y = City[I].Y));
// Enemies
for I := 0 to High(City) do
begin
repeat
X := RandomRange(1, MapWidth - 1);
Y := RandomRange(1, MapHeight - 1);
until (MapObj[X, Y] = reNone);
MapObj[X, Y] := reEnemies;
end;
end;

function InMap(X, Y: Integer): Boolean;
begin
Result := (X >= 0) and (X < MapWidth) and (Y >= 0) and (Y < MapHeight);
end;

procedure UpdateRadius(const AX, AY, AR: Integer; var MapLayer: TMapLayer; const AResEnum: TResEnum;
IgnoreRes: TIgnoreRes = []);
var
X, Y: Integer;
begin
for Y := -AR to AR do
for X := -AR to AR do
if (GetDist(AX + X, AY + Y, AX, AY) <= AR) and DisciplesRL.Map.InMap(AX + X, AY + Y) then
if (MapLayer[AX + X, AY + Y] in IgnoreRes) then
Continue
else
MapLayer[AX + X, AY + Y] := AResEnum;
end;

end.
Loading

0 comments on commit 50f600f

Please sign in to comment.