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 / creating a set of objects, each time a condition is met? How?

Author
Message
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 26th Dec 2004 03:19
Ok, I am making a sci-fi space stradegy game, I have the entire solor sytem created, and each planet has a variable to decide it's nationality, if the variable=0 it is neutral, if the variable=1 it is yours, if the planet=2 it is the enemies. My original design, called for 3 units to be created for each planet you capture, so if you want to build an army, you havet to take over the variouse planets. I decided to do this by creating a subroutine that would create 3 units each time if a planet=1, but this will not work properly, because if you capture a second planet, the program instantly gives you an "object already exists error" so how would I pull this off? I want to be able to create the same type of objects each time and have thier object numbers ogranized so that I can use an for-next command later on to dictate what they are to do!

Thanks.

Guns arn't the problem, people are the problem, shoot all the people and guns arn't a problem anymore.
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 26th Dec 2004 23:50
So I would have to create the 3 units for each planet, or create 9 subroutines that create the 3 units for each planet? Or I could have the object created, and just hide them, or position them off the map, and then when a planet=1 it loads that planets units?

Guns arn't the problem, people are the problem, shoot all the people and guns arn't a problem anymore.
demons breath
21
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 27th Dec 2004 03:49
make the subroutine say if object (x) is type 0 then use texture 1, if it's type 1 then use texture 2, if it's type 2 then use texture 3 (IF it's just the texture and stats that changes for the object then this should work cos the stats could be held in an array)

Am I the only one here who's really confused?
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 27th Dec 2004 04:14
Well you see I'm trying to do something like this....

I have a victory timer.

when one of your ships comes in contact with a planet the timer starts counting down.

if the timer=0 and the object and you are still colliding with the planet, the planet is yours, in other words the planet=1 because that means it is yours.

Now I wanted the subroutine to create 3 objects, and then call that subroutine each time a planet=1.

But normally if you capture a second planet, the program will return an "object already exists" error, becuase the objects were alreay created once. So I am trying to figure out how to create 3 objects per planet (if the planet=1) but do it in a way, so that I won't have to program 3 objects, for each planet.

Guns arn't the problem, people are the problem, shoot all the people and guns arn't a problem anymore.
demons breath
21
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 27th Dec 2004 04:55
what are the objects for? i dont understand [img] [/img]

by the way, make sure that you have something to check that the ship is colliding with the planet as the timer decreases, and to reset the timer if the ship moves away from it.

Am I the only one here who's really confused?
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 27th Dec 2004 07:37
You see, It is a stradegy game, there are 9 planets in the solar system, each planet you capture gives you 3 objects or units to control, so the more territory you have, the bigger your army becomes, that is why I am trying to create 3 objects each time a planet comes under your control.

Guns arn't the problem, people are the problem, shoot all the people and guns arn't a problem anymore.
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 28th Dec 2004 09:35
I would really like to know if this is possible?

Guns arn't the problem, people are the problem, shoot all the people and guns arn't a problem anymore.
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 29th Dec 2004 05:45
I'm sorry to have to keep bumping this, but the ability to create the same set of objects over and over again, is really needed! I just cannot continue my project, untill I know that this is possible.

Guns arn't the problem, people are the problem, shoot all the people and guns arn't a problem anymore.
empty
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 29th Dec 2004 08:10
Erm, just use different object number (or sets of numbers) for each planet as digital modr suggested.



If PlanetNumber = 1 ObjectNumber will range from 111 to 113
If PlanetNumber = 2 ObjectNumber will range from 121 to 123

and so on


Play Nice! Play Basic! Version 1.06
Major Payn
21
Years of Service
User Offline
Joined: 16th Dec 2003
Location: United States of America
Posted: 29th Dec 2004 10:25
Whoa, whoa, whoa, I'm confused now.

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: 5th Jan 2005 01:08
Couldn't you just make some code which makes a new object only if OBJECT EXIST(x)=0

?

Just make sure you save the three object numbers with the planet you've created already. Planet Object 40 in some array will hold 3 numbers for each object (or ship) 50, 51 and 56..

When you go to create another object, go back through the code (maybe better in a function) to check from 0 to 99999 UNTIL object exist(x)=0


?


the method above just uses some grouping labels with numbers. Team blue is 10, team Yellow is 20 and team Green can be 30. Each team can have10 people... or perhaps team blue wants to be 1010, yellow 1020 and Green 1030.. just make sure your function will check the correct numbers, it's set in stone.

Login to post a reply

Server time is: 2025-05-24 07:34:43
Your offset time is: 2025-05-24 07:34:43