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 / what's the math?

Author
Message
New Creature Feature
21
Years of Service
User Offline
Joined: 27th May 2004
Location: Tennessee- USA
Posted: 6th Jun 2004 08:18
I created an object in the shape of a sort of tunnel piece. I have the object loaded into DB (20 of them exactly, the same object) and have tried to place them randomly to create a random tunnel (not with multiple ways to go, just one path).

I have the z plane correct for the most part, but my x and y positions are off cuz the tunnel space is not wide enough for the camera to pass through without passing through the 'walls' of the tunnel pieces. I don't really want to angle the pieces like an actual tunnel (with a curved path) because the pieces are separate and animate by rotating left and right.

Sorry to bug whoever reads this but this is the idea:
#1 the camera is scrolling forward (got that one!)

#2 a very long tunnel composed of the same object. (right now I just placed 20), don't know how to make it so the same objects used earlier will just be replaced once they're off the screen, cuz you can't turn back and I don't want a million polygons of the same object in my game.

#3 the objects (tunnel pieces) are placed randomly so the tunnel path winds left and right and and up and down. (they look like a mess right now- I used the rnd command- still a mess)

#4 the pieces rotate in opposite directions. Each other one rotates left, the others rotate right (I got it but I did a rotate command for each one, cuz I don't know how to use the inc command which I think is the one I'm supposed to use.)

#5 I would like to place random textures on the object pieces or maybe for different levels place a different texture on the object. Haven't even tried that one yet.

#6. You can move left, right, up and down, but not forward or backward cuz the camera is constantly moving forward at a slow rate. Maybe as levels advance the forward speed would increase. I don't want the camera to rotate like you're looking in a 1st person game so I think I did the right thing by using the position camera command. (right?)

#7. Obviously there's gotta be some point of this: if you run into the walls- YOU DIE (well, not you obviously, your poor pitiful character who I haven't even thought of making yet). I haven't even tried to use the collision command yet.

Well, that's it- I am trying simple stuff for starters to get a hang of this and I am totally addicted to DB already.

If you can get this code to work feel free to use it in for your game ideas for some random tunnel runner/maze type games. This code is probably full of redundancy or major ignorance and I'm sorry for that. But the people on this forum have been so helpful and for that I am extremely thankful.

Alan

Therefore if any man be in Christ, he is a new creature: old things are passed away; behold, all things are become new. II Corinthians 5:17
New Creature Feature
21
Years of Service
User Offline
Joined: 27th May 2004
Location: Tennessee- USA
Posted: 6th Jun 2004 08:23
sorry- code didn't post- here you go
- Alan

sync on: sync rate 40
load image "texture.bmp",1
for ob=2 to 20
Load Object "tunnel.x",ob
texture object ob,1
scale object texture ob, 8,6
next ob

rem rotation variables for objects
ly=0
ry=360

rem Set seed for same random numbers
randomize 1

rem position objects in succession in random places
for ob=2 to 20
oz=oz+1
ox=rnd(1.5)
oy=rnd(1.5)
position object ob,ox,oy,oz
next ob

rem camera position variables

cx#=0
cy#=0
cz#=0

do

rem rotate every other object in opposite directions
zrotate object 2, ly
zrotate object 3, ry
zrotate object 4, ly
zrotate object 5, ry
zrotate object 6, ly
zrotate object 7, ry
zrotate object 8, ly
zrotate object 9, ry
zrotate object 10, ly
zrotate object 11, ry
zrotate object 12, ly
zrotate object 13, ry
zrotate object 14, ly
zrotate object 15, ry
zrotate object 16, ly
zrotate object 17, ry
zrotate object 18, ly
zrotate object 19, ry
zrotate object 20, ly
if ly=360 then ly=0
if ry=0 then ry=360
ly=ly+2
ry=ry-2

rem key controls
if upkey()=1 then cy#=cy#+.25
if downkey()=1 then cy#=cy#-.25
if leftkey()=1 then cx#=cx#-.25
if rightkey()=1 then cx#=cx#+.25
if cx#=0 then cx#=360
if cx#=360 then cx#=0

rem scrolling camera
cz#=cz#+.025
rem Update camera
position camera cx#,cy#,cz#
sync
loop

Therefore if any man be in Christ, he is a new creature: old things are passed away; behold, all things are become new. II Corinthians 5:17

Login to post a reply

Server time is: 2025-05-28 22:32:25
Your offset time is: 2025-05-28 22:32:25