1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
// ------------------------- Blood War RPG source by lanky -------------------------
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, OmegaScreen, OmegaImageList, OmegaSprite,
  OmegaInput, OmegaBitmapFont, uDij, ComCtrls, CommCtrl, pngimage, BackPack,
  Trade, Dialog, Spin, jpeg;
type
  TForm1 = class(TForm)
    OmegaScreen1: TOmegaScreen;
    Timer1: TTimer;
    OmegaSprite1: TOmegaSprite;
    OmegaImageList1: TOmegaImageList;
    OmegaInput1: TOmegaInput;
    Timer2: TTimer;
    OmegaBitmapFont1: TOmegaBitmapFont;
    ProgressBar1: TProgressBar;
    Panel1: TPanel;
    Button1: TButton;
    Button2: TButton;
    Panel2: TPanel;
    Edit1: TEdit;
    Button3: TButton;
    Memo1: TMemo;
    Button4: TButton;
    OmegaBitmapFont2: TOmegaBitmapFont;
    Button5: TButton;
    Panel3: TPanel;
    SpinButton1: TSpinButton;
    SpinButton2: TSpinButton;
    SpinButton3: TSpinButton;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Button6: TButton;
    GroupBox1: TGroupBox;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    OmegaBitmapFont3: TOmegaBitmapFont;
    Label9: TLabel;
    Label10: TLabel;
    Label11: TLabel;
    Image1: TImage;
    Image2: TImage;
    procedure Timer1Timer(Sender: TObject);
    procedure draw;
    procedure DrawPlayerVsEnemy;
    procedure hero;
    procedure wrog;
    procedure wrog_Move(jaki:byte);
    procedure ogien;
    procedure napierdalanka;
    procedure move_Mirror;
    procedure Itemy_Licz;
    procedure cien(Spr: TSprite);
    procedure swiat;
    procedure swiat_k;
    procedure Ai(jaki: byte);
    procedure WczytajGlob(Jaki: byte);
    procedure info;
    procedure Timer2Timer(Sender: TObject);
    procedure siatka;
    procedure RestartGame;
    procedure walka(NumerEnemy: byte);
    procedure Free;
    function konwersja(poz: integer): TPoint;
    function konAi(px,py,ex,ey: integer): string;
    function indeksM_bohatera(x,y: single): single;
    function odleglosc(Enemy: byte): byte;
    function CoWypada(JakiEnemy: byte): byte;  // zwraca jaki item wypada z enemy
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure Button1Click(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    procedure FormKeyUp(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure LvLUp(WhoDie: byte);
    procedure DodajPoziom;
    procedure SpinButton1UpClick(Sender: TObject);
    procedure SpinButton2UpClick(Sender: TObject);
    procedure SpinButton3UpClick(Sender: TObject);
    procedure SpinButton1DownClick(Sender: TObject);
    procedure SpinButton2DownClick(Sender: TObject);
    procedure SpinButton3DownClick(Sender: TObject);
    procedure ShowLabelPoziomUp;
    procedure Button6Click(Sender: TObject);
    procedure StrzalEnemy(OdKogo: byte);
    procedure LoadGame;
    procedure SaveGame;
    function LoadInt(Load: string): SmallInt;
    procedure FormResize(Sender: TObject);
    procedure FormCreate(Sender: TObject);  // zwraca 5 z map5.txt
  private
    { Private declarations }
  public

  end;
type
	 TEnemy = record // swiat_k, CoWypada, Wrog_Move, walka, LvLUp, i w timer kolizja, TForm1.Wrog;
	 obraz: array[0..10] of TSprite;   // Całe sprite enemy
	 bron: array[0..10] of TSprite;    // czym strzela enemy
	 zycie: array[0..10] of SmallInt;  // Hp enemy
	 Atak: array[0..10] of SmallInt;   // Atak Enemy
	 Inne: array[0..10] of SmallInt;   // inne
	 ruch_E: array[0..10] of string;   // stop, left, right itd.
	 trafil: array[0..10] of Boolean;  // czy enemy trafil playera z broni
	 LotKuli: array[0..10] of SmallInt; // co jaki czas ma strzelac enemy
end;

type
	 TPlayer = record
	 Zycie: SmallInt;
	 ZycieMax: SmallInt;
	 Obrona: SmallInt;
	 Atak: SmallInt;
	 Speed: Single;
	 SpeedOld: Single;
	 Kasa: integer;
	 LvL: integer;
	 Exp: Single;
	 ExpMax: SmallInt;
end;

type
	  TPoziomUp = record
	  Atak: byte;
	  Obrona: byte;
	  Hp: byte;
	  Glob: byte;
end;

type
	  TZegar = record
	  First: SmallInt;
	  Last: SmallInt;
	  Total: SmallInt;
end;


var
	  Form1: TForm1;
	  Enemy: TEnemy;
	  Player: TPlayer;
	  PoziomUp: TpoziomUp;
	  Zegar: TZegar;
	  Jaki_Enemy: array[0..10] of Boolean;  // sa oczywiscie false
	  Enemy_Mov: array[0..10] of TPoint;
	  Wojna: array[0..10] of Boolean; // z jakim enemy player sie aktualnie bije
	  Enemy_Mov_Old: array[0..10] of TPoint;
	  PlayerX, PlayerY: integer;
	  Map: array[0..15] of array [0..11] of Byte ; // 0 lub 1-kolizja
	  H: TSprite;       // bohater
	  Fire: TSprite; // fight(walka) fire(chmurka ognia)
	  Sw: array[0..15] of array[0..15] of TSprite;  // warstwa1
	  Sw2: array[0..15] of array[0..15] of TSprite;   // warstwa2
	  ItemsDraw: array[0..15] of array[0..11] of TSprite;  // itemy
	  III: TSprite;
	  CienDraw: array[0..15] of array[0..15] of TSprite;
	  Ruch_H: String;  // strony bohatera (dol, lewo, prawo, gora, stop)
	  Indeks_H: SmallInt; // pokazuje w którym kwadracie znajduje sie bohater
	  ruch: integer;
	  Kolizja: Boolean;
	  Siat: Boolean;   // siatka mapy
	  MapaKolizji : set of Byte; // kolizja mapy

	  Itt: array[0..100] of array[0..191] of SmallInt;   // przechowuje nazwe itemow
	  MapBol: array[0..100] of Boolean;  // do itemow
	  DelItems: array[0..100]of array[0..15]of array[0..15]of byte; //1-nazwa mapy, 2-PozycjaX, 3-PozycjaY 
          //(Pokazuje jakie itemy znikneły z mapy)
	  ZbiorDrawUp: set of byte;  //draw 2 warstwy Up
	  Load : string;    //mapa1.txt, mapa2.txt itd.
	  S: TStringList;
	  S2: TStringList;
	  IT: TStringList;
	  Global_X, Global_Y: array[0..4] of SmallInt;   // pozycja globalnej Mapy  (5 poziomów)
	  Poziom: byte; // poziomy mapy
	  PosP: SmallInt; // pozycja obecnej klatki bohatera
	  posE: array[0..10] of byte; // pozycja obecnej klatki Enemy
	  old: SmallInt; // pozycja wczesniejszej klatki bohatera
	  inv: byte;
	  klik: array[0..10] of byte;
	  klik2: SmallInt;
	  CC: array[0..10] of byte;
	  nn, oo: byte;
	  Fight: Boolean;
	  KeySpace: Boolean;
	  Han : Thandle;
	  Stream : TResourceStream;
	  Png: TPngObject;
implementation

{$R *.dfm}

procedure TForm1.hero;
begin
	H:= Tsprite.Create(OmegaSprite1);
	H.Image:= OmegaImageList1.ImageList.Items[0];
	H.X:= 250;
	H.Y:= 50;
	H.ScaleX:=0.8;
	H.ScaleY:=0.8;
	PlayerX:= 5;
	PlayerY:= 2;
	Player.zycie:= 1000;
	Player.ZycieMax:= 1000;
	Player.Atak:= 0;
	Player.Obrona:= 0;
	Player.Speed:= 1.4;
	Player.SpeedOld:= Player.Speed;
	Player.Kasa:= 0;
	Player.ExpMax:= 70;
	ProgressBar1.Top:= Form1.Height-48;
	ProgressBar1.Min:= 0;
	ProgressBar1.Max:= 1000;
	ProgressBar1.Position:= Player.zycie;
end;

function TForm1.indeksM_bohatera(x, y: single): single;
begin         // pokazuje na jakiej pozycji znajduje sie hero
	y:= y / 48+ 0.3; // + Kor_Y ;

	if y > 1 then x:= x+ 768;  // 48*15
	if y > 2 then x:= x+ 768;
	if y > 3 then x:= x+ 768;
	if y > 4 then x:= x+ 768;
	if y > 5 then x:= x+ 768;
	if y > 6 then x:= x+ 768;
	if y > 7 then x:= x+ 768;
	if y > 8 then x:= x+ 768;
	if y > 9 then x:= x+ 768;
	if y > 10 then x:= x+ 768;
	if y > 11 then x:= x+ 768;

	Result:= x / 48; // + Kor_X;    // +0.5 jak w lewo
end;

procedure TForm1.siatka;
var
y,x: integer;
begin
	for y:=0 to 15 do
	OmegaScreen1.LineV(y*48,0,600,0,0,0,1);  // y
	for x:=0 to 11 do
	OmegaScreen1.LineH(0,800,x*48,0,0,0,1);  // x
end;

procedure TForm1.swiat; ///////////////////// Swiat \\\\\\\\\\\\\\\\\\\
var
x,y,z,inx : SmallInt;
NazwaMapy: String;
NazwaItemow: String;

begin
	Zegar.First:= GetTickCount;
	Bonus.TempDown:= 0;
	Player.Speed:= Player.SpeedOld;

	S:= TStringList.Create;    // warstwa 1
	//S2:= TStringList.Create;   // warstwa 2
	//IT:= TStringList.Create;    // itemy

	S.LoadFromFile(Load);
	//S.LoadFromStream();
	//Load_W2:= Load;
	//Load_W2[1]:= 'w';
	//S2.LoadFromFile(Load_W2);
	//IT.LoadFromFile('iapa1.txt');

	NazwaMapy:= S.Strings[192];   //nazwy bmp mapy
	NazwaItemow:= S.Strings[577];  // nazwa bmp itemow
	inx:= 0;
	OmegaImageList1.ImageList.Items[1].CleanupInstance;   // warstwy
	OmegaImageList1.ImageList.Add;
	OmegaImageList1.ImageList.Items[1].Picture.LoadFromFile(NazwaMapy);
	OmegaImageList1.ImageList.Items[1].Init;
	OmegaImageList1.ImageList.Items[2].CleanupInstance; // itemy
	OmegaImageList1.ImageList.Add;
	Stream := TResourceStream.Create(Han, NazwaItemow, RT_RCDATA); // itemy
	Png.LoadFromStream(Stream);
	OmegaImageList1.ImageList.Items[2].Picture.Graphic:= Png;
	//OmegaImageList1.ImageList.Items[2].Picture.LoadFromFile(NazwaItemow);
	OmegaImageList1.ImageList.Items[2].Init;
	//ShowMessage(NazwaMapy);

	for y:=0 to 11 do
	for x:=0 to 15 do
	begin
                SW[X,Y].Free;
		SW2[X,Y].Free;
		CienDraw[X,Y].Free;
		ItemsDraw[X,Y].Free;
		III.Free;

		SW[X,Y]:= TSprite.Create(OmegaSprite1);
		SW2[X,Y]:= TSprite.Create(OmegaSprite1);
		CienDraw[X,Y]:= TSprite.Create(OmegaSprite1);
		ItemsDraw[X,Y]:= TSprite.Create(OmegaSprite1);
		III:= TSprite.Create(OmegaSprite1);
		SW[X,Y].Image:= OmegaImageList1.ImageList.Items[1];
		SW2[X,Y].Image:= OmegaImageList1.ImageList.Items[1];
		CienDraw[X,Y].Image:= OmegaImageList1.ImageList.Items[1];
		ItemsDraw[X,Y].Image:= OmegaImageList1.ImageList.Items[2];
		III.Image:= OmegaImageList1.ImageList.Items[2];
		SW[X,Y].ImageIndex:= StrToInt(S.Strings[inx]);
		CienDraw[X,Y].ImageIndex:= 33;
		CienDraw[X,Y].Visible:=False; //w swiat_k wybrane kafle dajemy na true;
		SW2[X,Y].ImageIndex:= StrToInt(S.Strings[inx+193]);
		if S.Strings[inx+193] = '0' then SW2[X,Y].Visible:= False;
		ItemsDraw[X,Y].ImageIndex:=  StrToInt(S.Strings[inx+385]);
		if S.Strings[inx+385] = '0' then ItemsDraw[X,Y].Visible:= False;

		for z:=0 to 191 do ITT[100][z]:= 0; // czyscimy tymczasowe itemy
		// aby po ponownym wejsciu na mape tymczasowe itemy poznikały)

		{for z:=1 to 50 do  // mapy(1-50)
		if Load = 'mapa'+IntToStr(z)+'.txt' then if DelItems[z][X,Y] = 1 then ItemsDraw[X,Y].Visible:= False; }
		if DelItems[LoadInt(Load)][X,Y]= 1 then ItemsDraw[X,Y].Visible:= False;
		SW[X,Y].X := x*48;
		SW[X,Y].Y := y*48;
		SW2[X,Y].X := x*48;
		SW2[X,Y].Y := y*48;
		ItemsDraw[X,Y].X := x*48;
		ItemsDraw[X,Y].Y := y*48;
		CienDraw[X,Y].X := x*48;
		CienDraw[X,Y].Y := y*48;
		CienDraw[X,Y].Alpha:= 120;
		inc(inx);
	end;

end;