SHOW:
|
|
- or go back to the newest paste.
| 1 | #=============================================================================== | |
| 2 | # G I _ H U D & G I _ A c t o r | |
| 3 | #=============================================================================== | |
| 4 | # Usage Terms | |
| 5 | #------------------------------------------------------------------------------- | |
| 6 | # The following script was developed exclusively to Wonderland Project and | |
| 7 | # anyone else should match the conditions below by under penalty of having longs | |
| 8 | # and strange conversations about rules, and of being overspammed with game | |
| 9 | # envites at its facebook profile. | |
| 10 | # | |
| 11 | # * To use tihs script you must first contact the original creator Guill by one | |
| 12 | # of the contact ways at the end of this register. | |
| 13 | # | |
| 14 | # * You you are not allowed to post this script in any forum or internet page | |
| 15 | # without a previous authorization given by the original creator Guill. | |
| 16 | #------------------------------------------------------------------------------- | |
| 17 | # How to Use | |
| 18 | #------------------------------------------------------------------------------- | |
| 19 | # 1: Paste the attached pictures at "Project/Graphics/Pictures" folder. | |
| 20 | # 2: Go to Configuration section at line 34 and set your preferences. | |
| 21 | # 3: Go to Commands section at line 24 and learn the basic functions. | |
| 22 | # 4: Type the functions at Event's Call Script command. | |
| 23 | #------------------------------------------------------------------------------- | |
| 24 | # Commands | |
| 25 | #------------------------------------------------------------------------------- | |
| 26 | # $gi_actor.heal(n) -> Heals the player in <n> health points. | |
| 27 | # $gi_actor.hurt(n) -> Hurts the player in <n> health points. | |
| 28 | # $gi_actor.grow_life(n) -> Enhance player's life by <n> hearts. | |
| 29 | # $gi_actor.get_key(x) -> Add <x> key. | |
| 30 | # Where <x> must be in ["cup","sword","club","gold"] | |
| 31 | # $gi_actor.drop_key -> Drop player's atual key. | |
| 32 | # $char_hud.change_face(x) -> Change HUD face to "<x>.png". | |
| 33 | #------------------------------------------------------------------------------- | |
| 34 | # Configuration | |
| 35 | #------------------------------------------------------------------------------- | |
| 36 | module GI_HUD_Config | |
| 37 | # Change the values after "=" by your preferences | |
| 38 | X = 0 # HUD screen X position in pixels | |
| 39 | Y = 0 # HUD screen Y position in pixels | |
| 40 | BG = "HUDBG.png" # File name at HUD background's image | |
| 41 | Heart = "Heart.png" # File name at empty heart image | |
| 42 | P1 = "P1.png" # File name at default player image | |
| 43 | Z = 90 # HUD screen Z position | |
| 44 | HUD_Switch = 1 # Visibility yelding switch | |
| 45 | # Put true if you want to regerate life when growing a new heart | |
| 46 | # Put false to otherwise | |
| 47 | Renew_Life = false | |
| 48 | end | |
| 49 | #------------------------------------------------------------------------------- | |
| 50 | # DO NOT CHANGE EVEN A DOT BELOW | |
| 51 | #------------------------------------------------------------------------------- | |
| 52 | ||
| 53 | class Spriteset_Map | |
| 54 | alias gi_ini initialize | |
| 55 | alias gi_upd update | |
| 56 | alias gi_dis dispose | |
| 57 | def initialize | |
| 58 | gi_ini | |
| 59 | $gi_actor = GI_Actor.new | |
| 60 | $char_hud = GI_HUD.new | |
| 61 | end | |
| 62 | def update | |
| 63 | $char_hud.update if not $char_hud == nil | |
| 64 | gi_upd | |
| 65 | end | |
| 66 | def dispose | |
| 67 | - | $char_hud.dispose if not $char_hud == nil |
| 67 | + | if not $char_hud == nil |
| 68 | if not $char_hud.disposed? | |
| 69 | $char_hud.dispose | |
| 70 | end | |
| 71 | end | |
| 72 | gi_dis | |
| 73 | end | |
| 74 | end | |
| 75 | ||
| 76 | class GI_Actor | |
| 77 | attr_accessor :max_life | |
| 78 | attr_accessor :life | |
| 79 | attr_accessor :key | |
| 80 | def initialize | |
| 81 | self.life = 12 | |
| 82 | self.max_life = 12 | |
| 83 | self.key = "" | |
| 84 | end | |
| 85 | def grow_life(n) | |
| 86 | $char_hud.grow_heart(n) | |
| 87 | end | |
| 88 | def hurt(n) | |
| 89 | $char_hud.drop_life(n) | |
| 90 | SceneManager.goto(Scene_Gameover) if self.life == 0 | |
| 91 | end | |
| 92 | def heal(n) | |
| 93 | $char_hud.add_life(n) | |
| 94 | end | |
| 95 | def get_key(x) | |
| 96 | if self.key == "" | |
| 97 | $char_hud.add_key(x) | |
| 98 | self.key = x | |
| 99 | end | |
| 100 | end | |
| 101 | def drop_key | |
| 102 | if not self.key == "" | |
| 103 | $char_hud.drop_key | |
| 104 | self.key = "" | |
| 105 | end | |
| 106 | end | |
| 107 | end | |
| 108 | ||
| 109 | class GI_HUD | |
| 110 | include GI_HUD_Config | |
| 111 | def initialize | |
| 112 | @vp = Viewport.new(0,0,544,416) | |
| 113 | @vp.z = Z | |
| 114 | @bg = Sprite.new(@vp) | |
| 115 | @bg.x = X | |
| 116 | @bg.y = Y | |
| 117 | @bg.bitmap = Cache.picture(BG) | |
| 118 | @bg.z = 1 | |
| 119 | @hearts = [] | |
| 120 | i = 0 | |
| 121 | while i < 3 do | |
| 122 | @hearts[i] = Sprite.new(@vp) | |
| 123 | @hearts[i].x = X + 50 + (18 * i) | |
| 124 | @hearts[i].y = Y + 8 | |
| 125 | @hearts[i].bitmap = Cache.picture(Heart) | |
| 126 | @hearts[i].z = 4 + i | |
| 127 | i += 1 | |
| 128 | end | |
| 129 | @player = Sprite.new(@vp) | |
| 130 | @player.x = X + 3 | |
| 131 | @player.y = Y | |
| 132 | @player.bitmap = Cache.picture(P1) | |
| 133 | @player.z = 2 | |
| 134 | @key = Sprite.new(@vp) | |
| 135 | @key.x = X + 160 | |
| 136 | @key.y = Y + 8 | |
| 137 | @key.z = 3 | |
| 138 | @life = $gi_actor.life | |
| 139 | @max_life = $gi_actor.max_life | |
| 140 | @lifes = [] | |
| 141 | i = 0 | |
| 142 | @liner = 8 | |
| 143 | @h_liner = 8 | |
| 144 | while i < 3 do | |
| 145 | draw_heart(i,4,i) | |
| 146 | i += 1 | |
| 147 | end | |
| 148 | end | |
| 149 | def update | |
| 150 | @bg.update | |
| 151 | @player.update | |
| 152 | @key.update | |
| 153 | @hearts.each do |i| | |
| 154 | i.update if not i.disposed? | |
| 155 | end | |
| 156 | @lifes.each do |i| | |
| 157 | i.update if not i.disposed? | |
| 158 | end | |
| 159 | $gi_actor.life = @life | |
| 160 | $gi_actor.max_life = @max_life | |
| 161 | if $game_switches[HUD_Switch] | |
| 162 | @vp.visible = true | |
| 163 | else | |
| 164 | @vp.visible = false | |
| 165 | end | |
| 166 | end | |
| 167 | def dispose | |
| 168 | @bg.dispose | |
| 169 | @player.dispose | |
| 170 | @key.dispose | |
| 171 | @hearts.each do |i| | |
| 172 | i.dispose if not i == nil | |
| 173 | end | |
| 174 | @lifes.each do |i| | |
| 175 | i.dispose if not i == nil | |
| 176 | end | |
| 177 | end | |
| 178 | def change_face(x) | |
| 179 | if File.exists("graphics/pictures/" + x + ".png")
| |
| 180 | @player = Sprite.new(@vp) | |
| 181 | @player.x = X + 3 | |
| 182 | @player.y = Y | |
| 183 | @player.bitmap = Cache.picture(x + ".png") | |
| 184 | @player.z = 2 | |
| 185 | end | |
| 186 | end | |
| 187 | def drop_life(n) | |
| 188 | aux = @life - n | |
| 189 | @life = 0 | |
| 190 | @lifes.each do |i| | |
| 191 | i.dispose if not i == nil | |
| 192 | end | |
| 193 | add_life(aux) | |
| 194 | end | |
| 195 | def grow_heart(n) | |
| 196 | aux = @max_life + n * 4 | |
| 197 | while aux > 48 do | |
| 198 | aux -= 4 | |
| 199 | n -= 1 | |
| 200 | end | |
| 201 | if n == 0 | |
| 202 | return | |
| 203 | end | |
| 204 | n -= 1 | |
| 205 | heart_n = (@max_life / 4).to_i | |
| 206 | i = heart_n | |
| 207 | while n >= 0 do | |
| 208 | i = 0 if heart_n == 6 | |
| 209 | i = 1 if heart_n == 7 | |
| 210 | i = 2 if heart_n == 8 | |
| 211 | i = 3 if heart_n == 9 | |
| 212 | i = 4 if heart_n == 10 | |
| 213 | i = 5 if heart_n == 11 | |
| 214 | if @max_life < 24 | |
| 215 | @h_liner = 8 | |
| 216 | else | |
| 217 | @h_liner = 22 | |
| 218 | end | |
| 219 | @hearts[heart_n] = Sprite.new(@vp) | |
| 220 | @hearts[heart_n].x = X + 50 + (18 * i) | |
| 221 | @hearts[heart_n].y = Y + @h_liner | |
| 222 | @hearts[heart_n].bitmap = Cache.picture(Heart) | |
| 223 | @hearts[heart_n].z = 4 + heart_n | |
| 224 | @max_life += 4 | |
| 225 | i += 1 | |
| 226 | heart_n += 1 | |
| 227 | n -= 1 | |
| 228 | end | |
| 229 | if Renew_Life | |
| 230 | n = @max_life - @life | |
| 231 | add_life(n) | |
| 232 | end | |
| 233 | end | |
| 234 | def add_life(n) | |
| 235 | aux = @life + n | |
| 236 | while aux > @max_life do | |
| 237 | aux -= 1 | |
| 238 | n -= 1 | |
| 239 | end | |
| 240 | if n == 0 then return; end | |
| 241 | life = @life % 4 | |
| 242 | heart_n = (@life / 4).to_i | |
| 243 | @life -= life | |
| 244 | if not @lifes[heart_n] == nil | |
| 245 | @lifes[heart_n].dispose | |
| 246 | @lifes[heart_n] = nil | |
| 247 | end | |
| 248 | n += life | |
| 249 | while n > 3 do | |
| 250 | draw_heart(heart_n,4,heart_n) | |
| 251 | @life += 4 | |
| 252 | heart_n += 1 | |
| 253 | n -= 4 | |
| 254 | end | |
| 255 | if n > 0 | |
| 256 | draw_heart(heart_n,n,heart_n) | |
| 257 | @life += n | |
| 258 | end | |
| 259 | end | |
| 260 | def draw_heart(s,k,i) | |
| 261 | if i == 6 then i = 0 end; if i == 7 then i = 1 end | |
| 262 | if i == 8 then i = 2 end; if i == 9 then i = 3 end | |
| 263 | if i == 10 then i = 4 end; if i == 11 then i = 5 end | |
| 264 | if @life < 24 | |
| 265 | @liner = 8 | |
| 266 | else | |
| 267 | @liner = 22 | |
| 268 | end | |
| 269 | @lifes[s.to_i] = Sprite.new(@vp) | |
| 270 | @lifes[s.to_i].x = X + 50 + 18 * i | |
| 271 | @lifes[s.to_i].y = Y + @liner | |
| 272 | @lifes[s.to_i].z = 16 + s.to_i | |
| 273 | @lifes[s.to_i].bitmap = Cache.picture(k.to_s + ".png") | |
| 274 | end | |
| 275 | def add_key(x) | |
| 276 | @key.bitmap = Cache.picture(x + "_k.png") | |
| 277 | end | |
| 278 | def drop_key | |
| 279 | @key.bitmap.dispose | |
| 280 | @key.bitmap = nil | |
| 281 | @key = Sprite.new(@vp) | |
| 282 | @key.x = X + 160 | |
| 283 | @key.y = Y + 8 | |
| 284 | @key.z = 3 | |
| 285 | end | |
| 286 | end | |
| 287 | #=============================================================================== | |
| 288 | # Contacts | |
| 289 | #------------------------------------------------------------------------------- | |
| 290 | # E-Mail: [email protected] | |
| 291 | # Forum Mundo RPG Maker: http://forums.mundorpgmaker.com.br/index.php?action=profile;u=57956 | |
| 292 | # Facebook Page: https://www.facebook.com/souza.psg | |
| 293 | #=============================================================================== |