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.

Author
Message
Silence
13
Years of Service
User Offline
Joined: 14th Oct 2012
Location:
Posted: 7th Mar 2013 21:58
(meekly crawls back to forum)

I have been bombarding this site non-stop with questions.

Good day everyone, I bring another problem at my hands. Being a beginner coder I tried making my own inventory system. Something very simple. Now you are playing as the character. The bottom screen holds a hotbar (similar to minecraft). I need each square in that hotbar to be as use of an inventory system. Now when I mean "Inventory" I dont mean the literal term.

Basically when you walk over an object the image will appear in the hot bar but you will not be able to get it out. It will just serve as a reminder of what you have. Any ideas?
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 8th Mar 2013 01:38
When you detect the player has picked up an item, display the image where you want on screen. Not difficult at all. Make a list of what items are available and simply keep track of what you currently have in possession. If player has it, display it!




"You're all wrong. You're all idiots." ~Fluffy Rabbit
Silence
13
Years of Service
User Offline
Joined: 14th Oct 2012
Location:
Posted: 8th Mar 2013 04:37
Phaelax, let's say I have just the image of a hot bar on the screen while you play. Then once you come in contact with the object I say "delete object,(objectID)" and then load up a small image and past it in the exact location of where the square is?

I know this is doable but I'm having ahard time having a hotbar picture appear on screen and stay there while you play. Can you point me in the right direction?
Sph!nx
17
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 8th Mar 2013 11:33 Edited at: 8th Mar 2013 11:35
You basically said it yourself how it works. It's easy:



When placing an image over another image, just move the paste command lower in the do-loop. Good luck!

Regards Sph!nx
www.mental-image.net
Silence
13
Years of Service
User Offline
Joined: 14th Oct 2012
Location:
Posted: 8th Mar 2013 16:24
This command keeps freezing on the section before the MainSection of the game. The loading bar finished but then I hear the music of the game start but it doesnt go to the Mainsection
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 8th Mar 2013 18:43
I think perhaps you should post your code so we can see exactly what's going on. I'm guessing your code isn't organized properly within the loop.

"You're all wrong. You're all idiots." ~Fluffy Rabbit
Silence
13
Years of Service
User Offline
Joined: 14th Oct 2012
Location:
Posted: 8th Mar 2013 19:10 Edited at: 8th Mar 2013 19:11
Dont worry I fixed it. I have it set so that when you hold "I" the inventory pops up c:

I have another question, what is a command to delete text? such as



but what is a command I can put in the IF THEN statement to delete text
Sph!nx
17
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 9th Mar 2013 12:25 Edited at: 9th Mar 2013 12:26
I'm sorry but I have a hard time understanding you. Do you wish to delete text or the image in the code?

In any case: Don't put load image in a constant loop, if that's what you are doing. Function A: Load the image (once) upon pressing I and function B would have the "paste" command, that constantly gets updated (IF the condition is set). Simply create a third function to delete the image and set the condition so it will no longer be updated to reverse the process.

Regards Sph!nx
www.mental-image.net
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 9th Mar 2013 23:33
I'm with Sphinx, your question makes no sense. And I still think you should post your code, because after looking at your example there I have a feeling you're do A LOT of things wrong.

"You're all wrong. You're all idiots." ~Fluffy Rabbit
Silence
13
Years of Service
User Offline
Joined: 14th Oct 2012
Location:
Posted: 10th Mar 2013 02:39 Edited at: 10th Mar 2013 03:43
Sorry for the misunderstanding. The game loads corrects? On he top left of the screen I wil have a tip that says "Hold 'I' to open your inventory. As soon as you open your inventory the tip should disappear. Clear now?

If you could help me with another problem that'd be very much appreciated too. I have the command

"AUTO OBJECT COLLISION 1,50,0" and this helps with all my models to have he corrected collision on them. My problem is that in the game I also have tiny models that arent for decoration or scenery. These models need to be 'collected' in a way.

I have a small little model hiding amonst the scenery but due to he auto object collision it creates a collision around it.

