hassen -
posté le 15/10/2013 à 13:52:34 (580 messages postés)
|
Alien | Domaine concerné: scripts Logiciel utilisé: Rpg maker xp Jai trouvé un script sur rpg maker xp qui donne un effet de wave comme celui de rpg maker 2003, mais je ne sais pas comment l'utiliser si quelqun peux m'aider !! voici le script :
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
| #========================================
# XP Wave Effect
#----------------------------------------
#by: zecomeia
#date: 01/03/2010
#for: RGSS
#version: 1.0
#www.colmeia-do-ze.blogspot.com
#----------------------------------------
=begin
Reproduction of the VX's wave effect
(see the help file of the RPGMaker VX
in the RGSS manual reference topic)
=end
#==============#
# Sprite class #
#==============#
class Sprite
include Math
attr_accessor :wave_amp
attr_accessor :wave_length
attr_accessor :wave_speed
attr_accessor :wave_phase
attr_accessor :temp_bitmap
alias initialize default_initialize rescue nil
alias default_initialize initialize
def initialize(viewport=nil)
@wave_amp = 0
@wave_length = 180
@wave_speed = 360
@wave_phase = 0.0
default_initialize(viewport)
@temp_bitmap = nil
end
alias update default_update rescue nil
alias default_update update
def update()
# the wave effect only works if wave_amp
# propertie is a number more than zero
wave_effect if @wave_amp > 0
default_update()
end
# Return the width of image, because when use
# obj.bitmap.width the value will be more than
# the original value(because effect)
def width()
return (self.bitmap.width - @wave_amp * 2)
end
#---------------
# Wave Effect
#---------------
def wave_effect()
return if self.bitmap.nil?
@temp_bitmap = self.bitmap if @temp_bitmap.nil?
cw = @temp_bitmap.width + (@wave_amp * 2)
ch = @temp_bitmap.height
# Follow the VX wave effect, each horizontal line
# has 8 pixel of height. This device provides less
# lag in game.
divisions = @temp_bitmap.height / 8
divisions += 1 if @temp_bitmap.height % 8 != 0
self.bitmap = Bitmap.new(cw, ch)
for i in 0..divisions
x = @wave_amp * Math.sin(i * 2 * PI / (@wave_length / 8).to_i + Math.deg_to_rad(@wave_phase))
src_rect = Rect.new(0, i*8, @temp_bitmap.width, 8)
dest_rect = Rect.new(@wave_amp + x, i * 8, @temp_bitmap.width, 8)
self.bitmap.stretch_blt(dest_rect, @temp_bitmap, src_rect)
end
# frame rate: VX = 60 | XP = 40
# wave speed compatibility VX to XP: wave_speed * 60/40
# then: wave_speed * 1.5
@wave_phase += @wave_speed * 1.5 / @wave_length
@wave_phase -= 360 if @wave_phase > 360
@wave_phase += 360 if @wave_phase < 0
end
end
#=============#
# module Math #
#=============#
module Math
#-------------------------------
# Conversion Degree to Radian
#-------------------------------
def Math.deg_to_rad(deg)
return (deg * PI) / 180.0
end
end |
|
School Urban Legends |