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 / I'm braindead tonight, help me return this object to it's home!

Author
Message
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 10th Jan 2005 12:14
weird title I know, but a rather simple task I assure.

You see, I have encorporated a little bit of code to allow the player to buy a nuclear war head (its a stradegy game), now there a few note worthy variables I have created....

Nukeexist `this variable will equel to 1 if a nuke has been bought
Nukelaunched `this variable will equel to 1 if the N key and the mouse is clicked, it launches the nuke towards the mouseses position.

Now the buy system works like this, the nuke is hidden inside the planet earth (space stradegy game ) when the buymenu is activated and the right key is pressed, the nuke is taken out of hiding, once out of hiding, the nuke can be activated by pressing the N key, clicking the mouse while the N key is held down, releases the nuke,and it is launched to it's destination, a cleverly placed object that is positioned at the mouses position at all times.

I wanted to make the code, return the nuke to it's hiding in the earth, if the nuke comes into contact with the mouse object, which would mean it reached it's destination, in other words I want nukeexist to equel 0, so that I can buy the nuke again, unfortunatly it hasn't worked out as I would have hoped. If I tell the object to return to it's position in a loop it will get stuck there, so I am unsure what to do, help?

Guns arn't the problem, people are the problem, shoot all the people and guns arn't a problem anymore.
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 11th Jan 2005 01:29
I think that tracking this is something that you should do with an inventory system, like the nuke might just be a entry in an array with all it's details. So you might go to earth and buy a nuke, then it would be added to your inventory, then when you launch it, you remove it from your inventory. You would just allow 1 nuke in the inventory at a time, so you might want to have other planets where you can buy nukes. The inventory system could take care of the objects properties like position, target, etc etc - I'm thinking you've probably considered this already, so it might be a case that expanding on your system is the best route so it can handle more things like this without too much direct coding.


Van-B


It's c**p being the only coder in the village.
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 11th Jan 2005 06:18
Well there is an inventory of sorts, I just can't figure out how to re-position the object when the nukeexist variable equals 0.

Guns arn't the problem, people are the problem, shoot all the people and guns arn't a problem anymore.
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 11th Jan 2005 06:50
Ahh, I see what you mean. I'd just use and extra value on nukeexist to control that, like if the nuke is at home then nukeexist=0, then when you buy one it goes to 1, then when you've used it, set nukeexist to -1.

If nukeexist=-1
nukeexist=0
position object nukeobject,etc,etc,etc
endif


Van-B


It's c**p being the only coder in the village.
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 11th Jan 2005 08:39 Edited at: 11th Jan 2005 08:40
I don't understand what is happening, but it is just not working. I am guessing there is a problem with collision, after all, there is always a problem with collision , well here is the code for launching the missile...



Note, object 8000, is the mouse object.

Guns arn't the problem, people are the problem, shoot all the people and guns arn't a problem anymore.
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 11th Jan 2005 16:10
Do you specifically need the collision detection? - I mean, you could calculate the distance between the mouse object position and the missile, when it get's within a certain range, you can swap out the collision check and set the nuke stuff as if it had collided properly.


Van-B


It's c**p being the only coder in the village.
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 12th Jan 2005 05:50
I don't know how to do all that distance stuff

Guns arn't the problem, people are the problem, shoot all the people and guns arn't a problem anymore.
Los
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Location:
Posted: 12th Jan 2005 06:24
Even I know that. It's circles I hate.


no no no no no no no no
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 12th Jan 2005 17:35
I made a little function for someone recently, you pass 2 object numbers and 2 limb numbers to it and it returns the distance between the limbs - or the object itself if you set 0 as the limb. I'll see if I can find it.


Van-B


It's c**p being the only coder in the village.
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 17th Jan 2005 10:21
But can you tell me how to get it working as is? Because obviously either the collision isn't working, or something else is going wrong, I just don't want to get into distance equations on something this simple.

Guns arn't the problem, people are the problem, shoot all the people and guns arn't a problem anymore.

Login to post a reply

Server time is: 2025-05-24 17:55:06
Your offset time is: 2025-05-24 17:55:06