Pixel Platformer (GPLAT 1 of 2)

G-PLAT!
Version: 1.2
Author: g@Mef@Ce
Date: 8/3/2011 (month day, year)


Version History
  • GPLAT 1.0 - 7/11/2011
  • GPLAT 1.1 - 7/18/2011
  • GPLAT 1.2 - 8/3/2011


Planned Future Versions
  • it's a surprise :'p

Gravity system for making side scrolling platformers with RMXP




Features
+ user friendly module for easy configuration +
    PLAYER:
  • gravity (w/ disable switch)
  • pixel movement & jump (on/off)
  • sprite alignment
  • dash button
  • dash speed
  • walk speed
  • jump button
  • jump sprite
  • jump animation
  • jump height
  • jump sound
  • air jump (double jump)
  • air jump animation


Screenshot?

Image



Instructions

Step 1.) copy the code

Step 2.) open RMXP > F11 (script database)

Step 3.) above "Main" > Insert new script

Step 4.) paste code into right side window

Step 5.) configure module to your liking

Step 6.) make your maps

*to make a platform, simply make any tile on your tileset impassable.

RMXP > F9 > Tileset tab > Passage

make the tile you are using for the platform an "X" and not an "O"




GPLAT 1 of 2 - Player gravity

  1.  
  2. #===============================================================================
  3. # Pixel Platformer v1.2 by G@MeF@Ce 8/3/2011 "GPLAT 1 of 2"
  4. # http://www.gameface101.com
  5. #-------------------------------------------------------------------------------
  6. # Original Pixel Movement Script by Cogwheel from 66rpg.com
  7. # special thanks to mr_wiggles and moghunter for RGSS support
  8. #
  9. # *free to use, must give credit, do not post on any other site
  10. #==============================================================================
  11.  
  12. module G101_GPLAT
  13.   #--------------------------------------------------------------------------
  14.   # * configure settings
  15.   #--------------------------------------------------------------------------
  16.  
  17.   GPLAT_DISABLE_SWITCH = 2        # switch ID to disable gravity switch
  18.   #
  19.   PIXEL_MOVE = true                # pixel movement & jump
  20.  
  21.   #SPRITE settings
  22.   UP    = 32                      #default 32 (0 < UP < 64)
  23.   DOWN  = 0                        #default 16 (0 < DOWN <64)
  24.   SIDE  = 32                      #default 32 (0 < SIDE <64)
  25.  
  26.   #SPEED settings
  27.   DASH_BUTTON = Input::C          # dash button
  28.   WALK_SPEED = 4.8                # set the walk speed
  29.   DASH_SPEED = 5.5                # set the dash speed
  30.  
  31.   #JUMP settings
  32.   JUMP_BUTTON = Input::A          # jump button
  33.   JUMP_SPRITE = ""            # jump graphic character name suffix
  34.   JUMP_ANIMATION_ID  = 0          # animation ID when jump
  35.   JUMP_MAX = 100                    # power of jump
  36.   JUMP_ADD = 4                    # height of single jump
  37.   JUMP_SOUND = ""    # Play Sound when jump
  38.   JUMP_VOLUME = 70                # set volume for jump sound
  39.   JUMP_PITCH = 100                # set the pitch for jump sound
  40.  
  41.   #AIR JUMP settings
  42.   AIR_JUMP_VAR = 1                # variable ID to set value for air jumps
  43.   AIR_JUMP_ANIMATION_ID = 0        # aniamtion ID when air jump
  44.  
  45. end
  46.  
  47. #==============================================================================
  48. # Game_Player
  49. #==============================================================================
  50. class Game_Player < Game_Character
  51.  
  52.   include G101_GPLAT
  53.                    
  54.   #--------------------------------------------------------------------------
  55.   # ● public instance variables
  56.   #--------------------------------------------------------------------------
  57.   attr_reader  :event                  
  58.   attr_accessor :move_speed            
  59.   #--------------------------------------------------------------------------
  60.   # ● update
  61.   #--------------------------------------------------------------------------
  62.   alias :update_original :update
  63.   def update
  64.  
  65.     @walk  = WALK_SPEED
  66.     @dash  = DASH_SPEED
  67.     @event = 4
  68.     @dot_m = PIXEL_MOVE
  69.  
  70.     if @revise_x == nil and @revise_y == nil
  71.       @revise_x = 0
  72.       @revise_y = 0
  73.     end
  74.     unless @dot_m
  75.       update_original
  76.       return
  77.     end
  78.     if @move_route_forcing
  79.       last_moving = moving?
  80.       last_real_x = @real_x
  81.       last_real_y = @real_y
  82.       if (@revise_x != 0 or @revise_y != 0) and not jumping? and @move == true
  83.         if @revise_x != @real_x - @x * 128 or @revise_y != @real_y - @y * 128
  84.           @revise_x = @real_x - @x * 128
  85.           @revise_y = @real_y - @y * 128
  86.         end
  87.  
  88.         distance1 = 2 ** @move_speed
  89.         distance2 = Math.sqrt(@revise_x ** 2 + @revise_y ** 2)
  90.  
  91.         if distance1 > distance2
  92.           @real_x = @real_x - @revise_x
  93.           @real_y = @real_y - @revise_y
  94.           @revise_x = 0
  95.           @revise_y = 0
  96.           anime_update
  97.         else
  98.           @real_x -= (distance1 * @revise_x / distance2).round
  99.           @real_y -= (distance1 * @revise_y / distance2).round
  100.           @revise_x = @real_x - @x * 128
  101.           @revise_y = @real_y - @y * 128
  102.           anime_update
  103.         end
  104.       else
  105.         super
  106.       end
  107.     else
  108.       @move = false
  109.  
  110.       unless moving? or $game_system.map_interpreter.running? or
  111.             @move_route_forcing or $game_temp.message_window_showing
  112.         @event_run = false
  113. #-------------------------------------------------------------------------------
  114.       case Input.dir8
  115.         when 1
  116.           $game_switches[GPLAT_DISABLE_SWITCH] ? move_lower_left_p : move_left_p
  117.         when 2
  118.           move_down_p if $game_switches[GPLAT_DISABLE_SWITCH]
  119.         when 3
  120.         $game_switches[GPLAT_DISABLE_SWITCH] ? move_lower_right_p : move_right_p
  121.         when 4
  122.           move_left_p
  123.         when 6
  124.           move_right_p
  125.         when 7
  126.         $game_switches[GPLAT_DISABLE_SWITCH] ? move_upper_left_p : move_left_p
  127.         when 8
  128.         move_up_p if $game_switches[GPLAT_DISABLE_SWITCH]
  129.         when 9
  130.         $game_switches[GPLAT_DISABLE_SWITCH] ? move_upper_right_p : move_right_p
  131.         end
  132.       end
  133.  
  134.       last_real_x = @real_x
  135.       last_real_y = @real_y
  136.       @real_x = @x * 128 + @revise_x
  137.       @real_y = @y * 128 + @revise_y
  138.       last_moving = moving?
  139.       move_on
  140.  
  141.       if (last_real_x != @real_x or last_real_y != @real_y)
  142.         @move_distance = 0 if @move_distance == nil
  143.         @move_distance += Math.sqrt((last_real_x - @real_x) ** 2 +
  144.                                       (last_real_y - @real_y) ** 2)
  145.         if @move_distance >= 128
  146.           @move_distance %= 128
  147.           increase_steps
  148.         end
  149.  
  150.         anime_update
  151.       else
  152.         @pattern = 0
  153.       end
  154.     end
  155.  
  156.     if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
  157.       $game_map.scroll_down(@real_y - last_real_y)
  158.     end
  159.  
  160.     if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
  161.       $game_map.scroll_left(last_real_x - @real_x)
  162.     end
  163.  
  164.     if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
  165.       $game_map.scroll_right(@real_x - last_real_x)
  166.     end
  167.  
  168.     if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
  169.       $game_map.scroll_up(last_real_y - @real_y)
  170.     end
  171.  
  172.     if last_moving
  173.       result = check_event_trigger_here([1,2])
  174.       if result == true
  175.         if (last_real_x / 128.0).round != @x and
  176.             (last_real_y / 128.0).round != @y
  177.           if @direction == 2 or @direction == 8
  178.             if (last_real_x / 128.0).round > @x
  179.               turn_left
  180.             else
  181.               turn_right
  182.             end
  183.           else
  184.             if (last_real_y / 128.0).round > @y
  185.               turn_up
  186.             else
  187.               turn_down
  188.             end
  189.           end
  190.         elsif (last_real_x / 128.0).round > @x
  191.           turn_left
  192.         elsif (last_real_x / 128.0).round < @x
  193.           turn_right
  194.         elsif (last_real_y / 128.0).round > @y
  195.           turn_up
  196.         elsif (last_real_y / 128.0).round < @y
  197.           turn_down
  198.         end
  199.       end
  200.  
  201.       if result == false
  202.         unless $DEBUG and Input.press?(Input::CTRL)
  203.           if @encounter_count > 0
  204.             @encounter_count -= 1
  205.           end
  206.         end
  207.       end
  208.     end
  209. #-------------------------------------------------------------------------------
  210.       unless $game_system.map_interpreter.running? or
  211.             @move_route_forcing or $game_temp.message_window_showing
  212.     if Input.press?(JUMP_BUTTON) and not $game_switches[GPLAT_DISABLE_SWITCH]
  213.       @twojump = 1 if @twojump == 0 and down1(((@x * 128 + @revise_x) / 128.0).round,
  214.           ((@y * 128 + @revise_y) / 128.0).round, 5, true)
  215.       if (not @apassed) and @twojump <= $game_variables[AIR_JUMP_VAR]
  216.        
  217.         if @twojump > 0
  218.           $game_player.animation_id = AIR_JUMP_ANIMATION_ID
  219.         elsif
  220.           $game_player.animation_id = JUMP_ANIMATION_ID
  221.         end
  222.  
  223.         @apassed = true
  224.         @jumpnow = JUMP_MAX
  225.         @twojump += 1
  226.  
  227.   $game_system.se_play(RPG::AudioFile.new(JUMP_SOUND, JUMP_VOLUME, JUMP_PITCH))
  228.       else
  229.         @jumpnow += 3      
  230.       end
  231.     else
  232.       @apassed = false
  233.     end
  234. #-------------------------------------------------------------------------------
  235.     if not $game_switches[GPLAT_DISABLE_SWITCH]
  236.       @jumpnow -= 10
  237.       if @jumpnow < 0
  238.         actor = $game_party.actors[0]
  239.         @character_name = actor.character_name #change graphic back to normal
  240.         @jumpnow = [@jumpnow, -JUMP_MAX].max
  241.         if not down1(((@x * 128 + @revise_x) / 128.0).round,
  242.           ((@y * 128 + @revise_y) / 128.0).round, -@jumpnow, true)
  243.           @jumpnow = 0
  244.           @twojump = 0
  245.         end
  246.       elsif @jumpnow > 0
  247.         actor = $game_party.actors[0]
  248.         @character_name = actor.character_name + JUMP_SPRITE#change to jump graphic
  249.         @jumpnow = [@jumpnow, JUMP_MAX].min
  250.         if not up1(((@x * 128 + @revise_x) / 128.0).round,
  251.           ((@y * 128 + @revise_y) / 128.0).round, @jumpnow, true)
  252.           @jumpnow = 0
  253.         end
  254.       end
  255.     end
  256. end #unless  
  257.     if Input.trigger?(Input::C)
  258.       check_event_trigger_here([0])
  259.       check_event_trigger_there([0,1,2])
  260.     end
  261.   end
  262.   #--------------------------------------------------------------------------
  263.   # ● Initialize
  264.   #--------------------------------------------------------------------------
  265.   def initialize
  266.     @jumpnow = 0
  267.     @twojump = 0
  268.     @apassed = false
  269.     @revise_x = 0
  270.     @revise_y = 0
  271.     @move == false
  272.     super
  273.   end
  274.   #--------------------------------------------------------------------------
  275.   # ● moving?
  276.   #--------------------------------------------------------------------------
  277.   def moving?
  278.     unless @dot_m
  279.       result = super
  280.       return result
  281.     end
  282.  
  283.     if @move_route_forcing
  284.       if @move == false
  285.         return false
  286.       end
  287.       super
  288.  
  289.     else
  290.       return (@x != (@real_x / 128.0).round or @y != (@real_y / 128.0).round)
  291.     end
  292.   end
  293.   #--------------------------------------------------------------------------
  294.   # ● moving_a?
  295.   #--------------------------------------------------------------------------
  296.   def moving_a?
  297.     if @move == false
  298.       if (@move_route.list[@move_route_index].code <= 14 or
  299.           @move_route.list[@move_route_index].code == 25)
  300.         @move = true
  301.       end
  302.       return false
  303.     end
  304.     moving?
  305.   end
  306.   #--------------------------------------------------------------------------
  307.   # ● update (jump)
  308.   #--------------------------------------------------------------------------
  309.   def update_jump
  310.  
  311.     @jump_count -= 1
  312.  
  313.     @real_x = (@real_x * @jump_count + @x * 128) / (@jump_count + 1)
  314.     @real_y = (@real_y * @jump_count + @y * 128) / (@jump_count + 1)
  315.     if @jump_count == 0
  316.       @revise_x = 0
  317.       @revise_y = 0
  318.     end
  319.   end
  320.   #--------------------------------------------------------------------------
  321.   # ● move_type custom
  322.   #--------------------------------------------------------------------------
  323.   def move_type_custom
  324.     unless @dot_m
  325.       super
  326.       return
  327.     end
  328.  
  329.     if jumping? or moving_a?
  330.       return
  331.     end
  332.  
  333.     while @move_route_index < @move_route.list.size
  334.       command = @move_route.list[@move_route_index]
  335.  
  336.       if command.code == 0
  337.         if @move_route.repeat
  338.           @move_route_index = 0
  339.         end
  340.  
  341.         unless @move_route.repeat
  342.           if @move_route_forcing and not @move_route.repeat
  343.             @move_route_forcing = false
  344.             @move_route = @original_move_route
  345.             @move_route_index = @original_move_route_index
  346.             @original_move_route = nil
  347.           end
  348.  
  349.           @stop_count = 0
  350.         end
  351.         return
  352.       end
  353.  
  354.       if command.code <= 14
  355.  
  356.         case command.code
  357.         when 1
  358.           move_down
  359.         when 2
  360.           move_left
  361.         when 3
  362.           move_right
  363.         when 4
  364.           move_up
  365.         when 5
  366.           move_lower_left
  367.         when 6
  368.           move_lower_right
  369.         when 7
  370.           move_upper_left
  371.         when 8
  372.           move_upper_right
  373.         when 9
  374.           move_random
  375.         when 10
  376.           move_toward_player
  377.         when 11
  378.           move_away_from_player
  379.         when 12
  380.           move_forward
  381.         when 13
  382.           move_backward
  383.         when 14
  384.           jump(command.parameters[0], command.parameters[1])
  385.         end
  386.  
  387.         if not @move_route.skippable and not moving? and not jumping?
  388.           return
  389.         end
  390.         @move_route_index += 1
  391.         return
  392.       end
  393.  
  394.       if command.code == 15
  395.         @wait_count = command.parameters[0] * 2 - 1
  396.         @move_route_index += 1
  397.         return
  398.       end
  399.  
  400.       if command.code >= 16 and command.code <= 26
  401.  
  402.         case command.code
  403.         when 16
  404.           turn_down
  405.         when 17
  406.           turn_left
  407.         when 18
  408.           turn_right
  409.         when 19
  410.           turn_up
  411.         when 20
  412.           turn_right_90
  413.         when 21
  414.           turn_left_90
  415.         when 22
  416.           turn_180
  417.         when 23
  418.           turn_right_or_left_90
  419.         when 24
  420.           turn_random
  421.         when 25
  422.           turn_toward_player
  423.         when 26
  424.           turn_away_from_player
  425.         end
  426.         @move_route_index += 1
  427.         return
  428.       end
  429.  
  430.       if command.code >= 27
  431.  
  432.         case command.code
  433.         when 27
  434.           $game_switches[command.parameters[0]] = true
  435.           $game_map.need_refresh = true
  436.         when 28
  437.           $game_switches[command.parameters[0]] = false
  438.           $game_map.need_refresh = true
  439.         when 29
  440.           @move_speed = command.parameters[0]
  441.         when 30
  442.           @move_frequency = command.parameters[0]
  443.         when 31
  444.           @walk_anime = true
  445.         when 32
  446.           @walk_anime = false
  447.         when 33
  448.           @step_anime = true
  449.         when 34
  450.           @step_anime = false
  451.         when 35
  452.           @direction_fix = true
  453.         when 36
  454.           @direction_fix = false
  455.         when 37
  456.           @through = true
  457.         when 38
  458.           @through = false
  459.         when 39
  460.           @always_on_top = true
  461.         when 40
  462.           @always_on_top = false
  463.         when 41
  464.           @tile_id = 0
  465.           @character_name = command.parameters[0]
  466.           @character_hue = command.parameters[1]
  467.           if @original_direction != command.parameters[2]
  468.             @direction = command.parameters[2]
  469.             @original_direction = @direction
  470.             @prelock_direction = 0
  471.           end
  472.           if @original_pattern != command.parameters[3]
  473.             @pattern = command.parameters[3]
  474.             @original_pattern = @pattern
  475.           end
  476.         when 42
  477.           @opacity = command.parameters[0]
  478.         when 43
  479.           @blend_type = command.parameters[0]
  480.         when 44
  481.           $game_system.se_play(command.parameters[0])
  482.         when 45
  483.           result = eval(command.parameters[0])
  484.         end
  485.         @move_route_index += 1
  486.         return
  487.       end
  488.     end
  489.   end
  490.   #--------------------------------------------------------------------------
  491.   # ● move_down platform
  492.   #--------------------------------------------------------------------------
  493.   def move_down_p
  494.     turn_down
  495.     distance = 2 ** @move_speed
  496.     down1(((@x * 128 + @revise_x) / 128.0).round,
  497.           ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  498.   end
  499.   #--------------------------------------------------------------------------
  500.   # ● move_down aaaagq
  501.   #--------------------------------------------------------------------------
  502.   def move_down_aaaagq
  503.     distance = 2 ** @move_speed
  504.     down1(((@x * 128 + @revise_x) / 128.0).round,
  505.           ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  506.   end
  507.   #--------------------------------------------------------------------------
  508.   # ● down1
  509.   #--------------------------------------------------------------------------
  510.   def down1(x, y, distance, down = false)
  511.     result = down2(x, y, distance)
  512.     if result == false
  513.       @event_run = check_event_trigger_touch(x, y+1)
  514.       return result
  515.     end
  516.     if @revise_x < -SIDE
  517.       result = down2(x, y + 1, distance, 4)
  518.       result &= down2(x - 1, y, distance)
  519.       if result == false
  520.         if down
  521.           move_lower_right_p
  522.           if @revise_x > SIDE
  523.             @revise_x = SIDE
  524.           end
  525.         end
  526.         return result
  527.       end
  528.     elsif @revise_x > SIDE
  529.       result = down2(x, y + 1, distance, 6)
  530.       result &= down2(x + 1, y, distance)
  531.       if result == false
  532.         if down
  533.           move_lower_left_p
  534.           if @revise_x < -SIDE
  535.             @revise_x = -SIDE
  536.           end
  537.         end
  538.         return result
  539.       end
  540.     end
  541.     @revise_y += distance
  542.     return result
  543.   end
  544.   #--------------------------------------------------------------------------
  545.   # ● down2
  546.   #--------------------------------------------------------------------------
  547.   def down2(x, y, distance, d = 2)
  548.     if @revise_y + distance > DOWN
  549.       unless passable?(x, y, d)
  550.         if @revise_y < DOWN
  551.           @revise_y = DOWN
  552.         end
  553.         return false
  554.       end
  555.     end
  556.     return true
  557.   end
  558.   #--------------------------------------------------------------------------
  559.   # ● move_left platform
  560.   #--------------------------------------------------------------------------
  561.   def move_left_p
  562.     turn_left
  563.     distance = 2 ** @move_speed
  564.     left1(((@x * 128 + @revise_x) / 128.0).round,
  565.           ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  566.   end
  567.   #--------------------------------------------------------------------------
  568.   # ● left1
  569.   #--------------------------------------------------------------------------
  570.   def left1(x, y, distance, left = false)
  571.     result = left2(x, y, distance)
  572.     if result == false
  573.       @event_run = check_event_trigger_touch(x-1, y)
  574.       return result
  575.     end
  576.     if @revise_y < -UP and $game_switches[GPLAT_DISABLE_SWITCH]
  577.       result = left2(x - 1, y, distance, 8)
  578.       result &= left2(x, y - 1, distance)
  579.       if result == false
  580.         if left
  581.           move_lower_left_p
  582.           if @revise_y > DOWN
  583.             @revise_y = DOWN
  584.           end
  585.         end
  586.         return result
  587.       end
  588.     elsif @revise_y > DOWN and $game_switches[GPLAT_DISABLE_SWITCH]
  589.       result = left2(x - 1, y, distance, 2)
  590.       result &= left2(x, y + 1, distance)
  591.       if result == false
  592.         if left
  593.           move_upper_left_p
  594.           if @revise_y < -UP
  595.             @revise_y = -UP
  596.           end
  597.         end
  598.         return result
  599.       end
  600.     end
  601.     @revise_x -= distance
  602.     return result
  603.   end
  604.   #--------------------------------------------------------------------------
  605.   # ● left2
  606.   #--------------------------------------------------------------------------
  607.   def left2(x, y, distance, d = 4)
  608.     if @revise_x - distance < -SIDE
  609.       unless passable?(x, y, d)
  610.         if @revise_x > -SIDE
  611.           @revise_x = -SIDE
  612.         end
  613.         return false
  614.       end
  615.     end
  616.     return true
  617.   end
  618.   #--------------------------------------------------------------------------
  619.   # ● move_right platform
  620.   #--------------------------------------------------------------------------
  621.   def move_right_p
  622.       turn_right
  623.     distance = 2 ** @move_speed
  624.     right1(((@x * 128 + @revise_x) / 128.0).round,
  625.             ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  626.   end
  627.   #--------------------------------------------------------------------------
  628.   # ● right1
  629.   #--------------------------------------------------------------------------
  630.   def right1(x, y, distance, right = false)
  631.     result = right2(x, y, distance)
  632.     if result == false
  633.       @event_run = check_event_trigger_touch(x+1, y)
  634.       return result
  635.     end
  636.     if @revise_y < -UP and $game_switches[GPLAT_DISABLE_SWITCH]
  637.       result = right2(x + 1, y, distance, 8)
  638.       result &= right2(x, y - 1, distance)
  639.       if result == false
  640.         if right
  641.           move_lower_right_p
  642.           if @revise_y > DOWN
  643.             @revise_y = DOWN
  644.           end
  645.         end
  646.         return result
  647.       end
  648.     elsif @revise_y > DOWN and $game_switches[GPLAT_DISABLE_SWITCH]
  649.       result = right2(x + 1, y, distance, 2)
  650.       result &= right2(x, y + 1, distance)
  651.       if result == false
  652.         if right
  653.           move_upper_right_p
  654.           if @revise_y < -UP
  655.             @revise_y = -UP
  656.           end
  657.         end
  658.         return result
  659.       end
  660.     end
  661.     @revise_x += distance
  662.     return result
  663.   end
  664.   #--------------------------------------------------------------------------
  665.   # ● right2
  666.   #--------------------------------------------------------------------------
  667.   def right2(x, y, distance, d = 6)
  668.     if @revise_x + distance > SIDE
  669.       unless passable?(x, y, d)
  670.         if @revise_x < SIDE
  671.           @revise_x = SIDE
  672.         end
  673.         return false
  674.       end
  675.     end
  676.     return true
  677.   end
  678.   #--------------------------------------------------------------------------
  679.   # ● move_up platform
  680.   #--------------------------------------------------------------------------
  681.   def move_up_p
  682.     turn_up
  683.     distance = 2 ** @move_speed
  684.     up1(((@x * 128 + @revise_x) / 128.0).round,
  685.         ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  686.   end
  687.   #--------------------------------------------------------------------------
  688.   # ● move_up_aaaagq
  689.   #--------------------------------------------------------------------------
  690.   def move_up_aaaagq
  691.     distance = 2 ** @move_speed
  692.     up1(((@x * 128 + @revise_x) / 128.0).round,
  693.         ((@y * 128 + @revise_y) / 128.0).round, distance, true)
  694.   end
  695.   #--------------------------------------------------------------------------
  696.   # ● up1
  697.   #--------------------------------------------------------------------------
  698.   def up1(x, y, distance, up = false)
  699.     result = up2(x, y, distance)
  700.     if result == false
  701.       @event_run = check_event_trigger_touch(x, y-1)
  702.       return result
  703.     end
  704.     if @revise_x < -SIDE
  705.       result = up2(x, y - 1, distance, 4)
  706.       result &= up2(x - 1, y, distance)
  707.       if result == false
  708.         if up
  709.           move_upper_right_p
  710.           if @revise_x > SIDE
  711.             @revise_x = SIDE
  712.           end
  713.         end
  714.         return result
  715.       end
  716.     elsif @revise_x > SIDE
  717.       result = up2(x, y - 1, distance, 6)
  718.       result &= up2(x + 1, y, distance)
  719.       if result == false
  720.         if up
  721.           move_upper_left_p
  722.           if @revise_x < -SIDE
  723.             @revise_x = -SIDE
  724.           end
  725.         end
  726.         return result
  727.       end
  728.     end
  729.     @revise_y -= distance
  730.     return result
  731.   end
  732.   #--------------------------------------------------------------------------
  733.   # ● up2
  734.   #--------------------------------------------------------------------------
  735.   def up2(x, y, distance, d = 8)
  736.     if @revise_y - distance < -UP
  737.       unless passable?(x, y, d)
  738.         if @revise_y > -UP
  739.           @revise_y = -UP
  740.         end
  741.         return false
  742.       end
  743.     end
  744.     return true
  745.   end
  746.   #--------------------------------------------------------------------------
  747.   # ● low_left platform
  748.   #--------------------------------------------------------------------------
  749.   def move_lower_left_p
  750.     unless @direction_fix
  751.       @direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
  752.     end
  753.     distance = (2 ** @move_speed) / Math.sqrt(2)
  754.     if @direction == 2
  755.       turn_left unless down1(((@x * 128 + @revise_x) / 128.0).round,
  756.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  757.       turn_down if @event_run
  758.       unless @event_run
  759.         if last_move?(@real_x, @real_y, 2, distance)
  760.           result = check_event_trigger_here([1,2], false)
  761.           if result == true
  762.             return
  763.           end
  764.         end
  765.         move_on
  766.         if @revise_y > DOWN and -UP > @revise_y - distance
  767.           @revise_y = DOWN
  768.         end
  769.         turn_down unless left1(((@x * 128 + @revise_x) / 128.0).round,
  770.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  771.         turn_left if @event_run
  772.       end
  773.     else
  774.       turn_down unless left1(((@x * 128 + @revise_x) / 128.0).round,
  775.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  776.       turn_left if @event_run
  777.       unless @event_run
  778.         if last_move?(@real_x, @real_y, 4, distance)
  779.           result = check_event_trigger_here([1,2], false)
  780.           if result == true
  781.             return
  782.           end
  783.         end
  784.         move_on
  785.         if  @revise_x + distance> SIDE and -SIDE > @revise_x
  786.           @revise_x = -SIDE
  787.         end
  788.         turn_left unless down1(((@x * 128 + @revise_x) / 128.0).round,
  789.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  790.         turn_down if @event_run
  791.       end
  792.     end
  793.   end
  794.   #--------------------------------------------------------------------------
  795.   # ● low_right platform
  796.   #--------------------------------------------------------------------------
  797.   def move_lower_right_p
  798.     unless @direction_fix
  799.       @direction = (@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
  800.     end
  801.     distance = (2 ** @move_speed) / Math.sqrt(2)
  802.     if @direction == 2
  803.       turn_right unless down1(((@x * 128 + @revise_x) / 128.0).round,
  804.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  805.       turn_down if @event_run
  806.       unless @event_run
  807.         if last_move?(@real_x, @real_y, 2, distance)
  808.           result = check_event_trigger_here([1,2], false)
  809.           if result == true
  810.             return
  811.           end
  812.         end
  813.         move_on
  814.         if @revise_y > DOWN and -UP > @revise_y - distance
  815.           @revise_y = DOWN
  816.         end
  817.         turn_down unless right1(((@x * 128 + @revise_x) / 128.0).round,
  818.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  819.         turn_right if @event_run
  820.       end
  821.     else
  822.       turn_down unless right1(((@x * 128 + @revise_x) / 128.0).round,
  823.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  824.       turn_right if @event_run
  825.       unless @event_run
  826.         if last_move?(@real_x, @real_y, 6, distance)
  827.           result = check_event_trigger_here([1,2], false)
  828.           if result == true
  829.             return
  830.           end
  831.         end
  832.         move_on
  833.         if @revise_x > SIDE and -SIDE > @revise_x - distance
  834.           @revise_x = SIDE
  835.         end
  836.         turn_right unless down1(((@x * 128 + @revise_x) / 128.0).round,
  837.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  838.         turn_down if @event_run
  839.       end
  840.     end
  841.   end
  842.   #--------------------------------------------------------------------------
  843.   # ● up_left platform
  844.   #--------------------------------------------------------------------------
  845.   def move_upper_left_p
  846.     unless @direction_fix
  847.       @direction = (@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
  848.     end
  849.     distance = (2 ** @move_speed) / Math.sqrt(2)
  850.     if @direction == 8
  851.       turn_left unless up1(((@x * 128 + @revise_x) / 128.0).round,
  852.                             ((@y * 128 + @revise_y) / 128.0).round, distance)
  853.       turn_up if @event_run
  854.       unless @event_run
  855.         if last_move?(@real_x, @real_y, 8, distance)
  856.           result = check_event_trigger_here([1,2], false)
  857.           if result == true
  858.             return
  859.           end
  860.         end
  861.         move_on
  862.         if @revise_y + distance > DOWN and -UP > @revise_y
  863.           @revise_y = -UP
  864.         end
  865.         turn_up unless left1(((@x * 128 + @revise_x) / 128.0).round,
  866.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  867.         turn_left if @event_run
  868.       end
  869.     else
  870.       turn_up unless left1(((@x * 128 + @revise_x) / 128.0).round,
  871.                             ((@y * 128 + @revise_y) / 128.0).round, distance)
  872.       turn_left if @event_run
  873.       unless @event_run
  874.         if last_move?(@real_x, @real_y, 4, distance)
  875.           result = check_event_trigger_here([1,2], false)
  876.           if result == true
  877.             return
  878.           end
  879.         end
  880.         move_on
  881.         if @revise_x > SIDE and -SIDE > @revise_x - distance
  882.           @revise_x = SIDE
  883.         end
  884.         turn_left unless up1(((@x * 128 + @revise_x) / 128.0).round,
  885.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  886.         turn_up if @event_run
  887.       end
  888.     end
  889.   end
  890.   #--------------------------------------------------------------------------
  891.   # ● up_right platform
  892.   #--------------------------------------------------------------------------
  893.   def move_upper_right_p
  894.     unless @direction_fix
  895.       @direction = (@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
  896.     end
  897.     distance = (2 ** @move_speed) / Math.sqrt(2)
  898.     if @direction == 8
  899.       turn_right unless up1(((@x * 128 + @revise_x) / 128.0).round,
  900.                             ((@y * 128 + @revise_y) / 128.0).round, distance)
  901.       turn_up if @event_run
  902.       unless @event_run
  903.         if last_move?(@real_x, @real_y, 8, distance)
  904.           result = check_event_trigger_here([1,2], false)
  905.           if result == true
  906.             return
  907.           end
  908.         end
  909.         move_on
  910.         if @revise_y + distance > DOWN and -UP > @revise_y
  911.           @revise_y = -UP
  912.         end
  913.         turn_up unless right1(((@x * 128 + @revise_x) / 128.0).round,
  914.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  915.         turn_right if @event_run
  916.       end
  917.     else
  918.       turn_up unless right1(((@x * 128 + @revise_x) / 128.0).round,
  919.                             ((@y * 128 + @revise_y) / 128.0).round, distance)
  920.       turn_right if @event_run
  921.       unless @event_run
  922.         if last_move?(@real_x, @real_y, 6, distance)
  923.           result = check_event_trigger_here([1,2], false)
  924.           if result == true
  925.             return
  926.           end
  927.         end
  928.         move_on
  929.         if @revise_x > SIDE and -SIDE > @revise_x - distance
  930.           @revise_x = SIDE
  931.         end
  932.         turn_right unless up1(((@x * 128 + @revise_x) / 128.0).round,
  933.                               ((@y * 128 + @revise_y) / 128.0).round, distance)
  934.         turn_up if @event_run
  935.       end
  936.     end
  937.   end
  938.   #--------------------------------------------------------------------------
  939.   # ● check event here
  940.   #--------------------------------------------------------------------------
  941.   def check_event_trigger_here(triggers, run = true)
  942.     result = false
  943.     if $game_system.map_interpreter.running?
  944.       return result
  945.     end
  946.     for event in $game_map.events.values
  947.       if event.x == ((@x * 128 + @revise_x) / 128.0).round and
  948.           event.y == ((@y * 128 + @revise_y) / 128.0).round and
  949.           triggers.include?(event.trigger)
  950.         if not event.jumping? and event.over_trigger?
  951.           if event.list.size > 1
  952.             if run == true
  953.               event.start
  954.             end
  955.             result = true
  956.           end
  957.         end
  958.       end
  959.     end
  960.     return result
  961.   end
  962.   #--------------------------------------------------------------------------
  963.   # ● move_on
  964.   #--------------------------------------------------------------------------
  965.   def move_on
  966.     if @y < (@y + @revise_y / 128.0).round
  967.       @y += 1
  968.       @revise_y -= 128
  969.     end
  970.     if @x > (@x + @revise_x / 128.0).round
  971.       @x -= 1
  972.       @revise_x += 128
  973.     end
  974.     if @x < (@x + @revise_x / 128.0).round
  975.       @x += 1
  976.       @revise_x -= 128
  977.     end
  978.     if @y > (@y + @revise_y / 128.0).round
  979.       @y -= 1
  980.       @revise_y += 128
  981.     end
  982.   end
  983.   #--------------------------------------------------------------------------
  984.   # ● update (anime)
  985.   #--------------------------------------------------------------------------
  986.   def anime_update
  987.     if @walk_anime
  988.       @anime_count += 1.5
  989.     elsif @step_anime
  990.       @anime_count += 1
  991.     end
  992.     if @anime_count > 18 - @move_speed * 2 #@event = 4?
  993.       if not @step_anime and @stop_count > 0
  994.         @pattern = @original_pattern
  995.       else
  996.         @pattern = (@pattern + 1) % 4
  997.       end
  998.       @anime_count = 0
  999.     end
  1000.   end
  1001.   #--------------------------------------------------------------------------
  1002.   # ● moveto (x,y)
  1003.   #--------------------------------------------------------------------------
  1004.   alias :moveto_original :moveto
  1005.   def moveto(x, y)
  1006.     @revise_x = 0
  1007.     @revise_y = 0
  1008.     moveto_original(x, y)
  1009.   end
  1010.   #--------------------------------------------------------------------------
  1011.   # ● last move?
  1012.   #--------------------------------------------------------------------------
  1013.   def last_move?(x, y, direction, distance)
  1014.     if direction == 2 or direction == 6
  1015.       distance *= -1
  1016.     end
  1017.     if (direction == 2 or direction == 8) and
  1018.         (y / 128.0).round != ((y - distance) / 128.0).round
  1019.       return true
  1020.     end
  1021.     if (direction == 4 or direction == 6) and
  1022.         (x / 128.0).round != ((x - distance) / 128.0).round
  1023.       return true
  1024.     end
  1025.     return false
  1026.   end
  1027. end
  1028.  
  1029. #==============================================================================
  1030. # Game_Character
  1031. #==============================================================================
  1032.  
  1033. class Game_Character
  1034.  
  1035.     include G101_GPLAT
  1036.  
  1037.   def update_move
  1038.     distance = 2 ** @move_speed
  1039.     if @x * 128 != @real_x and @y * 128 != @real_y
  1040.       distance /= Math.sqrt(2)
  1041.     end
  1042.     if @y * 128 > @real_y
  1043.       @real_y = [@real_y + distance, @y * 128].min
  1044.     end
  1045.     if @x * 128 < @real_x
  1046.       @real_x = [@real_x - distance, @x * 128].max
  1047.     end
  1048.     if @x * 128 > @real_x
  1049.       @real_x = [@real_x + distance, @x * 128].min
  1050.     end
  1051.     if @y * 128 < @real_y
  1052.       @real_y = [@real_y - distance, @y * 128].max
  1053.     end
  1054.     if @walk_anime
  1055.       @anime_count += 1.5
  1056.     elsif @step_anime
  1057.       @anime_count += 1
  1058.     end
  1059.   end
  1060. end
  1061.  
  1062. #==============================================================================
  1063. # Game_Event
  1064. #==============================================================================
  1065.  
  1066. class Game_Event < Game_Character
  1067.   def start
  1068.     if @list.size > 1
  1069.       if $game_player.event != 0
  1070.         $game_player.move_speed = $game_player.event
  1071.       end
  1072.       @starting = true
  1073.     end
  1074.   end
  1075. end
  1076. #end of script ^,^
  1077.  
Expand to see the code.



GPLAT 2 of 2 - Event gravity


  1. #===============================================================================
  2. # Event Gravity script by G@MeF@Ce "GPLAT 2 of 2" http://www.gameface101.com
  3. # special thanks to mr_wiggles for RGSS support
  4. # free to use, must give credit, do not post on any other site
  5. #===============================================================================
  6. module G_EG
  7.  
  8. GPLAT_SWITCH = 3    #switch ID to turn on/off event gravity
  9.  
  10. G_GRAVITY = 1      # Y coordinates to
  11.  
  12. G_DROP = 30        # speed of gravity pull
  13.  
  14. end
  15. #==============================================================================
  16. # ■ Game_Event
  17. #==============================================================================
  18. class Game_Event < Game_Character
  19. include G_EG
  20.   #--------------------------------------------------------------------------
  21.   # ● Frame Update
  22.   #--------------------------------------------------------------------------
  23.   alias gravity_update update
  24.   def update
  25.       #check_jump_event if $game_switches[GPLAT_SWITCH_ID]
  26.       gravity_update
  27.       if $game_switches[GPLAT_SWITCH] and $game_map.passable?(@x, @y+1, 2)
  28.         @y += 0# if @icon_name != nil
  29.         unless @id > 999 or @air_event or @fixed_event
  30.           @y += G_GRAVITY
  31.         end
  32.       end
  33.   end
  34.  
  35.   #--------------------------------------------------------------------------
  36.   # ● Refresh
  37.   #--------------------------------------------------------------------------
  38.   alias refresh_gravity refresh
  39.   def refresh
  40.       refresh_gravity
  41.       unless @page == nil
  42.           for i in @page.list
  43.               if i.code == 108 or i.code == 408
  44.                 # Code for Air event
  45.                 if i.parameters[0].upcase[/AIR/] != nil
  46.                     @air_event = true
  47.                 end
  48.                 # Code for Fixed event
  49.                 if i.parameters[0].upcase[/FIXED/] != nil
  50.                     @fixed_event = true
  51.                 end
  52.               end
  53.           end
  54.       end
  55.       if @air_event and $game_switches[GPLAT_SWITCH]
  56.         if @y != @old_y
  57.             case rand(6)
  58.               when 0..2; turn_right
  59.               when 3..6; turn_left
  60.             end
  61.             @old_y = @y
  62.         end
  63.       end
  64.   end
  65. end
  66.        
  67. #==============================================================================
  68. # Game_Character
  69. #==============================================================================
  70.   class Game_Character
  71.    
  72.       def update_move
  73.           distance = 2 ** @move_speed
  74.         if @y * 128 > @real_y
  75.           @real_y = [@real_y + distance, @y * 128].min
  76.           # event gravity
  77.         if self.is_a?(Game_Event) and $game_switches[G_EG::GPLAT_SWITCH] and
  78.           @air_event == nil
  79.           @real_y += G_EG::G_DROP
  80.         end
  81.         end
  82.             if @x * 128 < @real_x
  83.               @real_x = [@real_x - distance, @x * 128].max
  84.             end
  85.             if @x * 128 > @real_x
  86.               @real_x = [@real_x + distance, @x * 128].min
  87.             end
  88.             if @y * 128 < @real_y
  89.               @real_y = [@real_y - distance, @y * 128].max
  90.             end
  91.             if @walk_anime
  92.               @anime_count += 1.5
  93.             elsif @step_anime
  94.               @anime_count += 1
  95.             end
  96.           end
  97.     end
  98. #end of script ^,^
Expand to see the code.



Support
here at HBGames.org or the underground
http://www.gameface101.com



Known Compatibility Issues
? ~ let me know...




Restrictions

Do not post this script on any other site.

must give credit to http://www.gameface101.com
cogwheel for pixel movement

special thanks to mr_wiggles and moghunter for RGSS support

DEMO?
http://www.mediafire.com/?sr9n28vim1ini9j
password: shrooms

Enjoy!

^,^
Hot damn this looks cool :!: First pixel-platformer I've seen in awhile. Only thing that appears to be missing is an enemy feature, but I'm sure that's an easy addition.
regi wrote:
Only thing that appears to be missing is an enemy feature, but I'm sure that's an easy addition.


@regi - there's a link at the bottom of the original post for the second script ~> event gravity (still working on more features) ^,^
Looks like fun. I will have to check this out tomorrow.
this seems fucken grand bro. looks like the exact platform script that everybody always asks for and that's great. :cheers:

are the physics/FEEL customizable? like the strength of the gravity, jump height, falling speed, etc etc etc. like could this be easily altered by the user to fit the specific style of platformer he's going for?
Gubid wrote:
I will have to check this out tomorrow.


@Gubid - whenever you get the chance, it would be an honor for you to peep out the code, I'm still learning RGSS.
Seems to me the more you learn, the more you need to learn about what you just learned...

noise wrote:
are the physics/FEEL customizable? like the strength of the gravity, jump height, falling speed, etc etc etc. like could this be easily altered by the user to fit the specific style of platformer he's going for?


@noise - pretty much, I'll continue to add easy options in the module where in time more control/features will be added

EDIT: newer version of script (fixed event check error)

check out the Super Mockup Brothers demo to see the script in action! ^,^

http://gameface101.playogame.com/?pid=18
update!

small but needed fix, jump is disabled when message window is open.

event gravity script and demo link included in the original post.

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=75050