DEADSOFTWARE

Rewrited module for particles
authorDeaDDooMER <deaddoomer@deadsoftware.ru>
Fri, 8 Sep 2017 18:20:19 +0000 (21:20 +0300)
committerDeaDDooMER <deaddoomer@deadsoftware.ru>
Fri, 8 Sep 2017 18:20:19 +0000 (21:20 +0300)
BUGS
libs/Lib_particles_store.class [deleted file]
libs/Lib_particles_store.java [deleted file]
src/CAVE.mpsrc
src/Mobs.pas [moved from src/mobs.pas with 100% similarity]
src/Particles.mpsrc [new file with mode: 0644]
src/Phy.pas [moved from src/phy.pas with 100% similarity]
src/Player.mpsrc [moved from src/player.mpsrc with 95% similarity]
src/console.pas
src/items_logic.mpsrc
src/particles.mpsrc [deleted file]

diff --git a/BUGS b/BUGS
index d57ab45883f859ba3a04f41ac81ddda75ef85f37..cd5974ed4ef73cd5832d78c1d2d36c57a3a7099f 100644 (file)
--- a/BUGS
+++ b/BUGS
 - Предметы не сгорают в лаве (и никогда не сгорали, но всё же)
 - Не сбрасывается анимация игрока при старте новой игры
 - Кактусы не убивают
 - Предметы не сгорают в лаве (и никогда не сгорали, но всё же)
 - Не сбрасывается анимация игрока при старте новой игры
 - Кактусы не убивают
+- Динамит не взравется - просто мигает
 
 - Запилить блочный формат сохранений с переменным числом записей и версионированием блоков.
 - Перепроверить генерацию предметов в cокровищницах
 
 - Запилить блочный формат сохранений с переменным числом записей и версионированием блоков.
 - Перепроверить генерацию предметов в cокровищницах
-- Перепроверить рост деревьев
+- Перепроверить рост деревьев -- cм items_logic.updateBlock -> *_RND
 
 - Курсор на ремне должен быть чётче
 - В бете 8 была поддержка звука, надо вернуть.
 
 - Курсор на ремне должен быть чётче
 - В бете 8 была поддержка звука, надо вернуть.
diff --git a/libs/Lib_particles_store.class b/libs/Lib_particles_store.class
deleted file mode 100644 (file)
index 53fce20..0000000
Binary files a/libs/Lib_particles_store.class and /dev/null differ
diff --git a/libs/Lib_particles_store.java b/libs/Lib_particles_store.java
deleted file mode 100644 (file)
index 606d3df..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-class Lib_particles_store\r
- {\r
-  static byte[] particle_type;\r
-  static byte[] particle_ani;\r
-  static short[] particle_x;\r
-  static short[] particle_y;\r
-\r
-  public static void reset_particles(int len)\r
-   {\r
-    particle_type = new byte[len];\r
-    particle_ani = new byte[len];\r
-    particle_x = new short[len];\r
-    particle_y = new short[len];\r
-   }\r
-\r
-  public static void set_particle(int id, int type, int ani, int x, int y)\r
-   {\r
-    particle_type[id] = (byte) type;\r
-    particle_ani[id] = (byte) ani;\r
-    particle_x[id] = (short) x;\r
-    particle_y[id] = (short) y;\r
-   }\r
-\r
-  public static void set_particle_type(int id, int type)\r
-   {\r
-    particle_type[id] = (byte) type;\r
-   }\r
-\r
-  public static void set_particle_ani(int id, int ani)\r
-   {\r
-    particle_ani[id] = (byte) ani;\r
-   }\r
-\r
-  public static void set_particle_x(int id, int x)\r
-   {\r
-    particle_x[id] = (short) x;\r
-   }\r
-\r
-  public static void set_particle_y(int id, int y)\r
-   {\r
-    particle_y[id] = (short) y;\r
-   }\r
-\r
-  public static int get_particle_type(int id)\r
-   {\r
-    return particle_type[id] & 0xFF;\r
-   }\r
-\r
-  public static int get_particle_ani(int id)\r
-   {\r
-    return particle_ani[id] & 0xFF;\r
-   }\r
-\r
-  public static int get_particle_x(int id)\r
-   {\r
-    return particle_x[id];\r
-   }\r
-\r
-  public static int get_particle_y(int id)\r
-   {\r
-    return particle_y[id];\r
-   }\r
-}
\ No newline at end of file
index 4f61a7db150db7a01614a4bdc5f285d6244b66b3..0d305849e358ef1108de30fb24a68376cf90e8e9 100644 (file)
@@ -6,7 +6,6 @@ uses
  drop,\r
  invui,\r
  vars,\r
  drop,\r
  invui,\r
  vars,\r
- particles_store,\r
  randoms,\r
  memory,\r
  worldgen,\r
  randoms,\r
  memory,\r
  worldgen,\r
@@ -146,19 +145,8 @@ procedure ClearTextures;
 \r
     for ix := 0 to 15 do\r
       light[ix] := no;\r
 \r
     for ix := 0 to 15 do\r
       light[ix] := no;\r
-    for ix := 0 to 7 do\r
-      begin\r
-        pr_1[ix] := no;\r
-        pr_2[ix] := no;\r
-        pr_3[ix] := no;\r
-        pr_4[ix] := no;\r
-        pr_5[ix] := no;\r
-     end;\r
-\r
-    bubble := no;\r
-    for ix := 0 to 15 do\r
-      pr_boom[ix] := no;\r
 \r
 \r
+    Particles.FreeTextures;\r
     Mobs.FreeTextures;\r
 \r
     sky := no;\r
     Mobs.FreeTextures;\r
 \r
     sky := no;\r
@@ -208,7 +196,7 @@ procedure loadtexture(path:string);
 \r
   console.exec('textures.cfg', 'AUTO');\r
 \r
 \r
   console.exec('textures.cfg', 'AUTO');\r
 \r
-  player.loadSkin('char_ani.png', path);\r
+  Player.LoadSkin('char_ani.png', path);\r
   Mobs.LoadTextures(path);\r
 \r
   im:=ld_tex('gui.png',path,'gui/');\r
   Mobs.LoadTextures(path);\r
 \r
   im:=ld_tex('gui.png',path,'gui/');\r
@@ -258,22 +246,7 @@ procedure loadtexture(path:string);
     for ix:=0 to 15 do light[ix]:=rotate_image_from_image(im,16*ix,0,16,16,0);\r
    end;\r
 \r
     for ix:=0 to 15 do light[ix]:=rotate_image_from_image(im,16*ix,0,16,16,0);\r
    end;\r
 \r
-  if load_particles_tex then\r
-   begin\r
-    im:=ld_tex('particles.png',path,'terrain/');\r
-    for ix:=0 to 7 do\r
-     begin\r
-      pr_1[ix]:=rotate_image_from_image(im,8*ix,0,8,8,0);\r
-      pr_2[ix]:=rotate_image_from_image(im,8*ix,8,8,8,0);\r
-      pr_3[ix]:=rotate_image_from_image(im,8*ix,16,8,8,0);\r
-      pr_4[ix]:=rotate_image_from_image(im,8*ix,24,8,8,0);\r
-      pr_5[ix]:=rotate_image_from_image(im,8*ix,32,8,8,0);\r
-     end;\r
-    bubble:=rotate_image_from_image(im,0,40,8,8,0);\r
-    im:=ld_tex('explosion.png',path,'terrain/');\r
-    for ix:=0 to 15 do\r
-     pr_boom[ix]:=rotate_image_from_image(im,32*ix,0,32,32,0);\r
-   end;\r
+  Particles.LoadTextures(path);\r
 \r
   im:=ld_tex('partition.png',path,'gui/');\r
   gui[18]:=rotate_image_from_image(im,0,0,84,42,0);\r
 \r
   im:=ld_tex('partition.png',path,'gui/');\r
   gui[18]:=rotate_image_from_image(im,0,0,84,42,0);\r
@@ -338,18 +311,12 @@ procedure cleargame;
 \r
   //anim_del2:=0;\r
 \r
 \r
   //anim_del2:=0;\r
 \r
-  inv.resetData;\r
-\r
-  chest.resetData;\r
-\r
-  furnace.resetData;\r
-\r
-  drop.resetData;\r
-\r
+  Inv.ResetData;\r
+  Chest.ResetData;\r
+  Furnace.ResetData;\r
+  Drop.ResetData;\r
   Mobs.ResetData;\r
   Mobs.ResetData;\r
-\r
-  //gb_up_pa:=0;\r
-  reset_particles(max_particles+1);\r
+  Particles.ResetData;\r
 \r
   for ix:=0 to 255 do\r
    begin\r
 \r
   for ix:=0 to 255 do\r
    begin\r
@@ -516,31 +483,19 @@ procedure saveworld(path:string);
        write_byte(getBackMap(ix));\r
        write_byte(getBiomMap(ix));\r
       end;\r
        write_byte(getBackMap(ix));\r
        write_byte(getBiomMap(ix));\r
       end;\r
-     drw_load_line('Chests',55);\r
-     //Chests\r
-     chest.saveData;\r
-     drw_load_line('Furnaces',60);\r
-     //Furnaces\r
-     furnace.saveData;\r
-     drw_load_line('Mobs',70);\r
-     //Mobs\r
+\r
+     drw_load_line('Chests', 55);\r
+     Chest.SaveData;\r
+     drw_load_line('Furnaces', 60);\r
+     Furnace.SaveData;\r
+     drw_load_line('Mobs', 70);\r
      Mobs.SaveData;\r
      Mobs.SaveData;\r
