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 / Arrays in Types?

Author
Message
UFO
18
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 30th Oct 2007 01:27
I don't know what variables like:

Ship.x
and
Ship.y

are called, so I wasn't able to search it.

So here's my question:

how do you have arrays in types?

For example, if you were going to have multiple bullets in a 2D game on the screen, you would need the x,y,speed,damage, etc for each one. I want to use types with that, and arrays also. How would I do this?

Would you do it something like this?:



I doubt it, but I am just giving an example of what I am trying to do.

Thanks in advance

Your signature has been erased by a bad joke
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 30th Oct 2007 01:35
Dim Bullets(100) as bulletinfo

"It's like floating a boat on a liquid that I don't know, but I'm quite happy to drink it if I'm thirsty enough" - Me being a good programmer but sucking at computers
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 30th Oct 2007 02:20
Global Dim Bullets(100) as BulletInfo

But I think there is a quirk that ARRAYS MIGHT be Global just because they are arrays - but - when you start having multiple source files in one project - you might feel like I do - "If I want it global - I'll tell it I want it global" ... I do this as habit regardless when declaring global arrays because this is how you must do it for NONE array things... like

Global Bullet as BulletInfo

Good Luck

Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 30th Oct 2007 02:39
Arrays are global unless made local by the user, heh.

"It's like floating a boat on a liquid that I don't know, but I'm quite happy to drink it if I'm thirsty enough" - Me being a good programmer but sucking at computers
UFO
18
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 30th Oct 2007 14:20
So would you use it like this?:

Bullets.x(50)

Thank you for the help

Your signature has been erased by a bad joke
TechLord
21
Years of Service
User Offline
Joined: 19th Dec 2002
Location: TheGameDevStore.com
Posted: 30th Oct 2007 16:49
UFO, if your using different types of Bullets, you can use two custom types, one for the BulletProfile, and one for individual Bullet information per Instance.



This would allow you to create several types of BulletProfiles in which your Bullets inherit their intial property settings from.

PresFox
19
Years of Service
User Offline
Joined: 28th Aug 2005
Location:
Posted: 30th Oct 2007 17:30 Edited at: 30th Oct 2007 17:30
or you do:



Microsoft isnt evil, they just make really crappy operating systems -- Linus torvalds
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 30th Oct 2007 22:48
You might find a couple of tutorials quite handy...

Asset Management

Asset Blueprints

UFO
18
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 31st Oct 2007 00:28
Thanks, guys!

That was very helpful

Your signature has been erased by a bad joke
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 31st Oct 2007 04:09
UFO - one more thing - Windows Killer said he recommends dynamic bullets versus having a fixed amount. (Dynamic means create them as you need them and destroy then when you're done).

I agree - however - lest not forget sometimes - limits are the right solution - sometimes having fixed arrays is the right thing to do. It really depends on many factors.

DO favor dynamic of "fixed length" things normally when designing stuff - but there are times when limits - whether as fixed arrays or a max number of dynamic ones at one time - are perfect - to limit "the amount of stuff flying around" for example - and other reasons you may be able to dream up.

GOOD DESIGN is extremely important - but so is getting the most you can out of your software! Sometimes this means doing unconventional things to get a desired result.

Remember - think outside the box - after all thinking in the box is like being in jail

UFO
18
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 31st Oct 2007 14:27
Well, I ignored that part anyway.

I like having limited bullets because I find adding to arrays and stuff confusing. I don't plan on having an massive amount of bullets on the screen anyway.

Thanks though

Your signature has been erased by a bad joke
UFO
18
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 8th Nov 2007 00:33
Sorry for the double post.

Is is possible to have an array inside a type with an array?

Example:

Ship(x).Turretlocationx(y)

If so, how can I do it. I am having trouble getting it to work.

Thanks!

Your signature has been erased by a bad joke
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 8th Nov 2007 00:35
It's impossible. Go up to the top of Newcomer's Corner and click on Tutorials Thread. Inside you will find a tutorial on types, and it gives some work-arounds for your problem.

"It's like floating a boat on a liquid that I don't know, but I'm quite happy to drink it if I'm thirsty enough" - Me being a good programmer but sucking at computers
UFO
18
Years of Service
User Offline
Joined: 11th Oct 2005
Location:
Posted: 9th Nov 2007 01:29
Darn. I've been thinking of a way to get around it, so it shouldn't be much of a problem.

Thanks though

Your signature has been erased by a bad joke
Because you love me
19
Years of Service
User Offline
Joined: 24th Feb 2005
Location: Leicester, England
Posted: 12th Nov 2007 23:07 Edited at: 12th Nov 2007 23:16
It even works with strings! ace!

Only thing is, is it possible to do an array within a type somehow?

to look like...



...which doesnt work obviously

Nicholas John Joseph Taylor; Nick
[url]http://www.thesaturdaychannel.co.uk [/url]

Login to post a reply

Server time is: 2024-09-27 08:31:49
Your offset time is: 2024-09-27 08:31:49