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 / Why Does it Fire Only Once?

Author
Message
Relativity
20
Years of Service
User Offline
Joined: 29th Mar 2005
Location: Position is relative.
Posted: 4th Apr 2005 06:22
Here's a small segment of my program:



What I want it to do is to fire the object several times. However, when I run the program I can only fire once and then it won't fire again. Does anyone know why it wont create object 1 a second time, even though it is deleted?

the
-SithSpawn-
HWT
20
Years of Service
User Offline
Joined: 1st Apr 2005
Location: Earth
Posted: 4th Apr 2005 08:05
It is a simple problem - you forgot to reset the distance variable after the delete object 1 command.

Try the following:


Here's an example I made for just this purpose. It's a bit rough but I think you will be able to follow it.


HelloWorld Tommorrow
NanoBrain
20
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 4th Apr 2005 09:14 Edited at: 4th Apr 2005 09:18
SithSpawn,

The problem is that you are never resetting DISTANCE back to zero after it reaches 150. Therefore, each and every bullet after the first shot is being created, and then is straightforth deleted. This is because after the first shot, DISTANCE is already above 150 and remains at 150, so your code deletes each object right away, anytime after it's first creation.

So, to fix the problem, change this ifstatement :
to be


As an addition to this post, I would suggest using DISTANCE as the object's actual move distance. So, replace move object 1,15 with move object 1,DISTANCE. It is a good practice to get into this kind of habit. It can essentially save you much time, and sometimes, your processor.

+NanoBrain+
Relativity
20
Years of Service
User Offline
Joined: 29th Mar 2005
Location: Position is relative.
Posted: 6th Apr 2005 01:00
Yeah, thanks. I figured that out about 3 seconds after I made that post. I feel like such a noob.

"It's against my programming to impersonate a deity!"~C-3P0

Login to post a reply

Server time is: 2025-06-01 02:19:03
Your offset time is: 2025-06-01 02:19:03