• Welcome to Dark Bit Factory & Gravity.
 

3D Horizon[BB2D]

Started by Nightfly, July 04, 2007

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

Nightfly

Hi, I am looking for some example code that shows how to create a 3D scrolling horizon in 2D, as seen in such games as Space Harrier. I am also in need of code that would scale an object properly as it comes closer to the player. Here is what I have so far:


Graphics 320, 240, 16, 2
SetBuffer BackBuffer()
SeedRnd MilliSecs()

Color 0, 255, 0

tmpZ = 0
Repeat

tmpZ2 = 1
For y = 120 To 320
Line 0, y + tmpZ2, 320, y + tmpZ2
tmpZ2 = tmpZ2 + (tmpZ2 * .8)
Next

Color 0, 0, 0
Rect 180, 90, 25, 55, 1
Color 0, 255, 0
Rect 181, 91, 23, 53, 0

Flip: Cls
Until KeyDown(1)


now I just need help making it move forward when the user holds up. Thank you  :carrot:

Jim

What people usually do is pretend the object is in 3d, so it has a screen position (x and y) and a 'z' position, where the z is the distance away from the viewer.  Then one simple way to make the thing look smaller as it is further away is to divide x and y by z, and scale it to fit the screen, so

screenx = scale * x / z
screeny = scale * y / z

Jim
Challenge Trophies Won:

Shockwave

Welcome to the board Nightfly. :welcome:
Learning something like a 3D starfield would establish the principles that Jim has talked about.

Shout if you need help :)
Shockwave ^ Codigos
Challenge Trophies Won:

Clyde

How did you get on with this Nightfly dude?
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.


Challenge Trophies Won:

Jim

Who knows?  That was his first and last post nearly a year ago!

Jim
Challenge Trophies Won: