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.

DarkBASIC Professional Discussion / Just Some Queries Making A 3D Platformer

Author
Message
MonchoMeecho
15
Years of Service
User Offline
Joined: 10th Aug 2010
Location:
Posted: 11th Aug 2010 05:56 Edited at: 11th Aug 2010 11:23
Hey guys, I just have some questions about making a platformer using 3D assets.

Basically it's a clone of Super Mario World 1 - 1.

I've made all of the objects in 3DS Max and loaded them into Darkbasic (individual objects for special collision purpose), objects for the player, ground, question mark blocks, normal blocks, pipes and flagpole at the end. They're successfully all loaded in their respective positions in DarkBasic.

My Questions:
1. I can move the player left and right (only movement in this game, z axis is not a factor), there's no collision between him and the objects yet, but I'm wondering how can I make the camera stay fixed on the object as it moves?

2. How would I do something like a simple jump function for the player?

3. All of the question mark blocks are loaded in as one object, how would I make a collision only effect the one which is collided with?

Thanks for any help !

Whoops, forgot to put my code in thus far:


Mind the jump life thing, I'm was just seeing if I could get jumping working that way.
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 11th Aug 2010 09:24 Edited at: 11th Aug 2010 09:27
The camera can probably be positioned with the player object, like the player X and Y coordinate with the Z coordinate being -200 or something - whatever the scale of your game.

Personally, I would use a grid system if you aren't already, and have each block as a seperate object placed on the grid. Then, you can forget about using 3D collision and use the much more robust and system friendly array based collision. With that, it would be easy to flag the state of the block, very fast for collision detection, and you could have an invidisble block too - for things like pipes where the object would be bigger than the grid size. If you load in each block as an object, you could instance these objects and position them on your grid to construct the level, and it would be real fast because instanced objects render much quicker than standard objects.

For jumping, usually I would have an X and Y speed for the player, then movement affects the X speed, will allow for inertia and stuff. With the Y speed you can add gravity each loop to give nice arc's to falls and jumps, and if the player is on the ground, and the user pressed the jump button, then you just have to set the Y speed to a positive number. Will need tweaked so you get a good height, both the jump speed and the gravity, but it works nicely for me usually. Maybe try decresing the Y speed by 0.1, and setting the jump speed to 1.5 as a start.

Health, Ammo, and bacon and eggs!
MonchoMeecho
15
Years of Service
User Offline
Joined: 10th Aug 2010
Location:
Posted: 11th Aug 2010 11:34
I am not familiar with making grids in DBP and I am kind of on a time crunch to complete this game (college assessment), so depending on how difficult / time consuming it is, that may not be an option.

I love your idea for jumping however, thank you I'll try it out now.
MonchoMeecho
15
Years of Service
User Offline
Joined: 10th Aug 2010
Location:
Posted: 12th Aug 2010 10:49
Sorry to double post, this 'having to wait for posts to be approved' business is annoying.

But, how would I be able to load the same 3D object in multiple positions (like for loading a level) using arrays and co-ordinates via a notepad file?

I know it's something like:


But I'm having trouble understand how it works.
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 12th Aug 2010 13:15
Quote: "Personally, I would use a grid system if you aren't already, and have each block as a seperate object placed on the grid. Then, you can forget about using 3D collision and use the much more robust and system friendly array based collision. With that, it would be easy to flag the state of the block, very fast for collision detection, and you could have an invidisble block too - for things like pipes where the object would be bigger than the grid size. If you load in each block as an object, you could instance these objects and position them on your grid to construct the level, and it would be real fast because instanced objects render much quicker than standard objects.
"


You would be crazy not to use a grid. You could make an array to hold the level, just storing the block number at each grid location, then save and load the file as an array. It would be easy to make an editor for it too. A grid would save you a bunch of time I think.

Load each block as an object and keep track of each block, so you can save the block number and it always relates to the same model.
Make a 2D integer array to hold the block numbers on the grid, maybe MAP(256,32).
Position an instanced copy of the block at the relevant grid position, which is just multiplying that by the grid scale. If your standard brick block is 5x5 units on X and Y, then multiply the grid location by 5, and you have your X and Y position to place the instanced object.
Then to work out if a 2D location is inside a block, just divide the location by 5 and check the array at that location.

It makes everything else you have to do much easier - saving and loading levels, collision detection, level building, performance. You would start the instanced objects at a set point, then increase the object number as you go - say you start at object 1000. When it comes time to re-build the level geometry, you step through objects 1000 to whatever the current object is, and delete them, then step through the MAP array, and add the objects for the current level. This is all very quick, both to build the level, clear the level, and even render the level because instanced objects are just instances, not actual object data.

Health, Ammo, and bacon and eggs!
MonchoMeecho
15
Years of Service
User Offline
Joined: 10th Aug 2010
Location:
Posted: 13th Aug 2010 14:22
I'm sorry, but I'm having trouble trying to do what you're asking. I am still relatively new to the program (sorry, should have specified this in the original post), so some example code would be helpful (I have no intentions of stealing it, I just find that reading code helps me understand how things work in DBPro along with the theoretical side).

So just to specify, some things I need help with:
- keeping the player on the ground, so if after jumping and coming back down they don't go through the ground / get stuck inside it (I'm using Sparky's Collision, but if you can provide the way without it, it will also be greatly appreciated)
- loading the same object in multiple co-ordinates in 3D space by mapping them out in a notepad (x , y and z positions) file then putting them into an array. And after doing this, making it so colliding with one of these objects will only effect the one that is hit
- making an enemy that shoots at the player.

I know this must be a bit frustrating for you to hear, but I am just having trouble understanding what you're trying to tell me to do
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 13th Aug 2010 22:49
No worries, I wrote a long tutorial series on 2.5D platformers a while ago, I'm sure I can come up with a neat example for you.

Will get back to you as soon as I can.

Health, Ammo, and bacon and eggs!
MonchoMeecho
15
Years of Service
User Offline
Joined: 10th Aug 2010
Location:
Posted: 14th Aug 2010 04:43
Quote: "No worries, I wrote a long tutorial series on 2.5D platformers a while ago, I'm sure I can come up with a neat example for you.

Will get back to you as soon as I can."


Thank you for going to the trouble for me, it means a lot, really
DevilLiger
22
Years of Service
User Offline
Joined: 21st Nov 2003
Location: Fresno,CA,USA
Posted: 3rd Oct 2010 13:08
i tried something of a 3d platform until i came to a conclusion... i don't know how to animate 3d characters...

Login to post a reply

Server time is: 2026-07-24 23:12:42
Your offset time is: 2026-07-24 23:12:42