file Disabling Diagonal Movement

  • Posts: 321
  • Thank you received: 10
30 Mar 2013 17:54 #31
Well since maxRollVelocity isn't an absolute limit, but a value that is multiplied by input, airAcceleration probably is too. If you move ~1.4 times faster in the air, and you spend most of a level jumping....

Please Log in or Create an account to join the conversation.

  • FruBlox
  • FruBlox's Avatar Topic Author
  • Offline
  • Experienced Marbler
  • Experienced Marbler
  • Posts: 155
  • Thank you received: 2
30 Mar 2013 19:31 #32
Mar 30, 2013, 4:13am, admin wrote:If diagonal and normal movement are the same now then jumping does not matter, nor should any other value in marble.cs because you've limited the speed.

You can test better by going jumping forwards vs. jumping diagonally and check for differences and then better test for those.

If your goal was to have diagonal = forwards only speed, then you've succeeded and replicated a MBU/O player with an unmodded xbox360 controller.
From the results I've gotten, the diagonal speed = forwards speed only when you are not jumping. If you jump whilst moving diagonally, then you move faster than if you were moving forward and jumping. In that example it suggests that moving diagonally is what is giving you the extra speed, which is what I don't want.

Please Log in or Create an account to join the conversation.

  • Posts: 533
  • Thank you received: 14
30 Mar 2013 22:48 #33
Mar 29, 2013, 10:31pm, frublox wrote:The only other one that seems to even remotely control speed is airAcceleration, but that just controls how fast the marble moves whilst in the air. I should note that if you do not jump with this mod enabled, diagonal movement and normal movement are almost the exact same. Perhaps I'll play with that and see what I get.I looked at some posts on another thread and found some more marble settings. I modified a few of them by a factor of 1/sqrt(2) (I also put everything to 4 dp) and I got a diagonal movement closer to forward movement. I made further modifications using the settings and I got a configuration that gets ~2.56 on the Time Trial TM while going diagonally, but the final time of the marble is still different (so there's some sort of acceleration difference). I can't post the code now since my laptop is out of battery and I left the charger at school yesterday (I can't get it back until next Monday).

airAcceleration is new to me, have you tried changing that? Constant jumping essentially implies the marble is in the air almost all the time.

A time can be beaten, but a path can't be rediscovered. The best path stays forever.

Please Log in or Create an account to join the conversation.

  • FruBlox
  • FruBlox's Avatar Topic Author
  • Offline
  • Experienced Marbler
  • Experienced Marbler
  • Posts: 155
  • Thank you received: 2
30 Mar 2013 23:15 #34
Mar 30, 2013, 3:48pm, imacmatician wrote:
Mar 29, 2013, 10:31pm, frublox wrote:The only other one that seems to even remotely control speed is airAcceleration, but that just controls how fast the marble moves whilst in the air. I should note that if you do not jump with this mod enabled, diagonal movement and normal movement are almost the exact same. Perhaps I'll play with that and see what I get.I looked at some posts on another thread and found some more marble settings. I modified a few of them by a factor of 1/sqrt(2) (I also put everything to 4 dp) and I got a diagonal movement closer to forward movement. I made further modifications using the settings and I got a configuration that gets ~2.56 on the Time Trial TM while going diagonally, but the final time of the marble is still different (so there's some sort of acceleration difference). I can't post the code now since my laptop is out of battery and I left the charger at school yesterday (I can't get it back until next Monday).

airAcceleration is new to me, have you tried changing that? Constant jumping essentially implies the marble is in the air almost all the time.
Can you list the values you changed? From what I've seen, I haven't found any other values that would be relevant to marble speed/acceleration.

If anyone wants to try what I did for maxRollVelocity and angularAcceleration, use the value 3.5355339059327376220042218105242 (approximate, and you can probably do without that many decimal places) for airAcceleration. I'll try this and update accordingly.

UPDATE: This actually seems to work! Jumping made neither diagonal movement nor normal movement faster. Adding this to the code in the first post.

Please Log in or Create an account to join the conversation.

  • Jeff
  • Jeff's Avatar
  • Offline
  • Elite Marbler
  • Elite Marbler
  • PlatinumQuest Programmer
  • Posts: 1680
  • Thank you received: 205
31 Mar 2013 01:16 #35
Note guys that the airAcceleration static (tagged fields) field only takes affect whenever the marble is not colliding with something. Just wanted to clarify that, which hopefully you guys knew.

Just for your knowledge (because I am a geek and you know it!)

Tagged (Static) Fields are those that are callbacks to the engine.

Dynamic Fields are those that are only script related fields.

I am a programmer. Most here know me for being one of the major contributors to Marble Blast Platinum and PlatinumQuest.

Please Log in or Create an account to join the conversation.

  • FruBlox
  • FruBlox's Avatar Topic Author
  • Offline
  • Experienced Marbler
  • Experienced Marbler
  • Posts: 155
  • Thank you received: 2
