Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 10-26-2011, 04:26 AM
iBeatz iBeatz is offline
Kavan
iBeatz's Avatar
Join Date: Dec 2010
Location: Northern Ireland, UK
Posts: 154
iBeatz will become famous soon enough
Send a message via Yahoo to iBeatz
Tile Editor tile selection

Can anyone explain to me clearly as to exactly how you would go about selecting a group of tiles in a GuiDrawingPanel using the onMouseDragged event.
I just want the maths and code aspect of this, nothing fancy. Also, before you direct me to an example of a tile editor doing this, I've already searched the forums and can't make sense out of any of them.
__________________

Intelligence without ambition is like a bird without wings.

Reply With Quote
  #2  
Old 10-26-2011, 06:20 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
1. onMouseDown: Determine the tile the mouse is currently over and use it as your top-left reference point.
2. onMouseDragged: Determine the tile the mouse is currently over and use it as your bottom-right reference point.
3. onMouseUp: Do whatever with your selection.

I believe:

tile_x = mouse_x - (mouse_x % tile_width);
tile_y = mouse_y - (mouse_y % tile_height);

Will get you the top-left x and y of the tile your mouse is currently over.

% is for modulus which basically gives you the remainder from dividing a number. I.e: 20 % 16 equals 4.
__________________
Quote:
Reply With Quote
  #3  
Old 10-26-2011, 02:15 PM
iBeatz iBeatz is offline
Kavan
iBeatz's Avatar
Join Date: Dec 2010
Location: Northern Ireland, UK
Posts: 154
iBeatz will become famous soon enough
Send a message via Yahoo to iBeatz
Thanks!
One thing that I can't seem to do is get the mouse position on the tileset image according to the positioning of the screen the GuiDrawingPanel is at.
Any idea?
__________________

Intelligence without ambition is like a bird without wings.

Reply With Quote
  #4  
Old 10-26-2011, 03:30 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
You should be able to get the mouse x and y from params[1] and params[2].

onMouseDown(keymodifier,mousescreenx,mousescreeny, clickcount)
onMouseDragged(keymodifier,mousescreenx,mousescree ny)
onMouseUp(keymodifier,mousescreenx,mousescreeny)
__________________
Quote:
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 08:29 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.