• Anmelden

StorMeye

Rekrut

  • »StorMeye« ist der Autor dieses Themas

Motto: Die Kunst ist, vor lauter Pixel nicht das große Ganze aus den Augen zu verlieren.

  • Nachricht senden

1

Dienstag, 4. Januar 2011, 22:11

Suche Script für schräges Scrolling auf Maps

Hi zusammen,

ich bin im Moment auf der Suche nach einem Map Scrolling Script, das nicht nur gerade, sondern auch diagonal scrollen kann.
Ich hab schon die Suchen-Funktion und Google bemüht und hab das folgende Script gefunden:
http://www.rpg2s.net/forum/lofiversion/index.php?t10761.html

Es funktioniert aber nicht richtig. Wenn man in den Call-Script reinschreibt:

Quellcode

1
autoscroll(x,y)

(so, wie es beschrieben ist), scrollt er immer noch nur gerade.
Könnte sich jemand das Script bitte mal anschauen? Oder hat jemand zufällig ein Script, was das gleiche macht, und das funktioniert?

Vielen Dank schon mal im Voraus für die Hilfe!

Greetz
StorMeye

2

Mittwoch, 5. Januar 2011, 00:22

Hier ist das selbe Script von einer anderen Seite.
(Das Script von deiner Seite funktionierte auch bei mir nicht Diagonal)
Spoiler

Ruby Quellcode

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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
#==============================================================================
# ** Map Autoscroll
#------------------------------------------------------------------------------
# Wachunga
# Version 1.02
# 2005-12-18
#------------------------------------------------------------------------------
=begin
 
This script supplements the built-in "Scroll Map" event command with the
aim of simplifying cutscenes (and map scrolling in general). Whereas the
normal event command requires a direction and number of tiles to scroll,
Map Autoscroll scrolls the map to center on the tile whose x and y
coordinates are given.
 
FEATURES
- automatic map scrolling to given x,y coordinate (or player)
- destination is fixed, so it's possible to scroll to same place even if
origin is variable (e.g. moving NPC)
- variable speed (just like "Scroll Map" event command)
- diagonal scrolling supported
 
SETUP
Instead of a "Scroll Map" event command, use the "Call Script" command
and enter on the following on the first line:
 
autoscroll(x,y)
 
(replacing "x" and "y" with the x and y coordinates of the tile to scroll to)
 
To specify a scroll speed other than the default (4), use:
 
autoscroll(x,y,speed)
 
(now also replacing "speed" with the scroll speed from 1-6)
 
To scroll to the player, instead use the following:
 
autoscroll_player(speed)
 
 
Note: because of how the interpreter and the "Call Script" event command
are setup, the call to autoscroll(...) can only be on the first line of
the "Call Script" event command (and not flowing down to subsequent lines).
 
For example, the following call may not work as expected:
 
autoscroll($game_variables[1],
$game_variables[2])
 
(since the long argument names require dropping down to a second line)
A work-around is to setup new variables with shorter names in a preceding
(separate) "Call Script" event command:
 
@x = $game_variables[1]
@y = $game_variables[2]
 
and then use those as arguments:
 
autoscroll(@x,@y)
 
Note that the renaming must be in a separate "Call Script" because otherwise
the call to autoscroll(...) isn't on the first line.
 
Originally requested by militantmilo80:
http://www.rmxp.net/forums/index.php?showtopic=29519
 
#==============================================================================
=end
 
class Interpreter
SCROLL_SPEED_DEFAULT = 4
CENTER_X = (320 - 16) * 4
CENTER_Y = (240 - 16) * 4
=begin ------------------------------------------------------------------------
This method, called by a Call Script event command, scrolls the map to
center on the tile whose x and y coordinates are given (if valid).
 
As with the usual "Scroll Map" command, speed can range from 1 to 6, the
default being 4.
 
Note that diagonal scrolling has been added and happens automatically when
the destination is diagonal relative to the starting point (i.e., not
directly up, down, left or right).
=end #-------------------------------------------------------------------------
def autoscroll(x,y,speed=SCROLL_SPEED_DEFAULT)
if $game_map.scrolling?
return false
elsif not $game_map.valid?(x,y)
print 'Map Autoscroll: given x,y is invalid'
return command_skip
elsif not (1..6).include?(speed)
print 'Map Autoscroll: invalid speed (1-6 only)'
return command_skip
end
max_x = ($game_map.width - 20) * 128
max_y = ($game_map.height - 15) * 128
count_x = ($game_map.display_x - [0,[x*128-CENTER_X,max_x].min].max)/128
count_y = ($game_map.display_y - [0,[y*128-CENTER_Y,max_y].min].max)/128
if not @diag
@diag = true
dir = nil
if count_x > 0
if count_y > 0
dir = 7
elsif count_y < 0
dir = 1
end
elsif count_x < 0
if count_y > 0
dir = 9
elsif count_y < 0
dir = 3
end
end
count = [count_x.abs,count_y.abs].min
else
@diag = false
dir = nil
if count_x != 0 and count_y != 0
return false
elsif count_x > 0
dir = 4
elsif count_x < 0
dir = 6
elsif count_y > 0
dir = 8
elsif count_y < 0
dir = 2
end
count = count_x != 0 ? count_x.abs : count_y.abs
end
$game_map.start_scroll(dir, count, speed) if dir != nil
if @diag
return false
else
return true
end
end
 
