Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Zoom chara

From

Member

you can do that when the chara is approaching the top of the screen, it undergoes a slight zoom? (becomes smaller).
 
If Mode-7 is not what you're looking for, then you'd need to describe what else you would like to happen... if you just zoom the character at the top few rows, it'll look extremely off in terms of perspective, both because the character scales for no apparent reason, as well as because the tiles stay the same.
 
Mode-7 works in a way that additionally scales the tiles, meaning characters AND tiles will be in the correct perspective... like this:

mode7screenlk0.png

(think of the palmtrees as characters, as both are events)



There's a few very good Mode-7 scripts out there that work like a charm... and it would definately look more realistic than just scaling the character, I'd think.

Of course, it's up to you in the end... I can try to put something together if you want (as that shouldn't be too hard), however you need to tell me if you want the character to scale gradually or after a certain distance... (I really can't quite imagine what you want to do with it, so I'm having a bit of a problem seeing the details here... ^^ )
 
If you want I have one with pixel movement but it's not super easy to configure :
Code:
class Game_Map

  Maps_Depth = {}

  # To add depth to a map, you must write below :

  # Maps_Depth[id] = [max, min, factor, origin, default]

  # id => id of the map

  # max => The maximum zoom is used to limit the increase of the characters. (in %, 1 = 100%)

  # min => The minimum zoom is used to limit the decrease of the characters. (in %)

  # factor => The zoom factor is the value which the character zoom will be increased by when he moves of one tile verticaly. (in %)

  # origin => The origin of the zoom is the location on the map where the characters will have their default zoom. (in % from the bottom)

  #                  Below the origin the zoom increase, over it decrease.

  # default => The default zoom. (in %)

  #

  # Example :

  # Maps_Depth[1] = [2, 0.2, 0.05, 0, 1]

  

  attr_reader :amsu_depth

  

  alias amsu_game_map_setup setup

  def setup(map_id)

    if Maps_Depth.include?(map_id)

      map = load_data("Data/Map%03d.rvdata" % map_id)

      @amsu_depth = Maps_Depth[map_id].dup

      @amsu_depth[3] = (1-@amsu_depth[3]) * (map.height-1)

    else @amsu_depth = nil

    end

    amsu_game_map_setup(map_id)

  end

  

end

 