-     drw_load_line('Drop',80);\r
-     //Drop\r
-     drop.saveData;\r
-      drw_load_line('Particles',85);\r
-     //Particles\r
-     writeint(max_particles);\r
-     write_byte(gb_up_pa);\r
-     for ix:=0 to max_particles do\r
-      begin\r
-       write_byte(get_particle_type(ix));\r
-       write_byte(get_particle_ani(ix));\r
-       writeint(get_particle_x(ix));\r
-       writeint(get_particle_y(ix));\r
-      end;\r
-     drw_load_line('Other',90);\r
-     //Other\r
+     drw_load_line('Drop', 80);\r
+     Drop.SaveData;\r
+     drw_load_line('Particles', 85);\r
+     Particles.SaveData;\r
+\r
+     drw_load_line('Other', 90);\r
      write_byte(updx);\r
      write_byte(updy);\r
      writebool(osadki);\r
      write_byte(updx);\r
      write_byte(updy);\r
      writebool(osadki);\r
@@ -648,31 +603,17 @@ function loadworld(path:string):boolean;
        setBackMap(read_byte, ix);\r
        setBiomMap(read_byte, ix);\r
       end;\r
        setBackMap(read_byte, ix);\r
        setBiomMap(read_byte, ix);\r
       end;\r
-     drw_load_line('Chests',55);\r
-     //Chests\r
-     chest.loadData;\r
-     drw_load_line('Furnaces',60);\r
-     //Furnaces\r
-     furnace.loadData;\r
-     //Mobs\r
+     drw_load_line('Chests', 55);\r
+     Chest.LoadData;\r
+     drw_load_line('Furnaces', 60);\r
+     Furnace.LoadData;\r
      Mobs.LoadData;\r
      Mobs.LoadData;\r
-     drw_load_line('Drop',80);\r
-     //Drop\r
-     drop.loadData;\r
-     drw_load_line('Particles',85);\r
-     //Particles\r
-     max_particles:=readint;\r
-     reset_particles(max_particles+1);\r
-     gb_up_pa:=read_byte;\r
-     for ix:=0 to max_particles do\r
-      begin\r
-       set_particle_type(ix,read_byte);\r
-       set_particle_ani(ix,read_byte);\r
-       set_particle_x(ix,readint);\r
-       set_particle_y(ix,readint);\r
-      end;\r
-      drw_load_line('Other',90);\r
-     //Other\r
+     drw_load_line('Drop', 80);\r
+     Drop.LoadData;\r
+     drw_load_line('Particles', 85);\r
+     Particles.LoadData;\r
+\r
+     drw_load_line('Other',90);\r
      updx:=read_byte;\r
      updy:=read_byte;\r
      osadki:=readbool;\r
      updx:=read_byte;\r
      updy:=read_byte;\r
      osadki:=readbool;\r
@@ -1486,7 +1427,7 @@ var
       end; else\r
      if m_cur=-1 then\r
       begin\r
       end; else\r
      if m_cur=-1 then\r
       begin\r
-       s_particles:=not s_particles;\r
+       Particles.enabled := not Particles.enabled;\r
       end; else\r
      if m_cur=0 then\r
       begin\r
       end; else\r
      if m_cur=0 then\r
       begin\r
@@ -1540,7 +1481,7 @@ var
 \r
    drw_btn('Light:'+light_type,-3,m_cur,0,1);\r
    drw_btn('Weather:'+ifosad,-2,m_cur,0,1);\r
 \r
    drw_btn('Light:'+light_type,-3,m_cur,0,1);\r
    drw_btn('Weather:'+ifosad,-2,m_cur,0,1);\r
-   drw_btn('Particles:'+s_particles,-1,m_cur,0,1);\r
+   drw_btn('Particles:' + Particles.enabled, -1, m_cur, 0, 1);\r
    drw_btn('Hide GUI:'+not drawgui,0,m_cur,0,1);\r
    drw_btn('Touch:'+(load_key_tex>0),1,m_cur,0,1);\r
    drw_btn('JPEG:'+s_jpeg_quality,2,m_cur,0,1);\r
    drw_btn('Hide GUI:'+not drawgui,0,m_cur,0,1);\r
    drw_btn('Touch:'+(load_key_tex>0),1,m_cur,0,1);\r
    drw_btn('JPEG:'+s_jpeg_quality,2,m_cur,0,1);\r
@@ -2036,15 +1977,11 @@ procedure draw;
      draw_block(ix,iy);\r
    end;\r
   {===================[drop]===================}\r
      draw_block(ix,iy);\r
    end;\r
   {===================[drop]===================}\r
-  drop.draw(camx, camy);\r
+  Drop.Draw(camx, camy);\r
   {===================[particles]===================}\r
   {===================[particles]===================}\r
-  if s_particles then draw_particle;\r
+  Particles.Draw(camx, camy);\r
   {===================[player]===================}\r
   {===================[player]===================}\r
-  if hp>0 then\r
-   begin\r
-    player.draw(camx, camy);\r
-   end;\r
-\r
+  Player.Draw(camx, camy);\r
   {===================[mobs]===================}\r
   Mobs.Draw(camx, camy);\r
   {===================[draw_blocks]===================}\r
   {===================[mobs]===================}\r
   Mobs.Draw(camx, camy);\r
   {===================[draw_blocks]===================}\r
