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 / light following object

Author
Message
Konrad
18
Years of Service
User Offline
Joined: 24th Dec 2005
Location:
Posted: 9th Jan 2006 17:38
Hello
I am still making a maze game, and have now added a black backdrop.
What i want is for a nice white or yellow light to light the scene around my object.
using thr point light or whatever.
Here is my code.
Thanks!

Rem Setup sync
Sync On
Sync Rate 30
backdrop on
color backdrop rgb (0,0,0)
make light 1
color light 1,255,255,255
Rem Make Cubes
load image "Picture 031.jpg",21
make object box 21,50,50,10
position object 21,2000,0,1500
texture object 21,21
load image "flag.bmp",20
make object box 20,50,10,50
position object 20,2000,100,1900
texture object 20,20
make object box 6,1500,100,100
position object 6,2400,0,2000
make object box 8,1500,100,100
position object 8,2400,0,500
color object 8,rgb(255,255,25)
load image "kt.jpg",12
make object box 7,100,100,1500
position object 7,3100,0,1200
color object 7,rgb (0,0,250)
make object box 16,100,100,1500
position object 16,1600,0,1200
color object 16,rgb (0,0,0)
Rem Make sphere
Make object sphere 10,50
position object 10,1900,0,1900
texture object 10,12
set object collision to spheres 10
Rem Main loop
b=0

Do
show light 1
SET LIGHT TO OBJECT ORIENTATION 1,10

Rem Store Object angle Y in aY#
aY# = Object angle Y(10)

Rem Control input for camera
If Upkey()=1 then Move object 10,10
If downkey()=1 then Move object 10,-10
If Leftkey()=1 then Yrotate object 10,Wrapvalue(aY#-5)
If Rightkey()=1 then Yrotate object 10,Wrapvalue(aY#+5)
If spacekey()=1 then position object 10,X#,100,Z#;a=1
if inkey$() = CHR$(49) then b=0
if inkey$() = CHR$(50) then b=1
if inkey$() = CHR$(51) then b=2
if inkey$() = CHR$(52) then b=3
if inkey$() = CHR$(53) then b=4
if inkey$() = CHR$(54) then b=5
If object collision (10,6) > 0 then position object 10,X#,0,Z#
If object collision (10,7) > 0 then position object 10,X#,0,Z#
If object collision (10,8) > 0 then position object 10,X#,0,Z#
If object collision (10,16) > 0 then position object 10,X#,0,Z#
If object collision (10,20) > 0 then goto finish
Rem get player object position and store in X# and Z#
Y# = object position y(10)
X# = Object position x(10)
Z# = Object position z(10)

Rem get new camera position and store in cZ# and cX#
cZ# = Newzvalue(Z#,aY#-180,100)
cX# = Newxvalue(X#,aY#-180,100)

Rem position camera
if a=0 then Position Camera cX#,100,cZ#
if a=1 then position camera cX#,200,cZ#
if b=0 then position camera cX#,100,cZ#
if b=1 then position camera cX#,200,cZ#
if b=2 then position camera cX#,300,cZ#
if b=3 then position camera cX#,1,cZ#
if b=4 then position camera cX#,-100,cZ#
if b=5 then position camera cX#,10,cZ#
if b > 5 then b=0
Rem point the camera at the player object
Point camera X#,50,Z#

Rem Refresh Screen
Sync
fog on
fog distance 500
fog color rgb(0,0,0)
Loop
finish:
backdrop off
ink rgb (255,0,0) , rgb (0,0,0)
set text size 100
text 100,100,"Well done"
sync
wait key
exit


I am a noob. HELP!!!
The Nerd
20
Years of Service
User Offline
Joined: 5th Jun 2004
Location: Denmark
Posted: 9th Jan 2006 19:58
Now I didn't read the code(quite busy, gonna go and watch Lost in a moment)

But if you want a light to follow the object you could do something as this:


Just put the player position in the X,Y,Z...

Of course you need to make a light before you can use it. Use the command:



to do that.

I know I didn't explain it very well, but as I said, I'm just about to leave the computer

Hope it helps... Remember that you can only have a maximum og 8 lights(were one of the lights are taked to the ambient light).

Regards

-The Nerd

Free Particle Engine for DarkBasic Pro:
http://forum.thegamecreators.com/?m=forum_view&t=60141&b=5

Login to post a reply

Server time is: 2024-09-24 13:33:59
Your offset time is: 2024-09-24 13:33:59