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 / Need Help With this code.

Author
Message
Digi tronic
19
Years of Service
User Offline
Joined: 20th Aug 2004
Location: The Poconos, Pennsylvania, USA
Posted: 16th Apr 2014 01:16
Hi guys, I playing around with some demo code. I am trying to get a 3D globe object to show up on a scrolling starfield background. The scrolling background code was taken from one of the DB Pro tutorials. So when I try to put the spinning globe code in. the globe does not show up. here is the code. can anyone let me know what I am doing wrong?

sync rate 0
sync on
hide mouse
load image "Earth.bmp", 1,0
ink rgb(255,255,255),rgb(255,255,255)
make object sphere 1, 200, 40, 40
texture object 1, 1
set ambient light 100

starquantity = 400
starlayers = 5
speedfactor# = -0.75

type starfield
X AS FLOAT
Y AS FLOAT
Z AS INTEGER
speed AS FLOAT
color AS DWORD
endtype

dim stars(starquantity) as starfield
for s=0 to starquantity
stars(s).x = rnd(800)
stars(s).y = rnd(600)
stars(s).z = int(s/(starquantity/starlayers))+1
stars(s).speed = stars(s).z * speedfactor#
temp_col = (255/starlayers) * stars(s).z
stars(s).color = rgb(temp_col, temp_col, temp_col)
next s

repeat
cls 0
position object 1,40,40,0
SHOW OBJECT 1
yrotate object 1, object angle y(1)+1
for s=0 to starquantity
sx# = stars(s).x : sy# = stars(s).y
dot sx#, stars(s).y, stars(s).color
sy# = sy# - stars(s).speed
if sy# > 600 then sy# = 0
stars(s).y = sy#
next s
sync
until spacekey()=1
end
Phaelax
DBPro Master
20
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 17th Apr 2014 01:36
Just for future reference, you can post your code with code tags like this:

[ c o d e ]
code goes here
[ / c o d e ]

You don't need show object 1 because you never hid the object in the first place.

Take out the CLS command and it should look fine. Honestly, I'm not sure why that's affecting it at all, it shouldn't be.



WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 17th Apr 2014 17:56 Edited at: 19th Apr 2014 04:00
Try this code. I think you'll like it.



comment out "lock pixels" and "unlock pixels" and notice the difference in frames per second.
Digi tronic
19
Years of Service
User Offline
Joined: 20th Aug 2004
Location: The Poconos, Pennsylvania, USA
Posted: 21st Apr 2014 09:32
Thank you to all for your responses. I really appreciate the assistance.

Login to post a reply

Server time is: 2024-03-29 05:26:13
Your offset time is: 2024-03-29 05:26:13