@@ -2922,7 +2859,7 @@ procedure game;
   osadki_ani:=osadki_ani+1;\r
   if osadki_ani>7 then osadki_ani:=0;\r
 \r
   osadki_ani:=osadki_ani+1;\r
   if osadki_ani>7 then osadki_ani:=0;\r
 \r
-  if random(20)=random(20) then create_particle(6,x,y);\r
+  if Random(20) = Random(20) then Particles.Create(Particles.bubble, x, y);\r
 \r
   if gamemode=1 then begin hp:=666; hunger:=666; end;\r
 \r
 \r
   if gamemode=1 then begin hp:=666; hunger:=666; end;\r
 \r
@@ -2934,8 +2871,7 @@ procedure game;
   //if s_spawn_mob then if random(4096)=1547 then megaspawn;\r
 \r
   Mobs.Update;\r
   //if s_spawn_mob then if random(4096)=1547 then megaspawn;\r
 \r
   Mobs.Update;\r
-\r
-  if particle_upd then update_particle;\r
+  Particles.Update;\r
 \r
   if light_type>0 then\r
    begin\r
 \r
   if light_type>0 then\r
    begin\r
similarity index 100%
rename from src/mobs.pas
rename to src/Mobs.pas
diff --git a/src/Particles.mpsrc b/src/Particles.mpsrc
new file mode 100644 (file)
index 0000000..4b93e19
--- /dev/null
@@ -0,0 +1,166 @@
+unit Particles;\r
+\r
+interface\r
+\r
+  const\r
+    none = 0;\r
+    whiteSmoke = 1;\r
+    graySmoke = 2;\r
+    blackSmoke = 3;\r
+    redSmoke = 4;\r
+    pinkSmoke = 5;\r
+    bubble = 6;\r
+    explosion = 7;\r
+\r
+  var\r
+    enabled : boolean;\r
+\r
+  procedure Create(typ, x, y : integer);\r
+  procedure Update;\r
+  procedure Draw(camx, camy : integer);\r
+\r
+  procedure LoadTextures(path : string);\r
+  procedure FreeTextures;\r
+\r
+  procedure SaveData;\r
+  procedure LoadData;\r
+  procedure ResetData;\r
+\r
+implementation\r
+\r
+  uses vars, maps, func, canvas, jsr75i;\r
+\r
+  const\r
+    lastParticle = 64;\r
+\r
+  var\r
+    tail : integer;\r
+    ptype, px, py, pa : array [0..lastParticle] of integer;\r
+    smokeSprites : array [0..4, 0..7] of image;\r
+    explosionSprites : array [0..15] of image;\r
+    bubbleSprite : image;\r
+\r
+  procedure Create(typ, x, y : integer);\r
+    begin\r
+      if not enabled then exit;\r
+      ptype[tail] := typ;\r
+      px[tail] := x;\r
+      py[tail] := y;\r
+      pa[tail] := 0;\r
+      tail := (tail + 1) mod lastParticle;\r
+    end;\r
+\r
+  procedure Update;\r
+    var\r
+      typ, i : integer;\r
+    begin\r
+      if not enabled then exit;\r
+      for i := 0 to lastParticle do if ptype[i] <> none then begin\r
+        typ := ptype[i];\r
+        if (typ >= whiteSmoke) and (typ <= pinkSmoke) then begin\r
+          py[i] := py[i] - 1;\r
+          pa[i] := pa[i] + 1;\r
+          if pa[i] > 14 then ptype[i] := none;\r
+        end else if typ = bubble then begin\r
+          py[i] := py[i] - 1;\r
+          if GetMap(px[i] / 16, py[i] / 16) <> 50 then ptype[i] := none;\r
+        end else if typ = explosion then begin\r
+          pa[i] := pa[i] + 1;\r
+          if pa[i] > 15 then ptype[i] := none;\r
+        end;\r
+      end;\r
+    end;\r
+\r
+  procedure Draw(camx, camy : integer);\r
+    var\r
+      typ, i : integer;\r
+    begin\r
+      if not enabled then exit;\r
+      for i := 0 to lastParticle do if ptype[i] <> none then begin\r
+        typ := ptype[i];\r
+        if (typ >= whiteSmoke) and (typ <= pinkSmoke) then begin\r
+          DrawImage(smokeSprites[typ - 1, pa[i] / 2], px[i] - camx, py[i] - camy);\r
+        end else if typ = bubble then begin\r
+          DrawImage(bubbleSprite, px[i] - camx, py[i] - camy)\r
+        end else if typ = explosion then begin\r
+          DrawImage(explosionSprites[pa[i]], px[i] - camx, py[i] - camy);\r
+        end;\r
+      end;\r
+    end;\r
+\r
+  procedure LoadTextures(path : string);\r
+    var\r
+      im : image;\r
+      i, j : integer;\r
+    begin\r
+      if not enabled then exit;\r
+      im := ld_tex('particles.png', path, 'terrain/');\r
+      for i := 0 to 4 do begin\r
+        for j := 0 to 7 do begin\r
+          smokeSprites[i, j] := rotate_image_from_image(im, 8 * j, 8 * i, 8, 8, 0);\r
+        end;\r
+      end;\r
+\r
+      bubbleSprite := rotate_image_from_image(im, 0, 40, 8, 8, 0);\r
+\r
+      im := ld_tex('explosion.png', path, 'terrain/');\r
+      for i := 0 to 15 do begin\r
+        explosionSprites[i] := rotate_image_from_image(im, 32 * i, 0, 32, 32, 0);      \r
+      end;\r
+    end;\r
+\r
+  procedure FreeTextures;\r
+    var\r
+      nullimg : image;\r
+      i, j : integer;\r
+    begin\r
+      for i := 0 to 4 do begin\r
+        for j := 0 to 7 do begin\r
+          smokeSprites[i, j] := nullimg;\r
+        end;\r
+      end;\r
+\r
+      bubbleSprite := nullimg;\r
+\r
+      for i := 0 to 15 do begin\r
+        explosionSprites[i] := nullimg;\r
+      end;\r
+    end;\r
+\r
+  procedure SaveData;\r
+    var\r
+      i : integer;\r
+    begin\r
+      for i := 0 to lastParticle do begin\r
+        write_byte(ptype[i]);\r
+        WriteInt(px[i]);\r
+        WriteInt(py[i]);\r
+        WriteInt(pa[i]);\r
+      end;\r
+    end;\r
+\r
+  procedure LoadData;\r
+    var\r
+      i : integer;\r
+    begin\r
+      for i := 0 to lastParticle do begin\r
+        ptype[i] := read_byte;\r
+        px[i] := ReadInt;\r
+        py[i] := ReadInt;\r
+        pa[i] := ReadInt;\r
+      end;\r
+    end;\r
+\r
+  procedure ResetData;\r
+    var\r
+      i : integer;\r
+    begin\r
+      for i := 0 to lastParticle do begin\r
+        ptype[i] := none;\r
+        px[i] := 0;\r
+        py[i] := 0;\r
+        pa[i] := 0;\r
+      end;\r
+    end;\r
+\r
+end.\r
similarity index 100%
rename from src/phy.pas
rename to src/Phy.pas
similarity index 95%
rename from src/player.mpsrc
rename to src/Player.mpsrc
index 812a2b46829db0f2f7569a59afe7fb310bb5b3c5..b41c8e3b7ff82cfcc4eda09aa5e8cbb6f7f2895b 100644 (file)
@@ -1,4 +1,4 @@
-unit player;\r
+unit Player;\r
 \r
 interface\r
 \r
 \r
 interface\r
 \r
