SHOW:
|
|
- or go back to the newest paste.
1 | #============================================================================== | |
2 | # ** Sprite_HUD | |
3 | #------------------------------------------------------------------------------ | |
4 | # Autor: Valentine | |
5 | #============================================================================== | |
6 | #** HUD Modificada | |
7 | #============================================================================== | |
8 | - | # Modificado por: Senbonzakura |
8 | + | # Modificado por: Senbonzakura, LeonM² |
9 | #============================================================================== | |
10 | - | |
10 | + | |
11 | class Sprite_HUD < Sprite | |
12 | - | |
12 | + | attr_accessor :exp_sprite |
13 | ||
14 | def initialize | |
15 | super | |
16 | self.bitmap = Bitmap.new(600, 600) # Tamanho da tela da HUD | |
17 | self.x = 240 # Posição X da HUD | |
18 | self.y = 399 # POsição Y da HUD | |
19 | self.z = 0 # Profundidade da HUD | |
20 | self.bitmap.font.size = 18 # Tamanho da fonte | |
21 | self.bitmap.font.bold = true # Fonte c/ Bold ou não | |
22 | @back = Cache.system('HUD') # Imagem da Barra de HUD | |
23 | @HP_bar = Cache.system('Hp_Bar') # Imagem da Barra de HP | |
24 | @MP_bar = Cache.system('Mp_Bar') # Imagem da Barra de MP | |
25 | @XP_bar = Cache.system('Xp_Bar') # Imagem da Barra de EXP | |
26 | create_exp_bar | |
27 | create_hp_mp_bars | |
28 | - | |
28 | + | |
29 | end | |
30 | ||
31 | def dispose | |
32 | super | |
33 | @hp_sprite.bitmap.dispose | |
34 | - | |
34 | + | @hp_sprite.dispose |
35 | @mp_sprite.bitmap.dispose | |
36 | - | @exp_sprite = Sprite2.new |
36 | + | @mp_sprite.dispose |
37 | - | @exp_sprite.bitmap = Bitmap.new(600,3) # Tamanho da tela da HUD |
37 | + | |
38 | - | @exp_sprite.bitmap.font.size = 28 # Tamanho da Fonte da Letra |
38 | + | |
39 | - | @exp_sprite.bitmap.font.bold = true # Letra em Negrito ou não |
39 | + | |
40 | - | @exp_sprite.x = Graphics.width - 173 # Posição X da Barra de EXP |
40 | + | def create_hp_mp_bars |
41 | - | @exp_sprite.y = Graphics.height - 4 # Posição Y da Barra de EXP |
41 | + | #HPBAR |
42 | - | @exp_sprite.dragable = false |
42 | + | @hp_sprite = Sprite2.new |
43 | - | @exp_sprite.z = self.z |
43 | + | @hp_sprite.bitmap = @HP_bar |
44 | @original_y = self.y + 6 | |
45 | - | |
45 | + | @hp_sprite.x = self.x + 29 |
46 | @hp_sprite.y = @original_y | |
47 | @hp_sprite.dragable = false | |
48 | @hp_sprite.z = self.z + 1 | |
49 | #MP BAR | |
50 | @mp_sprite = Sprite2.new | |
51 | @mp_sprite.bitmap = @MP_bar | |
52 | @mp_sprite.x = self.x + 141 | |
53 | - | |
53 | + | @mp_sprite.y = @original_y |
54 | @mp_sprite.dragable = false | |
55 | @mp_sprite.z = self.z + 1 | |
56 | end | |
57 | def create_exp_bar | |
58 | @exp_sprite = Sprite2.new | |
59 | - | |
59 | + | @exp_sprite.bitmap = @XP_bar |
60 | - | def draw_hp_bar |
60 | + | @exp_sprite.x = self.x + 156 |
61 | - | # self.bitmap.blt(X, Y, @HP_bar, Rect.new(Altura, Largura, @HP_bar.width, @HP_bar.height * $game_actors[1].hp / $game_actors[1].mhp)) |
61 | + | @exp_y = self.y + 13 |
62 | - | self.bitmap.blt(30, 6, @HP_bar.angle = 180, Rect.new(0, 0, 100 / @HP_bar.width , @HP_bar.height * $game_actors[1].hp / $game_actors[1].mhp)) |
62 | + | @exp_sprite.y = @exp_y |
63 | - | |
63 | + | @exp_sprite.dragable = false |
64 | @exp_sprite.z = self.z + 1 | |
65 | - | # self.bitmap.blt(X, Y, @MP_bar, Rect.new(Altura , Largura, @MP_bar.width , @MP_bar.height * $game_actors[1].mp / $game_actors[1].mmp)) |
65 | + | |
66 | - | self.bitmap.blt(142, 6, @MP_bar, Rect.new(0, 0, 100 / @MP_bar.width , @MP_bar.height * $game_actors[1].mp / $game_actors[1].mmp)) |
66 | + | |
67 | ||
68 | def refresh | |
69 | draw_background | |
70 | - | @exp_sprite.bitmap.clear |
70 | + | |
71 | - | rect1 = Rect.new(0, 98, @exp_sprite.bitmap.width, @exp_sprite.bitmap.height) |
71 | + | |
72 | - | rect2 = Rect.new(0, 0, 170 * $game_actors[1].now_exp / $game_actors[1].next_exp, 26) # " 170 " é o comprimento da Barra EXP# |
72 | + | |
73 | - | exp = $game_actors[1].level >= Configs::MAX_LEVEL ? Vocab::MaxLevel : $game_actors[1].next_exp - $game_actors[1].now_exp |
73 | + | |
74 | - | @exp_sprite.bitmap.blt(0, 0, @back, rect1) |
74 | + | |
75 | - | @exp_sprite.bitmap.blt(0, 0, @XP_bar, rect2) |
75 | + | |
76 | def draw_background | |
77 | - | |
77 | + | |
78 | rect = Rect.new(0, 0, 640, 480) # Tamanho da tela da em aparece todos itens da hud | |
79 | self.bitmap.blt(7, 0, @back, rect) | |
80 | end | |
81 | ||
82 | def draw_hp_bar | |
83 | - | |
83 | + | percentage = @HP_bar.height * $game_actors[1].hp / $game_actors[1].mhp |
84 | @hp_sprite.y = @original_y + (@HP_bar.height - percentage) | |
85 | @hp_sprite.src_rect.y = (percentage - @HP_bar.height).abs | |
86 | end | |
87 | ||
88 | - | |
88 | + | |
89 | - | end |
89 | + | percentage = @MP_bar.height * $game_actors[1].mp / $game_actors[1].mmp |
90 | @mp_sprite.y = @original_y + (@MP_bar.height - percentage) | |
91 | @mp_sprite.src_rect.y = (percentage - @MP_bar.height).abs | |
92 | end | |
93 | ||
94 | def draw_exp_bar | |
95 | percentage = @XP_bar.height * $game_actors[1].now_exp / $game_actors[1].next_exp | |
96 | @exp_sprite.y = @exp_y + (@XP_bar.height - percentage) | |
97 | @exp_sprite.src_rect.y = (percentage - @XP_bar.height).abs | |
98 | end | |
99 | ||
100 | def draw_level | |
101 | rect = Rect.new(0, 600, 29, 30) | |
102 | self.bitmap.blt(0, 77, @back, rect) | |
103 | self.bitmap.draw_text(600, 10, 30, 18, $game_actors[1].level, 1) | |
104 | end | |
105 | ||
106 | def update | |
107 | super | |
108 | @exp_sprite.update | |
109 | end | |
110 | ||
111 | end |