31 Mar 2013 01:19 #36
Mar 30, 2013, 6:16pm, jeff wrote:Note guys that the airAcceleration static (tagged fields) field only takes affect whenever the marble is not colliding with something. Just wanted to clarify that, which hopefully you guys knew.

Just for your knowledge (because I am a geek and you know it!)

Tagged (Static) Fields are those that are callbacks to the engine.

Dynamic Fields are those that are only script related fields.
I kind of guessed that.

Either way the code will work in any circumstance the marble is in (that I have tested). If anyone has problems, let me know.

Please Log in or Create an account to join the conversation.

  • Posts: 533
  • Thank you received: 14
02 Apr 2013 15:40 #37
Tested it in a number of places, there are no problems as far as I am aware.

A time can be beaten, but a path can't be rediscovered. The best path stays forever.

Please Log in or Create an account to join the conversation.

  • FruBlox
  • FruBlox's Avatar Topic Author
  • Offline
  • Experienced Marbler
  • Experienced Marbler
  • Posts: 155
  • Thank you received: 2
02 Apr 2013 22:04 #38
Apr 2, 2013, 8:40am, imacmatician wrote:Tested it in a number of places, there are no problems as far as I am aware.

I think it would be interesting to play with this feature as a sort of handicap (like no jumping, for instance).

Please Log in or Create an account to join the conversation.

  • Jeff
  • Jeff's Avatar
  • Offline
  • Elite Marbler
  • Elite Marbler
  • PlatinumQuest Programmer
  • Posts: 1680
  • Thank you received: 205
02 Apr 2013 22:18 #39
Yeah that would be pretty neat to play with. And of course disabling jumping would be so easy, just have a global variable that stops jumping lol.

I am a programmer. Most here know me for being one of the major contributors to Marble Blast Platinum and PlatinumQuest.

Please Log in or Create an account to join the conversation.

  • Posts: 533
  • Thank you received: 14
03 Apr 2013 18:42 #40
Apr 2, 2013, 3:04pm, frublox wrote:
Apr 2, 2013, 8:40am, imacmatician wrote:Tested it in a number of places, there are no problems as far as I am aware.

I think it would be interesting to play with this feature as a sort of handicap (like no jumping, for instance). I'm going to make a video to be released either in 1-2 weeks or sometime next month (most likely the latter). From preliminary playing, I've found that the marble handles much differently from normal play. When playing normally, one use diagonal movement every time two movement keys are pressed at once, even if one is not specifically moving diagonally for a significant duration. That can happen when turning, when stopping, or even when changing direction without camera movement.

I also enjoyed testing this code and figuring out what the different values do to the marble. I think I'll go into some coding in the near future, it sounds like a good idea for me.

A time can be beaten, but a path can't be rediscovered. The best path stays forever.

Please Log in or Create an account to join the conversation.

  • Jeff
  • Jeff's Avatar
  • Offline
  • Elite Marbler
  • Elite Marbler
  • PlatinumQuest Programmer
  • Posts: 1680
  • Thank you received: 205
03 Apr 2013 21:00 #41
^ programming is a good thing to learn ( slightly biased opinion from me much, eh? )

It is like solving a big puzzle, except it never ends....:c

I am a programmer. Most here know me for being one of the major contributors to Marble Blast Platinum and PlatinumQuest.

Please Log in or Create an account to join the conversation.

  • FruBlox
  • FruBlox's Avatar Topic Author
  • Offline
  • Experienced Marbler
  • Experienced Marbler
  • Posts: 155
  • Thank you received: 2
03 Apr 2013 22:07 #42
Apr 3, 2013, 2:00pm, jeff wrote:^ programming is a good thing to learn ( slightly biased opinion from me much, eh? )

It is like solving a big puzzle, except it never ends....:c
Programming isn't the puzzle, debugging is. (IMO)


Apr 3, 2013, 11:42am, imacmatician wrote:
Apr 2, 2013, 3:04pm, frublox wrote:

I think it would be interesting to play with this feature as a sort of handicap (like no jumping, for instance). I'm going to make a video to be released either in 1-2 weeks or sometime next month (most likely the latter). From preliminary playing, I've found that the marble handles much differently from normal play. When playing normally, one use diagonal movement every time two movement keys are pressed at once, even if one is not specifically moving diagonally for a significant duration. That can happen when turning, when stopping, or even when changing direction without camera movement.

I also enjoyed testing this code and figuring out what the different values do to the marble. I think I'll go into some coding in the near future, it sounds like a good idea for me.
It doesn't occur when just any two movement keys are pressed -- just the ones that allow the player to use diagonal movement. Pressing W and S together doesn't cause the changes for diagonal movement, and neither does pressing A and D.

Anyway, I'm looking forward to seeing your video. It'll be a real test of this code.

Please Log in or Create an account to join the conversation.

  • dobrakmato
  • dobrakmato's Avatar
  • Offline
  • Experienced Marbler
  • Experienced Marbler
  • Posts: 134
  • Thank you received: 0
19 Apr 2013 19:55 #43
Nice, but to optimize code, you have to check for diagonal movement only in two cases.

