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.

Ice Sliding

Kaoii

Member

This is the ice sliding script I found on the forum that I was going to use in my game:

Code:
#================================================= =============================
# ** 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
if $game_map.terrain_tag(@x, @y) == 3 and passable?(@x, @y, @direction)
dir = @direction
else
dir = Input.dir4
end

case dir
when 2
move_down
when 4
move_left
when 6
move_right
when 8
move_up
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

class Game_Character
def refresh_walk_anime(old_x, old_y)
if $game_map.terrain_tag(old_x, old_y) == 1 and
$game_map.terrain_tag(@x, @y) != 1
@walk_anime = true
elsif $game_map.terrain_tag(@x, @y) == 1
@walk_anime = false
end if self.is_a?(Game_Player)
end

def move_down(turn_enabled = true)
turn_down if turn_enabled

if passable?(@x, @y, 2)
turn_down
@y += 1
refresh_walk_anime(@x, @y-1)
increase_steps
else
check_event_trigger_touch(@x, @y+1)
end
end

def move_left(turn_enabled = true)
turn_left if turn_enabled

if passable?(@x, @y, 4)
turn_left
@x -= 1
refresh_walk_anime(@x+1, @y)
increase_steps
else
check_event_trigger_touch(@x-1, @y)
end
end

def move_right(turn_enabled = true)
turn_right if turn_enabled

if passable?(@x, @y, 6)
turn_right
@x += 1
refresh_walk_anime(@x-1, @y)
increase_steps
else
check_event_trigger_touch(@x+1, @y)
end
end

def move_up(turn_enabled = true)
turn_up if turn_enabled

if passable?(@x, @y, 8)
turn_up
@y -= 1
refresh_walk_anime(@x, @y+1)
increase_steps
else
check_event_trigger_touch(@x, @y-1)
end
end
end

However, ingame I have encountered a bug where my character's move animation will lock regardless if I'm on ice or not. This happens in towns and other large maps. Is there an alternative slide script to use?
 

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