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