I was thinking instead of walking over to collect it. I can just click with the mouse over the object and delete it. My question is how will the mouse know that it is over an object to delete?
luskos
19
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 10th Mar 2013 10:02


Coding is My Kung Fu!
And My Kung Fu is better than Yours!
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 10th Mar 2013 18:56
Quote: "I wil have a tip that says "Hold 'I' to open your inventory. As soon as you open your inventory the tip should disappear. Clear now?"


Your inventory only displays when you hold I, correct? Well, displaying the text is done the same way. You can just through in an ELSE command to what you already have. So, if pressing I then show the inventory image, otherwise(else) show the text.



"You're all wrong. You're all idiots." ~Fluffy Rabbit
Silence
13
Years of Service
User Offline
Joined: 14th Oct 2012
Location:
Posted: 10th Mar 2013 19:01 Edited at: 10th Mar 2013 19:55
Thank you Phaelex for you help.

Thank you luskos. I knew this code already and was trying to play around with it but I just couldnt get it. Will someone show me an example?

Let's use something random for me to get the idea on how this works.

make object box 1,2000,2000,2000
position object 1,650,10,750


What would the code be to have it deleted with the mouse and why?

For a clearer explanation, I would just like that once I click on the object, the object should be deleted off the screen and load up a small image representation to make it seem as though they collected it when the player really didnt.

I was thinking of

if mouseclick()=1
delete object 1
load image "whatever.bmp",1
Paste image 1,(x,y)
endif

but of course, this will work anywhere even if they arent in the same room as the object, and will not work with the many other collectables I have made.
luskos
19
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 10th Mar 2013 21:06 Edited at: 10th Mar 2013 21:25
In the example i provide there is two types of objects collectable and non-collectable.Spheres and cubes.If you click with the mouse over non-collectable object nothing happens, but if it's collectable it's deleted and you must add the rest.Code:


Coding is My Kung Fu!
And My Kung Fu is better than Yours!
Silence
13
Years of Service
User Offline
Joined: 14th Oct 2012
Location:
Posted: 10th Mar 2013 21:21
Can you explain how this works?
luskos
19
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 10th Mar 2013 21:33 Edited at: 10th Mar 2013 21:37
You have array of objects named Objects, you expand it to the number of objects you have, then if you want to add an object as collectable you do : Objects(object number).IsCollectable = TRUE.Objects(Object number).IsCollectable = FALSE if it's not collectable.Then if there is mouseclick over an object and if is collectable = TRUE delete it and do whatever you want to do with your image.If you still do not understand the code search "UDT" in the forum.It means User Defined Type.Learn how they work and you will be ok.

Coding is My Kung Fu!
And My Kung Fu is better than Yours!
Silence
13
Years of Service
User Offline
Joined: 14th Oct 2012
Location:
Posted: 10th Mar 2013 22:06 Edited at: 10th Mar 2013 22:14
Oh for goodness sakes. I tried putting your code into my game and tweaking it but the forsaken cubes wont even load into the game now. I'm going to attach the code in a word file so you can see the issue. For SOME reason. I can never ever get a zipped file to post to the forum. So I hope you can just look through the code without executing the file.
luskos
19
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 10th Mar 2013 22:56
Your problem is that you don't know how to organize your code properly.I've seen you use multiple loops.In your game you only need 1.You are free to use more of them if you know how to manage them.I bet there is bunch of other stuff you don't do right it's too much code to make it right for you.You lack basics.Here is how you are supposed to do it.

In the first part of your code you initialize stuff like sync rate, window mode, display mode, you declare variables, constants, globals, load images and models for your game.In the mid of your code is your main loop you need only one, this is the place where almost everything in your game happens, you tell your game what you want to do with everything you have, it's the place for your statemennts, finite loops, cases, whiles, endwhiles and so on...In this main loop you can call subroutines with gosub command which you put outside the loop, just beneath it.Gosub command is like jump, you tell the game to jump outside the main loop execute some code and then jump back where it was this is good practice if you want to keep main loop clean and easy to read and follow.The last part of your code could be functions.You call function in your main loop.Functions can have 2 types of variables in them.Local variables and global variables.Local variables are for functions only.Once your game finish the function they are destroyed and their value isn't kept anywhere.With global variables you can assign value within the function and read it in your main loop.Arrays are global.

