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.

Code Snippets / Some 2D Matrix Functions

Author
Message
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 20th Jul 2006 21:22 Edited at: 20th Jul 2006 21:30
More functions for you to play with. I'll post more info in a second.

[edit]
Ok, here are the functions:
MakeMatrix2D() - Make's a matrix
DrawMatrix2D() - Draws it
RandomizeMatrix2D() - Duh
SmoothMatrix2D() - Smooths it
SetMatrixHeight2D() - Set's the height of a tile
LockTile2D() - Tiles value can't be changed by smoothing etc.
UnlockTile2D() - The opposite of the above
GetGroundHeight2D() - Gets the height of matrix at any x position
GetMatrixHeight2D() - Gets the height of a tile
GetTileGradient2D() - Gets the gradient of a tile
GetTileNumber2D() - Finds what tile you are on at any x position
GetTileAngle2D() - Gets the angle of a selected tile
GetTileHardness2D() - Finds if a tile is locked or not.


No texturing here, not entirely sure how that would be done in 2D heh. Anyway, enjoy.



Here's a simple demo just to show how it works:




And here's another demo that uses physics and stuff. The jittery-ness has nothing to do with the functions, just slightly sloppy coding, aha.



No media is needed.

The Nerd
20
Years of Service
User Offline
Joined: 5th Jun 2004
Location: Denmark
Posted: 20th Jul 2006 22:08
Very nice functions here!

I really like that 2D Matrix. The demo with the physics are awesome too.

Well done!

Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 22nd Jul 2006 14:07 Edited at: 22nd Jul 2006 14:07
Nice 2D Matrix! Just one thing... when you go out of the screen on the left side in your second demo you get an error saying "Array does not exist or array subscript out of bounds" or something like that. Just a heads up. A simple boundary can easily fix that one. Besides that, the Physics demo was awesome!

My Functions: Mine
Post yours: Post
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 22nd Jul 2006 17:12
Thanks, but I only threw that together in about 5 mins, and I had forgotten then I could scroll it, so it wasn't as good as it could be heh.

Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 23rd Jul 2006 13:34
WOW ONLY 5 MINUTES!? You must be a master of physics!

Jedi Lord
20
Years of Service
User Offline
Joined: 11th Jun 2004
Location: Jedi Temple
Posted: 26th Jul 2006 08:12
Wierd it have errors and I couldn't use it.
It said something about subscript line.

Whoa... I like a shiny thing... let's touch it .
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 26th Jul 2006 20:00
Hmm.. could you explain a little more?

Login to post a reply

Server time is: 2024-11-23 03:40:13
Your offset time is: 2024-11-23 03:40:13