Since the diagonal movement is based on pressing two keys, you shoud check only for moveleft and moveright or moveforward and movebackward.

Please Log in or Create an account to join the conversation.

  • FruBlox
  • FruBlox's Avatar Topic Author
  • Offline
  • Experienced Marbler
  • Experienced Marbler
  • Posts: 155
  • Thank you received: 2
20 Apr 2013 16:55 #44
Apr 19, 2013, 12:55pm, dobrakmato wrote:Nice, but to optimize code, you have to check for diagonal movement only in two cases.

Since the diagonal movement is based on pressing two keys, you shoud check only for moveleft and moveright or moveforward and movebackward.

I specifically left out checking those key combinations because they don't cause diagonal movement. Pressing forward and backward together doesn't even move the marble, nor does pressing left and right.

Please Log in or Create an account to join the conversation.

  • Posts: 321
  • Thank you received: 10
20 Apr 2013 19:02 #45
I think that what Mato means is that you only need to check isMovingDiagonally() in 2 of your movement functions, not all 4. You will always be pressing either left or right when moving diagonally, so you can remove the if statements from forward and back. Or you could remove the if statements from right and left, same effect. Probably makes more sense to remove it from forward and back because they are (most likely) used more.

Currently you are checking isMovingDiagonally() twice every time 2 buttons are pressed at once, and if it returns true changing the values twice as well (to the same thing).

It didn't even occur to me until Mato mentioned it.

Please Log in or Create an account to join the conversation.

  • Jeff
  • Jeff's Avatar
  • Offline
  • Elite Marbler
  • Elite Marbler
  • PlatinumQuest Programmer
  • Posts: 1680
  • Thank you received: 205
20 Apr 2013 20:09 #46
@Don.Gato and Mato - makes sense to me, as it is redundant to check them twice.

@Frublox, i suggest you change what they said, keep the left/right keys checking,but restore the forwards/backwards keys to the original.

I am a programmer. Most here know me for being one of the major contributors to Marble Blast Platinum and PlatinumQuest.

Please Log in or Create an account to join the conversation.

  • FruBlox
  • FruBlox's Avatar Topic Author
  • Offline
  • Experienced Marbler
  • Experienced Marbler
  • Posts: 155
  • Thank you received: 2
20 Apr 2013 23:58 #47
Well, that makes a lot more sense than what I thought he meant.

I'll change it now.

Please Log in or Create an account to join the conversation.

  • whirligig
  • whirligig's Avatar
  • Offline
  • Professional Marbler
  • Professional Marbler
  • Posts: 444
  • Thank you received: 261
15 Jun 2013 03:05 #48
Code:function isMovingDiagonally()
{
if (($mvLeftAction && $mvForwardAction) || ($mvRightAction && $mvForwardAction) || ($mvLeftAction && $mvBackwardAction) || ($mvRightAction && $mvBackwardAction))
return true;
}

a) You aren't returning anything if the test fails; in TS this probably returns an empty string, but this would cause crashes in other languages, and it's not good practice anyway.
b) if (x) return true; else return false; is equivalent to just saying return x;. In other words, there's no reason to have an if test if you're just returning a simple boolean expression.
c) This can be simplified even further by taking advantage of the fact that TS and many other languages use 0 and 1 to represent boolean true and false, so you can treat them as numbers.

Here's a revised isMovingDiagonally() accounting for the above:

Code:function isMovingDiagonally()
{
return ($mvForwardAction + $mvBackwardAction + $mvLeftAction + $mvRightAction == 2);
}

This code has slightly different behavior in three ways:

-If you press three keys at once, it will register as normal movement, while the original would register this as diagonal. This is a desirable change, as pressing three keys ends up equating to normal movement, not diagonal movement.
-If you press two opposing keys, however, it will register as diagonal movement. This isn't desired, but it won't matter, because here the marble isn't accelerating.
-The biggest issue is that this code fails if you're using anything but key presses—anything that uses moveXAxis and moveYAxis will cause this code to give false negatives. However, this isn't a terrible issue, as you'd probably want separate joystick code anyway.

Also, my intuition tells me that maxRollVelocity shouldn't need to change, but Don.Gato just said otherwise, which I find odd.

Please Log in or Create an account to join the conversation.

  • FruBlox
  • FruBlox's Avatar Topic Author
  • Offline
  • Experienced Marbler
  • Experienced Marbler
  • Posts: 155
  • Thank you received: 2
19 Jun 2013 18:46 #49
Thanks for the revision, whirligig (most of my code isn't that efficient since I always forget to revise it). I'll update the code in the first post.

As for moveXAxis and moveYAxis, I've yet to experiment with them. Perhaps by using them it's possible to achieve disabled diagonal movement for the keyboard and joysticks simultaneously.

For maxRollVelocity, I still need to do some testing to see which variables actually play a role in capping diagonal movement. Then I can see if perhaps you're right about it not needing to change.

Please Log in or Create an account to join the conversation.

Moderators: Doomblah
Time to create page: 2.184 seconds