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 Discussion / Using sprites in a 3D environment (DBC)

Author
Message
Hangar18
19
Years of Service
User Offline
Joined: 13th Mar 2007
Location:
Posted: 22nd Mar 2007 11:58
Hi Again, I am trying to use sprites in a 3D environment which probably is a bit dumb but does anyone have any tips. The game is sort of 2D in that you can only fly along the X and Y axis (its a top down space shooter) but can zoom in and out on the Z axis. Using an object ship say positioned at 20,10,0, I tried creating a blowing up effect by hiding the object after a bullet hit it and replacing it with an explosion sprite TDK kindly gave me (nb. I intend using my own sprites and am just using TDKs for the time being until I can get the game to work). I positioned the sprite at 20,10 but of course in 2D its a quite different location from 20,10,0 in 3D. Furthermore zooming in and out changes the 3D postion relative to the camera but not the sprite. Does anyone have any tips on how to get round this? i.e. can you create a 3D sprite. Forgive my ignorance I'm still quite new to all this and the tuts/examples in DBC didnt help.

THanks.
TDK
Retired Moderator
23
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 22nd Mar 2007 23:35
Quote: "you can only fly along the X and Y axis"


First of all, if it's a top down 3D view then you are flying along the X and Z axis - not X and Y.

Quote: "but can zoom in and out on the Z axis"


You would also be zooming in on the Y axis. Minor points I know, but important for what you have to do.

For the size of the sprite, simply base it on the distance between the camera and the exploding object. The greater the distance, the smaller the sprite. Something like:



Save this code snippet as a DBA file in the same folder as the snippet I posted in the other thread as it uses the same explosion image set for the sprite.

TDK_Man

Hangar18
19
Years of Service
User Offline
Joined: 13th Mar 2007
Location:
Posted: 23rd Mar 2007 01:58
Thank you again TDK!!!!

Just a bit confused as to why I am in the X,Z plane and not the X,Y? The reason I ask this is because I thought that by saying position object 20,10,0 I was saying position object at X = 20, Y = 10 and Z = 0. And the camera while positioned at 0,0,-60, its only the -60 that changes when you zoom in and out (and the -60 is on the Z axis).
TDK
Retired Moderator
23
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 23rd Mar 2007 02:27
Quote: "And the camera while positioned at 0,0,-60, its only the -60 that changes when you zoom in and out (and the -60 is on the Z axis)."


Ah OK... that's not top down it's side view!

Your "its a top down space shooter" comment threw me...

The snippet I posted above is top down - ie the camera is elevated on the Y axis and pointing down at Y=0.

For a clearer picture, just create a matrix in your program (which can only be on the X/Z plane). In a top-down program the camera would be above the matrix looking down on it.

Your program is a space shooter so the side view doesn't really matter.

The code I posted being true top-down could also be used pointing down to say cars on a matrix whereas yours would be viewing the matrix side-on.

TDK_Man

Hangar18
19
Years of Service
User Offline
Joined: 13th Mar 2007
Location:
Posted: 23rd Mar 2007 03:29
Thank you TDK. I am extremely grateful for your help.

Login to post a reply

Server time is: 2026-07-05 22:39:51
Your offset time is: 2026-07-05 22:39:51