About Store Forum Documentation Contact
Donations:
207$/mo



Post Reply 
inventory help
Author Message
craksy Offline
Member

Post: #16
Re: inventory help
yea now i got another error =(

code:
Code:
Game::Item checkItems()
{
    Game::Item *temp =NULL;
    for(int i=0;i<ELMS(Items);i++)
    {
        if(Dist(Items[i].pos(), Players[0].pos())< 2.0)
        {
            temp =&Items[i];
        }
    }
    return temp;

}

and it says:
1>.\Game.cpp(40) : error C2660: 'Esenthel::Game::Item::Item' : function does not take 1 arguments


thanks for helping me!
hope you can help me out with this one too
01-08-2009 03:29 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #17
Re: inventory help
returning pointers is handled this way:
Game::Item* checkItems()

not this way:
Game::Item checkItems()
01-08-2009 03:54 PM
Find all posts by this user Quote this message in a reply
craksy Offline
Member

Post: #18
Re: inventory help
i am learning a whole lot about pointers this way pfft

anyway, new error -.-'

1>.\Game.cpp(48) : error C2664: 'Esenthel::Game::Obj::itemPickUp' : cannot convert parameter 1 from 'Esenthel::Game::Item *(__cdecl *)(void)' to 'Esenthel::Game::Item &'


can you help me out with this one too? :oops:
sorry -.-'
01-08-2009 04:13 PM
Find all posts by this user Quote this message in a reply
craksy Offline
Member

Post: #19
Re: inventory help
sorry for double posting, but i would really like answer to my above question!

also, i have another quick one about the gui:
its it possible to make circular windows?
i thaught it would be cool, in my game, if you interact with stuff, and then a little circle pops up with the available option for the specific item, around the edge xD

thanks in advance smile
01-09-2009 10:41 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #20
Re: inventory help
if you want help with this error
Code:
>.\Game.cpp(48) : error C2664: 'Esenthel::Game::Obj::itemPickUp' : cannot convert parameter 1 from 'Esenthel::Game::Item *(__cdecl *)(void)' to 'Esenthel::Game::Item &
you'll need to double click on the error line, which will point you to the source code line, and please paste it here

yes it is possible to do circular windows,
you'd need to extend the base Window class make your own, and extend mainly
Window::test and Window::draw
01-09-2009 11:01 PM
Find all posts by this user Quote this message in a reply
craksy Offline
Member

Post: #21
Re: inventory help
to be honest i have no idea how to do that window thingy...
think ill just do it later, when i get a little more experience with the engine!

and i got the error because i forgot to put the argument thingy "()" after my function call, and forgot to refer to it as a pointer...
but still it will only pick up the items in order :S
have any idea what might be wrong?
heres my code:

Code:
Game::Item* checkItems()
{
    Game::Item *temp =NULL;
    for(int i=0;i<ELMS(Items);i++)
    {
        if(Dist(Items[i].pos(), Players[0].pos())< 2.0)
        {
            temp =&Items[i];
        }
    }
    return temp;

}
/******************************************************************************/
void Player::updateItems()
{
    if(Kb.bp(KB_LCTRL)){
        if(Items.elms()){
            if(Dist(Items[0].pos(), Players[0].pos())<=1) itemPickUp(*checkItems());
        }
    }

}

it runs without errors, but i can still only pick up the items in order as if i used Items[0] as argument for the itemPickUp...
can you tell me whats wrong?
01-10-2009 02:41 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #22
Re: inventory help
your algorithm is wrong

it should be more like this

void Player::updateItems()
{
if(Kb.bp(KB_LCTRL))
{
if(Item *item=checkItems())
itemPickUp(*item);
}
}
01-10-2009 12:20 PM
Find all posts by this user Quote this message in a reply
craksy Offline
Member

Post: #23
Re: inventory help
thanks alot! it works great grin

but i dont really understand this line:

if(Item *item=checkItems())
to me it looks like "if a new pointer with the value 'checkIems* is created, then do the following:"
but i suppose thats not what it do? but to me it looks like decklaring a new variable.... which i have never seen in an if statement :S

could you please explain it to me? not that its that important now that it works, but i prefer to actually understand my code pfft

thanks in advance grin
01-10-2009 12:42 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #24
Re: inventory help
if(Item *item=checkItems())

is equal to

Item *item=checkItems();
if(item!=NULL)


which means:
that it checks if "checkItems" actually returned a valid pointer to an item (valid means not NULL)
01-10-2009 12:54 PM
Find all posts by this user Quote this message in a reply
craksy Offline
Member

Post: #25
Re: inventory help
ah i see!
so "if(variable name)"
means if variable name, is not null?

anyway thanks for the help grin
01-10-2009 01:58 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #26
Re: inventory help
yes
01-10-2009 02:58 PM
Find all posts by this user Quote this message in a reply
craksy Offline
Member

Post: #27
Re: inventory help
Esenthel Wrote:you can make it 2 ways (at least) :

1) in world editor store for each item additional parameter like
String icon_name, and inside it set the path to your icon, for exameple String icon_name "obj/item/axe/icon.gfx"
later in game when creating item object (Item::create)
icon=Gfxs(obj_params.getParam("icon_name)->asStr());

or simplier

2) keep all icons of your meshes named as mesh_name+".gfx" (having a mesh "obj/item/axe/axe.mesh" have icon "obj/item/axe/axe.mesh.gfx")
then when creating item object (Item::create)
Char *mesh_name=Meshs(obj_params.mesh);
icon=Gfxs(S+mesh_name+".gfx"); // use mesh name appended by ".gfx"

hmm i am still not quite sure how to do this...
i have made an extention of the Game::item struct, and made a variable Gfx icon;
now you say i have to set the icon in the item::create! but that isnt used, when you get the items from the world! is it?
or will i have to extend that one too, and then set the icon in there?
kinda confused here :/

hope you can explain it in a little more detail :/

thanks in advance smile
01-11-2009 04:19 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #28
Re: inventory help
struct Item : Game::Item
{
Gfx *icon;
void create(ObjParams ..)
{
__super::create(..);
icon=Gfxs(..);
}
..
}
01-11-2009 05:09 PM
Find all posts by this user Quote this message in a reply
craksy Offline
Member

Post: #29
Re: inventory help
i suppose ill have to fill out the ".."s?
and if so: what do i put in the __super::create?
and always wondered: whats the __super thing about?

thanks
01-11-2009 05:32 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #30
Re: inventory help
__super is the base class of an object
in this example its (Game::Chr)

and if so: what do i put in the __super::create?
this is covered in most of the tutorials in "Game Basics"
01-11-2009 05:42 PM
Find all posts by this user Quote this message in a reply
Post Reply