-
Notifications
You must be signed in to change notification settings - Fork 0
/
obj_view.object.gmx
163 lines (150 loc) · 4.71 KB
/
obj_view.object.gmx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<!--This Document is generated by GameMaker, if you edit it by hand then you do so at your own risk!-->
<object>
<spriteName><undefined></spriteName>
<solid>0</solid>
<visible>-1</visible>
<depth>0</depth>
<persistent>0</persistent>
<parentName><undefined></parentName>
<maskName><undefined></maskName>
<events>
<event eventtype="0" enumb="0">
<action>
<libid>1</libid>
<id>603</id>
<kind>7</kind>
<userelative>0</userelative>
<isquestion>0</isquestion>
<useapplyto>-1</useapplyto>
<exetype>2</exetype>
<functionname></functionname>
<codestring></codestring>
<whoName>self</whoName>
<relative>0</relative>
<isnot>0</isnot>
<arguments>
<argument>
<kind>1</kind>
<string>/// camera move around
zoom = 1;
zoom_level = 1;
bfollowplayer = false;
bcameracontrol = true;
// move to player
if(instance_exists(obj_player)){
x = obj_player.x;
y = obj_player.y;
}
ispress_right = false;
selectbox1_x = 0;
selectbox1_y = 0;
selectbox2_x = 0;
selectbox2_y = 0;
view_wview[0] = 320 * zoom;
view_hview[0] = 240 * zoom;
view_xview[0] = x - view_wview / 2;
view_yview[0] = y - view_hview / 2;
</string>
</argument>
</arguments>
</action>
</event>
<event eventtype="3" enumb="0">
<action>
<libid>1</libid>
<id>603</id>
<kind>7</kind>
<userelative>0</userelative>
<isquestion>0</isquestion>
<useapplyto>-1</useapplyto>
<exetype>2</exetype>
<functionname></functionname>
<codestring></codestring>
<whoName>self</whoName>
<relative>0</relative>
<isnot>0</isnot>
<arguments>
<argument>
<kind>1</kind>
<string>///move 10% toward the player
// current += (target - current) * 0.1;
if(bfollowplayer){
if(instance_exists(obj_player)){
//fixed view port to update
view_xview[0] = x - view_wview / 2;
view_yview[0] = y - view_hview / 2;
//add lag move here
x += (obj_player.x - x) * 0.1;
y += (obj_player.y - y) * 0.1;
}
}
if(bcameracontrol){
//zoom with mouse wheel
zoom_level = clamp(zoom_level + (((mouse_wheel_down() - mouse_wheel_up())) * 0.1), 0.1, 5);
//Step 1: get the current ratio of the mouse to the view
_mouse_x=(mouse_x-view_xview)/view_wview;
_mouse_y=(mouse_y-view_yview)/view_hview;
//Step 2: Update view widths and height.
view_wview = 320 / zoom_level;
view_hview = 240 / zoom_level;
//Step 3: Update position of view based on ratio and mouse position.
view_xview=mouse_x-view_wview*_mouse_x;
view_yview=mouse_y-view_hview*_mouse_y;
//
//drag camera
if(mouse_check_button_pressed(mb_middle)){
drag_x = mouse_x;
drag_y = mouse_y;
//show_debug_message("CLICK?");
}
if(mouse_check_button(mb_middle)){
//draw view
view_xview = drag_x - (mouse_x - view_xview);
view_yview = drag_y - (mouse_y - view_yview[0]);
//doesn't go outside view
//view_xview = max(0,min(view_xview, room_width - view_wview));
//view_yview = max(0,min(view_yview, room_height - view_hview));
//change cursor
window_set_cursor(cr_size_all);
//show_debug_message("drag? "+string(drag_x)+":"+string(drag_y));
//show_debug_message("drag? :"+string(view_xview[0]));
}
if(mouse_check_button_released(mb_middle)){
window_set_cursor(cr_default);
}
/*
///zoom
if(mouse_wheel_up()){
zoom = max(0.1,zoom - 0.10);
}
if (mouse_wheel_down()){
zoom +=0.10;
}
*/
//default view port init and sacle to 1
//view_wview = 320 * zoom_level;
//view_hview = 240 * zoom_level;
//view_wview = 320 * zoom_level;
//view_hview = 240 * zoom_level;
//view_xview[0] = view_wview / 2
//view_yview[0] = view_hview / 2
}
</string>
</argument>
</arguments>
</action>
</event>
</events>
<PhysicsObject>0</PhysicsObject>
<PhysicsObjectSensor>0</PhysicsObjectSensor>
<PhysicsObjectShape>0</PhysicsObjectShape>
<PhysicsObjectDensity>0.5</PhysicsObjectDensity>
<PhysicsObjectRestitution>0.100000001490116</PhysicsObjectRestitution>
<PhysicsObjectGroup>0</PhysicsObjectGroup>
<PhysicsObjectLinearDamping>0.100000001490116</PhysicsObjectLinearDamping>
<PhysicsObjectAngularDamping>0.100000001490116</PhysicsObjectAngularDamping>
<PhysicsObjectFriction>0.200000002980232</PhysicsObjectFriction>
<PhysicsObjectAwake>-1</PhysicsObjectAwake>
<PhysicsObjectKinematic>0</PhysicsObjectKinematic>
<PhysicsShapePoints/>
</object>