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.

[SOLVED]45 Degree Turning Issue...

With help from some other scripters, I've modified the movement system to use WASD and axle based turning... (Old help topic.) However, since then I've stopped using Pixelmovement (It was interfering with my mouse movement script), and for some reason I'm no longer able to use my turn_left_45 and turn_right_45 functions. However, I'm not sure if that's the cause or not because I can no longer find Cogwheel's Pixelmovement script to test with in a new project. It dosen't seem like it would make any difference, but even so, I can't find anything wrong with my script. The only scripts it should require are the SDK and AWorks' Input Module. If someone could help me, I'd REALLY appreciate it. I've included my script and links to the SDK and AIM topics below. (AIM need's a .dll)

SDK
AWorks' Input Module

My Script:
Code:
#===============================================================================

# Sorry there's like NO comments... The part not involing movement isn't mine,

# and I was too lazy to comment everything else because I didn't think others

# would ever be needing to read it. >_>

#===============================================================================

 

class Game_Character

 

  def move_lower_left

    unless @direction_fix

      @direction = 1

    end

    if passable?(@x, @y, 1)

      @x -= 1

      @y += 1

      increase_steps

    end

  end

#-------------------------------------------------------------------------------

  def move_lower_right

    unless @direction_fix

      @direction = 3

    end

    if passable?(@x, @y, 3)

      @x += 1

      @y += 1

      increase_steps

    end

  end

#-------------------------------------------------------------------------------

  def move_upper_left

    unless @direction_fix

      @direction = 7

    end

    if passable?(@x, @y, 7)

      @x -= 1

      @y -= 1

      increase_steps

    end

  end

#-------------------------------------------------------------------------------

  def move_upper_right

    unless @direction_fix

      @direction = 9

    end

    if passable?(@x, @y, 9)

      @x += 1

      @y -= 1

      increase_steps

    end

  end

#-------------------------------------------------------------------------------

  def turn_lower_left

    unless @direction_fix

      @direction = 1

      @stop_count = 0

    end

  end

#-------------------------------------------------------------------------------

  def turn_upper_left

    unless @direction_fix

      @direction = 7

      @stop_count = 0

    end

  end

#-------------------------------------------------------------------------------

  def turn_lower_right

    unless @direction_fix

      @direction = 3

      @stop_count = 0

    end

  end

#-------------------------------------------------------------------------------

  def turn_upper_right

    unless @direction_fix

      @direction = 9

      @stop_count = 0

    end

  end

#-------------------------------------------------------------------------------

  def turn_right_45

    case @direciton

    when 1

      turn_left

    when 2

      turn_lower_left

    when 3

      turn_down

    when 6

      turn_lower_right

    when 9

      turn_right

    when 8

      turn_upper_right

    when 7

      turn_up

    when 4

      turn_upper_ight

    end

  end

#-------------------------------------------------------------------------------

  def turn_left_45

    case @direciton

    when 1

      turn_down

    when 2

      turn_lower_right

    when 3

      turn_right

    when 6

      turn_upper_right

    when 9

      turn_up

    when 8

      turn_upper_left

    when 7

      turn_left

    when 4

      turn_lower_left

    end

  end

end

#===============================================================================

 

class Sprite_Character

 

  def update

    super

    if @tile_id != @character.tile_id or

       @character_name != @character.character_name or

       @character_hue != @character.character_hue

      @tile_id = @character.tile_id

      @character_name = @character.character_name

      @character_hue = @character.character_hue

      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

      else

        self.bitmap = RPG::Cache.character(@character.character_name,

          @character.character_hue)

        @cw = bitmap.width / 4

        @ch = bitmap.height / 8

        self.ox = @cw / 2

        self.oy = @ch

      end

    end

    self.visible = (not @character.transparent)

    if @tile_id == 0

      sx = @character.pattern * @cw

      case @character.direction

      when 1

        sy = 0

      when 2

        sy = 1 * @ch

      when 3

        sy = 2 * @ch

      when 4

        sy = 3 * @ch

      when 6

        sy = 4 * @ch

      when 7

        sy = 5 * @ch

      when 8

        sy = 6 * @ch

      when 9

        sy = 7 * @ch

      end

      self.src_rect.set(sx, sy, @cw, @ch)

    end

    self.x = @character.screen_x

    self.y = @character.screen_y

    self.z = @character.screen_z(@ch)

    self.opacity = @character.opacity

    self.blend_type = @character.blend_type

    self.bush_depth = @character.bush_depth

    if @character.animation_id != 0

      animation = $data_animations[@character.animation_id]

      animation(animation, true)

      @character.animation_id = 0

    end

  end

end

#===============================================================================

 

class Game_Player

 

  def update_player_movement

    move_forward if Input.press?(Keys::W)

    turn_left_45 if Input.press?(Keys::A)

    move_backward if Input.press?(Keys::S)

    turn_right_45 if Input.press?(Keys::D)

  end

end
EDIT: I just noticed that I left the modifications to the sprites in there... Not sure if they're part of the problem or not, so I'll keep it just in case. And, again... Sorry for the uncommented code. >_>
 
lol, it's not that big issue, there's just a spelling mistake in case @direction, but it also took me some time to realize^^

your next problem will be, that your turning too fast, you hit A once, but turn 3-4 times to the left... try to make a wait count to prevent this ;)

keep it up ^^

ahh, and at turn_right_45, at when 4 there has to stand turn_upper_left ;)
 
~facepalms~ Omg... A spelling error... 3 of them, now that i've looked over it again...
Never had that issue before. I guess there's a first for everything. Thanks so much. (Again)

As for the turn speed, that's another thing I didn't notice... But, I can solve that by switching the "A" and "D" keys to triggers instead of presses. :biggrin:

EDIT: And, after fixing and testing, I'm gonna have to modify move_forward as well... lol, damn thing dosen't know what to do when facing diagonals. But hey, that's what tests are for. Again, ty so much. I can't believe it was a mere spelling mistake. >_>
 

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