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.

Newcomers DBPro Corner / Help regarding my Map Editor

Author
Message
nackidno
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Där solen aldrig skiner
Posted: 30th Jul 2008 21:30
Hi, I have been working on a level editor for some times now. And I have come to the point where I really do need help because of my noobishness.

My problem I hope someone can help me with :

I am trying to load a texture from a directory of the users choice.
Or to add more details:

I want that when I press the T-key, a window pop up appears, asking the user after a texture. And when the user have selected a texture, the editor will then use it as the current texture when placing objects.

If someone know how to do this, I will appreciate the help!
OR, if there are any plug-ins that simplify this, I will appreciate that too!

// Nackidno

- Elias, Damezean, Nackidno, Wonderboy

AntocGames - http://antocgames.se.nu/
Nano brain
16
Years of Service
User Offline
Joined: 7th May 2008
Location:
Posted: 31st Jul 2008 01:05 Edited at: 31st Jul 2008 01:12
BLUE GUI is a great plugin. I recommend it.

Otherwise, for starters you need to(overview):



Now, this will create a simplified image viewer without scrolling. Therefore, you will only be able to display a limited number of textures. However, this should give you something to play with, which might take you some time. Need help with it? Just ask.
nackidno
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Där solen aldrig skiner
Posted: 31st Jul 2008 01:24 Edited at: 31st Jul 2008 01:25
Thanks a lot Nano, I will check these steps out today, it's 00.30 here. But after I get some sleep of course, otherwise it will have no effect, true?

I will report back if I encounter any problems.

- Elias, Damezean, Nackidno, Wonderboy

AntocGames - http://antocgames.se.nu/
Nano brain
16
Years of Service
User Offline
Joined: 7th May 2008
Location:
Posted: 31st Jul 2008 01:27
True, if you're tired. Good luck.
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 31st Jul 2008 02:57 Edited at: 31st Jul 2008 03:01
Or, if you're not up to doing all of that, you could use the OpenFileBox command in Gogas Free DBP Plugin v2.0. It's really great and is very useful. I've attached it if you'd like to use it, for I spent quite some time looking for it and forgot where I found it, so I figured I'd save you the trouble . Props go to Synergy K (at least I think that's the alias he now goes under) for creating the awesome plugin and Vibe Runner for writing the help files.

Attachments

Login to view attachments
nackidno
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Där solen aldrig skiner
Posted: 31st Jul 2008 10:19 Edited at: 31st Jul 2008 10:22
I tried 60[]'s version first, since it seemed simpliest.

It does load the texture, one. But when I ope up the window again to load it, nothing happens, it's still the same texture. How come? Please help me.

Oh, and I got the code here :



EDIT : I noticed something, why doesn't the board support '\' in the posts? It's kinda frustrating actually.

- Elias, Damezean, Nackidno, Wonderboy

AntocGames - http://antocgames.se.nu/
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 31st Jul 2008 15:19 Edited at: 31st Jul 2008 15:24
A few things:
***You need to reload the image after you get the new image's filepath. You only load the image once at the start of your program, so how can the textures ever be different?

***When you reload the image, you may want to load it into a different image number than the previous one. All you would need to do is make a variable that keeps track of image numbers and increase it when you load a texture... When I didn't do that and loaded all of the images into image number 1, the editor would crash unless I retextured all of the objects. But then you can't have multiple textures. So make sure that you load images to different images so each image has its own number, otherwise you'll only be able to support 1 image at a time and as a result only 1 texture at a time. Keep in mind you could also find the "free image" to do this (much like you find the "free object" in your object placing routine).


-I noticed a small bug with Gogas plugin when I was designing my level editor. I'm not sure if this is happening to you or anyone else for that matter for it may have just been a coding error on my part (although I checked for bugs for quite some time), but the OpenFile command seemed to change my base or working directory for some reason.

+Anyway, I updated your code, taking all of the above into account (including that little bug that may not even be a bug. You can remove that part if you like, I was only being cautious). I added the increasing image number thing, and if the user presses cancel then the image will not load. Don't worry, not much was changed at all