Coding is My Kung Fu!
And My Kung Fu is better than Yours!
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 11th Mar 2013 01:36
Why'd you upload your code as a Word document?

For starters, ditch your entire loading method. You're making the user wait several unnecessary seconds with all those needless WAIT commands.

Use relative paths for loading media instead of absolute. (otherwise your game isn't going to work if you move it or for anyone else)
When you create your project file, the current folder it resides in is your root folder. So if your project is in a folder called C:\Users\Dania\Desktop\Team Kryptic\ then you should just load your images like this: load image "media\image.bmp", 1

if scancode()=0 then exit
This is going to exit almost immediately most likely because unless the user holds down a key constantly, it's always going to be 0.


Take a look at this code below. This is a good start for a typical program. I couldn't quite make it fit to your code exactly because frankly I have no clue what you're trying to do. I've been coding for about 15 years, so that might tell you something about your own code if I can't even figure out the structure of what it's suppose to do.




Judging by the amount of media you're loading, you're attempting to make a fairly decent size project. I would strongly encourage you put this project on hold and start with a far more simple game like pong. Yea it's not as exciting, but you need a firm grasp on code structure and organization before tackling anything larger.

"You're all wrong. You're all idiots." ~Fluffy Rabbit
Silence
13
Years of Service
User Offline
Joined: 14th Oct 2012
Location:
Posted: 11th Mar 2013 15:10
Thank you all for your opinions and advice. I cannot ditch this game because I'm making it for a coding class for a grade. Sadly, none of you really answered my real question which is why I couldnt have the objects being clicked away and deleted. I will say that though your advice is helpful it will take a long time to clean up. And the reason I did it in a word file was because DBPro was acting odd and wouldnt save.

Now with all that aside, may you please answer my question and help me?
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 11th Mar 2013 17:22 Edited at: 11th Mar 2013 17:26
Keep at it Silence. You have quite a lot working as I can see from your snippet, you seem a lot more knowledgeable about DBP than what you imply.

You would have probably figured out this problem on your own if you made an in-depth analysis of your question.

What Phaelax said is right, if you structured the program in that manner, you would have easily of gotten Luskos's solution to work. Currently your program makes something simple too confusing.

What you should do is start with your question: "why I couldnt have the objects being clicked away and deleted"

Why can you delete an object? You know this; so that leaves the clicking part.

How do you detect an object click; Luskos showed you that. So that leaves the grouping of objects that are allowed to be clicked.

How do you group things in DBP? What is a group? Items that carry a similar attribute, at least in this case, give the objects that can be deleted that attribute. Store a group number in an array like Luskos did; or invest in a free download of Matrix1 utilities which supplies object grouping commands.

You want to now display an image in place of the object. What is an easy way to display an image continuously on screen? Sprites. How do you put the sprite at the screen location of an object? Where is the object screen location? In the Object Screen X() and Object Screen Y() expressions. Once finished displaying the image, delete the sprite. Heck, you could even fade the sprite out using Set Sprite Alpha, deleting it at zero sprite alpha.

Quote: "the reason I did it in a word file was because DBPro was acting odd and wouldnt save"


My first time hearing about something like this. So your IDE is not saving... Might need to repair the installation or try out the Indigo IDE. I've seen in the past that the forum will not upload files at certain sizes below 100mb; (it might be a browser thing). Try zipping parts of the project into separate zip files; if you know how to copy and paste a file into a folder, then making separate zip files should be quite easy to do.

Silence
13
Years of Service
User Offline
Joined: 14th Oct 2012
Location:
Posted: 12th Mar 2013 00:30
Thank you al for your help and paitence. I decided to just leave this idea and go for a much smoother one that works flawlessly (also included working pause menu as well!)

Again thank you for your kindness.

-Silence

Login to post a reply

Server time is: 2026-07-08 07:25:42
Your offset time is: 2026-07-08 07:25:42