Hi, I'm planning on eventually making a game set in a city with a top-down view like that in GTA (It won't be a GTA-like game before anyone gets excited). Anyway i made the "3D" buildings using layers, but noticed that only if i start directly under one of them does it line up, other ones all move 'with' the one i start underneath and are VERY misaligned when i get to them. I wonder if there is any way to 'offset' the movement of layers so that they 'line up' over where the camera is. Or will i have to position the layers of my buildings really far apart in remote areas of the map and get them to line up by trial and error?
Ahh, i had already seen another example that did that, but it uses lots of active objects, which if you make a large area would cause problems. The layers let you use background objects... guess i'll have to set up the buildings by trial and error and just playtest a lot to make sure they line up right... getting ahead of myself anyway, gotta make sprites first
Actually, it doesn't use as many as you'd think. only about 4-5 per building.
You can even same more space if you have a dummy objects that's invisible that actually fires the layers (which is how the engine works), and then simply deactivate it when it's not on the playfield (Actually, it's slightly larger than the playfield, otherwise you'll get "pop" in.)
I'm not the best at splainin' things Lucy, so if you want an example I'll bust out the voxel engine and make the neccessary modifications.
Yeah, it can sometimes be a major pain to line up your objects so that the perspective is correct- especially if you add new things later, or things that need to be displayed under or over what you want ordered or you create a bunch of new objects at runtime. Like 20 trees in a forest, blah. Trial and error, is what I'd recommend.
--
"Del Duio has received 0 trophies. Click here to see them all."
"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"
DXF Games, coming next: Hasslevania 2- This Space for Rent!
Well actually i suppose it would be possible to do a calculation based on the distance from the starting position (in XY coordinates) to the top left corner of the bottom floor of the building, and then work out how many pixels further away the subsequent floors will be based on the movement coefficient of the layer they are on, and place the top left corner of the next floor up at that distance. Though in a large city it might start producing silly numbers, the solution is to not have tall buildings near the edges, or to make the frame much bigger than what you can actually "get to". Or not have fake 3D buildings .
"Well actually i suppose it would be possible to do a calculation based on the distance from the starting position (in XY coordinates) to the top left corner of the bottom floor of the building, and then work out how many pixels further away the subsequent floors will be based on the movement coefficient of the layer they are on, and place the top left corner of the next floor up at that distance."
That is EXACTLY what the voxel engine does. You don't even need to code anything, just make a single active object with each frame being a "slice" of a building. Seriously, it is the BEST way to accomplish what you are trying to do. Adding 3d buildings in your game will be as simple as dropping a SINGLE ACTIVE object on your level (To act as the layer spawner)
Let us suppose you have a total of 7 buildings onscreen with 6 layers each.
7*6 = 42 actives. If you code it the way I suggestted above (The spawners deactivating when they are off the screen) you can keep it at this number.
I've already used this engine to make a faux 3d background for a verticle shooter game in TGF, which has an active object limit of just 260 objects and it worked beautifully. So I don't know why you're so concerned about "having too many actives".
Because background objects don't slow the game down... then again didn't MMF 1.5 have a limit of 10,000 or so, and (apparently) MMF2's runtime is faster, and i would assume (EXPECT) it to have an even larger limit, so i probably will use that method
"I've already used this engine to make a faux 3d background for a verticle shooter game in TGF, which has an active object limit of just 260 objects and it worked beautifully."
I suspect you don't even read these posts; and it's pretty obvious that you're not familiar with the capabilities of MMF/TGF if you believe that this will "slow your game down"
Using Layers in your crazy way is much more likely to slow your game down, as well as make it a complete bitch to develop in the first place (Placeing multiple levels of BG's on different layers, then using some cobbled together formula to hope that they line up?)
I'm not trying to bag on you or anything, but you're basically re-inventing the wheel to be a square. The Voxel was originally MADE FOR GTA LIKE GAMES; so I guess I'm just trying to figure out why you're so against using it. Give a REAL reason please ("too many objects" or "it's slow" are NOT valid reasons, because they're both false unless you have no idea how to code in the slightest)
It was my understanding that more active objects used up more ram but background objects didnt. Then again i didnt think that layers might also use up more. I was planning on using the vector engine anyway, as its simpler once the events are put in. Like this game will ever be finished, i'm still drawing the cars (havent even done the main character's one yet!). Plus i have loads of other driving games planned that i will do first to test things and get the hang of various skills before the 'main' one
Hmm, and actually having the spawners deactivate when offscreen had been something i was planning to do with the generation of the 'other cars' driving around. Back when i was n00bishly trying to make a GTA game (with the default engines so most cars went at the same top speed and it was 16mb and i had barely even started on it) every road on the vast map had cars driving around weather you could see them or not. The 450mhz computer didnt like that very much...
Glad I sould show you the light . If you need any type of help with the voxel engine (Like having it "turn off" when the 3d object is off the screen; the example wasn't set up that way so it had fewer events so it could be easily adapted) feel free to contact me, I'll make any modifications to it that you need, and I can give you a few tips on designing the voxel GFX in and of themselves.
Bah, my GTA clone had no buildings, only the top corner of the map had roads, most cars had the same (slow) top speed, which was the same speed as bullets went, "handling" was simply the size of the turning circle (the "Capricorn"'s was huge) and the cars driving around the roads would just suddenly 'snap' around 90 degrees when they got to a corner!
BUT it did actually have other cars driving around the roads, they did have an attempt at different capabilities for different cars (which i had drawn myself!), your guy looked like a person and not like a pink circle with comedy eyes in... so it was the best Click GTA clone i had seen, all the others i've had have been, er, not great.
(Though GTA-C 2 was kind of fun in a way, wonder if the bloke is still around somewhere and still has it?)