forum.boolean.name

forum.boolean.name (http://forum.boolean.name/index.php)
-   2D-программирование (http://forum.boolean.name/forumdisplay.php?f=13)
-   -   База игры в XML (http://forum.boolean.name/showthread.php?t=2773)

Xupypr 21.02.2007 16:57

Re: Xml парсер
 
решил засунуть базу игры в xml
возникла проблемка, пишет что не может определить структуру ветвей. хз, вроде все правильно сделал. вот кусок кода из базы

Код:


<?xml version="1.0" ?>
<base>
<entity type="monstr">
<class>name="soldier"</class>
<model>file="monstr\soldier\tris.md2"</model>
<skin>file="monstr\soldier\skin.pcx"</skin>
<frame>
 <attack1>firstkey="0" secondkey="11"</attack1>
 <attack2>firstkey="11" secondkey="29"</attack2>
 <attack3>firstkey="29" secondkey="38"</attack3>
 <attack4>firstkey="38" secondkey="44"</attack4>
 <pain1>firstkey="44" secondkey="49"</pain1>
 <pain2>firstkey="49" secondkey="54"</pain2>
 <pain3>firstkey="54" secondkey="61"</pain3>
 <pain4>firstkey="61" secondkey="79"</pain4>
 <pain5>firstkey="79" secondkey="96"</pain5>
 <run>firstkey="99" secondkey="105"</run>
 <pain6>firstkey="126" secondkey="145"</pain6>
 <idle1>firstkey="146" secondkey="176"</idle1>
 <idle2>firstkey="175" secondkey="214"</idle2>
 <step>firstkey="215" secondkey="223"</step>
 <idle3>firstkey="224" secondkey="247"</idle3>
 <die1>firstkey="271" secondkey="279"</die1>
 <die2>firstkey="308" secondkey="342"</die2>
 <die3>firstkey="343" secondkey="387"</die3>
 <die4>firstkey="441" secondkey="464"</die4>
</frame>
<chardata> life="80" speed="0.2" angspeed="0.5" arange="200" dammin="5" dammax="15" reloadtime="500" resfire="50" resbullet="70" resplasma="90" resfreez="1" ressuperg="10"</chardata>
<dropitem> count="4" item1="bullet2" chance1="10" item2="weapon2" chance2="5" item3="weapon3" chance3="2" item4="bullet3" chance4="3"</dropitem>
</entity>
<entity inv="armor">
 <class name="bullet2"/>
 <model="inv\bullet2\bullet2.b3d"/>
 <skin="inv\bullet2\bullet2.jpg"/>
 <sell="5"/>
 <weight="1"/>
</entity>
</base>

в самом блитце код правильный 100%

Xupypr 22.02.2007 11:10

Re: Xml парсер
 
вот я тут немного переделал, но все равно в блитце тормозится на строчке count=xmlnodechildcount(worldnode) и пишет Object does not exist. компилятор останавливается на этой же функции xmlnodechildcount
Код:


<?xml version="1.0" ?>
<base>
<entity type="monstr">
<class name="soldier"/>
<model file="monstr\soldier\tris.md2"/>
<skin file="monstr\soldier\skin.pcx"/>
<frame>
 <attack1 firstkey="0" secondkey="11"/>
 <attack2 firstkey="11" secondkey="29"/>
 <attack3 firstkey="29" secondkey="38"/>
 <attack4 firstkey="38" secondkey="44"/>
 <pain1 firstkey="44" secondkey="49"/>
 <pain2 firstkey="49" secondkey="54"/>
 <pain3 firstkey="54" secondkey="61"/>
 <pain4 firstkey="61" secondkey="79"/>
 <pain5 firstkey="79" secondkey="96"/>
 <run firstkey="99" secondkey="105"/>
 <pain6 firstkey="126" secondkey="145"/>
 <idle1 firstkey="146" secondkey="176"/>
 <idle2 firstkey="175" secondkey="214"/>
 <step firstkey="215" secondkey="223"/>
 <idle3 firstkey="224" secondkey="247"/>
 <die1 firstkey="271" secondkey="279"/>
 <die2 firstkey="308" secondkey="342"/>
 <die3 firstkey="343" secondkey="387"/>
 <die4 firstkey="441" secondkey="464"/>
</frame>
<chardata life="80" speed="0.2" angspeed="0.5" arange="200" dammin="5" dammax="15" reloadtime="500" resfire="50" resbullet="70" resplasma="90" resfreez="1" ressuperg="10"/>
<dropitem count="4" item1="bullet2" chance1="10" item2="weapon2" chance2="5" item3="weapon3" chance3="2" item4="bullet3" chance4="3"/>
</entity>
<entity inv="armor">
<class name="bullet2"/>
<model file="inv\bullet2\bullet2.b3d"/>
<skin file="inv\bullet2\bullet2.jpg"/>
<sell money="5"/>
<weight weight="1"/>
</entity>
</base>

помагите плизз, 2 дня сижу не пойму в чем тут дело.

moka 24.02.2007 00:13

Re: База игры в XML
 
worldnode это что у тебя? Ты должен найти сперва определённую ветвь, затем искать у неё чайлды.

Xupypr 27.02.2007 17:08

Re: База игры в XML
 
МоКа, base мну главная ветвь, все остальные открываются и закрываются по всем правилам. вот глянь блитцкод:

Код:


worldnode = xmlNodeFind("base", rootnode)
;Get the handle of the world node
count = xmlNodeChildCount(worldnode) ;Get the world node's child count
Stop
For i = 1 To count ;Loop through each child node of the world node
entitynode = xmlNodeChild(worldnode, i) ;Get the child node
If xmlNodeNameGet(entitynode) = "entity" Then ;Check if it's an entity
t$ = xmlNodeAttributeValueGet(entitynode, "type")
;Get the entity type
End If
 
If t = "monstr" Then
class = xmlnodefind("class",entitynode)
monstr.monstr = New monstr
monstr\name$ = xmlNodeAttributeValueGet(class, "name")
model = xmlnodefind("model",entitynode)
monstr\model$ = xmlNodeAttributeValueGet(model, "file")
skin = xmlnodefind("skin",entitynode)
...
 
dropitem = xmlnodefind("dropitem",entitynode)
count = xmlNodeAttributeValueGet(dropitem, "count")
 
For j=count To 1 Step -1
monstr\dropitems.dropitem = New dropitem
monstr\dropitems\name$ = xmlNodeAttributeValueGet(dropitem, "item"+Str$(j))
monstr\dropitems\chance = xmlNodeAttributeValueGet(dropitem, "chance"+Str$(j))
Next
 
End If
 
Next

Администраторы, зачем мои сообщения в тему переделали? Я писал в топике LIB, че теперь это делает в 2 д проганье?

moka 28.02.2007 02:16

Re: База игры в XML
 
Нельзя искать в корневой ветви.
Сделай так:

Цитата:

<?xml version="1.0" ?>
<base>
<objects>
<entity type="monstr">
<class name="soldier"/>
<model file="monstr\soldier\tris.md2"/>
<skin file="monstr\soldier\skin.pcx"/>
<frame>
<attack1 firstkey="0" secondkey="11"/>
<attack2 firstkey="11" secondkey="29"/>
<attack3 firstkey="29" secondkey="38"/>
<attack4 firstkey="38" secondkey="44"/>
<pain1 firstkey="44" secondkey="49"/>
<pain2 firstkey="49" secondkey="54"/>
<pain3 firstkey="54" secondkey="61"/>
<pain4 firstkey="61" secondkey="79"/>
<pain5 firstkey="79" secondkey="96"/>
<run firstkey="99" secondkey="105"/>
<pain6 firstkey="126" secondkey="145"/>
<idle1 firstkey="146" secondkey="176"/>
<idle2 firstkey="175" secondkey="214"/>
<step firstkey="215" secondkey="223"/>
<idle3 firstkey="224" secondkey="247"/>
<die1 firstkey="271" secondkey="279"/>
<die2 firstkey="308" secondkey="342"/>
<die3 firstkey="343" secondkey="387"/>
<die4 firstkey="441" secondkey="464"/>
</frame>
<chardata life="80" speed="0.2" angspeed="0.5" arange="200" dammin="5" dammax="15" reloadtime="500" resfire="50" resbullet="70" resplasma="90" resfreez="1" ressuperg="10"/>
<dropitem count="4" item1="bullet2" chance1="10" item2="weapon2" chance2="5" item3="weapon3" chance3="2" item4="bullet3" chance4="3"/>
</entity>
<entity inv="armor">
<class name="bullet2"/>
<model file="inv\bullet2\bullet2.b3d"/>
<skin file="inv\bullet2\bullet2.jpg"/>
<sell money="5"/>
<weight weight="1"/>
</entity>
</objects>
</base>
И код:
Цитата:

worldnode = xmlNodeFind("base", worldnode)
objectsnode = xmlNodeFind("objects", worldnode)
;Get the handle of the world node
count = xmlNodeChildCount(objectsnode) ;Get the world node's child count
Stop
For i = 1 To count ;Loop through each child node of the world node
entitynode = xmlNodeChild(objectsnode, i) ;Get the child node
If xmlNodeNameGet(objectsnode) = "entity" Then ;Check if it's an entity
t$ = xmlNodeAttributeValueGet(entitynode, "type")
;Get the entity type
End If

If t = "monstr" Then
class = xmlnodefind("class",entitynode)
monstr.monstr = New monstr
monstr\name$ = xmlNodeAttributeValueGet(class, "name")
model = xmlnodefind("model",entitynode)
monstr\model$ = xmlNodeAttributeValueGet(model, "file")
skin = xmlnodefind("skin",entitynode)
...

dropitem = xmlnodefind("dropitem",entitynode)
count = xmlNodeAttributeValueGet(dropitem, "count")

For j=count To 1 Step -1
monstr\dropitems.dropitem = New dropitem
monstr\dropitems\name$ = xmlNodeAttributeValueGet(dropitem, "item"+Str$(j))
monstr\dropitems\chance = xmlNodeAttributeValueGet(dropitem, "chance"+Str$(j))
Next

End If

Next
Перенесли потомучто это не относится к разработке библиотек, и не к 3д графике, поэтому в 2д. Подобной тематики темы в 2д. Всё правельно. ТЕмболее вопрос не относительно функционированию библиотеки, или её багов, ну и подобного, вопрос относительно ситуации, а то что используется библиотека это второстепенно. Надеюсь администрация, поэтому перенесла.

Xupypr 28.02.2007 12:35

Re: База игры в XML
 
Мока, большое спасибо.

moka 28.02.2007 23:58

Re: База игры в XML
 
Всегда рад помочь, если что обращайся ещё. ;)


Часовой пояс GMT +4, время: 23:20.

vBulletin® Version 3.6.5.
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Перевод: zCarot