index 309fc28ad37eced65ea48ae0f7e353669f33f07a..c6c2f69dd056e7db6d8f3cdbcb8f94be8a5093d2 100644 (file)
@@ -8,7 +8,6 @@ interface
   osadki:boolean;\r
   bl_upd:integer;\r
   s_get_drp:boolean;\r
   osadki:boolean;\r
   bl_upd:integer;\r
   s_get_drp:boolean;\r
-  particle_upd:boolean;\r
   drw_back:boolean;\r
   drw_sm:boolean;\r
   s_max_fps:integer;\r
   drw_back:boolean;\r
   drw_sm:boolean;\r
   s_max_fps:integer;\r
@@ -17,13 +16,11 @@ interface
   light_type:integer;\r
 \r
   ifosad:boolean;\r
   light_type:integer;\r
 \r
   ifosad:boolean;\r
-  //s_particles:boolean; - module\r
 \r
   load_sm:integer;\r
   load_sky_siz:integer;\r
   load_back_tex:boolean;\r
   load_weather_tex:boolean;\r
 \r
   load_sm:integer;\r
   load_sky_siz:integer;\r
   load_back_tex:boolean;\r
   load_weather_tex:boolean;\r
-  load_particles_tex:boolean;\r
   load_light_tex:boolean;\r
   load_gui_tex:boolean;\r
 \r
   load_light_tex:boolean;\r
   load_gui_tex:boolean;\r
 \r
@@ -40,7 +37,6 @@ interface
   sd:string;\r
 \r
   EOFstr, ENDstr:boolean;\r
   sd:string;\r
 \r
   EOFstr, ENDstr:boolean;\r
-  //max_particles:integer; - module\r
 \r
  procedure save_settings;\r
  procedure load_settings;\r
 \r
  procedure save_settings;\r
  procedure load_settings;\r
@@ -49,11 +45,31 @@ interface
  procedure addToLog(str:string);\r
 \r
 implementation\r
  procedure addToLog(str:string);\r
 \r
 implementation\r
-uses keyboard,particles_store,vars,maps,items,canvas,mobs,worldgen,jsr75i,particles,func, player,sensor, drop, inv, furnace, items_store, video;\r
+\r
+  uses\r
+    keyboard,\r
+    vars,\r
+    maps,\r
+    items,\r
+    canvas,\r
+    mobs,\r
+    worldgen,\r
+    jsr75i,\r
+    particles,\r
+    func,\r
+    player,\r
+    sensor,\r
+    drop,\r
+    inv,\r
+    furnace,\r
+    items_store,\r
+    video;\r
+\r
 const\r
  CON_LOG_SIZE=9;\r
  PARSER_MAX_STR=15;\r
  MAX_IMGREG=2;\r
 const\r
  CON_LOG_SIZE=9;\r
  PARSER_MAX_STR=15;\r
  MAX_IMGREG=2;\r
