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 / Object control/code

Author
Message
Sph!nx
15
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 14th Feb 2009 22:02 Edited at: 14th Feb 2009 22:03
Hi all. I made my own (limb) object loading with all the great help from IanM. See this thread.

I got my entities loaded properly and I can control the player character in the main game loop.

Now I have a code that tells when the player hits the object_cube, the cube gets destroyed. Even though the player code has the same setup, it gives an error (object not found) for the cube. I figured defining them as a global it would be fixed, but absolutely no change.

Here is the map code :


Any help is greatly appreciated!

Thanks!

Regards,
Sph!nx
Sph!nx
15
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 15th Feb 2009 16:05
Can't figure this out. Defining them as global makes no difference and why does he move one character and not all? Also don't understand why it gives the error for the cube.

I've packed and uploaded everything, code and content, for you to view it in the proper context and see the error. You can download it from here.

Again, help is greatly appreciated.

Thanks!

Regards,
Sph!nx
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 16th Feb 2009 04:44 Edited at: 16th Feb 2009 04:45
You're checking collision against an object you've deleted. Run through your code logically.

1. Your player hits the cube
2. Your program checks if the player hits the cube
3. Your program deletes the cube because there was a collision
4. Your program checks if the player hits the cube, except the cube doesnt exist anymore.

Just add an IF OBJECT EXIST(object_cube) = 1... ENDIF around the collision check code, and it will stop the program from checking for a collision if the object has been deleted.

Alternatively, it might be better to use the exclude object or hide object commands to just stop rendering the cube object. It wont be deleted, just hidden.

Sph!nx
15
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 19th Feb 2009 19:27
Thanks RUCCUS!

I will give it a try.

Regards,
Sph!nx
Sph!nx
15
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 21st Feb 2009 13:48 Edited at: 21st Feb 2009 13:49
Thanks again, RUCCUS!

It works. Well, in a way it does not give me the error like before. And it also removes the cube on collision, but it only does that for one cube only. The other cubes get ignored completely.

My next question is, how would I make it so that this code would work with all the cubes?

You can download the source files to take a proper look and here is the code I use now :




Thanks a lot!

Regards,
Sph!nx
Sph!nx
15
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 23rd Feb 2009 13:00
I really need some help with this. I cant seem to get the code to work on all the entities, the cube in this instance.

Anyone?

Regards,
Sph!nx
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 23rd Feb 2009 13:38
this might do it.



Dark Physics makes any hot drink go cold.
Sph!nx
15
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 23rd Feb 2009 17:30
I have that now. It works, but only for one of the cubes, not all of the cube limbs.

Regards,
Sph!nx
Sph!nx
15
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 27th Feb 2009 22:35
Searched everywhere I could think of but couldn't find anything. I really need help with this. Anyone?

Regards,
Sph!nx
Sph!nx
15
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 28th Feb 2009 12:44 Edited at: 28th Feb 2009 12:47
I'm beginning to think, its not possible what I want. No one got any more input on my problem?

The only thing I want to accomplish, is that the code (delete the cube on collision) will work for all the placed cubes (limbs) and not just the one.

And for that matter, I wish to have the movement code of the player character work for the other placed characters as well.

Please take a look at the updated source! I'm really stuck on this and any help is greatly appreciated!

Regards,
Sph!nx
Sph!nx
15
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 28th Feb 2009 19:17 Edited at: 28th Feb 2009 19:18
Could it be that the code with the object collision/cube deletion should have some kind of for..next loop in it to make it work for all the (duplicate) cube objects, just like the 'load entities' part?

If so, please explain how, cause I've tried everything I knew without success.

Here is the map load and map run code again:



Thanks!

Regards,
Sph!nx
Sph!nx
15
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 1st Mar 2009 12:34 Edited at: 1st Mar 2009 12:35
This is becoming a major frustration. No one is able to help me? Is it even possible what I want?

Seriously, I'm getting desperate, on the brink of giving up...

Regards,
Sph!nx
James H
17
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 1st Mar 2009 13:35
Based on your last snippet I think this is what you need.
Replace

with
Sph!nx
15
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 1st Mar 2009 15:36 Edited at: 1st Mar 2009 15:44
Thanks for the input, but it does not work. Instead it does not render my world mesh at all and instead of removing/hiding the cube, it hides the character on collision.

Also, effect only applies to one of the cube, and not all...

I basically got the code working like I want it to, I just want it to work for all cubes (limbs/objects with the same name) and not just the one.

Thanks anyway, any more help is greatly appreciated!

Regards,
Sph!nx
James H
17
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 1st Mar 2009 17:18
Sorry it should be oc=object collision(player,0) - why on earth would you need to lock the backbuffer for object control? If this isn`t about just object control then can you state what it is your after? No one here has the media to load so I have no idea why your mesh doesn`t get rendered, I suggest you remove the backbuffer stuff.
Sph!nx
15
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 1st Mar 2009 17:29 Edited at: 1st Mar 2009 17:40
Thanks! Made some progress. when both collide all cubes (and all other placed player duplicates for that matter) gets deleted.

