Hi again. I don't know the language syntaxe/semantics, but let's think a little in pseudo code:
- Create a inventoryfunction InventoryCreate (width, height) Invbox.width=width Invbox.height=height Invbox.objects=NULL Invbox.nrobjects=0 return Invboxend - Create a Objfunction ObjectCreate(some_vars_about_the_object, inv_width, inv_height, inv_image) Obj.vars= some_vars_about_the_object ... ... Obj.inv_width=inv_width Obj.inv_height=inv_height Obj.inv_image=inv_image return Objend -- Add a object to a inventory on position X,Yprocedure InventoryAddObject(inv, obj, x, y) -- check to see if it fits if inv.width < x+ obj.inv_width return "does not fit" if inv.height <y+ obj.inv_height return "does not fit" for every object already in inventory if inv_obj.x < x+ obj.inv_width and inv_obj.x+ inv_obj.width >= x return "does not fit" ..... same for Y end inv.objects[inv.nrobjects].x=x inv.objects[inv.nrobjects].y=y inv.objects[inv.nrobjects].obj=obj inv.nrobjects++end-- Now using itinv=InventoryCreate(10,5)obj=ObjectCreate("Sword", "blablabla", 1,3, "cool_sword.jpg")-- get mouse position, find that user wants to "drop a sword in the inventory", transform the X,Y screen coordinates to a inventory X,YInventoryAddObject(inv, obj, x,y)
this is was just typed without too much thinking. But it would help you sort some ideas, I hope :)
About the other question: you can post the executable, or the source code, it isn't forbiden in here. Its just a personal oppinion about posting full functional source code: users just grab it, use it, without knowing what it does or how it does it.