class Game_Character

  

  attr_reader :x2, :y2, :zoom

  

  alias amsu_game_character_initialize initialize

  def initialize

    amsu_game_character_initialize

    @x2, @y2, @zoom, @real_move_speed = 0, 0, 1, @move_speed

  end

  

  def moving?

    return (@real_x != @x2 or @real_y != @y2)

  end

  

  alias amsu_moveto moveto

  def moveto(x, y)

    amsu_moveto(x, y)

    @x2, @y2, @zoom, @last_real_y = x*256, y*256, 1

    update_zoom

  end

  

  alias amsu_update update

  def update

    amsu_update

    update_zoom

  end

  

  def update_jump

    @jump_count -= 1

    @real_x = (@real_x * @jump_count + @x2) / (@jump_count + 1)

    @real_y = (@real_y * @jump_count + @y2) / (@jump_count + 1)

    update_bush_depth

  end

  

  def update_move

    distance = 2 ** @real_move_speed

    x256 = @x*256; y256 = @y*256

    @y2 = Math.max(@y2 - distance, y256) if @y2 > y256 and !passable?(@x, @y+1)

    @x2 = Math.min(@x2 + distance, x256) if @x2 < x256 and !passable?(@x-1, @y)

    @x2 = Math.max(@x2 - distance, x256) if @x2 > x256 and !passable?(@x+1, @y)

    @y2 = Math.min(@y2 + distance, y256) if @y2 < y256 and !passable?(@x, @y-1)

    @real_y = Math.min(@real_y + distance, @y2) if @y2 > @real_y

    @real_x = Math.max(@real_x - distance, @x2) if @x2 < @real_x

    @real_x = Math.min(@real_x + distance, @x2) if @x2 > @real_x

    @real_y = Math.max(@real_y - distance, @y2) if @y2 < @real_y

    update_bush_depth unless moving?

    if @walk_anime

      @anime_count += 1.5

    elsif @step_anime

      @anime_count += 1

    end

  end

  

  alias amsu_move_type_random move_type_random

  def move_type_random

    if @move_frequency == 5

      case rand(10)

      when 9; @stop_count = 0

      when 0; move_random(Math.max(@real_move_speed, 5))

      else  ; move_forward(Math.max(@real_move_speed, 5))

      end

    else amsu_move_type_random

    end

  end

  

  alias amsu_move_type_toward_player move_type_toward_player

  def move_type_toward_player

    if @move_frequency == 5

      if (@x - $game_player.x).abs + (@y - $game_player.y).abs < 20

      then rand(6) < 4 ? move_toward_player(@real_move_speed) : move_forward(@real_move_speed)

      else move_type_random

      end

    else amsu_move_type_toward_player

    end

  end

  

  def update_zoom

    if depth = $game_map.amsu_depth

      if @last_real_y != @real_y

        @last_real_y = @real_y

        @zoom = Math.middle(depth[1], depth[4] - (depth[3]-@real_y/256.0) * depth[2], depth[0])

      end

      @real_move_speed = Math.middle(0, (@move_speed+(dash? ? 1 : 0))*@zoom, 8)

    else @real_move_speed = Math.middle(0, @move_speed+(dash? ? 1 : 0), 8)

    end

  end

  

  def move_down(turn_ok = true, speed = 8)

    new_y = @y+1

    unless passable?(@x, new_y)

      if @y2 == @y*256

        turn_down if turn_ok

        check_event_trigger_touch(@x, new_y)

        return @move_failed = true

      else speed -= 1; new_y = @y

      end

    end

    turn_down

    if (@y = ((@y2 = Math.min(@y2+2**speed, new_y*256))/256.0).round) > $game_map.height

      @y -= $game_map.height

      @y2 -= $game_map.height*256

      @real_y -= $game_map.height*256

    end

    increase_steps

    @move_failed = false

  end

  

  def move_left(turn_ok = true, speed = 8)

    new_x = @x-1

    unless passable?(new_x, @y)

      if @x2 == @x*256

        turn_left if turn_ok

        check_event_trigger_touch(new_x, @y)

        return @move_failed = true

      else speed -= 1; new_x = @x

      end

    end

    turn_left

    if (@x = ((@x2 = Math.max(@x2-2**speed, new_x*256))/256.0).round) < 0

      @x += $game_map.width

      @x2 += $game_map.width*256

      @real_x += $game_map.width*256

    end

    increase_steps

    @move_failed = false

  end

  

  def move_right(turn_ok = true, speed = 8)

    new_x = @x+1

    unless passable?(new_x, @y)

      if @x2 == @x*256

        turn_right if turn_ok

        check_event_trigger_touch(new_x, @y)

        return @move_failed = true

      else speed -= 1; new_x = @x

      end

    end

    turn_right

    if (@x = ((@x2 = Math.min(@x2+2**speed, new_x*256))/256.0).round) > $game_map.width

      @x -= $game_map.width

      @x2 -= $game_map.width*256

      @real_x -= $game_map.width*256

    end

    increase_steps

    @move_failed = false

  end

  

  def move_up(turn_ok = true, speed = 8)

    new_y = @y-1

    unless passable?(@x, new_y)

      if @y2 == @y*256

        turn_up if turn_ok

        check_event_trigger_touch(@x, new_y)

        return @move_failed = true

      else speed -= 1; new_y = @y

      end

    end

    turn_up

    if (@y = ((@y2 = Math.max(@y2-2**speed, new_y*256))/256.0).round) < 0

      @y += $game_map.height

      @y2 += $game_map.height*256

      @real_y += $game_map.height*256

    end

    increase_steps

    @move_failed = false

  end

  

  def move_lower_left(speed = 8)

    las_dir = @direction

    move1 = move_down(false, speed)

    move2 = move_left(false, speed)

    las_dir == 6 ? turn_left : las_dir == 8 ? turn_down : nil if move1 == move2

    @move_failed = move1 && move2

  end

  

  def move_lower_right(speed = 8)

    las_dir = @direction

    move1 = move_down(false, speed)

    move2 = move_right(false, speed)

    las_dir == 4 ? turn_right : las_dir == 8 ? turn_down : nil if move1 == move2

    @move_failed = move1 && move2

  end

  

  def move_upper_left(speed = 8)

    las_dir = @direction

    move1 = move_up(false, speed)

    move2 = move_left(false, speed)

    las_dir == 6 ? turn_left : las_dir == 2 ? turn_up : nil if move1 == move2

    @move_failed = move1 && move2

  end

  

  def move_upper_right(speed = 8)

    las_dir = @direction

    move1 = move_up(false, speed)

    move2 = move_right(false, speed)

    las_dir == 4 ? turn_right : las_dir == 2 ? turn_up : nil if move1 == move2

    @move_failed = move1 && move2

  end

  

  def move_random(speed = 8)

    case rand(4)

    when 0;  move_down(false, speed)

    when 1;  move_left(false, speed)

    when 2;  move_right(false, speed)

    when 3;  move_up(false, speed)

    end

  end

  

  def move_toward_player(speed = 8)

    sx = distance_x_from_player

    sy = distance_y_from_player

    if sx != 0 or sy != 0

      if sx.abs > sy.abs

        sx > 0 ? move_left(true, speed) : move_right(true, speed)

        sy > 0 ? move_up(true, speed) : move_down(true, speed) if @move_failed and sy != 0

      else

        sy > 0 ? move_up(true, speed) : move_down(true, speed)

        sx > 0 ? move_left(true, speed) : move_right(true, speed) if @move_failed and sx != 0

      end

    end

  end

  

  def move_forward(speed = 8)

    case @direction

    when 2;  move_down(false, speed)

    when 4;  move_left(false, speed)

    when 6;  move_right(false, speed)

    when 8;  move_up(false, speed)

    end

  end

  

  alias amsu_jump jump

  def jump(x_plus, y_plus)

    amsu_jump(x_plus, y_plus)

    @x2 += x_plus*256

    @y2 += y_plus*256

  end

  

