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 / 2D Sprites in 3D World?

Author
Message
Yart
20
Years of Service
User Offline
Joined: 23rd Jun 2004
Location: Turkey Sandwich
Posted: 11th Aug 2004 15:21
Hey people! I finally decided to start working on my first serious DarkBASIC Pro game, "Kyokudai-Seikon", an RPG that has an 3D environment with 2D sprites. One problem, how do I make 2D sprites and actually have them running around the world? (Kinda like Ragnarok Online)

Thanks people!

Pie!
Sir Spaghetti Code
20
Years of Service
User Offline
Joined: 12th Jul 2004
Location: Just left of Hell
Posted: 11th Aug 2004 16:13
Ouch! I think that Db is either in 2D or 3D mode. Not really seen anything done like this. I have tried putting sprites in a 3D enviroment just to see if it could be done, and I got errors. I am still very new to DB, so I am probably wrong...

"I attribute the quarrelsome nature of the Middle Ages young men entirely to the want of the soothing weed."
-Jerome K. Jerome(1859-1927),Writer
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 11th Aug 2004 22:45
A sprite in a 3D world is simply a plain that always points towards the camera position.

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins, source and the Interface library for Visual C++ 6, .NET and now for Dev-C++ http://www.matrix1.demon.co.uk
Dodo
20
Years of Service
User Offline
Joined: 8th Aug 2004
Location: eating lunch
Posted: 12th Aug 2004 01:50
hey you could try making very thin 3D models, that would have the same effect. and it would be easier to animate. i think.
Cartmanbeeps
20
Years of Service
User Offline
Joined: 9th Dec 2003
Location:
Posted: 12th Aug 2004 03:05
hmmm... Ive been wanting to do something like that. But collision would be a pain.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 12th Aug 2004 04:06
You could use either a simple bounds checking (maths collision) or place an invisible cube or box at the same position.

Here is the way I would deal with it:



Doing it this way (using limbs) means that I have one object to worry about for positioning, collision, texturing etc, instead of two objects.

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins, source and the Interface library for Visual C++ 6, .NET and now for Dev-C++ http://www.matrix1.demon.co.uk
Yart
20
Years of Service
User Offline
Joined: 23rd Jun 2004
Location: Turkey Sandwich
Posted: 12th Aug 2004 06:58 Edited at: 12th Aug 2004 07:00
hey cool! thanks!

Although I want to make a 3D world... meaning non Side Scroller (until you get caught in a random fight). How would I make it so that the sprite has 8 directions, but still a flat plain that always aim's towards the camera and when the camera goes around the plain, the sprite changes to make it look like it's actually turning?
Kinda like those old shooters like Duke Nukem 3D and Doom?

Pie!
Enclosed
20
Years of Service
User Offline
Joined: 8th Jun 2004
Location: Colorado
Posted: 12th Aug 2004 07:13
I would have 8 plains all in one spot with 7 of them hidden each having their own picture of the characters direction. Then whenever the camera rotates 45 degrees or more I would unhide the correct plain and hide the old one. However I do not know if this would interfere with how you are doing collision. Oh and just so ya know I dont even know if my way would work but it sounds like it should Good Luck.
Yart
20
Years of Service
User Offline
Joined: 23rd Jun 2004
Location: Turkey Sandwich
Posted: 12th Aug 2004 07:25 Edited at: 12th Aug 2004 07:28
umm... but the camera is going to be turning too... how would that work?

I need code to fully understand!

And besides, I only want 1 plain for each NPC and for the Hero... I don't need to fill up my code like that with 8 per guy...

Pie!
Enclosed
20
Years of Service
User Offline
Joined: 8th Jun 2004
Location: Colorado
Posted: 12th Aug 2004 07:27 Edited at: 12th Aug 2004 07:31
Well I'd need your code to make code and fully understand

Edit: Lol thats some code but Ill try to whip sumthing up for ya...
Yart
20
Years of Service
User Offline
Joined: 23rd Jun 2004
Location: Turkey Sandwich
Posted: 12th Aug 2004 07:29 Edited at: 12th Aug 2004 07:29
Ok here

make object plain 1,somesizes

I never even made them yet 'cause I don't know how lol!

Pie!
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 12th Aug 2004 07:35
Those old games used a single plain, and changed the texture to suit the direction and animation frame. They were also true sprites in that they were incapable of facing any way except towards the camera.

That's something that is easy to solve for plains though - use the POINT OBJECT command to point the object towards the camera position.

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins, source and the Interface library for Visual C++ 6, .NET and now for Dev-C++ http://www.matrix1.demon.co.uk
Yart
20
Years of Service
User Offline
Joined: 23rd Jun 2004
Location: Turkey Sandwich
Posted: 12th Aug 2004 07:39
cool... now how about that direction stuff? for when the camera goes around and changes the texture of the plain to make it look like a 2D sprite that is rotating?

Pie!
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 12th Aug 2004 07:52
That would be totally under your control.

You need to work out what angle the camera is at in relation to each sprite, and then determine which texture set you would use.

eg (keeping it simple)
If your cameras Y angle is 0, and the sprites angle is 0, you would see their back. The same would occur if both were looking at an angle of 45 degrees - this implies a subtraction somewhere.