+\r
 var\r
  logSTR: array [0..CON_LOG_SIZE] of string;\r
  lastCommand:string;\r
 var\r
  logSTR: array [0..CON_LOG_SIZE] of string;\r
  lastCommand:string;\r
@@ -151,7 +167,7 @@ procedure save_settings;
   t:=addRecordStoreEntry(rs,version);\r
   t:=addRecordStoreEntry(rs,''+light_type);\r
   t:=addRecordStoreEntry(rs,''+ifosad);\r
   t:=addRecordStoreEntry(rs,version);\r
   t:=addRecordStoreEntry(rs,''+light_type);\r
   t:=addRecordStoreEntry(rs,''+ifosad);\r
-  t:=addRecordStoreEntry(rs,''+s_particles);\r
+  t:=addRecordStoreEntry(rs, '' + Particles.enabled);\r
   t:=addRecordStoreEntry(rs,''+drawgui);\r
   t:=addRecordStoreEntry(rs,''+s_jpeg_quality);\r
   t:=addRecordStoreEntry(rs,''+load_key_tex);\r
   t:=addRecordStoreEntry(rs,''+drawgui);\r
   t:=addRecordStoreEntry(rs,''+s_jpeg_quality);\r
   t:=addRecordStoreEntry(rs,''+load_key_tex);\r
@@ -176,7 +192,7 @@ procedure load_settings;
    end;\r
   light_type:=stringtointeger(readRecordStoreEntry(rs,2));\r
   ifosad:=sett_ld_bool(readRecordStoreEntry(rs,3));\r
    end;\r
   light_type:=stringtointeger(readRecordStoreEntry(rs,2));\r
   ifosad:=sett_ld_bool(readRecordStoreEntry(rs,3));\r
-  s_particles:=sett_ld_bool(readRecordStoreEntry(rs,4));\r
+  Particles.enabled := sett_ld_bool(readRecordStoreEntry(rs, 4));\r
   drawgui:=sett_ld_bool(readRecordStoreEntry(rs,5));\r
   s_jpeg_quality:=stringtointeger(readRecordStoreEntry(rs,6));\r
   load_key_tex:=stringtointeger(readRecordStoreEntry(rs,7));\r
   drawgui:=sett_ld_bool(readRecordStoreEntry(rs,5));\r
   s_jpeg_quality:=stringtointeger(readRecordStoreEntry(rs,6));\r
   load_key_tex:=stringtointeger(readRecordStoreEntry(rs,7));\r
@@ -529,12 +545,6 @@ procedure exeCommand(str:string);
   if com='GET_DRP' then\r
    s_get_drp:=strToBool(nextWord);\r
   else\r
   if com='GET_DRP' then\r
    s_get_drp:=strToBool(nextWord);\r
   else\r
-  {if com='AI_UPD' then\r
-   ai_upd:=strToBool(nextWord);\r
-  else}\r
-  if com='PRT_UPD' then\r
-   particle_upd:=strToBool(nextWord);\r
-  else\r
   if com='MAX_FPS' then\r
    s_max_fps:=decodeInt(nextWord); else\r
   if com='DRW_BACK' then\r
   if com='MAX_FPS' then\r
    s_max_fps:=decodeInt(nextWord); else\r
   if com='DRW_BACK' then\r
@@ -571,7 +581,7 @@ procedure exeCommand(str:string);
    light_type:=decodeInt(nextWord);\r
   else\r
   if com='S_PARTICLES' then\r
    light_type:=decodeInt(nextWord);\r
   else\r
   if com='S_PARTICLES' then\r
-   s_particles:=strToBool(nextWord);\r
+   Particles.enabled := strToBool(nextWord);\r
   else\r
   if com='LOAD_SKY' then\r
    load_sky_siz:=decodeInt(nextWord);\r
   else\r
   if com='LOAD_SKY' then\r
    load_sky_siz:=decodeInt(nextWord);\r
@@ -585,9 +595,6 @@ procedure exeCommand(str:string);
   if com='LOAD_WEATHER_TEX' then\r
    load_weather_tex:=strToBool(nextWord);\r
   else\r
   if com='LOAD_WEATHER_TEX' then\r
    load_weather_tex:=strToBool(nextWord);\r
   else\r
-  if com='LOAD_PARTICLES_TEX' then\r
-   load_particles_tex:=strToBool(nextWord);\r
-  else\r
   if com='LOAD_LIGHT_TEX' then\r
    load_light_tex:=strToBool(nextWord);\r
   else\r
   if com='LOAD_LIGHT_TEX' then\r
    load_light_tex:=strToBool(nextWord);\r
   else\r