Quote: "EDIT : I noticed something, why doesn't the board support '' in the posts? It's kinda frustrating actually."

I think it's a forum bug that only happens sometimes? I'm not really sure... I haven't posted code that needs a file path in a while.

nackidno
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Där solen aldrig skiner
Posted: 31st Jul 2008 21:25
I did think of something similar to that at first. But I actually tried the way you mentioned about the same image number. I did never increase it.

Thanks, it works just as it should now. Really helped me out!

- Elias, Damezean, Nackidno, Wonderboy

AntocGames - http://antocgames.se.nu/
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 31st Jul 2008 21:43
No problem. Good luck with the editor

nackidno
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Där solen aldrig skiner
Posted: 1st Aug 2008 00:13
Sooooo.... I have run into another problem.

I try to delete one of the objects when pressing the delete-key. But nothing happens.

The delete code looks like this :



When object one collides with NewWall, it will collide with the specific Wall?

Or does it actually refer to the newest wall placed? since the Variables NewWall increases every time I place a new wall.

I bet it's my second thought.

Please, How do I come around this problem? I have tried some ways, but it didn't work. Nothing happens. It surprise me that the program doesn't crash, it tends to do that when I experiment though.

Best wishes // Nackidno

- Elias, Damezean, Nackidno, Wonderboy

AntocGames - http://antocgames.se.nu/
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 1st Aug 2008 00:51
@Nackindo:

Quote: "Or does it actually refer to the newest wall placed? since the Variables NewWall increases every time I place a new wall."


That is correct. It can only delete the newest wall placed using that method. If it doesn't do that then I'm not quite sure what's wrong :/.

You could do this:


However, I do recommend that you use arrays for this editor, keeping track of all object data (position, size, object number, image number for a texture, kind of object) as you place the objects. It will make things a lot easier later on. The above code will delete any object it comes in contact with, even if it's just there for decoration. But what if you only want to delete only walls? You can either reserve a set number of object numbers for walls only (10-1000 or something) and check against those, or you could simply sift through your array, deleting only objects whose kind is a wall. There's more flexibility if you keep track of all of your objects. Your collision code is valid and will work, but when it comes to saving and loading I believe that you would be happy you used arrays. Heck, there's even a SAVE ARRAY command . If you don't know how to use arrays you can always visit this thread and scroll through the tutorials. I wrote one on arrays (it has a lot of "!" lol) and TDK also has a bunch of tutorials, one of which I'm sure is on arrays. Once you know arrays it may also be useful to learn User-Defined-Types (UDTs), but then you can't use the SAVE ARRAY command to save. You'd need to use the file commands (ex. Open To Write, etc.).

If you don't plan on adding saving/loading, then I guess doing it without arrays wouldn't be too bad... but I'd still use arrays reguardless.

Anyway, let me know if the code I posted works or if you're having any more problems .

nackidno
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Där solen aldrig skiner
Posted: 1st Aug 2008 16:30 Edited at: 1st Aug 2008 16:48
I have read the array tutorials, yours and TDKs, but I wonder (since it was never covered), can I store a variable into all the 'dressers' and 'cabinets'. Instead of one at a time? That will take a very long time, 35*35 arrays.


Anyways, if I store the variable NewWall for example into walls(1,35), it will refer to the newer wall placed? Like the deleting issue? So how do I refer to all the walls? Change the NewWall to an array? I'm so confused right now, but brainstorming usually come in handy.

EDIT : I noticed something when I now scrolled through the tutorial again for the third time, Can I put the variable NewWall into walls(35)? Will that put the variable into the Whole walls array. or just only into the dresser 35, along with 35:s all 35 cabinets?

- Elias, Damezean, Nackidno, Wonderboy

AntocGames - http://antocgames.se.nu/
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 1st Aug 2008 18:02 Edited at: 1st Aug 2008 18:13
No the way you have it now is 100% fine . You won't need to remove anything, just add. Have a look at this little example I put together. I would have used a UDT, but it seems you were trying to use an array so I've done it that way.

