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.

Faced Direction Movement and Rotation Request

Hello peoples, how are your collective days going?

Okay, this is going to sound silly because I know that by deleting some stuff I can do this with events, but honestly I can't for the life of me remember what to delete.  I'm looking to request a script that will change the way movement works - slightly.  I want "up" to move you in the direction you are facing, left to turn you 90 degrees left, and right to turn you 90 degrees right.  Pressing down should switch you 180 degrees.

So if your at 9,9, and you press anything but "up", you're still in the same location, just the direction your facing changed.

I got a real easy common event that would work if I knew what to delete... but I can't remember.  So either someone'll help me out and lemme know, come up and go "here you go :D" with something else that'll work, or I'll be ignored and be sad :(... don't make your favorite admin sad now :p

Have a good one

P.S. if you couldn't tell by the topic icon, I'm requesting this for RMXP.  Have a good one.
 
You could go into Game_Player and replace
Code:
case Input.dir4
when 2
  move_down
when 4
  move_left
when 6
  move_right
when 8
  move_up
end
with:
Code:
if Input.trigger?(Input::DOWN)
  turn_180
elsif Input.trigger?(Input::LEFT)
  turn_left_90
elsif Input.trigger?(Input::RIGHT)
  turn_right_90
elsif Input.press?(Input::UP)
  move_forward
end
It works alright-ish...it's not incredibly smooth though, and doesn't account for 2 directions at the same time
 
There ya go.
Code:
class Game_Player < Game_Character
  def move_up(*args)
    move_forward
  end
  def move_left(*args)
    turn_left_90
  end
  def move_right(*args)
    turn_right_90
  end
  def move_down(*args)
    turn_180
  end
end

It will work only for the player, but if you want it to work for both player and events, just change the first line for: class Game_Character

I didn't had the time to test the script so if there's something wrong with, feel free to complain! ;)

EDIT: I totally forgot about the turn_90/180 feature... gotta change that.
 
I tried that approach first, problem is, due to the nature of how it checks for inputs (it uses Input.press?) as soon as you try to turn, it starts spinning on the spot 20 times per second(i.e. once every frame)
 
Dammit, I knew I did it too fast. You get a stack error because move_forward uses move_up when you're facing up. So, move_up uses move_forward which uses move_up. Then the script goes like: WTF, my head will exploooode!

So i guess you're method is the best for now. I personally hate to rewrite the default scripts like that but if sixty don't care about it, I'd say go for this one.
 
Actually I didn't even notice this conversation, I was having fun with Beran's method :eek:

It doesn't mother me to rewrite, since this is a fairly low script project.  Only the player moves, and there's really nothing this is going to conflict with, or even cause an issue with from my testing.

Thanks to Beran, and thanks Dargor too :)
 

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