@@ -612,12 +619,6 @@ procedure exeCommand(str:string);
   if com='LOAD_MINIMAP_TEX' then\r
    load_minimap_tex:=strToBool(nextWord);\r
   else\r
   if com='LOAD_MINIMAP_TEX' then\r
    load_minimap_tex:=strToBool(nextWord);\r
   else\r
-  if com='MAX_PARTICLES' then\r
-   begin\r
-    max_particles:=decodeInt(nextWord);\r
-    reset_particles(max_particles+1);\r
-   end;\r
-  else\r
   if com='EXEC' then\r
    begin\r
     tmp:=nextWord;\r
   if com='EXEC' then\r
    begin\r
     tmp:=nextWord;\r
index efcee9fb5ecb4034a8e3c47b848166b25fd43625..a3d41c04f757880049a1db63f27694ee9ad375bb 100644 (file)
@@ -148,7 +148,7 @@ procedure boom(rr,mm,xx,yy:integer);
      begin\r
       if 30<=random(100) then destroy_block_1(getmap(ix,iy),ix,iy);\r
       setmap(0,ix,iy);\r
      begin\r
       if 30<=random(100) then destroy_block_1(getmap(ix,iy),ix,iy);\r
       setmap(0,ix,iy);\r
-      create_particle(7,(ix*16)+8-16,(iy*16)+8-16);\r
+      Particles.Create(Particles.explosion, (ix * 16) + 8 - 16, (iy * 16) + 8 - 16);\r
      end;\r
    end;\r
   minhp:=minhp/360;\r
      end;\r
    end;\r
   minhp:=minhp/360;\r
@@ -1184,7 +1184,7 @@ procedure fluidLogic(x, y, ifbx, thenbx, ifby, thenby:integer);
 procedure updateBlock(x, y:integer);\r
  const\r
   GRASS_RND=128;\r
 procedure updateBlock(x, y:integer);\r
  const\r
   GRASS_RND=128;\r
-  TORCH_RND=128;\r
+  TORCH_RND=10;\r
   SPAWN_RND=128;\r
   SPAWN_RAD=128;\r
   GENWOOD_RND=1024;\r
   SPAWN_RND=128;\r
   SPAWN_RAD=128;\r
   GENWOOD_RND=1024;\r
@@ -1238,7 +1238,7 @@ procedure updateBlock(x, y:integer);
   if block=26 then\r
    begin\r
     if random(TORCH_RND)=random(TORCH_RND) then\r
   if block=26 then\r
    begin\r
     if random(TORCH_RND)=random(TORCH_RND) then\r
-     create_particle(2, x*16+4, y*16+4);\r
+     Particles.Create(Particles.graySmoke, x * 16 + 4, y * 16 + 4);\r
    end;\r
   else\r
   if block=50 then\r
    end;\r
   else\r
   if block=50 then\r
@@ -1346,7 +1346,7 @@ procedure updateBlock(x, y:integer);
   if block=105 then\r
    begin\r
     if random(TORCH_RND)=random(TORCH_RND) then\r
   if block=105 then\r
    begin\r
     if random(TORCH_RND)=random(TORCH_RND) then\r
-     create_particle(4, x*16+4, y*16+4);\r
+     Particles.Create(Particles.redSmoke, x * 16 + 4, y * 16 + 4);\r
    end;\r
   else\r
   if (block = 106) or (block = 125) then\r
    end;\r
   else\r
   if (block = 106) or (block = 125) then\r
