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 / Stumbling Block with 3D objects

Author
Message
Veega
14
Years of Service
User Offline
Joined: 13th Jan 2010
Location: Findlay, OH
Posted: 18th Jan 2010 18:13
Ok, I am writing a bejeweled clone as my first project (only have known DBPro for about 4 weeks) and honestly, I have surprised my self seeing as I can load the first set of gems, select one (it spins) select another and they exchange places... Here is my problem... I wrote it depending on OBJ #'s... seeing as this will probably only work till I clear the first set and new ones load... Here in lies my biggest issues... How should I refer to my gems? Like I said, as of now gem1 and gem2 are object numbers found by Pick Object (mousex(), mousey(), 1, 154) as there are 154 objects currently. I believe if I could get a good referring system, i could finish and re adapt what I have. My only thought is if I stay with object numbers I have to create several hundred thousand lol and that doesn't seem logical. My code is posted... I realize that I may have redundant or useless code... if you see anything else that may work better, feel free to suggest!
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 19th Jan 2010 08:17 Edited at: 19th Jan 2010 09:25
ok, first thing. instead of:


try:

saves you (and our already-overworked hard drives) 153 loads

next, you shouldn't ever need to create more gem objects than can be visible at any one time. period. more on this later...

re: a reference system for this, an array is perfect here; you've already got tank(x,y) going so you're on the right track. take a look at this little "gem swapper" i wrote especially for you (and me, since i think it's the easiest way i could explain it).
pay attention to the _checkgems: routine at the very end where the array coordinates are derived from the object x & z values.


ok, back:

to finish on the reference system, i'm using the board() array to hold colors. you can add whatever you want here, of course. ie, texture numbers or other object settings with minimal difficulty. when objects occupy those grid-spaces, you can reference the array and apply whatever settings are held there to the new object.

also, note, my objects never move. they simple re-color themselves giving the illusion that they've swapped places. again, not sure how your game is gonna play out but judging from the movegems() function in your code (and your other thread), you intend to literally swap x/y/z positions. as you can see, if you set the objects with the new settings based on the array, you won't have to. alas, if you still want to re-position the objects, the "swap colors" part in the gem swapper can be modified to suit your needs. changing the existing code in your movegems() function:

to

...should work (but, you should get used to using floats instead of integers for 3d stuff).

as for the notion of creating "several hundred thousand" objects, forget it again, you shouldn't need more than can be visible at any one time. assuming your game will be "removing" matching gems from the board and then introducing new gems at some point, why not re-use those objects, placing them wherever you want and re-"skinning" them as "new" gems, or moving them off the screen and hiding them until they're needed again? keep track of unused gem objects by using an array like FreeGems() that you would fill with hidden/"removed" object numbers and draw from as needed. ie, if a gem is remove from play, move and hide it from vision and add its object number to FreeGems(). say 3 seconds later you want a new gem to "spawn", pull one from FreeGems(), show it, place and set it up however you want.

anyway, enough from me. i hope this helps

Virtual Nomad @ California, USA
AMD Phenomâ„¢ X4 9750 Quad-Core @ 2.4 GHz . 8 GB PC2-6400 RAM
ATI Radeon HD 3650 @ 512 MB . Vista Home Premium 64 Bit

Login to post a reply

Server time is: 2024-11-24 20:59:26
Your offset time is: 2024-11-24 20:59:26