end

 

class Game_Player

  def move_by_input

    return if $game_map.interpreter.running? or !movable?

    case Input.dir8

    when 1;  move_lower_left(@real_move_speed)

    when 2;  move_down(true, @real_move_speed)

    when 3;  move_lower_right(@real_move_speed)

    when 4;  move_left(true, @real_move_speed)

    when 6;  move_right(true, @real_move_speed)

    when 7;  move_upper_left(@real_move_speed)

    when 8;  move_up(true, @real_move_speed)

    when 9;  move_upper_right(@real_move_speed)

    end

  end

end

 

class Sprite_Character

  alias amsu_update update

  def update

    amsu_update

    self.zoom_x = self.zoom_y = @tile_id == 0 ? @character.zoom : 1

  end

end

 

module Math

  def self.min(x, max) x < max ? x : max end

  def self.max(x, min) x > min ? x : min end

  def self.middle(min, x, max) x > min ? x < max ? x : max : min end

end
 

From

Member

Of course, it's up to you in the end... I can try to put something together if you want (as that shouldn't be too hard), however you need to tell me if you want the character to scale gradually or after a certain distance... (I really can't quite imagine what you want to do with it, so I'm having a bit of a problem seeing the details here... ^^ )
The character must undergo a zoom and starts walking in the middle of the screen. =)
Unfortunately Mode7 not 'what I'm looking for çç
Using maps drawn, and I would need a simple thing ^^

@zeus81: This script, do not work O_o
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top