• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Windows Drag And Zoom

A

Ashish Jivram

Guest
I am using gamemaker to create a floorplan system. I have developed a large amount of it myself but I have bumped into an issue which i am unable to solve.

What i am trying to do is to have the functionality of where the user can zoom into the plan and drag the plan around to see different parts using a second view. I have got the zoom and drag working but i am not able to limit the drag. I will send you my GMZ project file so you can have a look. If you click on "Francis Crick" and then use the scroll to zoom in and then left click to drag the floor plan, you should understand the issue.

https://drive.google.com/file/d/0B4liWCMT8W4MT1ptcFlDR2dxcnc/view?usp=sharing

I have attached my project if you would like to have a look
 
A

Ashish Jivram

Guest
This is the code which is limiting the drag from the room but i want the limit to be the view, not the room:

  1. if (mouse_check_button(mb_left)) && view_wview[1] < 700 {
  2. // actual dragging logic:
  3. view_xview[1] = drag_x - (mouse_x - view_xview[1])
  4. view_yview[1] = drag_y - (mouse_y - view_yview[1])
  5. // make sure view doesn't go outside the room:
  6. view_xview[1] = max(0, min(view_xview[1], room_width - view_wview[1]))
  7. view_yview[1] = max(0, min(view_yview[1], room_height - view_hview[1]))
  8. }
 
Top