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 / stupid newbie array question

Author
Message
dumb newbie
11
Years of Service
User Offline
Joined: 2nd Mar 2013
Location:
Posted: 2nd Mar 2013 12:39
Hi everyone.
Sorry to take up your time with stupid questions but, trying to get the hang of this programming deal.
A while ago I did a basic programming course using DBpro and one of the tasks was to create a static 2D image.
I created a night skyline in 2D which now to advance my experience with 3D, I want to recreate in 3D.
I understand that unlike in 2D which I only needed to set x,y coordinates, that in 3D each building will need to be an object. I thought I could create a dimensional array to hold the objects, but when I try, keep getting an object number error.
I will display code here I am trying and hope someone can help.

rem create building
for counter=2 to 29
dim buildings(counter)
make object cube buildings(counter),rnd(25)
next counter
Kevin Picone
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 2nd Mar 2013 15:56 Edited at: 2nd Mar 2013 15:58
Your code would presumably error since the MAKE OBJECT CUBE command is expecting an Object INDEX from 1 to (However many objects are allowed). In your example, DBpro is pulling the value out of the Buildings() array at position of counter, which will be ZERO, so it'll fail. This zero will be passed back into the Make OBJECT Cube command as the Object ID..

The DIM statement is also not being used appropriately. DIM is a declaration. Generally, we'd declare our ARRAY at the top of the program, then proceed to fill it up with stuff, numbers in this case. Bellow I've put the dim at the start of the program. So the Buildings array is being declared and upon execution it'll be sized to hold 30 (31 actually) separate integer values in it.

If we want to store Object Numbers in the buildings array, then create our object using the Object Number stored within our array which is what I think your after. Then we need to assign each cell in the array with a valid Object Number. Once that's done, we can be use the buildings() array like so..





Most people tend to roll themselves a 'get free object' function. Which is just a routine that searches for Object Numbers that are not currently in use. If you search, you'll find lots of solutions on the forums already.

MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 2nd Mar 2013 16:18
Hello dumb newbie - Welcome to the forums...

I would like to recommend

HO-DBPRO VOL. 1

HO-DBPRO VOL. 2

There are cheaper quicker to receive PDF versions too, and I can say are priceless for every DBPro developer you can get through them within a few weeks if you spend the time on them...

Volume 1 has 20~ pages on Arrays...

See you around

pcRaider
16
Years of Service
User Offline
Joined: 30th May 2007
Location:
Posted: 3rd Mar 2013 01:27
night skyline?



Single Dimension Arrays?
TDK's Programming Tutorials For Beginners [DBC/P]
http://forum.thegamecreators.com/?m=forum_view&t=99497&b=10

Login to post a reply

Server time is: 2024-03-28 10:36:18
Your offset time is: 2024-03-28 10:36:18