![]() |
Visual Inventory Tutorial - Printable Version +- Mirage Engine (https://mirage-engine.uk/forums) +-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61) +--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18) +---- Forum: Resources (https://mirage-engine.uk/forums/forumdisplay.php?fid=49) +---- Thread: Visual Inventory Tutorial (/showthread.php?tid=883) |
Visual Inventory Tutorial - JokeofWeek - 19-04-2007 Alright well, on my way to programming my game, I was searching for a Visual Inventory code and found GSD's, but I saw that it was a very long code and was probably laggy, so I decided to remake the code. Then I wondered whether I should rip it from Elysium, and I decided not to, seeing as Elysium is very buggy. It's pretty simple, and will probably be less laggy, considering it doesn't re-load the item surface into a picture box and stuff. As you might notice, there are some similarities between GSD's and the Elysium and my tut. So first things first, this isn't a full tutorial. I have completed the code, but I want people to learn, and figuring out how to code things is the best way. Of course, you can ask questions on how to add the use + drop code in, but it's just not for copy paste. I'm just telling you how to blt the items and how to have a good base. You have to add the code for drop + using items. Oh my god, how hard :wink: So first, make a picture box called PicInventory, or whatever you want. Now, inside it, make 12 picInv boxes so it's an array. (However, make sure to start at 1 and not 0, so you have picInv 1 - picinv 12 and not picInv 0 - picInv - 11) Also, add a shape called SelectedItem with the following stats : BorderWidth = 2 Left = The left of the first picInv, - 1 Top = The top of the first picInv, - 1 Width = 35 Height = 35 Now, this is for a base base base mirage, with 24 inventory slots. Also, add a label or picturebox, whichever you want called PicUp and PicDown. These will be our scrollers. Now, at the top of frmMirage's code, add this : Code: Private InvScroll As Byte And add this in modGlobals Code: ' Used for visual inventory Now, the inventory scrolling set set for a layout like this : x | x | x | x x | x | x | x x | x | x | x So if you want a differnt layout, figure it out ![]() Then add this code : Code: Private Sub picDown_Click() This is what sets the scrolling and selecting. Now for the blitting. Make a timer called tmrBltInv with an interval of 50 or 100 (your choice) and the enabled set to false Now add this code : Code: Private Sub tmrBltInv_Timer() We're almost done! Now, in sub initDirectX, under the code Code: frmMirage.show Add : Code: frmMirage.tmrBltInv.Enabled = True And there you have it! You now have an optimized visual inventory system. Instead of blitting 24, it only blits 12 items, and instead of making picItems in the memory again as a picturebox on frmMirage, it blits directly from the surface. Now, up to you to add the drop / use code :wink: I was even nice enough to set up the Item Selected variable for you ![]() Any bug reports or comments, feel free to say so ![]() - Rian - 19-04-2007 Sweet tutorial dude. I'm gonna play with it a little when I get home ![]() I've been looking for a different way to do the visual inventory ![]() - JokeofWeek - 19-04-2007 Sonire Wrote:Sweet tutorial dude. I'm gonna play with it a little when I get home Aha, no problem ![]() Re: Visual Inventory Tutorial - original - 26-03-2008 When i add this, i get this error: Procedure declaration does not match description of event or procedure having the same name. It high lites this code: Code: Private Sub picInv_Click(Index As Integer Re: Visual Inventory Tutorial - original - 26-03-2008 I have that, what i showed you is what it highlighted. It didn't highlight ")". Re: Visual Inventory Tutorial - Robin - 27-03-2008 This tutorial is no better than the Elysium way of doing things. You need to move away from having a large array of bloated controls. You could easily have done this using only one picture box. Re: Visual Inventory Tutorial - William - 27-03-2008 Robin Wrote:This tutorial is no better than the Elysium way of doing things.Last time I checked es used bitblt? Re: Visual Inventory Tutorial - Robin - 27-03-2008 William Wrote:Robin Wrote:This tutorial is no better than the Elysium way of doing things.Last time I checked es used bitblt? It doesn't matter if you use BitBlt or BltToDC or if you even set up a clipper to each bloody picture box and render it in DX7. The point is that using more than one picture box is simply lazy. Re: Visual Inventory Tutorial - William - 27-03-2008 That might be the case here, but 2 picture boxes doesn't really matter. But of course, in one sence, it could be called lazy. Re: Visual Inventory Tutorial - Joost - 29-04-2008 I feel dumb, but anyway, The use item code is no problem, but I want to drop with right-click. What's the best way of doing that? Another parameter to the function or something like it? |