-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Driving Backwards #95
Conversation
Thanks, I will review it! I would implement in this way: The train stores every overdriven signal in an array. If the train detects a signal in front, which is stored in this array, the train should turn that signal status to 1. |
Okay, here is a short summary on how I implemented it:
Looks like Oh and I didn't yet check if you can drive past a station, then reverse into it and still service it. I think the game tells you "you drove past a station, go to the next one". So we would probably need to reset the station when reversing into it. |
Very nice and clean code! At newer contributions I try to respect the following code guidelines: https://www.gdquest.com/docs/guidelines/best-practices/godot-gdscript/ Could you please explain me the difference between |
Oh, of course. I can do a bit of refactoring to follow the code guidelines, no problem. :) Oh, |
Okay, yeah, good Idea! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code is okay in general 👍
I tested it on Hainfurt now and also had the AI and Autopilot problems, that is fixed now :) I will look into signals being handled too early now 👍 |
Signals should no longer trigger early. This was indeed due to wrong initial distanceOnRoute, if |
Why did you made the reverse state global? :) |
Because it is accessed from multiple files, not just in Player.gd, and it's nicer to just write |
I have now refactored the Station logic, which makes it easier to read and understand, and I've also changed it a little. The station now only counts as missed if the whole train went past the station. ( Just like when the end of train is not yet in the station, when the train drives past the station a bit, Also fixed a bug where people got out of the train when the player passed the station signal and opened the doors, but the train was not yet fully in the station. (people would walk in mid air) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only did brain compilation but looks good overall. Just some style stuff
FORWARD = 1, | ||
NEUTRAL = 0, | ||
REVERSE = -1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FORWARD = 1, | |
NEUTRAL = 0, | |
REVERSE = -1 | |
FORWARD = 1, | |
NEUTRAL = 0, | |
BACKWARD = -1 |
if not forward: | ||
currentSlope = - currentSlope | ||
currentSlope = -currentSlope | ||
if reverser == ReverserState.REVERSE: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if reverser == ReverserState.REVERSE: | |
if reverser == ReverserState.BACKWARD: |
# drivenDistance = 0 - distanceOnRail | ||
change_to_next_rail() | ||
var driven_distance = speed * delta | ||
if reverser == ReverserState.REVERSE: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if reverser == ReverserState.REVERSE: | |
if reverser == ReverserState.BACKWARD: |
if distanceOnRail < 0: | ||
change_to_next_rail() | ||
var driven_distance = speed * delta | ||
if player.reverser == ReverserState.REVERSE: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if player.reverser == ReverserState.REVERSE: | |
if player.reverser == ReverserState.BACKWARD: |
forward = baked_route_direction[routeIndex] | ||
if forward and (player.reverser == ReverserState.FORWARD): | ||
distance_on_rail -= currentRail.length | ||
if not forward and (player.reverser == ReverserState.REVERSE): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if not forward and (player.reverser == ReverserState.REVERSE): | |
if not forward and (player.reverser == ReverserState.BACKWARD): |
if not forward and (player.reverser == ReverserState.REVERSE): | ||
distance_on_rail -= currentRail.length | ||
|
||
if player.reverser == ReverserState.REVERSE: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if player.reverser == ReverserState.REVERSE: | |
if player.reverser == ReverserState.BACKWARD: |
|
||
if not forward and (player.reverser == ReverserState.FORWARD): | ||
distance_on_rail += currentRail.length | ||
if forward and (player.reverser == ReverserState.REVERSE): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if forward and (player.reverser == ReverserState.REVERSE): | |
if forward and (player.reverser == ReverserState.BACKWARD): |
@HaSa1002 |
I believe, you rather drive backwards than driving reverse |
Well, in a car the "Rückwärtsgang" is the "Reverse gear", so I'd say you are driving "in reverse", rather than "backwards". |
Then it is personal preference, I guess. I have no strong opinion about that as I am not a native speaker. Both is understandable IMO. Func fact: There is a comment in your code under a |
I forgot to ask you to rename your files to |
Will do 👍 |
c50333f
to
35ec4af
Compare
|
The mobile version needs buttons for the reverser as well |
Will fix these, no problem :)
There will be #108 at some point, which might help reduce controller mappings.
This will need UI work. Don't want to overload a tiny mobile screen with more and more controls.
There are the 3 possible directions and a knob next to it (might be hard to see, the cabin lighting is awfully dark) that points to the selected direction. This will be useful for #108.
This is a but of a weird one. Yes, R being above F, you'd think that R goes forward and F goes backwards, but also Reverse and Forward. So I'm not sure which is less confusing 😅 |
I think #108 will fix that, but not the controller stuff, as you don't want to use a cursor through a controller. I am thinking about a radial or quick slot menu. |
I think #108 will work fine on controllers. I was thinking of doing it like TSW2 (they have an xbox version on which this works fine): you don't enable the mouse cursor and move that around, rather you have a little "crosshair" in the center of your screen and whatever control is below that gets selected. When you press the interact button, the view gets locked and moving the view stick / mouse around then moves the control. On a mobile, of course you could do all that with your finger. I am not opposed at all to a radial menu though, that is actually a really good idea! Even for PC. |
About the mobile HUD, I've just had an idea:
And then while driving:
Basically making the arrows choose the direction you want to go in. |
Co-authored-by: Johannes Witt <johawitt@outlook.de>
f36234c
to
0aa2daa
Compare
I would say this merge request is done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't close the doors via controller anymore, but not a blocker since we need to rework controller input anyhow.
LGTM.
You should still be able to close the doors. I changed to behaviour so that when you press "doors right" and the doors are already open, they will then close. |
A good to know. But yeah not a problem really, as it was added in this dev version |
Implement driving backwards. Solves #77.
There are quite a lot of changes to core driving logic, so you probably want to review this properly.
So far I have done some limited testing on the tutorial map, but it seemed to work fine there.
To Do:
Known issues: