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 / RollerCoaster Matrices? DBC

Author
Message
Zombie 20
19
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 17th Mar 2007 10:31
Hi there, i was wondering, would i be able to combine multiple matrices to create a rollercoast simulation by adding a first person camera to a box and having them move forward. Or perhaps a racing game?

"You can't expect to weild supreme executive power just because some watery t**t throws a bl***y sword at you..."
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 18th Mar 2007 00:28
Hi Zombie,

You sure could! One thing to keep in mind when using multiple matrices is that large matrices consume a lot of processing power. If you use smaller 1 tile matrices, you can cut down on the processing consumption.



Depending on your abilities and how much time you are willing to put into the coding, you could "draw" the roller coaster as you go along with only what has to be immediately visible. This could allow you an almost limitless size of a racetrack or roller coaster - where all the data is stored in files and/or in memory or is calculated on the fly and only the info that needs to be seen is updated.

Enjoy your day.
Zombie 20
19
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 18th Mar 2007 01:48
Thanks Latch,

That was helpful. However, i am a complete newb to darkbasic but not to the basic language, i'll work with it and see what i come up with. Thanks for your help.

"You can't expect to weild supreme executive power just because some watery t**t throws a bl***y sword at you..."
Mnemonix
23
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: Skaro
Posted: 18th Mar 2007 11:06
Hi Zombie, as the resident Monty Python and the Holy Grail expert, it is my duty to point out two things wrong with your signature quote.

1. Wield is spelt incorrectly.
2. Dennis doesn't say "bl***y" so take that out



Unless it was cut from all versions I have seen

Zombie 20
19
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 18th Mar 2007 18:40
Well latch, i added a camera to the matrix as well as a sphere that marks the starting point. I just wanted to update everyone, thanks again.

autocam off

make matrix 1,1000/25,1000,1,25
make matrix 2,1000,1000/25,25,1

position camera 100,100,-200

for z=2 to 25
ang=ang+20
for x=0 to 1
y#=100*sin(ang)
set matrix height 1,x,z,y#
next x
next z

update matrix 1

wait key
make object sphere 1,20
scale object 1, 100,100,-200

do
if upkey()=1 then move camera 10.0
if downkey()=1 then move camera -10.0
if leftkey()=1 then angley#=wrapvalue(angley#-2.0)
if rightkey()=1 then angley#=wrapvalue(angley#+2.0)

xrotate camera 0.0
yrotate camera angley#
zrotate camera 0.0




loop

Mnemonix

Thank you for bringing that to my attention, i'm a big python fan myself, have a good day and enjoy your spam and eggs.

"You can't expect to weild supreme executive power just because some watery t**t throws a bl***y sword at you..."
Zombie 20
19
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 18th Mar 2007 20:08
one thing i'm having some trouble with is enabling the camera to follow all of the track, i cannot get it to follow when the matrix dips down. If anyone could shed some light on this, i would appreciate it.

"You can't expect to weild supreme executive power just because some watery t**t throws a bl***y sword at you..."
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 19th Mar 2007 01:33 Edited at: 19th Mar 2007 01:37
Hi Zombie,

In case you didn't know, it's easier to read the code in a post if you put it in a code box. You can do that by highlighting all of the code, and clicking on the CODE button located at the top left of the post.

There is a command to get the height at any position on the matrix. It is called GET GROUND HEIGHT. If you get the X and Z coordinates at any given point on a particular matrix, using GET GROUND HEIGHT will return the Y height of the terrain. You can then use that value to reposition the y value of your camera or object that's at that particular spot.

I added a little to the code. You should use SYNC ON and SYNC RATE to set and control manually the screen refresh, i.e. how many times per second the screen is redrawn. Usually at the end of the main loop (before LOOP), include the SYNC command to cause the refresh to happen. This will smooth the flow of your program and allow you to set the overall speed so that the program will run consistantly on different machines. I also added an example of the GET GROUND HEIGHT:



Enjoy your day.
Zombie 20
19
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 19th Mar 2007 06:25
Thank you again latch, i appreciate all of your help. I have to say, the more and more i add to your code, the more fun it becomes, i'm having a blast and wanted to say thank you for giving me the tools to make something so cool. Now that the camera moves, i can finally begin to make a cool hybrid for my big project. A race/coaster game.

Thank you again, i'll keep you updated, i'll post my track for you.

"You can't expect to wield supreme executive power just because some watery tart throws a sword at you..."
Zombie 20
19
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 19th Mar 2007 08:27


Well its not much but just wanted to update, as of now, i'm working on walls.

"You can't expect to wield supreme executive power just because some watery tart throws a sword at you..."
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 25th Mar 2007 02:03
Hi Zombie,

I took a look at your demo and it seems to be going ok. I noticed that the "tracks" seem a little bit disproportionate. That may be intentional on your part. But if it isn't, I'll explain why I set up the matrices in the code example I posted the way that I did.

The commands from my example:

make matrix 1,1000/25,1000,1,25
make matrix 2,1000,1000/25,25,1


set up the matrix so that each tile is square. In matrix 1, since Z is 1000 units long, and is made up of 25 tiles, each tile's Z length is 1000/25. Now, I have only 1 tile in the X direction. I can't have it equal to 1000 units so I have to figure out what the X unit length should be if I want the X tile to be square with the Z tiles. Since I know that the Z length of 1 tile is 1000/25, I have to calculate that for X so the X unit length become 1000/25 thus to set up matrix 1 I use the command

make matrix 1,1000/25,1000,1,25

For matrix 2, I have it set to 25 tiles in the X direction at 1000 X units. So I do the same thing except I'm switching X and Z

make matrix 2,1000,1000/25,25,1

What if I wanted the track to be 25 tiles in the Z direction and 3 tiles wide in the X direction? I still want each tile to be nice and square. Based on a Z unit length of 1000, we know that a single tile out of 25 in the Z direction = 1000/25 = 40 units . So if I want 3 tiles in the X direction, I just multiply 3*40 to get the total X unit length. My matrix command could then look like:

make matrix 1,3*40,1000,3,25
or
make matrix 1,(1000/25)*3,1000,3,25

This applies if you want to keep the tiles square.

Enjoy your day.
Zombie 20
19
Years of Service
User Offline
Joined: 26th Nov 2006
Location: Etters, PA
Posted: 25th Mar 2007 02:52
thanks latch, i appreciate your insight, its intentional that its not proporniate. I just like it a little better, but your code was really good too.

I'm attempting new things with it, right now as i said i'm working on walls for a racer type game and then i'd like to use it again for a marble run type game, which is why i've been trying to get the camera to follow a ball as it goes on the track. People have shown me, i just have to code it in.

well, other than that, i've been reading tutorials, asking questions and i'm now aggravated with a completley new subject, 2d platformers, i can't for the life of me figure them out. But thats why i'm asking for help.

I'll post again when i've got a working demo of a racer or rollercoaster.

http://img256.imageshack.us/img256/442/zombiesmk8.jpg

Login to post a reply

Server time is: 2026-07-06 03:57:36
Your offset time is: 2026-07-06 03:57:36