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 Professional Discussion / Getting the matrix tile under the mouse cursor

Author
Message
Blobby 101
20
Years of Service
User Offline
Joined: 17th Jun 2006
Location: England, UK
Posted: 5th Jun 2011 19:56
Hey, I've got a matrix of 32*32 tiles and I need to be able to get the x and y tile numbers (like you'd use for setting the texture of a matrix tile) for the tile that's under the cursor, I guess i'd use something like pick screen but i'm not sure how this'd translate to a matrix.

cheers!

Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 5th Jun 2011 23:37
Unfortunately the PICK OBJECT command relies on an actual object, PICK SCREEN might be an option.

Personally, I wouldn't sweat it - I would position a dummy object at each matrix tile location in turn, and check the distance between the objects screen X and Y location, and the mouse pointer. Storing the closest tile each time.

Health, Ammo, and bacon and eggs!
Blobby 101
20
Years of Service
User Offline
Joined: 17th Jun 2006
Location: England, UK
Posted: 6th Jun 2011 00:28
hmm.. yeah - that's probably the best way to go about it, maybe doing that in reverse, positioning the dummy objects and then using pick object to get the object number of the right square - cheers!

Burning Feet Man
18
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 6th Jun 2011 15:19
I recall seeing a demo of a matrix with green tiles, and when clicked they turned red. I've searched for ages trying to find it, but prolly gonna end up coding my own variation. Will post it here when I get it done... Unless of course someone knows the demo I'm talking about?

Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 6th Jun 2011 16:37
Hi there.
Not long ago, I try to make my matrix editor, and made a lot of proves...for manipulating matrix, I made this piece of code.I hope it can help.

cheers.





I'm not a grumpy grandpa
Scorpyo
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: italy
Posted: 6th Jun 2011 20:40
You could put the planes in this example in the middle tile positions ,and get the tile number when you pass the mouse over.
And when you're done just hide them.
It's just for editing tho, it's useless for in game situation.
Cheers
Find here attached a pic of DBP matrix "logic"

chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 6th Jun 2011 21:10
@Scorpyo

Your idea works as well, I made proves as well with a grid of objects 40* 40 and it slows down a bit the frame rate...that´s way I get rid of object as we can just subdivide the matrix with no objects at all. Perhaps 40*40 don´t solow so much, but if we have 100*100 we can see the difference

as you said:

Quote: "It's just for editing tho, it's useless for in game situation."


Here is the same example, but this one saves matrix to BMP file.




Cheers.

I'm not a grumpy grandpa
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 6th Jun 2011 21:23
Will this be a flat matrix?

chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 6th Jun 2011 21:31
Quote: "Will this be a flat matrix?"



That deppends of what you edit. Finally you save pressing SPACEKEY.

set matrix height 1,ox,oz,heigh#+hg#



Cheers.

I'm not a grumpy grandpa
Blobby 101
20
Years of Service
User Offline
Joined: 17th Jun 2006
Location: England, UK
Posted: 6th Jun 2011 21:49
Ah, thanks - yeah it's flat. I'll have a look at putting one of these in, I'd copped out and just gone for arrowkeys instead of mouse (It's a level editor ) but i may as well use this now I've got it xD

Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 7th Jun 2011 13:09
Well if you just need the tile of a flat matrix, there's this:
http://dbcodecorner.com/showcode.php?snippet=14

And then here's one idea for a random matrix:
http://dbcodecorner.com/showcode.php?snippet=43

Burning Feet Man
18
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 10th Jun 2011 02:04 Edited at: 10th Jun 2011 02:05
Hey team! I seriously can't believe that the thread I've spent HOURS looking for over the past month, just returned as the first hit in a search I ran! Hopefully this is the code you're after, its pretty cool stuff!

Some of the highlights:

Clickable Matrix Tiles, generated textures are used along with the commands Pick Object & Get pick Vector. Unfortunately this code doesn't seemed to be REM'd with the original author though.

http://forum.thegamecreators.com/?m=forum_view&t=143615&b=7




Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 10th Jun 2011 19:54
@Burning Feet Man
That´ s cool !! ....sometimes the more simple is the greates codes.

Cheers.

I'm not a grumpy grandpa
petethesparky
15
Years of Service
User Offline
Joined: 18th Mar 2011
Location:
Posted: 14th Jun 2011 14:50 Edited at: 14th Jun 2011 20:09
I'm working on a matrix editor right now if you're interested, I do have a demo up in the WIP section of the forum, although it is quite an old version.

My blog about the project is RIGHT HERE if you fancy a read

EDIT : The latest demo version is RIGHT HERE

chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 17th Jun 2011 23:04
@petethesparky
Nice work !! You`v got a complete tutorial thanks...I will keep it.

Cheers.

I'm not a grumpy grandpa

Login to post a reply

Server time is: 2026-07-10 14:05:22
Your offset time is: 2026-07-10 14:05:22