From: DeaDDooMER Date: Thu, 7 Sep 2017 11:01:53 +0000 (+0300) Subject: Clean module Mobs for reimplementation mobs X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=f69f36f1ce7426048c8ddfef03f7b237164403ad;p=cavecraft.git Clean module Mobs for reimplementation mobs --- diff --git a/BUGS b/BUGS index b3be881..bdb696b 100644 --- a/BUGS +++ b/BUGS @@ -29,7 +29,7 @@ + Печь не светится когда работает * Потеря контрастности при малом количестве источников света + Слишком много золота -Курсор на ремне должен быть чётче +* Курсор на ремне должен быть чётче + Один уголь выплавляет 7 предметов, хотя должно быть 8 По лестнице можно лезть даже если она стоит выше игрока + Игрок возраждается в точке своей смерти, вместо точки спавна diff --git a/make.sh b/make.sh index 7236ef0..06809a4 100755 --- a/make.sh +++ b/make.sh @@ -1,5 +1,7 @@ #!/bin/sh +set -e + NAM=CaveCraft VER=1.9.0 VEN=DeaDSoftWare @@ -67,7 +69,8 @@ jar cfM bin.jar \ $(printJarClass $OBJ) \ $(printJarClass $LIB) \ -C $OBJ META-INF \ - -C $RES . + -C $RES . \ + LICENSE # http://www.oracle.com/technetwork/systems/index-156899.html diff --git a/src/CAVE.mpsrc b/src/CAVE.mpsrc index af345fd..4f61a7d 100644 --- a/src/CAVE.mpsrc +++ b/src/CAVE.mpsrc @@ -13,7 +13,7 @@ uses canvas, items, safeload, - mob, + mobs, console, effects, particles, @@ -159,7 +159,7 @@ procedure ClearTextures; for ix := 0 to 15 do pr_boom[ix] := no; - mob.freeSkin; + Mobs.FreeTextures; sky := no; sun := no; @@ -209,7 +209,7 @@ procedure loadtexture(path:string); console.exec('textures.cfg', 'AUTO'); player.loadSkin('char_ani.png', path); - mob.loadSkin(path); + Mobs.LoadTextures(path); im:=ld_tex('gui.png',path,'gui/'); gui[0]:=rotate_image_from_image(im,0,0,16,16,0); @@ -346,7 +346,7 @@ procedure cleargame; drop.resetData; - mob.resetData; + Mobs.ResetData; //gb_up_pa:=0; reset_particles(max_particles+1); @@ -524,7 +524,7 @@ procedure saveworld(path:string); furnace.saveData; drw_load_line('Mobs',70); //Mobs - mob.saveData; + Mobs.SaveData; drw_load_line('Drop',80); //Drop drop.saveData; @@ -655,7 +655,7 @@ function loadworld(path:string):boolean; //Furnaces furnace.loadData; //Mobs - mob.loadData; + Mobs.LoadData; drw_load_line('Drop',80); //Drop drop.loadData; @@ -2046,7 +2046,7 @@ procedure draw; end; {===================[mobs]===================} - mob.draw(camx, camy); + Mobs.Draw(camx, camy); {===================[draw_blocks]===================} for ix:=minx to maxx do for iy:=miny to maxy do @@ -2292,9 +2292,9 @@ function rt_useweap:boolean; damg:=1; if posi=0 then - i:=mob.findAndHit(damg, x-TILE_SIZE, y, TILE_SIZE+(w/2), h, -2, -3); + i:=Mobs.findAndHit(damg, x-TILE_SIZE, y, TILE_SIZE+(w/2), h, -2, -3); else - i:=mob.findAndHit(damg, x+(w/2), y, TILE_SIZE+(w/2), h, 2, -3); + i:=Mobs.findAndHit(damg, x+(w/2), y, TILE_SIZE+(w/2), h, 2, -3); if i<>-1 then begin @@ -2729,9 +2729,9 @@ procedure phyhandler; var i:integer; begin - player.calcPhysics; - mob.updatePhy; - drop.calcPhy; + Player.CalcPhysics; + Mobs.UpdatePhy; + Drop.CalcPhy; end; procedure light_fillrect(l,x,y,r:integer); @@ -2933,7 +2933,7 @@ procedure game; //if s_spawn_mob then if random(4096)=1547 then megaspawn; - mob.update; + Mobs.Update; if particle_upd then update_particle; diff --git a/src/console.pas b/src/console.pas index d239081..309fc28 100644 --- a/src/console.pas +++ b/src/console.pas @@ -49,7 +49,7 @@ interface procedure addToLog(str:string); implementation -uses keyboard,particles_store,vars,maps,items,canvas,mob,worldgen,jsr75i,particles,func, player,sensor, drop, inv, furnace, items_store, video; +uses keyboard,particles_store,vars,maps,items,canvas,mobs,worldgen,jsr75i,particles,func, player,sensor, drop, inv, furnace, items_store, video; const CON_LOG_SIZE=9; PARSER_MAX_STR=15; @@ -473,13 +473,6 @@ procedure exeCommand(str:string); fly:=false; end; else - {if com='KILL_MOBS' then - for i:=0 to 31 do - begin - mob[i].m_type:=0; - mob[i].m_hp:=0; - end; - else} if com='SPAWN' then begin player.setX(get_spawn_x*16+4); diff --git a/src/items_logic.mpsrc b/src/items_logic.mpsrc index 6c730f6..efcee9f 100644 --- a/src/items_logic.mpsrc +++ b/src/items_logic.mpsrc @@ -12,7 +12,7 @@ interface procedure updateBlock(x, y:integer); implementation - uses invui, maps, drop, console, furnace, png3, func, jpeg, mob, vars, bmp, items, chest, inv, player, items_store, particles, worldgen, phy, sign; + uses invui, maps, drop, console, furnace, png3, func, jpeg, mobs, vars, bmp, items, chest, inv, player, items_store, particles, worldgen, phy, sign; procedure usebonemeal(block:integer); var @@ -853,7 +853,7 @@ procedure destroy_block_cr(id, xx, yy:integer); begin if getBlockColl(block)=0 then begin - mob.create(M_ZOMBY, x*16, y*16); + Mobs.Create(Mobs.zomby, x * 16, y * 16); decItem(invcur); end; end; diff --git a/src/mobs.pas b/src/mobs.pas index 72f062f..ebe716e 100644 --- a/src/mobs.pas +++ b/src/mobs.pas @@ -1,615 +1,263 @@ -unit mob; +unit Mobs; interface - const - M_NONE=0; - M_ZOMBY=1; - MOB_TYPES=1; + const + (* Типы мобов *) + none = 0; + zomby = 1; - procedure create(_type, x, y:integer);//Создать моба - function findAndHit(value, x, y, w, h, addvx, addvy:integer):integer; + procedure Create(typ, x, y : integer); + function FindAndHit(value, x, y, w, h, addvx, addvy : integer) : integer; - procedure update;//Обновление логики - procedure updatePhy;//Обновление физики - procedure draw(camx, camy:integer);//Отрисовка + (* Части главного цикла *) + procedure Update; + procedure UpdatePhy; + procedure Draw(camx, camy : integer); - procedure saveData;//Сохранение всех данных - procedure loadData;//Загрузка всех данных - procedure resetData;//Сброс всех данных + (* Управление сохранениями *) + procedure SaveData; + procedure LoadData; + procedure ResetData; - procedure loadSkin(path:string);//Загрузка текстур - procedure freeSkin;//Выгрузка текстур + (* Управление текстурами *) + procedure LoadTextures(path : string); + procedure FreeTextures; implementation - uses phy, player, canvas, jsr75i, func; - const - MAX_MOBS=31; - MAX_ANIMREG=3; - - AI_NONE=0; - AI_ZLOY=1; - var - mob_type, mob_x, mob_y, mob_vx, mob_vy, mob_posi, mob_hp:array [0..MAX_MOBS] of integer; - mob_jmp:array [0..MAX_MOBS] of boolean; - mob_anim:array [0..MAX_MOBS, 0..MAX_ANIMREG] of integer; - tab_w, tab_h, tab_hp, tab_speedx, tab_jumph, tab_ai:array [0..MOB_TYPES] of integer; - - texture_left, texture_right:array [0..MOB_TYPES, 0..0] of image; - tex_x, tex_y, tex_w, tex_h:array [0..1, 0..MOB_TYPES, 0..0] of integer; - - part_max: array [0..MOB_TYPES] of integer; - part_tex, part_x, part_y, part_anim: array [0..MOB_TYPES, 0..0] of integer; - - function getType(i:integer):integer; - begin - getType:=mob_type[i]; - end; - - function getX(i:integer):integer; - begin - getX:=mob_x[i]; - end; - - function getY(i:integer):integer; - begin - getY:=mob_y[i]; - end; - - function getVX(i:integer):integer; - begin - getVX:=mob_vx[i]; - end; - - function getVY(i:integer):integer; - begin - getVY:=mob_vy[i]; - end; - - function getPosi(i:integer):integer; - begin - getPosi:=mob_posi[i]; - end; - - function getHp(i:integer):integer; - begin - getHp:=mob_hp[i]; - end; - - function getW(i:integer):integer; - begin - getW:=tab_w[mob_type[i]]; - end; - - function getH(i:integer):integer; - begin - getH:=tab_h[mob_type[i]]; - end; - - function getSpeedX(i:integer):integer; - begin - getSpeedX:=tab_speedx[mob_type[i]]; - end; - - function getJumpH(i:integer):integer; - begin - getJumpH:=tab_jumph[mob_type[i]]; - end; - - function getJmp(i:integer):boolean; - begin - getJmp:=mob_jmp[i]; - end; - - procedure setType(value, i:integer); - begin - mob_type[i]:=value; - end; - - procedure setX(value, i:integer); - begin - mob_x[i]:=value; - end; - - procedure setY(value, i:integer); - begin - mob_y[i]:=value; - end; - - procedure setVX(value, i:integer); - begin - mob_vx[i]:=value; - end; - - procedure setVY(value, i:integer); - begin - mob_vy[i]:=value; - end; - - procedure setPosi(value, i:integer); - begin - mob_posi[i]:=value; - end; - procedure setHp(value, i:integer); - begin - mob_hp[i]:=value; - end; + uses phy, player, canvas, jsr75i, func; - procedure setJmp(value:boolean; i:integer); - begin - mob_jmp[i]:=value; - end; + const + lastType = 1; + lastMob = 31; - procedure initTab(_type, w, h, hp, speedx, jumph, ai:integer); - begin - tab_w[_type]:=w; - tab_h[_type]:=h; - tab_hp[_type]:=hp; - tab_speedx[_type]:=speedx; - tab_jumph[_type]:=jumph; - tab_ai[_type]:=ai; - end; + var + mtype, mx, my, mvx, mvy, mpos, mhp : array [0..lastMob] of integer; + mjump : array [0..lastMob] of boolean; + tw, th, thp, tjump : array [none..lastType] of integer; - procedure initTexture(img:image; mobtype, texid, posi, centerx, centery:integer); - begin - tex_w[posi, mobtype, texid]:=getImageWidth(img); - tex_h[posi, mobtype, texid]:=getImageHeight(img); - if posi=0 then - texture_left[mobtype, texid]:=img; - else - texture_right[mobtype, texid]:=img; - tex_x[posi, mobtype, texid]:=centerx; - tex_y[posi, mobtype, texid]:=centery; - end; - - procedure setMaxTextures(mobtype, max:integer); - var - i:integer; - begin - max:=max+1; - debug('setMaxTextures(mobtype, max:integer);'); - bytecode - getstatic field 'mob', 'texture_left', '[[Ljavax/microedition/lcdui/Image;'; - iload 0; - iload 1; - multianewarray class '[Ljavax/microedition/lcdui/Image;', 1; - aastore; - - getstatic field 'mob', 'texture_right', '[[Ljavax/microedition/lcdui/Image;'; - iload 0; - iload 1; - multianewarray class '[Ljavax/microedition/lcdui/Image;', 1; - aastore; + procedure UseObject(i : integer); + begin + Phy.LoadObject(mx[i], my[i], tw[mtype[i]], th[mtype[i]], mvx[i], mvy[i], mjump[i]); end; - for i:=0 to 1 do - bytecode - //tex_x[i][mobtype]=new int[max]; - getstatic field 'mob', 'tex_x', '[[[I'; - iload_2; - aaload; - iload_0; - iload_1; - multianewarray class '[I', 1; - aastore; - - getstatic field 'mob', 'tex_y', '[[[I'; - iload_2; - aaload; - iload_0; - iload_1; - multianewarray class '[I', 1; - aastore; - - getstatic field 'mob', 'tex_w', '[[[I'; - iload_2; - aaload; - iload_0; - iload_1; - multianewarray class '[I', 1; - aastore; - - getstatic field 'mob', 'tex_h', '[[[I'; - iload_2; - aaload; - iload_0; - iload_1; - multianewarray class '[I', 1; - aastore; + procedure UpdateObject(i : integer); + begin + mx[i] := Phy.GetX; + my[i] := Phy.GetY; + mvx[i] := Phy.GetVelX; + mvy[i] := Phy.GetVelY; + mjump[i] := Phy.GetJmp; end; - end; - procedure setMaxParts(mobtype, max:integer); + procedure InitTab(typ, w, h, hp : integer); begin - part_max[mobtype]:=max; - max:=max+1; - - bytecode - getstatic field 'mob', 'part_tex', '[[I'; - iload_0; - iload_1; - multianewarray class '[I', 1; - aastore; - - getstatic field 'mob', 'part_x', '[[I'; - iload_0; - iload_1; - multianewarray class '[I', 1; - aastore; - - getstatic field 'mob', 'part_y', '[[I'; - iload_0; - iload_1; - multianewarray class '[I', 1; - aastore; - - getstatic field 'mob', 'part_anim', '[[I'; - iload_0; - iload_1; - multianewarray class '[I', 1; - aastore; - end; + assert((typ >= 0) and (typ <= lastType)); + tw[typ] := w; + th[typ] := h; + thp[typ] := hp; end; - procedure initPart(mobtype, partid, tex, x, y, animreg:integer); + function GetW(i : integer) : integer; begin - part_tex[mobtype, partid]:=tex; - part_x[mobtype, partid]:=x; - part_y[mobtype, partid]:=y; - part_anim[mobtype, partid]:=animreg; + result := tw[mtype[i]]; end; -procedure loadPhy(i:integer); - begin - phy.loadObject(mob_x[i], mob_y[i], tab_w[mob_type[i]], tab_h[mob_type[i]], mob_vx[i], mob_vy[i], mob_jmp[i]); - end; - -procedure storePhy(i:integer); - begin - mob_x[i]:=phy.getX; - mob_y[i]:=phy.getY; - mob_vx[i]:=phy.getVelX; - mob_vy[i]:=phy.getVelY; - mob_jmp[i]:=phy.getJmp; - end; - -{===== =====} - - procedure create(_type, x, y:integer);//Создать моба - var - i, j:integer; - begin - debug('Create mob '+_type+' @ '+x+'x'+y); - for i:=0 to MAX_MOBS do - if mob_type[i]=M_NONE then - begin - mob_type[i]:=_type; - mob_x[i]:=x; - mob_y[i]:=y; - mob_vx[i]:=0; - mob_vy[i]:=0; - mob_posi[i]:=0; - mob_hp[i]:=tab_hp[_type]; - mob_jmp[i]:=false; - for j:=0 to MAX_ANIMREG do - mob_anim[i, j]:=0; - - debug('Created mob is '+i); - exit; - end; - end; - - procedure die(i:integer);//Убить - begin - mob_type[i]:=M_NONE; - end; - - procedure hit(value, i:integer);//Нанести урон - var - hp:integer; - begin - hp:=getHp(i)-value; - if hp>0 then - setHp(hp, i); - else - die(i); - end; - - function findAndHit(value, x, y, w, h, addvx, addvy:integer):integer; - var - i:integer; - begin - for i:=0 to MAX_MOBS do - if getType(i)<>M_NONE then - if CollTwoObj(x, y, w, h, getX(i), getY(i), getW(i), getH(i)) then - begin - setVX(getVX(i)+addvx, i); - setVX(getVY(i)+addvy, i); - hit(value, i); - findAndHit:=i; - exit; - end; - - findAndHit:=-1; - end; - - procedure goUp(i:integer); - begin - loadPhy(i); - phy.jumpObj(getJumpH(i)); - storePhy(i); - end; - - procedure goDown(i:integer); - begin - - end; - - procedure goLeft(i:integer); - begin - setVX(-getSpeedX(i), i); - setPosi(0, i); - end; - - procedure goRight(i:integer); - begin - setVX(getSpeedX(i), i); - setPosi(1, i); - end; - - function testSolid(i, vector : integer) : boolean; - var - x, y : integer; - begin - y := (getY(i) + getH(i)) / 16 - 1; - - if vector > 0 then - x := (getX(i) + getW(i) / 2 + 16 / 2) / 16; - else - x := (getX(i) + getW(i) / 2 - 16 / 2) / 16; - - testSolid := phy.isSolid(x, y, getVX(i), getVY(i)); - end; + function GetH(i : integer) : integer; + begin + result := th[mtype[i]]; + end; - function collideWithPlayer(i : integer) : boolean; - begin - collideWithPlayer := CollTwoObj(getX(i), getY(i), getW(i), getH(i), player.getX, player.getY, player.getW, player.getH); - end; + function GetMaxHp(i : integer) : integer; + begin + result := thp[mtype[i]]; + end; - function canBite(i : integer) : boolean; - begin - canBite := collideWithPlayer(i); - end; + function GetJumpHeight(i : integer) : integer; + begin + result := tjump[mtype[i]]; + end; - procedure updateZloyAiAnim(i : integer); - const - DEL=1; - var - a_a, a_d, a_f:integer; - begin - a_a:=mob_anim[i, 1]; - a_d:=mob_anim[i, 2]; - a_f:=mob_anim[i, 3]; - - a_d:=a_d+1; - if a_d>DEL then - begin - a_d:=0; - a_a:=a_a+1; - if a_f=1 then - begin - a_a:=0; - a_f:=0; - end; - else - if a_a=3 then - begin - a_a:=1; - a_f:=1; - end; - end; - - mob_anim[i, 1]:=a_a; - mob_anim[i, 2]:=a_d; - mob_anim[i, 3]:=a_f; - end; + procedure Jump(i : integer); + begin + UseObject(i); + Phy.JumpObj(GetJumpHeight(i)); + UpdateObject(i); + end; - procedure updateZloyAi(i : integer); - var - vector : integer; - begin - if player.getX < getX(i) then - begin - goLeft(i); - vector := -1; - end; - else if player.getX > getX(i) then + procedure Step(i, vec : integer); begin - goRight(i); - vector := 1; + if vec < 0 then + begin + mvx[i] := mvx[i] + vec; + mpos[i] := 0; + end + else if vec > 0 then + begin + mvx[i] := mvx[i] + vec; + mpos[i] := 1; + end; end; - if vector <> 0 then + function IsSolidStep(i, vec : integer) : boolean; + var + x, y : integer; begin - updateZloyAiAnim(i); - if testSolid(i, vector) then - goUp(i); + if vec > 0 then x := (mx[i] + GetW(i) / 2 + 16 / 2) / 16; + else x := (mx[i] + GetW(i) / 2 - 16 / 2) / 16; + y := (my[i] + GetH(i)) / 16 - 1; + result := Phy.IsSolid(x, y, mvx[i], mvy[i]); end; - if collideWithPlayer(i) then - player.biteIt(1, vector); - end; + function CollisionWithPlayer(i : integer) : boolean; + begin + result := CollTwoObj( + mx[i], my[i], GetW(i), GetH(i), + Player.GetX, Player.GetY, Player.GetW, Player.GetH + ); + end; - procedure update; - var - i, _type, ai:integer; - begin - for i:=0 to MAX_MOBS do - begin - _type:=getType(i); - - if _type<>M_NONE then - begin - ai:=tab_ai[_type]; - if ai=AI_ZLOY then - updateZloyAi(i); - end; - end; - end; +(* ============= Public ============= *) - procedure updatePhy;//Обновление физики - var - i:integer; - begin - for i:=0 to MAX_MOBS do - begin - loadPhy(i); - phy.calc(true); - storePhy(i); - end; - end; + procedure Create(typ, x, y : integer); + var + i : integer; + begin + Assert((typ >= 0) and (typ <= lastType)); + Debug('Create mob ' + typ +' @ ' + x + 'x' + y); + for i := 0 to lastMob do if mtype[i] = none then + begin + mtype[i] := typ; + mx[i] := x; + my[i] := y; + mvx[i] := 0; + mvy[i] := 0; + mpos[i] := 0; + mhp[i] := thp[typ]; + mjump[i] := false; + debug('Created mob is ' + i); + exit; + end; + Debug('Mob type ' + typ + ' not created'); + end; - procedure drawPart(mobtype, texid, posi, anim, x, y, camx, camy:integer); - begin - x:=x-tex_x[posi, mobtype, texid]-camx; - y:=y-tex_y[posi, mobtype, texid]-camy; + function FindAndHit(value, x, y, w, h, addvx, addvy : integer) : integer; + var + i : integer; + begin +(* + for i:=0 to MAX_MOBS do + if getType(i)<>M_NONE then + if CollTwoObj(x, y, w, h, wx[i], wy[i], GetW(i), GetH(i)) then + begin + setVX(getVX(i) + addvx, i); + setVX(getVY(i) + addvy, i); + hit(value, i); + findAndHit := i; + exit; + end; +*) + findAndHit := -1; + end; + + procedure Update; + var + i : integer; + begin + (* TODO *) + end; - if CollTwoObj(x, y, tex_w[posi, mobtype, texid], tex_h[posi, mobtype, texid], 0, 0, getWidth, getHeight) then - if posi=0 then - drawImage(texture_left[mobtype, texid+anim], x, y); - else - drawImage(texture_right[mobtype, texid+anim], x, y); - end; + procedure UpdatePhy; + var + i : integer; + begin + for i := 0 to lastMob do + begin + UseObject(i); + Phy.Calc(true); + UpdateObject(i); + end; + end; - procedure draw(camx, camy:integer);//Отрисовка - var - i, j, _type:integer; - begin - for i:=0 to MAX_MOBS do - begin - _type:=mob_type[i]; - if _type<>M_NONE then - begin - for j:=0 to part_max[_type] do - drawPart(_type, part_tex[_type, j], mob_posi[i], mob_anim[i, part_anim[_type, j]], mob_x[i]+part_x[_type, j], mob_y[i]+part_y[_type, j], camx, camy); - end; - end; - end; + procedure Draw(camx, camy:integer); + var + i : integer; + begin + for i := 0 to lastMob do if mtype[i] <> none then + begin + SetColor(0, 0, 255); + FillRect(mx[i] - camx, my[i] - camy, GetW(i), GetH(i)); + end; + end; - procedure loadSkin(path:string);//Загрузка текстур - var - im:image; - begin - setMaxTextures(M_ZOMBY, 5); - im:=ld_tex('zombie_ani.png', path, 'mobs/'); - // IMG, TYPE, ID, POSI, X, Y - initTexture(rotate_image_from_image(im, 6, 2, 8, 8, 0), M_ZOMBY, 0, 0, 4, 8);//head[left] - initTexture(rotate_image_from_image(im, 8, 10, 4, 12, 0), M_ZOMBY, 1, 0, 2, 0);//body[left] - initTexture(rotate_image_from_image(im, 0, 10, 12, 4, 0), M_ZOMBY, 2, 0, 10, 2);//hands[left] - initTexture(rotate_image_from_image(im, 0, 52, 12, 12, 0), M_ZOMBY, 3, 0, 6, 0);//legs[left] - initTexture(rotate_image_from_image(im, 13, 52, 12, 12, 0), M_ZOMBY, 4, 0, 6, 0); - initTexture(rotate_image_from_image(im, 26, 52, 12, 12, 0), M_ZOMBY, 5, 0, 6, 0); - - initTexture(rotate_image_from_image(im, 27, 2, 8, 8, 0), M_ZOMBY, 0, 1, 4, 8);//head[right] - initTexture(rotate_image_from_image(im, 29, 10, 4, 12, 0), M_ZOMBY, 1, 1, 2, 0);//body[right] - initTexture(rotate_image_from_image(im, 29, 10, 12, 4, 0), M_ZOMBY, 2, 1, 2, 2);//hands[right] - initTexture(rotate_image_from_image(im, 39, 52, 12, 12, 0), M_ZOMBY, 3, 1, 6, 0);//legs[right] - initTexture(rotate_image_from_image(im, 52, 52, 12, 12, 0), M_ZOMBY, 4, 1, 6, 0); - initTexture(rotate_image_from_image(im, 65, 52, 12, 12, 0), M_ZOMBY, 5, 1, 6, 0); - end; + procedure LoadTextures(path : string); + var + im:image; + begin + // im:=ld_tex('zombie_ani.png', path, 'mobs/'); + end; - procedure freeSkin;//Выгрузка текстур - var - i, j, len:integer; - nullimg:image; - begin - for i:=0 to MOB_TYPES do - begin - bytecode - getstatic field 'mob', 'texture_left', '[[Ljavax/microedition/lcdui/Image;'; - iload_0;//i - aaload; - arraylength; - iconst_1; - isub; - istore_2;//len - end; - for j:=0 to len do - begin - texture_left[i, j]:=nullimg; - texture_right[i, j]:=nullimg; - end; - end; - end; + procedure FreeTextures;//Выгрузка текстур + var + i : integer; + nullimg : image; + begin + (* TODO *) + end; - procedure saveData; + procedure SaveData; var - i, j : integer; + i : integer; begin - for i := 0 to MAX_MOBS do + for i := 0 to lastMob do begin - write_byte(mob_type[i]); - writeint(mob_x[i]); - writeint(mob_y[i]); - writeint(mob_vx[i]); - writeint(mob_vy[i]); - write_byte(mob_posi[i]); - writeint(mob_hp[i]); - writebool(mob_jmp[i]); - for j := 0 to MAX_ANIMREG do - write_byte(mob_anim[i, j]); + write_byte(mtype[i]); + writeint(mx[i]); + writeint(my[i]); + writeint(mvx[i]); + writeint(mvy[i]); + write_byte(mpos[i]); + writeint(mhp[i]); + writebool(mjump[i]); end; end; - procedure loadData;//Загрузка всех данных + procedure LoadData; var - i, j : integer; + i : integer; begin - for i := 0 to MAX_MOBS do + for i := 0 to lastMob do begin - mob_type[i] := read_byte; - mob_x[i] := readint; - mob_y[i] := readint; - mob_vx[i] := readint; - mob_vy[i] := readint; - mob_posi[i] := read_byte; - mob_hp[i] := readint; - mob_jmp[i] := readbool; - for j := 0 to MAX_ANIMREG do - mob_anim[i, j] := read_byte; + mtype[i] := read_byte; + mx[i] := readint; + my[i] := readint; + mvx[i] := readint; + mvy[i] := readint; + mpos[i] := read_byte; + mhp[i] := readint; + mjump[i] := readbool; end; end; - procedure resetData;//Сброс всех данных + procedure ResetData; var - i, j:integer; + i : integer; begin - for i := 0 to MAX_MOBS do + for i := 0 to lastMob do begin - mob_type[i]:=M_NONE; - mob_x[i]:=0; - mob_y[i]:=0; - mob_vx[i]:=0; - mob_vy[i]:=0; - mob_posi[i]:=0; - mob_hp[i]:=0; - mob_jmp[i]:=false; - for j := 0 to MAX_ANIMREG do - mob_anim[i, j]:=0; + mtype[i] := none; + mx[i] := 0; + my[i] := 0; + mvx[i] := 0; + mvy[i] := 0; + mpos[i] := 0; + mhp[i] := 0; + mjump[i] := false; end; end; initialization - // TYPE W H HP SX JH, AI_TYPE - initTab(M_NONE, 0, 0, 0, 0, 0, AI_NONE); - setMaxParts(M_NONE, -1); - - initTab(M_ZOMBY, 8, 32, 10, 1, 7, AI_ZLOY); - setMaxParts(M_ZOMBY, 3); - // TYPE PART, TEX, X, Y ANIM - initPart(M_ZOMBY, 0, 0, 4, 8, 0);//Head - initPart(M_ZOMBY, 1, 1, 4, 8, 0);//Body - initPart(M_ZOMBY, 2, 2, 4, 10, 0);//Hands - initPart(M_ZOMBY, 3, 3, 4, 20, 1);//Legs + InitTab(none, 0, 0, 0); + InitTab(zomby, 8, 32, 10); end.