diff --git a/src/particles.mpsrc b/src/particles.mpsrc
deleted file mode 100644 (file)
index ba3c7c4..0000000
+++ /dev/null
@@ -1,139 +0,0 @@
-unit particles;\r
-\r
-interface\r
- var\r
-  bubble:image;\r
-  pr_1:array [0..7] of image;\r
-  none1:image;\r
-  pr_2:array [0..7] of image;\r
-  none2:image;\r
-  pr_3:array [0..7] of image;\r
-  none3:image;\r
-  pr_4:array [0..7] of image;\r
-  none4:image;\r
-  pr_5:array [0..7] of image;\r
-  none5:image;\r
-  pr_boom:array [0..15] of image;\r
-  none6:image;\r
-  \r
-  max_particles:integer;\r
-  s_particles:boolean;\r
-  gb_up_pa:integer;\r
-\r
- procedure create_particle(tp,ix,iy:integer);\r
- procedure update_particle;\r
- procedure draw_particle;\r
-\r
-implementation\r
- uses vars,maps,particles_store;\r
-\r
-procedure create_particle(tp,ix,iy:integer);\r
- var\r
-  i:integer;\r
- begin\r
-  if s_particles=true then\r
-  for i:=0 to max_particles do\r
-   if get_particle_type(i)=0 then\r
-    begin\r
-     set_particle(i,tp,0,ix,iy);\r
-     exit;\r
-    end;\r
- end;\r
-\r
-procedure null_particle(i:integer);\r
- begin\r
-  set_particle(i,0,0,0,0);\r
- end;\r
-\r
-procedure pr_ai_1(i,maxani:integer);\r
- begin\r
-  set_particle_y(i,get_particle_y(i)-1);\r
-  set_particle_ani(i,get_particle_ani(i)+1);\r
-  if get_particle_ani(i)>maxani then null_particle(i);\r
- end;\r
-\r
-procedure pr_ai_bubble(i:integer);\r
- var\r
-  xx,yy:integer;\r
- begin\r
-  set_particle_y(i,get_particle_y(i)-1);\r
-  xx:=get_particle_x(i) div 16;\r
-  yy:=get_particle_y(i) div 16;\r
-  if getmap(xx,yy)<>50 then null_particle(i);\r
- end;\r
-\r
-procedure pr_ai_boom(i:integer);\r
- begin\r
-  set_particle_ani(i,get_particle_ani(i)+1);\r
-  if get_particle_ani(i)>15 then null_particle(i);\r
- end;\r
-\r
-procedure update_particle;\r
- var\r
-  i:integer;\r
- begin\r
-  if s_particles=true then\r
-   begin\r
-    for i:=0 to max_particles do\r
-     if get_particle_type(i)>0 then\r
-      begin\r
-       if get_particle_type(i)=1 then pr_ai_1(i,5); else\r
-       if get_particle_type(i)=2 then pr_ai_1(i,5); else\r
-       if get_particle_type(i)=3 then pr_ai_1(i,5); else\r
-       if get_particle_type(i)=4 then pr_ai_1(i,5); else\r
-       if get_particle_type(i)=5 then pr_ai_1(i,5); else\r
-       if get_particle_type(i)=6 then pr_ai_bubble(i); else\r
-       if get_particle_type(i)=7 then pr_ai_boom(i); else\r
-        null_particle(i);\r
-      end;\r
-    gb_up_pa:=gb_up_pa+1;\r
-    if gb_up_pa>=2 then gb_up_pa:=0;\r
-   end;\r
- end;\r
-\r
-procedure draw_particle;\r
- var\r
-  i:integer;\r
- begin\r
-  for i:=0 to max_particles do\r
-   if get_particle_type(i)>0 then\r
-   begin\r
-    if get_particle_type(i)=1 then\r
-     begin\r
-      if (get_particle_x(i)-camx>-8) and (get_particle_x(i)-camx<getwidth) and (get_particle_y(i)-camy>-8) and (get_particle_y(i)-camy<getheight) then\r
-      drawimage(pr_1[get_particle_ani(i)],get_particle_x(i)-camx,get_particle_y(i)-camy);\r
-     end; else\r
-    if get_particle_type(i)=2 then\r
-     begin\r
-      if (get_particle_x(i)-camx>-8) and (get_particle_x(i)-camx<getwidth) and (get_particle_y(i)-camy>-8) and (get_particle_y(i)-camy<getheight) then\r
-      drawimage(pr_2[get_particle_ani(i)],get_particle_x(i)-camx,get_particle_y(i)-camy);\r
-     end; else\r
-    if get_particle_type(i)=3 then\r
-     begin\r
-      if (get_particle_x(i)-camx>-8) and (get_particle_x(i)-camx<getwidth) and (get_particle_y(i)-camy>-8) and (get_particle_y(i)-camy<getheight) then\r
-      drawimage(pr_3[get_particle_ani(i)],get_particle_x(i)-camx,get_particle_y(i)-camy);\r
-     end; else\r
-    if get_particle_type(i)=4 then\r
-     begin\r
-      if (get_particle_x(i)-camx>-8) and (get_particle_x(i)-camx<getwidth) and (get_particle_y(i)-camy>-8) and (get_particle_y(i)-camy<getheight) then\r
-      drawimage(pr_4[get_particle_ani(i)],get_particle_x(i)-camx,get_particle_y(i)-camy);\r
-     end; else\r
-    if get_particle_type(i)=5 then\r
-     begin\r
-      if (get_particle_x(i)-camx>-8) and (get_particle_x(i)-camx<getwidth) and (get_particle_y(i)-camy>-8) and (get_particle_y(i)-camy<getheight) then\r
-      drawimage(pr_4[get_particle_ani(i)],get_particle_x(i)-camx,get_particle_y(i)-camy);\r
-     end; else\r
-    if get_particle_type(i)=6 then\r
-     begin\r
-      if (get_particle_x(i)-camx>-8) and (get_particle_x(i)-camx<getwidth) and (get_particle_y(i)-camy>-8) and (get_particle_y(i)-camy<getheight) then\r
-      drawimage(bubble,get_particle_x(i)-camx,get_particle_y(i)-camy);\r
-     end; else\r
-    if get_particle_type(i)=7 then\r
-     begin\r
-      if (get_particle_x(i)-camx>-32) and (get_particle_x(i)-camx<getwidth) and (get_particle_y(i)-camy>-32) and (get_particle_y(i)-camy<getheight) then\r
-      drawimage(pr_boom[get_particle_ani(i)],get_particle_x(i)-camx,get_particle_y(i)-camy);\r
-     end;\r
-   end;\r
- end;\r
-\r
-end.\r