This example code may seem long, but a lot of it is just comments. I've made each "dresser" of the array represent an object. Then, I use cabinet 1 to store the object's X Position, cabinet 2 for Y Position, cabinet 3 for Z Position, cabinet 4 for object number, and cabinet 5 for the object's type. In this program, type 1=cube, type 2=cone, and type 3=sphere. In your editor you might have type 1 be a floor and type 2 be a wall. You may not have a type 3.

Anyway, this program is basically there to demonstrate how one might go about storing data about an object in arrays and how useful it can be later on (In my progam I used the information on what type of object it was to do some creative coloring ).

The only reason I try to find the "dresser/object slot that isn't in use" is because doing it that way (just like you do with the object) should make your deleting routines much easier. All you'd need to do is delete the object and set the object's number (stored in our array) to 0. Our checks for the dresser/object slot that isn't in use will say "Hey! That slot isn't in use!" if the object number of the slot is 0. Hmm... that sounds kinda confusing. Just remember that all number (integer/float) variables (and arrays) by default have a 0 in them. Well, this probably makes no sense but hopefully this program will bring it all together:




EDIT:
Quote: "
EDIT : I noticed something when I now scrolled through the tutorial again for the third time, Can I put the variable NewWall into walls(35)? Will that put the variable into the Whole walls array. or just only into the dresser 35, along with 35:s all 35 cabinets?
"


I just tried that and it didn't do anything:



So I'm afraid the answer is no. But if you want to do that, then why not use a couple of for/next loops?


^That should do the trick?

*******************************************************************
EDIT 2: Sorry if I've kinda confused the heck out of you with this... If it makes no sense, feel free to wait for more responses. Maybe someone else would be able to explain it better?

nackidno
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Där solen aldrig skiner
Posted: 1st Aug 2008 20:54
A challenge! this will certainly get me going with Arrays! I will report back when I actually manage to use this example's goal in the editor. If I fail, I will report even then.

- Elias, Damezean, Nackidno, Wonderboy

AntocGames - http://antocgames.se.nu/
nackidno
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Där solen aldrig skiner
Posted: 1st Aug 2008 21:26 Edited at: 1st Aug 2008 23:52
I have looked through your example, and the object type cabinet...

This line ----> AllObjects#(ObjectSlot,5)=1 --- It identify the current object as a '1', right? And if I open up a saved array, does that object look like an '1'?

Tell me if I'm wrong since I don't see anything else referred to the 5th cabinet.

Ooouuuhh...I think my heads going to blow up, spent all days on only arrays.

[EDIT] - Btw, what does this b/c mean? In this:


[EDIT-2] - When I open up the saved array, is it supposed to look like this?





[EDIT-3] - Does the save array commands save the objects position if I save the array like this? :



This was a lot of questions on the same time, so I hope some people will actually respond on them

hanks in advance // Nackidno

- Elias, Damezean, Nackidno, Wonderboy

AntocGames - http://antocgames.se.nu/
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 2nd Aug 2008 00:44 Edited at: 2nd Aug 2008 00:46
Quote: "This line ----> AllObjects#(ObjectSlot,5)=1 --- It identify the current object as a '1', right?"

Yes.

Quote: "Tell me if I'm wrong since I don't see anything else referred to the 5th cabinet."


It may be useful to have the object type stored in an array. That way you automatically know what type of object it is when you load it into your game.

Also, I wrote this at the top of the code:
Quote: "5: Object type>>>
#1: Cube
#2: Cone
#3: Sphere
"


That's what I mean by object type. Cabinet #5 holds what kind of object it is. 1 means cube, 2 means cone, and 3 means sphere.
Quote: "[EDIT] - Btw, what does this b/c mean? In this:

"

