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 Professional Discussion / Deleting objects with in an array

Author
Message
Daniel wright 2311
User Banned
Posted: 2nd Apr 2011 22:22 Edited at: 2nd Apr 2011 22:33
So im reposting this hoping for some help, this is the code, The objects nights will not hide with in this array, I do not know why? Its driving me crazy. I cant move them,I cant hide them, I cant even delete them, Ive tryed everything. after the timer

timekill(nights)=timekill(nights)+1


I cant do anything with object nights but I can delete object 4 with no problems, object 4 is not set in any array, So i know it the array doing it.




my signature keeps being erased by a mod So this is my new signature.
Daniel wright 2311
User Banned
Posted: 3rd Apr 2011 03:51
Well, Ive waited for an answer on this with no help, SO IM BUMPING THIS WITH HOPES SOMEONE WILL LOOK INTO HEALPING ME, I STILL HAVE NOT FIGURED IT OUT.

my signature keeps being erased by a mod So this is my new signature.
BillR
23
Years of Service
User Offline
Joined: 19th Mar 2003
Location: United States
Posted: 3rd Apr 2011 06:47 Edited at: 3rd Apr 2011 07:04
well we know the hide object command works, so your conditional code

never gets executed.....time for some debug code



Using debug code to show the values of your variables is a great way
to help track down where the problems are with your code.

It is ALWAYS best to post code we can compile for testing to help solve your problem
And please don't double post for the same problem.

If you want to post all your code here or email it to me or post a compilable example with the same problem, I will find out where the problem is.
Daniel wright 2311
User Banned
Posted: 3rd Apr 2011 10:30
So any how, i had to write all my code long hand, here is all i did, this is what i was trying my best to avoid.



my signature keeps being erased by a mod So this is my new signature.
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 3rd Apr 2011 18:01
Indentation. Really, it's the easiest and best programming tool in your toolbox.

I also notice that you have variables such as attac1 (without a k) and attack1 - are they supposed to be different variables?

Also, you have 16 of each of these. Replace them with an array.

You also have a lot of repeated code checking for collisions - if you use an array like I suggested, you can make a single loop to check for collisions.

You are also missing a ton of ENDIF statements. If you indent, you'd notice this immediately.

Finally, you have no NEXT to your FOR loop - if the end of the loop is at the end of the code, then your collision checks are useless after the first set has taken place, for example if object 3 is in collision with object 19 first time through the loop, it's still going to be in collision through the rest of the loops.

Daniel wright 2311
User Banned
Posted: 3rd Apr 2011 20:11
@IanM

Hello,

Quote: "I also notice that you have variables such as attac1 (without a k) and attack1 - are they supposed to be different variables?"


this was on purpose

Quote: "Also, you have 16 of each of these. Replace them with an array."


check the first post, that was what the whole thread is about my friend.

Quote: "You are also missing a ton of ENDIF statements. If you indent, you'd notice this immediately."


Ive never used indent

Quote: "Finally, you have no NEXT to your FOR loop - if the end of the loop is at the end of the code, then your collision checks are useless after the first set has taken place, for example if object 3 is in collision with object 19 first time through the loop, it's still going to be in collision through the rest of the loops."


The long hand code I posted works perfect, its the code in the first post I need help with, this code I just posted is what I was trying to avoid.

thanks for your help

my signature keeps being erased by a mod So this is my new signature.
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 3rd Apr 2011 23:30
Quote: "check the first post, that was what the whole thread is about my friend"

Really? Ok, then quote the bit where it talks about attack and attac arrays

Quote: "Ive never used indent"

Then I think I'm through here... if you can't be bothered to make your code easy to read, I won't read it.

Good luck

Daniel wright 2311
User Banned
Posted: 4th Apr 2011 00:07 Edited at: 4th Apr 2011 00:07
@ ianM

Here is the code I was needing help with with explainations behind it if it helps you help me, thanks



my signature keeps being erased by a mod So this is my new signature.

Login to post a reply

Server time is: 2026-07-11 14:56:52
Your offset time is: 2026-07-11 14:56:52