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.

[Resolved] Puck's Standframe System + Sprinting.

Status
Not open for further replies.
I feel so dirty to ask, but I must make a script request  :cry:.

What I'm asking may or may not be simple. I'm not sure. I can script a fairly noobish window, but when it comes to changing dynamics like sprite movement, I'm at a total loss. :(

Anyway, I'm looking for Puck's More StandFrames System, integrated with a simple Dash add-on.

You can find Puck's script here:
http://rmxp.org/forums/index.php?topic=36387.0

From Puck:

what it does:
  - allows you to set the number of frames, standframes and directions for each character-graphic
    by adding a short string to their name
  - you can set default values so you don't need to edit every file
  - you can choose 1 or more (animated) standframes which will only be shown while standing still
    and are NOT used for the move-animation
  - you can adjust the stand- and move-animationspeed
  - you can activate 8-directional movement

  • just place it above main and below the other scripts
  • you can set up as many frames as you want for heros and events by adding f[n] to the name of their charactergraphic
    ("n" stands for the number of frames)
  • you can set the directions for each charactergraphic by adding d[n] to its name ("n" is the number of directions and has to be 4 or 8 )
  • you can set standframe(s) for your charactergraphic (which is/are only used if you don't move) by adding s["n"] to its name
    ("n" stands for the number of standframes)
  • you can set default values for frames standframes and directions so you don't need to change the name of every charactergraphic
    just edit "DEFAULT_FRAMES", "DEFAULT_STANDFRAMES" and "DEFAULT_DIRECTIONS" to your needs
  • you can activate 8-directional movement by setting "EIGHT_DIRECTIONS" to "true"
  • if you set "STANDANIMATION" to "true" and a charactergraphic has more than 1 standframe, it will be animated if it doesn't move.
    the standframes will NOT be used for the move-animation
  • you can change the standanimation-speed be changing "STANDANIMATION_SPEED". the number means how long each             
    frame will be displayed, so a smaller value means a faster animation
  • you can change the "MOVEANIMATION_SPEED", a smaller value means a faster animation (does NOT affect the movespeed).
    most likely you will not need to change this because the animation speed is automatically increased if a graphic has a lot of frames

compatibility:
  - most likely not compatible with other movement systems and scripts that change charactergraphic

script & demo:
Script as a ".txt" file
Demo Project

edit: I had to remove the script because it was too long... you can copy it from the demo project or download it as a .txt file

Basically, this script reads filenames to determine how many frames/directions a sprite has. If it has no special filename text, it plays like a normal 4x4 grid sprite. It has an option for 8-directional movement, which I will probably not be using.

What I would like, is when the player holds down a key (say, shift), the character will go from walking at Speed 4 to walking at Speed 5. Simple stuff.

However, I want the sprite graphic to change to a "dash" sprite. Additionally, if the character stops moving, even if the Sprint key/button is depressed, it will go back to the Idle stance. That may be less feasible, but it looks so crappy to have the character leaning into a run when they're facing a wall going nowhere :P

I don't want it to be necessary to have the Sprint animation! My hero character will end up with ~60 sprites only for them (expressions, actions, etc), and I don't want retarded Dash equivalents for every stinkin' one :P. Also, I need it to be able to be turned on or off at my will (through events).

---------------

IN SUMMARY

Puck's sprite system. Character has an Idle and a Walking Animation. Idle when they stop.
Player presses Shift.
If player is moving, sprite set changes to Sprint version.
If player is not moving, it goes to Idle, regardless of the key pressed.
When player lets go of Shift, sprite reverts to Walking Animation/Idle combo.
It is not necessary to have the Dash Sprite for every sprite.
Dash capabilities can be turned off at my will (with events).


Let me know how possible this is.
 
Double posting but whatever... Insert below the script above.

Code:
module Dash
  Version       = ['May 6th, 2008: 1:10am GMT-6:00', 0.9]
  Dash_Button   = Input::SHIFT
  Dash_Speed    = 5
  Sprite_Suffix = '_dash'
  Switch        = 1
end

class Game_Character
  def is_dashing?
    return @dashing
  end
  def start_dashing(speed = Dash::Dash_Speed)
    @pre_dash_speed = @move_speed
    @move_speed = speed
    @dashing = true
  end
  def stop_dashing
    @move_speed = @pre_dash_speed
    @dashing = false
  end
end

class Game_Player
  alias_method :seph_dashsprite_gmplyr_update, :update
  alias_method :seph_dashsprite_gmplyr_cn,     :character_name
  def character_name
    n = seph_dashsprite_gmplyr_cn.dup
    if moving? && is_dashing?
      begin
        RPG::Cache.character(n + Dash::Sprite_Suffix, hue)
        n += Dash::Sprite_Suffix
      rescue
        # no sprite found
      end
    end
    return n
  end
  def update
    if $game_switches[Dash::Switch]
      if Input.press?(Dash::Dash_Button) && is_dashing? == false
        start_dashing
      elsif is_dashing? && Input.press?(Dash::Dash_Button) == false
        stop_dashing
      end
    end
    seph_dashsprite_gmplyr_update
  end
end

Ok. I haven't tested it, but it should work. Just edit this:
Code:
  Dash_Button   = Input::SHIFT
  Dash_Speed    = 5
  Sprite_Suffix = '_dash'
  Switch        = 1

Dash button is just the input button. I have it set to shift like you asked. Speed is the speed which is set for 5. The suffix goes at the end of your filename. So 001-Character01_dash or whatever it is. Switch is whatever switch must be on to use the dash feature. Just make sure you don't turn the switch on while the player is dashing. I could make sure this never happens, but I am lazy and I doubt it will be a problem.

If the file isn't found, it just won't change spriteset.

That should do the trick. Let me know if you have any problems.
 
I wasn't able to test it last night because I got my new processor and all my new fans + heatsync but I will have a compy tonight to test :3

and boys don't fight over me ... although sixty ... seph DID beat you to the punch by buying the cow insteada just hogging all the milk! :O
 
Hey I don't have much time to type because I have a friend over, but the script isn't really working. I mean, the game doesn't crash or anything, but when I insert this as a new script under the other scripts for the movement system, and turn on Switch 1 in the game, and I have a character graphic in there labeled with the filename+"_dash", nothing happens when I press Shift and move. :/

edit: it doesn't work when I plug it into an empty game either (that has puck's script)
 