=begin ------------------------------------------------------------------------
This method is identical to autoscroll(...) except that it scrolls the
map to center on the player.
=end #-------------------------------------------------------------------------
def autoscroll_player(speed=SCROLL_SPEED_DEFAULT)
autoscroll($game_player.x,$game_player.y,speed)
end
 
end
 
#------------------------------------------------------------------------------
 
class Game_Map
 
def scroll_downright(distance)
@display_x = [@display_x + distance, (self.width - 20) * 128].min
@display_y = [@display_y + distance, (self.height - 15) * 128].min
end
 
def scroll_downleft(distance)
@display_x = [@display_x - distance, 0].max
@display_y = [@display_y + distance, (self.height - 15) * 128].min
end
 
def scroll_upright(distance)
@display_x = [@display_x + distance, (self.width - 20) * 128].min
@display_y = [@display_y - distance, 0].max
end
 
def scroll_upleft(distance)
@display_x = [@display_x - distance, 0].max
@display_y = [@display_y - distance, 0].max
end
 
def update
# Refresh map if necessary
if $game_map.need_refresh
refresh
end
# If scrolling
if @scroll_rest > 0
# Change from scroll speed to distance in map coordinates
distance = 2 ** @scroll_speed
# Execute scrolling
case @scroll_direction
#----------------------------------------------------------------------------
# Begin Map Autoscroll Edit
#----------------------------------------------------------------------------
when 1 # down left
scroll_downleft(distance)
#----------------------------------------------------------------------------
# End Map Autoscroll Edit
#----------------------------------------------------------------------------
when 2 # Down
scroll_down(distance)
#----------------------------------------------------------------------------
# Begin Map Autoscroll Edit
#----------------------------------------------------------------------------
when 3 # down right
scroll_downright(distance)
#----------------------------------------------------------------------------
# End Map Autoscroll Edit
#----------------------------------------------------------------------------
when 4 # Left
scroll_left(distance)
when 6 # Right
scroll_right(distance)
#----------------------------------------------------------------------------
# Begin Map Autoscroll Edit
#----------------------------------------------------------------------------
when 7 # up left
scroll_upleft(distance)
#----------------------------------------------------------------------------
# End Map Autoscroll Edit
#----------------------------------------------------------------------------
when 8 # Up
scroll_up(distance)
#----------------------------------------------------------------------------
# Begin Map Autoscroll Edit
#----------------------------------------------------------------------------
when 9 # up right
scroll_upright(distance)
#----------------------------------------------------------------------------
# End Map Autoscroll Edit
#----------------------------------------------------------------------------
end
# Subtract distance scrolled
@scroll_rest -= distance
end
# Update map event
for event in @events.values
event.update
end
# Update common event
for common_event in @common_events.values
common_event.update
end
# Manage fog scrolling
@fog_ox -= @fog_sx / 8.0
@fog_oy -= @fog_sy / 8.0
# Manage change in fog color tone
if @fog_tone_duration >= 1
d = @fog_tone_duration
target = @fog_tone_target
@fog_tone.red = (@fog_tone.red * (d - 1) + target.red) / d
@fog_tone.green = (@fog_tone.green * (d - 1) + target.green) / d
@fog_tone.blue = (@fog_tone.blue * (d - 1) + target.blue) / d
@fog_tone.gray = (@fog_tone.gray * (d - 1) + target.gray) / d
@fog_tone_duration -= 1
end
# Manage change in fog opacity level
if @fog_opacity_duration >= 1
d = @fog_opacity_duration
@fog_opacity = (@fog_opacity * (d - 1) + @fog_opacity_target) / d
@fog_opacity_duration -= 1
end
end
 
end
zum Lesen den Text mit der Maus markieren

Ich habe dir eine kleine Demo dazu gemacht.
Die Map scrollt in diesem Fall von der Player Position nach den Koordinaten 1.1, die ich mit diesem Befehl aufgerufen habe:
autoscroll(1,1)
In der Demo Scrollt die Map Diagonal.

Diagonal-Scroll.rar

MFG
Realität ist auch nur eine Art von Rollenspiel.

StorMeye

Rekrut

  • »StorMeye« ist der Autor dieses Themas

Motto: Die Kunst ist, vor lauter Pixel nicht das große Ganze aus den Augen zu verlieren.

  • Nachricht senden

3

Mittwoch, 5. Januar 2011, 12:11

Das Script funktioniert einwandfrei. Vielen Dank dafür!

Social Bookmarks