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.

Newcomers DBPro Corner / More than one of an object?

Author
Message
Yart
20
Years of Service
User Offline
Joined: 23rd Jun 2004
Location: Turkey Sandwich
Posted: 20th Jul 2004 12:16
Hey people! It's me again! Woohoo! Ok so anyway,
How can I make an object, like a gun shot or bullet, duplicate itself as another image and still does the same thing as the other ones? And how can I make each object generated have it's own Health? Like an enemy in a game.

-Thanks!

My avatar sucks!
Xander
21
Years of Service
User Offline
Joined: 3rd Mar 2003
Location: In college...yeah!
Posted: 20th Jul 2004 12:31 Edited at: 20th Jul 2004 12:34
Are you dealing with 3D or 2D? In 3D you don't duplicate as images, but you can make objects using the same mesh and texture. In 2D, you just make another sprite using the same image.

In Firewall I have 50 ammo objects per team. At the beginning of the game, during setup, I do this: (numopp is the number of opponents)


When ever a robot shoots, the game goes through a subroutine to look for an unused ammo object:



Then, in the game loop, it looks through the ammo objects, checks if each one is on, and manages it. (I use many more arrays than I showed, like the ammos' angles, speeds, powers, etc...)

Xander Moser of Bolt Software
Firewall: Your Computer's First Defense - Real Time Strategy game
[href][/href]
Yart
20
Years of Service
User Offline
Joined: 23rd Jun 2004
Location: Turkey Sandwich
Posted: 20th Jul 2004 13:08 Edited at: 20th Jul 2004 15:04
Hmm... I don't get it N00BIFIED!

Can you explain every line of code in that code for me like as if you were talking to a n00b who knows nothnig about programming? (Ok so I know a bit... but yeah, please!) And every command, if it's not too hard for you to explain what each command does, well then thanks alot!

Anyway, thanks for trying to help anyway... but I know sometime I'll get it... oh and btw, I liked your game

My avatar sucks!
Yart
20
Years of Service
User Offline
Joined: 23rd Jun 2004
Location: Turkey Sandwich
Posted: 24th Jul 2004 16:48
(Bumped 'cause of no response after going to next page of threads)

Ok... lets start with something more simple, what if all I had was simply,

for the amount of Chickens, how would I make one Chicken per NumberOfChick in a random position or a set position? Say if it was in 3D with .3DS files.

My avatar sucks!
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 24th Jul 2004 18:47
The problem is, no one understands the question!
You can paste the graphics of any object onto to any other, making mulple objects look the same, and the helath status and all is up to you and any object matrix you make. So we don't get what you're asking... Can you explain?

Any truly great code should be indisguishable from magic.
Yart
20
Years of Service
User Offline
Joined: 23rd Jun 2004
Location: Turkey Sandwich
Posted: 25th Jul 2004 11:54 Edited at: 25th Jul 2004 11:54
Ok so I read it over once, and the answer to my not-makingsenseness was 'cause of fatique

Anyway, ok lets say I had 6 chickens, how would I give them each their own variable? Like seeds. (Or am I basically reasking the questing I put in the first place that'll get me the same answer as before?)

My avatar sucks!
Elron
20
Years of Service
User Offline
Joined: 22nd Jul 2004
Location: TX
Posted: 25th Jul 2004 12:22 Edited at: 25th Jul 2004 12:23
chickens just rolls off the toungue better

"if it's not broke, i have not tried"
Xander
21
Years of Service
User Offline
Joined: 3rd Mar 2003
Location: In college...yeah!
Posted: 26th Jul 2004 09:56
It's spelled tongue

Anyway...

Okay, you want six chickens....I can give you six sort of chick looking things:

This code will dimension an array, then assign a number to each chicken and load a chicken object for each chicken:



Now, whenever you want to do something with a chicken, just access the chicken object like this:

position object chickenobject(1),x,y,z

or...

position object chickenobject(2),x,y,z

Now, to control all of them, do this:



To control them, just dimension arrays for their speed and direction, and other AI stuff...

Does that help a little?

Xander Moser of Bolt Software
Firewall: Your Computer's First Defense - Real Time Strategy game
[href][/href]
Yart
20
Years of Service
User Offline
Joined: 23rd Jun 2004
Location: Turkey Sandwich
Posted: 27th Jul 2004 17:37 Edited at: 27th Jul 2004 21:53
Whoa... cool! Thanks alot! Yeap that helped alot, I actually understood that time! But how about giving each their own variable? (I'll try to look into the first example you gave) Like lets say, they each have 3 eggs. Then all of a sudden, another object comes in, The Big Bad Wolf!!! If the wolf touches the chicken, the chicken loses an egg and is warped to a random position until he is out of eggs then the wolf has no purpose for her anymore so the wolf eats her!!! (How would you also destory one?)

Pie!
Xander
21
Years of Service
User Offline
Joined: 3rd Mar 2003
Location: In college...yeah!
Posted: 28th Jul 2004 04:36
Okay, I will expand on the chicken code. Forget my first post, that was kind of confusing...I think it was pretty late when I wrote that.

I slightly modified the code. There is a new array: chickenegg(). The program dimensions it, then gives each chicken 3 eggs to start with


Now, this code detects collision between each chicken and the wolf. If they hit, an egg is subtracted and the chicken is positioned randomly. If the chicken gets all its gets taken away, it is deleted.



I hope that is okay, tell me if you need anything else.

Xander Moser of Bolt Software
Firewall: Your Computer's First Defense - Real Time Strategy game
[href][/href]
Yart
20
Years of Service
User Offline
Joined: 23rd Jun 2004
Location: Turkey Sandwich
Posted: 28th Jul 2004 10:25
umm dude... why is it saying that the object in line 16 has already been loaded?

(Line 16: load object "Chicken.3ds",chickenobject(a))

Oh yeah... I even modelled a little chick lol!

Pie!
Xander
21
Years of Service
User Offline
Joined: 3rd Mar 2003
Location: In college...yeah!
Posted: 30th Jul 2004 05:58
The first snippet of code that I gave you in my last post should replace the first snippet in the other post. I hope that isn't too confusing...You only need to load the chicken objects once.

This:


Should be replaced with this:


Xander Moser of Bolt Software
Firewall: Your Computer's First Defense - Real Time Strategy game
[href][/href]
demons breath
21
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 1st Aug 2004 20:59
couldn't you do:



so that in chickenarray, the first number is the number of chickens take away 1 (because arrays start from 0, not 1 like normal counting), and the second number, 0, means that there is only one variable. In this, 3 is stored. Then you would have something like


where the stuff between the #'s is stuff i couldnt be bothered to figure out. This should mean that if the chicken has more than 0 eggs, then it takes away one from the value of the array (which is the number of eggs). If it's 0 then it should delete the chicken... I think... unless I have it all wrong

Am I the only one here who's really confused?

Login to post a reply

Server time is: 2024-11-27 03:40:04
Your offset time is: 2024-11-27 03:40:04