(It means it's a cube. See above chart)

The only reason I used numbers was because I couldn't write "cube" there. I would have used AllObjects#(ObjectSlot,5)="cube", but I couldn't because the AllObjects# array can't hold strings. So, I just replaced the word "cube" with the number 1. It's nothing special, I could have just as easily made cube's special number 935 or something.

Quote: "[EDIT-2] - When I open up the saved array, is it supposed to look like this?"

Yup . I don't know how to read it, but DarkBasic does via the LOAD ARRAY command

Quote: "[EDIT-3] - Does the save array commands save the objects position if I save the array like this? :

"

If you put it in the array, then yes There's only one thing wrong with that code.

My tutorial:
Quote: "Now the SAVE ARRAY command is one who isn't so bright. All he can know is how many dressers [the array] has. If you tell him anything else he'll return some kind of annoying error. "


So, you Save Array command should be like this:


You've been working on arrays all day?! Take a break if you want to lol. But trust me-- once you get a hang of these they can be really awesome

nackidno
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Där solen aldrig skiner
Posted: 2nd Aug 2008 11:27
Thanks a lot! You really helped me out Sixty Squares!

So if I load that array into another program (If that is possible). Does it show the objects in that program then? Or do I have to load all the objects first somehow?

- Elias, Damezean, Nackidno, Wonderboy

AntocGames - http://antocgames.se.nu/
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 2nd Aug 2008 16:52 Edited at: 2nd Aug 2008 17:08
Quote: "Thanks a lot! You really helped me out Sixty Squares!"

Quite welcome

Quote: "So if I load that array into another program (If that is possible). Does it show the objects in that program then? Or do I have to load all the objects first somehow?"


Of course it's possible! Remember-- when you save the array, all you're really saving are a bunch of numbers. It's up to you to use these numbers properly. If you want to load all of your objects again, you'll have to remake them. AND reposition them. But that shouldn't be too hard, because you've already saved all of the position data in your array! That's what some of the numbers in that bunch of numbers are for . For example, looking at the example I provided, one might load a level like this: (after you'd saved)



As a matter of fact, here's the sample editor I provided with both saving and loading examples:



EDIT: You may want to put this in a new project file so you can easily delete the saved level file when you're done with the example...

nackidno
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Där solen aldrig skiner
Posted: 4th Aug 2008 20:51
Hmmm... I can't get it to work really. Saving the map is working (I think) since I don't get any error. But loading the map is another thing. I can't get it load it.

I used your loading example for this. Since my editor is much like it. When using your save example, it loads perfectly. But with my saved array, it doesn't load at all.

Here is my code so far:



And here is the loading (Copied and a wee mod)



I just can't think of anything wrong. Or does it have to do with that I changed the Array a little, little by adding another Cabinet? If that's the case I just feel silly.

Please help!

- Elias, Damezean, Nackidno, Wonderboy

AntocGames - http://antocgames.se.nu/
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 5th Aug 2008 00:34 Edited at: 5th Aug 2008 00:35
Quote: "Or does it have to do with that I changed the Array a little, little by adding another Cabinet? If that's the case I just feel silly."