Still, my world mesh is not getting rendered and I have removed the backbuffer stuff.

Thanks so far!

Edit :
I fiddled with the code you provided. It appeared that it hidden the world at start.

I changed the 0 into object_cube and also made the object thats gonna be hidden to the cube as well.

It works now, but just for the single cube again

Regards,
Sph!nx
James H
17
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 1st Mar 2009 17:41
Have you tried loading in the object using LOAD OBJECT as opposed to B3D LOAD OBJECT to see if it appears? I`ve only just realised that the B3D command is extends plugin but as far as I can tell you have no need to use this particular command.
James H
17
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 1st Mar 2009 17:45
Ok - sorry for double post - just read your edit.

Change "if oc>0" to "if oc>0 and oc<>map"
Sph!nx
15
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 1st Mar 2009 18:12
Thanks a lot!

It works. I added what you said and it works. Now it works not just for the cube but also when two player characters collide one of them (not the one that is controled) gets hidden as well.

How is that? How can I make it that it only works for the cubes? Tried several things myself.

This is the code I now use:


Regards,
Sph!nx
James H
17
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 1st Mar 2009 18:39
When creating objects for cubes, keep the cube object numbers between a range and likewise do the same for player object numbers.
For arguments sake we shall say there are a max of 10 players and your world is made up of 30 cubes, therefore when you create the objects that represent these players we know the object numbers are 1 to 10, and the cube object numbers are 11 to 40.
Here we could write

Because all the player object numbers never exceed 10, another players collision won`t get checked. However, this will prevent the cubes from disappearing when another player collides with the cube. ie if you are player 1 and player 1`s object number is one, the only collision being checked here is between object 1 and all of the cubes. If you wish for all ten players to make the cubes hide when they collide with them you would put the code in a for next loop;
Sph!nx
15
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 1st Mar 2009 18:46 Edited at: 1st Mar 2009 19:24
Well, I have all available plugins for DB-pro and one of them, I believe the matrix plugin, makes the use of object numbers obsolete and refers to them in one single name.

So I use that to simplify things for me.

On the other hand, I wish the use this same code for more than one map/world so its always unknown how many of the same object/limb is going to be used...

Edit:
Is there some kind of count to be done, justy like with the object loading code, where it counts the limbs with the same name?

I tried some stuff with that too without success, so how do I do it then?

Regards,
Sph!nx
James H
17
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 1st Mar 2009 19:59 Edited at: 1st Mar 2009 20:00
You will need to think along the lines of limits before coding. Go back to your psuedo and determine how many objects you need for what, then instead of assigning ranges that are near each other, assign them further away

32 players max
30 cubes level one
50 cubes level two

by my previous suggestion this code should look something like


Now as you have said the limits are as of yet unknown so all you have to do is to use perform checklist and checklist quantity() to get the number of limbs used for each level and pass the result through. If you wish to still add to levels after loading multiple levels then just leave a large enough gap between object ranges.
ie you may decide to add anything between 0 and 2000 limbs for level 1, so instead of starting to create objects for level two at object number 64, start it at 2064 and finish at 2114. Just remember to leave large enough gaps between ranges. If you must use free object function, then think about creating your own function where you pass it two values - a start and end object number to check between.
Sph!nx
15
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 1st Mar 2009 20:09
Hmmmm, So there is no way to make a counter, that counts all objects with the same name, that than can be used to form the loop for the actions?

Thanks for all your help so far!

Regards,
Sph!nx
James H
17
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 1st Mar 2009 22:52
Yes there is but its not as straight forward as just making a counter with loops and storing data. It all depends on what you want to do overall. So far you have the answers of what you have asked except that last question - which really depends on;
What actions? Are these actions in the main loop or during loading or both?
Why do you need the name of every object in the level?
Although my snippet loads all the levels prior to the loop there is no need to, they can just as easily by loaded between levels, either re-use the existing objects or delete/reload them.

Can you give a broader sense of what it is your trying to do here?
Sph!nx
15
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 3rd Mar 2009 20:31 Edited at: 3rd Mar 2009 20:36
Okay, I will explain what I want to accomplish here.

A while back, I started to work on a 'general' fps engine. I took half-life as example.

Although I'm alone on my effort to code an engine, I normally work with a small team. We all use several editors to build custom content for existing games, like half-life (source engine and gold source engine).

We now use 3D world studio to build our maps for our own (potential) engine.

All my previous work was done with Blitz 3D. There I managed to build a very basic engine that loads the map, read the limbs (they are called children with Blitz)and places objects at the limb position. Eventually I also want to be able to read and use the limbs properties.

The 'entities' (limbs + their object code) are defined in a '.DEF' file, so the others can simply place them in the map editor, load up the engine and play-test what they made.

The idea is that I give them as much freedom for world and other content creation, without diving into the code for the most basic stuff.

If you are a little bit familiar with modding half-life,quake or any other FPS engine for that matter, you know what I speak off.

My objective is, build a game engine with just main loop with the so called entities. The main loop must be able to load any map, defined by the player through the menu, a load command, or a command in the 'console'(another window that holds an input for developers commands).

All code must be in the loop, no matter if its used or not, cause the other guys (mappers, modelers) can make all kinds of content, designed for the code of the engine.

I hope you understand what I mean....

Regards,
Sph!nx
James H
17
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 3rd Mar 2009 23:51
This lies in the realms of level editing really which can be a complex thing to pull off. Your best bet it here is to put some psuedo together of the prog from blitz, I just spent a quick half hour making notes on how I would go about it, but didn`t get to far.
As you will be able to tell from the notes a lot of consideration has to go in to this, and I`m not good at explaining things. You might want to take someone elses advice here, they might explain things better

Sph!nx
15
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 4th Mar 2009 20:50 Edited at: 4th Mar 2009 20:51
This looks really complex to me . The technique used is quite easy in comparison, yet 'translating' it to the basic language of Dark Basic is a little tougher than I thought.

Also, some very easy setups that can be done with a few lines of code, needs a whole other approach with DB pro.

The DEF file is just one file, that basically list all the entities the mapper needs. Its not a real bridge between the editor and the code, cause the mapper can always name the children whatever they want. The def simply makes sure they use the correct ones.

I'm really, really grateful for everything you did for me so far!!

Didn't realize this was so hard with DB pro... I've tried everything I could, but still being a n00b, I'm really hitting the wall here.

Isn't there nobody else willing to share his/hers thoughts on this with me? So many views, so little response.

Regards,
Sph!nx
Sph!nx
15
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 5th Mar 2009 15:54 Edited at: 5th Mar 2009 15:57
I've got another idea!

I thought of not using the object code for the specified object name but could we make it so that the code works for all objects containing a certain string in the name?

Ive tried implementing it for the object cube, so this piece of code will work for all objects containing the name object_cube, with the instr command, but had little success.

Perhaps someone could implement it for me? This is the original code for the object_cube in the main game loop:


Anyone?

Regards,
Sph!nx
z i l c h vortex
17
Years of Service
User Offline
Joined: 20th Feb 2007
Location: united kingdom
Posted: 5th Mar 2009 23:59
If you set up the cubes using this command


Dont put that into the loop.
Then use this command to check if there colliding if so delete put this in the loop.



If you are having trouble still add my Msn IDH_Josh@hotmail.com

life is short but so am i
Sph!nx
15
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 7th Mar 2009 02:13
Thanks, but I haven't got that kind of setup. please, look at the code in more previous posts. Posted the complete map code several times.

I also use Extends library that makes object numbers obsolete by giving them a name.

Your suggestion also gives me the need to know in the code how many entities/objects will be used per map, and thats what I don't want...


Thanks anyway

Regards,
Sph!nx
Sph!nx
15
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 8th Mar 2009 05:55
No, I think I really need to make some kind of search that searches for the amount of entities that have the same name.

Then than result must be used somehow in the action code inside the main loop. Only, I don't know how...


Anyone?

Regards,
Sph!nx
Sph!nx
15
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 9th Mar 2009 23:41
Am I approaching this all wrong? Is there a different map load and map run setup, regarding the objects, that is that flexible?

... I really need help! I'm considering going back to Blitz 3D and build my game on that.

Regards,
Sph!nx
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 10th Mar 2009 21:59
Sticking to using object ranges (something that extends doesn't let you do) is actually easier. However ...

I have not used blitz for a long while (and that was a demo), but the blitz way of doing things is to create an object and get a handle ... something like extends creates an object and gives you a handle.

Then you'd store the handle in a variable or an array for later use. Do the same thing here.

Collisions would be handled by looping through the content of the array and checking the handle for collision against your player object/handle.

The techniques are universal and will work in DBPro just as well as in blitz, or for that matter, any language with arrays.

Sph!nx
15
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 10th Mar 2009 22:37 Edited at: 10th Mar 2009 22:40
Thanks a lot, IanM! That sounds a lot more in the direction of what I want!

For Blitz, there was no need to create the arrays to store the handles, it does that automatic, so I do need to read up on arrays, handles and such but now I have an idea on what angle to view it all.

Thanks again. I know it's best if I fiddle this out on my own, and I know I'm asking a lot here, but could you perhaps write a small example in my code?


p.s
If you ever need any help from me, content wise (models, graphics, maps, etc.), just send me an email! This counts for everyone who took the effort to help me with this.

Regards,
Sph!nx

Login to post a reply

Server time is: 2024-09-28 02:29:38
Your offset time is: 2024-09-28 02:29:38