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.

DarkBASIC Discussion / A question about object deletion

Author
Message
Yodaman Jer
User Banned
Posted: 3rd Jan 2009 22:18
Hey all, sorry to make another thread, but I need help with this.

I remember a while back there was a way to assign a letter to an object as opposed to regular numbers, thusly making it possible to delete certain objects (such as un-collected coins) when the player loses all their lives.

This is what the code looks like now:



I want it to look like this:




My game requires you collect all 50 coins to continue on to the next level. However, when the player loses all lives, I want to be able to delete the coins that were not collected. I can't do this successfully at all, unless I make the object numbers letters. Then in the main program loop I could have something like:



My question is how do I do this exactly? How do I make the objects use letters instead of numbers? I remember it is possible, but I just can't recall how to implement it.

"People still have 1024x768?" -Jeku
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 4th Jan 2009 00:36
for you, you should use a for t loop:



Now the deleting. Are you deleting the ones collected in the main loop?

If so, you would to this:


TheComet

Peachy, and the Chaos of the Gems

Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 4th Jan 2009 00:37 Edited at: 4th Jan 2009 00:39
[EDIT] - TheComet beat me to it!

For whatever number you want an object to be, use a variable.

If every time you want to access object 1, you could assign it a variable:
a=1

So now just reference object 1 with 'a'
position object a,x,y,z

Or you can create an array to hold all of the objects you want. Say you have 10 objects for the whole game but they are numbered 100 200 300 400 500 600 700 800 900 1000. You could use an array that is dimensioned with 10 indexes to store these numbers:



So you could reference each object by the array:
position object obj(5),x,y,z
That positions object 500 at x y and z

Does that answer your question?

Enjoy your day.
Yodaman Jer
User Banned
Posted: 4th Jan 2009 04:48
Indeed, it does answer a few of my questions! Thanks guys!

"People still have 1024x768?" -Jeku
Yodaman Jer
User Banned
Posted: 4th Jan 2009 23:27 Edited at: 5th Jan 2009 00:45
Well, actually, I have encountered a new problem and I consulted the help manual but it isn't working.


I've made it so that when the player collects all 50 coins, you go to level 2. However, because I am using static collision, I cannot delete the static collision boxes, thusly meaning that in level 2 when the player is moving, it's on top of invisible collision boxes from the first level.

I'm using this code as the main collision deteciont:



But I want to change it so that is uses box collision (I know doing that requires lots of guess work for oblongish objects, but I'm willing to deal with that) instead of static, since you can delete collision boxes that aren't static.

My question is, what exactly in that block of code do I have to change in order for box collision to work?

Sorry for asking noobish questions, but this one is really a puzzler (at least for me). Thanks to any and all who help!

EDIT:

After further analysis, I saw the obvious answer, and had I looked further into my code originally I would have seen my own question answered before I even asked it.

Instead of this:




I needed to remove this:




And that is all of the change I needed to do for box collision...hehehe. Sorry for posting that everyone. But maybe someone will find this helpful one day, at the cost of my embarrassment.

Login to post a reply

Server time is: 2026-07-05 01:48:01
Your offset time is: 2026-07-05 01:48:01