Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Need help with my diablo-like inventory!

Author
Message
geomancer12 xD
15
Years of Service
User Offline
Joined: 14th Feb 2009
Location:
Posted: 14th Feb 2009 16:33
I have been developing an inventory engine lately, and i run to a few problems. I have attached my source code, you can freely download it, but if you use it somewhere, gimme credit . Problem is, i wanna create an inventory with drag&drop items and slots...Diablo-like. But how could i make , if i had more weapons on screen, control moouseover and click events for it? For example, i got a sword and an axe. When i would mouseover a sword, it would say \"sword\", and when i would mouse over axe, then it would say \"axe\". Please try to modify my source and tell me what should i do. Thanks!

Attachments

Login to view attachments
Hayer
18
Years of Service
User Offline
Joined: 4th Nov 2005
Location: Norway
Posted: 16th Feb 2009 00:30 Edited at: 16th Feb 2009 00:54
I would attack this problem with
- A UD-array
- Simple math, 2d screen -> MouseX/Y
- Spirites

now, go and try to solove the problem ur self while i look at ur scode


- Think of the inventory as squares. Maybe 30 squares in the width, and 10squares in height. Each square is 32x32. Now u can paint the inventroy to the screen. So know i'll leave u with that and see if u come up with anyway to handle what space is taken and what is not. Ask if u cant get it to work...

And use vectors and struct or maybe even a invetroy_class

Keep it simple.
Questions? Mail me
geomancer12 xD
15
Years of Service
User Offline
Joined: 14th Feb 2009
Location:
Posted: 17th Feb 2009 21:47
Thanks for help...i think i got it. I'll try. But check out the code and post your edited version if you come up with something! Credit given ^^
Bran flakes91093
16
Years of Service
User Offline
Joined: 13th Sep 2008
Location: Crazy Land
Posted: 18th Feb 2009 04:19
I have the dragging working, but I don't know if it's what you want. Plus, it does have a problem - You can't drag it too fast or you lose it.


geomancer12 xD
15
Years of Service
User Offline
Joined: 14th Feb 2009
Location:
Posted: 18th Feb 2009 12:21
Thanks! But what causes this bug...if i drag too fast, i just drops...?
Bran flakes91093
16
Years of Service
User Offline
Joined: 13th Sep 2008
Location: Crazy Land
Posted: 18th Feb 2009 14:34
Well, the game can only go so fast code-wise, so if you drag too fast, the sprite can't catch up, and the mouse will not be directly over the sprite, and won't trigger the if statement:



But this is probably fixable if you check if the user has released the mouse button yet before it drops it.
Bran flakes91093
16
Years of Service
User Offline
Joined: 13th Sep 2008
Location: Crazy Land
Posted: 18th Feb 2009 15:13
Boy I've really outdone myself this time. I don't know if I should be actually handing you code instead of just giving you ideas on how to do it, but I personally love the idea of your project.

Now, you can:
-Have multiple weapons
-Drag a weapon on top of another and not pick it up
-Drag weapons as fast as you possibly can

No grid control yet , but I'll definitely work on trying it.
BUT! I have organized everything into a neat little class, so all you have to do is add a weapon via the constructor and call Update() and Draw() when needed. Isn't that awesome?!?!?

Just tell me if I'm being too helpful by handing you this code lol.


geomancer12 xD
15
Years of Service
User Offline
Joined: 14th Feb 2009
Location:
Posted: 19th Feb 2009 11:52
This is awesome! Thanks man! Ill give you a credit
Btw, do you have msn or xfire? So you can join our development team... We already got 3d designer, a programmer, and...we could use one more
geomancer12 xD
15
Years of Service
User Offline
Joined: 14th Feb 2009
Location:
Posted: 19th Feb 2009 12:06
I have an idea about the grid.
We have this in our source :


So, if we have a grid of...say 25x10 squares, then we must define size of items in squares. For example, Xsize=3, Ysize=2, etc. So that would look like this :


That shouldn't be a problem. Now we should make some squares, and try to read the position of the item in grid...Well, i can't think of anything that would solve this part. Any ideas?
geomancer12 xD
15
Years of Service
User Offline
Joined: 14th Feb 2009
Location:
Posted: 19th Feb 2009 12:19
Check this out...I did the snapping part. Now how do i detect where the item dropped?... Should i use an array?
Bran flakes91093
16
Years of Service
User Offline
Joined: 13th Sep 2008
Location: Crazy Land
Posted: 19th Feb 2009 18:28 Edited at: 19th Feb 2009 19:24
Actually... I went ahead and made two more classes.
A GridControl class that pretty much does all the work, and a GridArea class that the GridControl class uses.

Download the project attached. It now has a fully working grid system.

Now you can drag weapons and when released, they will fall into the grid that they are closest to. And, if there is already a weapon in the grid space, they weapon you drop on it will go back to the previous grid that it was in.

The whole thing is extremely flexible to suit grid size etc. Just change the call to the GridControl constructor while initializing gridControl in Main.cpp You can add more rows, columns, and customize it.

And about the joining your dev team, I don't think I can. I'm only 15 and this is just my week off from school, so I won't have much time to do anything starting Monday. But I do like the credit part.

My aim screename : Branflakes91093

My live screename : Branflakes (I think)

My email : Branflakes91093@live.com (I don't check the aol one)

Any questions about the code let me know, because I found it to be a little confusing as I was making it.

Attachments

Login to view attachments
geomancer12 xD
15
Years of Service
User Offline
Joined: 14th Feb 2009
Location:
Posted: 19th Feb 2009 21:31
I'm 15 too xD
Hmm i think you misunderstood the "credit" context. I meant as a mentioning your name in the credits part of the game, not paying you money
Btw your programming skills are pretty high for your years. Awesome work you done on the project. Thanks again
Bran flakes91093
16
Years of Service
User Offline
Joined: 13th Sep 2008
Location: Crazy Land
Posted: 20th Feb 2009 01:17
No, I knew what the credit part meant, I'm not expecting you to pay me lol.

You're very welcome. Tell me if you need any more help and thank you for the compliment.

Login to post a reply

Server time is: 2024-09-30 19:34:57
Your offset time is: 2024-09-30 19:34:57