If your angle is 0, and the sprites angle is 90, you would see their right side. The same if your angle was 90 and theirs was 180 - this suggests that your should subtract the camera angle from the sprites angle (180 - 90 = 90, 90 - 0 = 90)

Using the same logic for 180 and 270 degrees, this works well, as long as you adjust the result to keep it within the 0 to 360 degree range. After that, it's just a matter of assigning texture ranges to a range of angle and switching texture sets when necessary.

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins, source and the Interface library for Visual C++ 6, .NET and now for Dev-C++ http://www.matrix1.demon.co.uk
Yart
20
Years of Service
User Offline
Joined: 23rd Jun 2004
Location: Turkey Sandwich
Posted: 12th Aug 2004 08:28 Edited at: 12th Aug 2004 09:27
OH! So if I had something like this for 4 directions

(Up being away from camera)



Maybe edited a bit to make it look in the proper directions, would that work?
(If I do get it working, I will more than likely post it in the Code Snippets section)

Pie!
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 13th Aug 2004 03:16
That's the general idea

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins, source and the Interface library for Visual C++ 6, .NET and now for Dev-C++ http://www.matrix1.demon.co.uk
Yart
20
Years of Service
User Offline
Joined: 23rd Jun 2004
Location: Turkey Sandwich
Posted: 13th Aug 2004 09:37 Edited at: 13th Aug 2004 09:38
Hmm... I get an error like

#100001: Could not determine parameter type of '@$L0 and' at line 60.

For this line.


Pie!
Yart
20
Years of Service
User Offline
Joined: 23rd Jun 2004
Location: Turkey Sandwich
Posted: 13th Aug 2004 11:46 Edited at: 13th Aug 2004 11:59
I solved that problem... but now I got a different problem. But first to say, IT WORKS!!!... for 270 degrees. I can turn around for 270 dgerees while the plain is looking at the camera and the picture changes... just when you get to the 3 image, the plain rotates and you don't get to see it! Since I have nothing to hide in the source code, I'm putting it all on here... including stuff you don't need but just to let you know what it does.

kyodukai-seikon.dbpro (Project File)

kyokudai-seikon.dba (Main Source File)


kyokudai-seikon-images.dba (Image Loading File)


kyokudai-seikon-camera.dba (Camera Rotation/Moving File)


Help! Try it out yourself and provide your own images.

Pie!
Hell Dragonz43
20
Years of Service
User Offline
Joined: 27th Jul 2004
Location: at home or at work
Posted: 13th Aug 2004 12:07 Edited at: 13th Aug 2004 12:16
u could just use the sprite command. It works 100% ok when i use it in a 3D game.

Make Camera 1

Load Image "Name here",1

Sprite 1,1,1,1

Do
Loop

_______________________________________________
My website: http://www.freewebs.com/mycomputergames/
Yart
20
Years of Service
User Offline
Joined: 23rd Jun 2004
Location: Turkey Sandwich
Posted: 13th Aug 2004 12:23 Edited at: 13th Aug 2004 14:59
SAY WHAT!?!?!? YOU CAN DO THAT!??!?! HOW COME NOBODY EVER TOLD ME?!?!?!

But what about the camera rotating around it and making the image change? Same thing basically as a plain?
And secondly, does lighting apply?

EDIT: Hmm... I tried this in a look after making another plain.

yrotate object 3,camera angle y()

and I get the exact results as the textured plain!

And I then changed it to a box... was still the same!

Pie!
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 14th Aug 2004 04:22
Yes, you could use a sprite, but ...

- that would force you to come up with a way of resizing the image as it changed distance. It's far easier to let DirectX do this for you.

- You would also need to work out your own collision, as sprite collision is not good enough for what you need

- Lighting will not apply


You need to keep the plain pointed at the camera - the simple way to do this is to use the POINT OBJECT command with the camera position as the coordinates.

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins, source and the Interface library for Visual C++ 6, .NET and now for Dev-C++ http://www.matrix1.demon.co.uk
Cartmanbeeps
20
Years of Service
User Offline
Joined: 9th Dec 2003
Location:
Posted: 14th Aug 2004 04:26
Mahhhstahr never ahsked........ - Gollum
Yart
20
Years of Service
User Offline
Joined: 23rd Jun 2004
Location: Turkey Sandwich
Posted: 15th Aug 2004 10:43 Edited at: 15th Aug 2004 11:30
Quote: "You need to keep the plain pointed at the camera - the simple way to do this is to use the POINT OBJECT command with the camera position as the coordinates."


Hey! Not a bad idea! I should try that.

EDIT: WOOHOO! IT WORKED! OMG! Thanks alot!

But since my code got REALLY messy by trying this out, I'm redoing my code. Thanks alot guys! OMG! Man now I can start!

EDIT AGAIN: DANGIT! TURNS OUT THE DICTIONARY WAS WRONG AND MY GAME NAME HAS SOMETHING TO DO WITH MARRIAGE!
Name changed to Kyokudai-Enaajii

Pie!

Login to post a reply

Server time is: 2024-09-22 20:13:10
Your offset time is: 2024-09-22 20:13:10