I just tested that theory (i'm using DBP u6.6) and yes, that seems to be the problem . In your loading program, DIM the array in the same way you did in your level editor ( like this: DIM AllObjects#(1000,6) ). More specifically, DIM it with the same dimensions (dressers/cabinets) that the saved array has.

Just remember that your loading program is going to create cubes, cones, and spheres unless you change it .

Furthermore, you don't need to use MAKE CAMERA 1 if you want to use the CONTROL CAMERA USING ARROWKEYS command. The default camera is camera number 0, so writing CONTROL CAMERA USING ARROWKEYS 0,0.5,0.5 is perfectly valid.

nackidno
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Där solen aldrig skiner
Posted: 5th Aug 2008 00:51


Oooouuuhh.... Now I really feel silly! I accidentally added another zero to the 'dressers'. It was ten thousand instead of one thousand..



Thanks anyway Sixty, you have been a great help for me, I will never forget!!

- Elias, Damezean, Nackidno, Wonderboy

AntocGames - http://antocgames.se.nu/
Outscape
16
Years of Service
User Offline
Joined: 23rd May 2008
Location:
Posted: 5th Aug 2008 01:00
lol nacko just told me on msn
Quote: "
Nacko: Cool^^
Nacko: YES!
Nacko: I finally, Finally! Got loading maps WORKING!
Nacko: I just want to hug Sixty! xD
"

it looks like you have a fan club sixty


www.freewebs.com/outscape
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 5th Aug 2008 03:45 Edited at: 5th Aug 2008 03:45
Haha I'm glad you've finally got it working . If you encounter any more problems feel free to post.

nackidno
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Där solen aldrig skiner
Posted: 6th Aug 2008 13:12 Edited at: 6th Aug 2008 13:21
Hmmmm..Guess I'm not really done yet. The loaded map is messed up.

It does only load half the map? It's like it has been cut of from upper right to lower left?

See attached pic, since I have absolutely no idea of that might be wrong. I hope you guys have any idea of what the problem might be.

EDIT - Nope, the objects just disappear as it pleases?! The walls and floor disappear but the player object doesn't. I have tried a lot of times, and the player never disappear..?

My code right now :

Editor


Loading Levels



- Elias, Damezean, Nackidno, Wonderboy

AntocGames - http://antocgames.se.nu/

Attachments

Login to view attachments
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 6th Aug 2008 17:38
You've changed the way you DIM your level, but you never changed the way you save it.


This:


should be:



That would explain why 1/2 of the level is being cut off. You're only saving 1/2 of the array (1,000 is half of 2,000)

nackidno
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Där solen aldrig skiner
Posted: 6th Aug 2008 18:37
Uuuhh... I'm pretty I changed that to 2000, oh well.

Thanks again Sixty, I think I'll take a short break from programming now!

- Elias, Damezean, Nackidno, Wonderboy

AntocGames - http://antocgames.se.nu/
nackidno
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Där solen aldrig skiner
Posted: 6th Aug 2008 19:38
I changed my mind, I'll continue with programming a little while before the break.

Still no go. It halves the level anyway.

I changed the two for-next loops in the loader to 1 to 2000. Nothing happens..

I know, I ask too much (Or it really do feel like it).

- Elias, Damezean, Nackidno, Wonderboy

AntocGames - http://antocgames.se.nu/
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 6th Aug 2008 21:48
Hmm... I made the changes you said you made, and this level loaded perfectly (see attached picture for level)

Attachments

Login to view attachments
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 6th Aug 2008 21:51 Edited at: 6th Aug 2008 22:23
And here is the map file

I'm using version 6.6. of Dark Basic Professional by the way, but that shouldn't be causing any issues...

Attachments

Login to view attachments
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 6th Aug 2008 21:56
And finally, here is the whole project in a .ZIP file. TRY RUNNING THE EXE CALLED "Nackindo Load" THAT IS ALREADY THERE. DO NOT COMPILE THE CODE AND MAKE A NEW EXE! See if it works then. The map is included.

Attachments

Login to view attachments
nackidno
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Där solen aldrig skiner
Posted: 6th Aug 2008 22:15
I don't get it. The maps load just perfectly in the editor, with the exact same code as the loader. But the loader still have this error.

Did you try the level loader?

[EDIT] - This might be a bug, I'm really, really frustrated right now. That new camera deleted those objects! When I deleted the camera. All the objects load just fine! If this is abug, then can it be fixed in the new update?

// Nackidno

- Elias, Damezean, Nackidno, Wonderboy

AntocGames - http://antocgames.se.nu/
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 6th Aug 2008 22:26
OOPS I forgot to mention the changes I made to the level loader. I thought it was broken until I noticed that I had to press "l" to load .
Changes (they're in the ZIP file):
-No camera 1
-Added MAKE MATRIX for orientation purposes

As for the camera thing, my level loaded just fine when I put the camera back. Of course, I made the camera first thing. I'm not sure if it's a bug or not. Try making some other examples of what you think is wrong and see if it happens there too?



Login to post a reply

Server time is: 2024-09-27 18:15:00
Your offset time is: 2024-09-27 18:15:00