khmp

Sponsor

Code:
class Game_Character
  alias_method :seph_dashsprite_gmchar_initialize, :initialize
  def initialize
    seph_dashsprite_gmchar_initialize
    @dashing = false
  end
  def is_dashing?
    return @dashing
  end
  def start_dashing(speed = Dash::Dash_Speed)
    @pre_dash_speed = @move_speed
    @move_speed = speed
    @dashing = true
  end
  def stop_dashing
    @move_speed = @pre_dash_speed
    @dashing = false
  end
end

Replace the game_character he gave you with this one. I think it should work then. Or at least the character runs around.

Good luck with it Venetia! :thumb:
 

khmp

Sponsor

I think the problem Mr. SephirothSpawn is that there is no initialize of @dashing to anything. So it stays nil, which if put into a conditional will always be false even if you are checking it against false.

Code:
@dashing = nil
if @dashing == false || @dashing == true
  p 'test' # I will never print
end

I just threw in the initialize of Game_Character to set @dashing to false.
 
@khmp: That works now, except it still doesn't change the sprite set.

http://pixelcocktail.com/hosted_items/P ... Frames.zip

There's a link to the demo Puck made with the script you made (+khmp's addition).
The main character's sprite graphic comes with an image file labeled with the "_dash", which is a bright red version, so you'll know. As you can see, after you talk to the little dude to turn on Switch 1, you can walk faster with Shift, but the sprite doesn't change. :/

edit: oops, wait, khmp posted something, lemme test
 
I lol'd.

I forgot. I used hue instead of @character_hue. So it never added the '_dash' because it always errored.

This should work:
Code:
module Dash
  Version       = ['May 7th, 2008: 10:31am GMT-6:00', 1.0]
  Dash_Button   = Input::SHIFT
  Dash_Speed    = 5
  Sprite_Suffix = '_dash'
  Switch        = 1
end

class Game_Character
  alias_method :seph_dashsprite_gmchar_initialize, :initialize
  def initialize
    seph_dashsprite_gmchar_initialize
    @dashing = false
  end
  def is_dashing?
    return @dashing
  end
  def start_dashing(speed = Dash::Dash_Speed)
    @pre_dash_speed = @move_speed
    @move_speed = speed
    @dashing = true
  end
  def stop_dashing
    @move_speed = @pre_dash_speed
    @dashing = false
  end
end

class Game_Player
  alias_method :seph_dashsprite_gmplyr_update, :update
  alias_method :seph_dashsprite_gmplyr_cn,     :character_name
  def character_name
    n = seph_dashsprite_gmplyr_cn.dup
    if moving? && is_dashing?
      begin
        RPG::Cache.character(n + Dash::Sprite_Suffix, @character_hue)
        n += Dash::Sprite_Suffix
      rescue
        # no sprite found
      end
    end
    return n
  end
  def update
    if $game_switches[Dash::Switch]
      if Input.press?(Dash::Dash_Button) && is_dashing? == false
        start_dashing
      elsif is_dashing? && Input.press?(Dash::Dash_Button) == false
        stop_dashing
      end
    end
    seph_dashsprite_gmplyr_update
  end
end
 
Status
Not open for further replies.

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