Sire Modérateur de l'ombre
Nombre de messages : 67 Age : 32 Niveau RPG Maker : Noob de 1er classe -_- Date d'inscription : 01/04/2007
Feuille de personnage Karma: (70/100) Light points: (70/100) Dark points: (0/100)
| Sujet: 3D Isométrique façon Kingdom Hearts Dim 1 Avr - 2:36 | |
| -|- Voici le script permettant de faire de la 3D Isométrique comme Kingdom Hearts. -|- - Code:
-
#============================================================================== # ** Game_Character (Modification) #------------------------------------------------------------------------------ # This class deals with characters. It's used as a superclass for the # Game_Player and Game_Event classes. #==============================================================================
DIR_8_FRAMES = 8 # This holds the number of motion frames when walking DIR_8_STAND = true # This determines if separate frame used for standing
class Game_Character
attr_reader :step_anime attr_reader :stop_count
#-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update # Branch with jumping, moving, and stopping if jumping? update_jump elsif moving? update_move else update_stop end # If animation count exceeds maximum value # * Maximum value is move speed * 1 taken from basic value 18 if @anime_count > 18 - @move_speed * 2 # If stop animation is OFF when stopping if not @step_anime and @stop_count > 0 # Return to original pattern @pattern = @original_pattern # If stop animation is ON when moving else # Update pattern @pattern = ((@pattern 1 ) % DIR_8_FRAMES) end # Clear animation count @anime_count = 0 end # If waiting if @wait_count > 0 # Reduce wait count @wait_count -= 1 return end # If move route is forced if @move_route_forcing # Custom move move_type_custom return end # When waiting for event execution or locked if @starting or lock? # Not moving by self return end # If stop count exceeds a certain value (computed from move frequency) if @stop_count > (40 - @move_frequency * 2) * (6 - @move_frequency) # Branch by move type case @move_type when 1 # Random move_type_random when 2 # Approach move_type_toward_player when 3 # Custom move_type_custom end end end
#-------------------------------------------------------------------------- # * Move Lower Left (Rewritten for diagonal animation) #-------------------------------------------------------------------------- def move_lower_left unless @direction_fix @direction = 1 end if (passable?(@x, @y, 2) and passable?(@x, @y 1, 4)) or (passable?(@x, @y, 4) and passable?(@x - 1, @y, 2)) turn_downleft @x -= 1 @y = 1 increase_steps end end
#-------------------------------------------------------------------------- # * Move Lower Right (Rewritten for diagonal animation) #-------------------------------------------------------------------------- def move_lower_right unless @direction_fix @direction = 3 end if (passable?(@x, @y, 2) and passable?(@x, @y 1, 6)) or (passable?(@x, @y, 6) and passable?(@x 1, @y, 2)) turn_downright @x = 1 @y = 1 increase_steps end end
#-------------------------------------------------------------------------- # * Move Upper Left (Rewritten for diagonal animation) #-------------------------------------------------------------------------- def move_upper_left unless @direction_fix @direction = 7 end if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 4)) or (passable?(@x, @y, 4) and passable?(@x - 1, @y, 8)) turn_upleft @x -= 1 @y -= 1 increase_steps end end
#-------------------------------------------------------------------------- # * Move Upper Left (Rewritten for diagonal animation) #-------------------------------------------------------------------------- def move_upper_right unless @direction_fix @direction = 9 end if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 6)) or (passable?(@x, @y, 6) and passable?(@x 1, @y, 8)) turn_upright @x = 1 @y -= 1 increase_steps end end
#-------------------------------------------------------------------------- # * Turn Up Left (Rewritten for diagonal animation) #-------------------------------------------------------------------------- def turn_upleft unless @direction_fix @direction = 7 @stop_count = 0 end end
#-------------------------------------------------------------------------- # * Turn Up Right (Rewritten for diagonal animation) #-------------------------------------------------------------------------- def turn_upright unless @direction_fix @direction = 9 @stop_count = 0 end end
#-------------------------------------------------------------------------- # * Turn Down Left (Rewritten for diagonal animation) #-------------------------------------------------------------------------- def turn_downleft unless @direction_fix @direction = 1 @stop_count = 0 end end
#-------------------------------------------------------------------------- # * Turn Down Right (Rewritten for diagonal animation) #-------------------------------------------------------------------------- def turn_downright unless @direction_fix @direction = 3 @stop_count = 0 end end end
#============================================================================== # ** Game_Player #------------------------------------------------------------------------------ # This class handles the player. Its functions include event starting # determinants and map scrolling. Refer to "$game_player" for the one # instance of this class. #==============================================================================
class Game_Player < Game_Character
#-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update # Remember whether or not moving in local variables last_moving = moving? # If moving, event running, move route forcing, and message window # display are all not occurring unless moving? or $game_system.map_interpreter.running? or @move_route_forcing or $game_temp.message_window_showing
# Move player in the direction the directional button is being pressed # Rewritten for diagonal animation case Input.dir8 when 2 move_down when 4 move_left when 6 move_right when 8 move_up when 7 move_upper_left when 9 move_upper_right when 3 move_lower_right when 1 move_lower_left end end
# Remember coordinates in local variables last_real_x = @real_x last_real_y = @real_y super # If character moves down and is positioned lower than the center # of the screen if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y # Scroll map down $game_map.scroll_down(@real_y - last_real_y) end # If character moves left and is positioned more let on-screen than # center if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X # Scroll map left $game_map.scroll_left(last_real_x - @real_x) end # If character moves right and is positioned more right on-screen than # center if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X # Scroll map right $game_map.scroll_right(@real_x - last_real_x) end # If character moves up and is positioned higher than the center # of the screen if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y # Scroll map up $game_map.scroll_up(last_real_y - @real_y) end # If not moving unless moving? # If player was moving last time if last_moving # Event determinant is via touch of same position event result = check_event_trigger_here([1,2]) # If event which started does not exist if result == false # Disregard if debug mode is ON and ctrl key was pressed unless $DEBUG and Input.press?(Input::CTRL) # Encounter countdown if @encounter_count > 0 @encounter_count -= 1 end end end end # If C button was pressed if Input.trigger?(Input::C) # Same position and front event determinant check_event_trigger_here([0]) check_event_trigger_there([0,1,2]) end end end end
#============================================================================== # ** Sprite_Character #------------------------------------------------------------------------------ # This sprite is used to display the character.It observes the Game_Character # class and automatically changes sprite conditions. #==============================================================================
class Sprite_Character < RPG::Sprite
#-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update super # If tile ID, file name, or hue are different from current ones if @tile_id != @character.tile_id or @character_name != @character.character_name or @character_hue != @character.character_hue # Remember tile ID, file name, and hue @tile_id = @character.tile_id @character_name = @character.character_name @character_hue = @character.character_hue # If tile ID value is valid if @tile_id >= 384 self.bitmap = RPG::Cache.tile($game_map.tileset_name, @tile_id, @character.character_hue) self.src_rect.set(0, 0, 32, 32) self.ox = 16 self.oy = 32 # If tile ID value is invalid else self.bitmap = RPG::Cache.character(@character.character_name, @character.character_hue) if DIR_8_STAND @cw = bitmap.width / (DIR_8_FRAMES 1) # Movement frames w/ stand else @cw = bitmap.width / (DIR_8_FRAMES) # Movement frames regular end @ch = bitmap.height / 8 # This sets for 8 directions self.ox = @cw / 2 self.oy = @ch end end # Set visible situation self.visible = (not @character.transparent) # If graphic is character if @tile_id == 0 # Set rectangular transfer
# Set horizontal transfer (animation frames) if not @character.step_anime and @character.stop_count > 0 sx = (@character.pattern) * @cw else sx = (@character.pattern 1) * @cw end # If you want the standing frame to be PART of the walking animation... # like the default sprites (very plain...) comment out the above set # of statements EXCEPT sx = (@character.pattern) * @cw
# Set vertical transfer (direction) dir = @character.direction # These routines allow for eight dec = (dir == 7 or dir== 9) ? 3 : 1 # directional movement. I forgot sy = (dir - dec) * @ch # how I came up with it. Really.
self.src_rect.set(sx, sy, @cw, @ch) end # Set sprite coordinates self.x = @character.screen_x self.y = @character.screen_y self.z = @character.screen_z(@ch) # Set opacity level, blend method, and bush depth self.opacity = @character.opacity self.blend_type = @character.blend_type self.bush_depth = @character.bush_depth # Animation if @character.animation_id != 0 animation = $data_animations[@character.animation_id] animation(animation, true) @character.animation_id = 0 end end end ~ Vous aurez besoin de character de ce type pour utiliser ce script. ~ | |
|