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 / How to clear/delete all objects in a game?

Author
Message
MiRRoRMaN
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location: Netherlands
Posted: 10th Oct 2002 00:40
I tried this:

cls 0
delete object on
for kut = 1 to 65535 step 1
delete object kut
wait vbl
next kut

But it keeps giving the error that the range is from 1 to 65535?

Is there some way to default the application so it can just restart in the opening screen? This is just making me crazy.

Thanks in advance.
SFSW
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location:
Posted: 10th Oct 2002 01:10
I'd just run a quick loop:

for i = 1 to 65535
if object exist(i)=1 then delete object i
next i



It's three lines, short and sweet.

xtom
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Ireland
Posted: 10th Oct 2002 01:55
delete object on is giving you the error. It's not even a command.
xtom
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Ireland
Posted: 10th Oct 2002 01:58
It's probably trying to delete object 0.
indi
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 10th Oct 2002 07:12
"on" in that sense would be a variable of zero

no website at moment
MiRRoRMaN
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location: Netherlands
Posted: 10th Oct 2002 15:06
for i = 1 to 65535
if object exist(i)=1 then delete object i
next i

I tried this and it still gives me that error

I'm trying to build a loop in the free open source of that 3D tetris game.

indi
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 10th Oct 2002 15:18
sync on
sync rate 0


ink rgb(255,255,255),1
text 10,10,"loading all media spaces"
sync

for i = 1 to 100
if object exist(i)=0 then make object cube i,1
text 10,30,STR$(i)
sync

next i

text 10,50,"finsihed loading all media spaces"
text 10,70,"press a key to delete all media spaces"
sync

suspend for key
cls



for i = 1 to 100
text 10,30,STR$(i)
if object exist(i)=1 then delete object i
next i
text 10,50,"finsihed deleting all media spaces"
text 10,70,"press a key to end"
sync
suspend for key

end

no website at moment
MiRRoRMaN
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location: Netherlands
Posted: 11th Oct 2002 00:21
Nope, it still wont work I don't know what I am doing wrong. If I put that in it says the object doesnt exist.

SFSW
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location:
Posted: 11th Oct 2002 00:51
Then it's something in your syntax, I copied it to DBPro and hit F5, ran fine.

MiRRoRMaN
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location: Netherlands
Posted: 11th Oct 2002 01:13
Its all about this source:

http://www.darkbasic.com/gallery_view.php?galleryid=10&p=6&catid=

Please, if you wanna help me out, download it and try and let it loop back to the first screen after the high score table so that the game starts over and over and over again (like any game)

I'm really curious as to what I am doing wrong. I know I'm doing something wrong, I should mention once again that I'm a newbie to DarkBasic.

Fixing this sounds like a good way to learn something.

Milamber
21
Years of Service
User Offline
Joined: 27th Sep 2002
Location: Australia
Posted: 11th Oct 2002 18:18
Try stepping through the code and seeing precisely which command returns the error, and what the values of the variables are. This should tell you where the prob is, so you can work on fixing it.

System Specs: AMD Athlon 1700+ XP, GA-7VRX motherboard, 128MB DDR RAM, GeForce2 MX400 64MB VRAM
SFSW
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location:
Posted: 11th Oct 2002 20:22
Check your in-box. Your code is fixed and loops fine now. It wasn't a matter of deleting objects, you needed to reset your variables before the game session restarted. The function routine you used for dropping the grid tried to use objects that no longer existed after the board was cleared.

MiRRoRMaN
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location: Netherlands
Posted: 12th Oct 2002 03:44
SFSW to what email address did you sent it? I didnt get the mail, could you please resend it to rio@home.nl?

Thanx!!!!

SFSW
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location:
Posted: 12th Oct 2002 09:01
I sent it to jonas.ohrn something, whatever was on your website. I've sent another copy to the rio@home.nl address also.

MiRRoRMaN
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location: Netherlands
Posted: 12th Oct 2002 16:21
SFSW Thank you very much! I've checked it out! It was a pretty dumb error lol I've been out of basic for a long time. I've programmed in AMOS in the Amiga for years and the minute I saw what you did with the source I figured "of course"!

I wanna thank everyone who answered on this problem. I guess this solution solves a lot of programming problems I've had so far, resetting values.... of course!

Login to post a reply

Server time is: 2024-04-26 21:02:36
Your offset time is: 2024-04-26 21:02:36