-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Make three strike battle any other strike battle and add an option to steal tires #5307
base: master
Are you sure you want to change the base?
Conversation
src/modes/three_strikes_battle.cpp
Outdated
lerp_time = float(m_kart_info[id].m_lives-1)/float(UserConfigParams::m_ffa_time_limit); | ||
int lerp_lower = floor(lerp_time*gradientLength); | ||
|
||
color = video::SColor(255, lerp(redGradient[lerp_lower+1],redGradient[lerp_lower+2],lerp_time*gradientLength-lerp_lower), lerp(greenGradient[lerp_lower+1],greenGradient[lerp_lower+2],lerp_time*gradientLength-lerp_lower), lerp(blueGradient[lerp_lower+1],blueGradient[lerp_lower+2],lerp_time*gradientLength-lerp_lower)); |
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.
For readability, please don't use lines that are that long, and use spaces around operators, after commas, etc. (not just here).
Regarding this particular line, it might be better to introduce an auxiliary function to find the color to not retype the same code three times for three gradient arrays, especially because it's used in another place.
|
||
m_tire_stealing->setVisible(!UserConfigParams::m_use_ffa_mode); | ||
getWidget<LabelWidget>("tire-stealing-text")->setVisible(!UserConfigParams::m_use_ffa_mode); | ||
getWidget<LabelWidget>("tire-stealing-text")->setText(_("Steal tires"), false); |
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.
Each tab → 4 spaces
src/modes/three_strikes_battle.hpp
Outdated
// ------------------------------------------------------------------------ | ||
const int redGradient[12] = {30, 64, 255, 255, 255, 128, 0, 0, 0, 0, 0, 0}; | ||
// ------------------------------------------------------------------------ | ||
const int greenGradient[12] = {0, 0, 0, 128, 255, 255, 255, 128, 255, 128, 0, 0}; |
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.
These arrays are used in the implementation only, it might be better to move them to .cpp into e.g. anonymous namespace
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 style is alright now I suppose.
src/modes/three_strikes_battle.cpp
Outdated
{ | ||
int redVal = lerp(redGradient[lerp_index + 1], redGradient[lerp_index + 2], lerp_time); | ||
int greenVal = lerp(greenGradient[lerp_index + 1], greenGradient[lerp_index + 2], lerp_time); | ||
int blueVal = lerp(blueGradient[lerp_index + 1], blueGradient[lerp_index + 2], lerp_time); |
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.
This could be a separate function on an array/vector to invoke three times, but I suppose at this point it's kinda ok already.
im not sure if its just me but the colors feel alright to me, yes, they're darker, but i think it's still quite distinguishable - at least for me, which is why im going to do something about it. should be just a small change to the gradient values. as for the tires, i checked it and theres quite some more related bugs i need to fix and for using the spare tire karts to get over the initial amount of lives i just kinda forgot when i was modifying that code edit: i looked it up and the funny colors are because of sampling the gradient outside of range, which is apparently not recomended, so i will fix that |
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.
Other than these, the code seems fine. Colors are better, I'm not sure I like the changing colors over max value, but I'll let developers decide.
{ | ||
if (r) | ||
r->addMessage(_("You can have at most 3 lives!"), k, 2.0f); | ||
r->addMessage(_("You can't go over the starting amount!"), k, 2.0f); |
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 have at most %d lives!")
might be better to not involve many changes for translation, but I'm not exactly sure because it would involve plural forms of the word life
. At the very least, "over the starting amount" implies question "amount of what?" for me, though I'm not a native speaker.
Please consult any Transifex expert among the developers before editing.
src/modes/three_strikes_battle.cpp
Outdated
lerp_time = float(m_kart_info[id].m_lives-1)/float(UserConfigParams::m_ffa_time_limit); | ||
int lerp_lower = floor(lerp_time*gradientLength); | ||
|
||
color = color = calculateColor(lerp_lower % (gradientLength + 2), lerp_time * gradientLength - lerp_lower); |
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.
repeated color =
src/modes/three_strikes_battle.cpp
Outdated
/* Must be 3 lower than the length of the array so it doesn't | ||
and so that it connects once you get more lives than the starting amount. | ||
The first and last items in the array must be the same.*/ | ||
const int gradientLength = 9; |
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 don't have to justify why 9 is 12 minus 3 if you just define arrays using it:
const int GRADIENT_LENGTH = 9;
const int redGradient[GRADIENT_LENGTH + 3] = {....} ...
Or maybe just using vectors and not bothering about sizes is fine...
int greenVal = lerp(greenGradient[lerp_index], greenGradient[lerp_index + 1], lerp_time); | ||
int blueVal = lerp(blueGradient[lerp_index], blueGradient[lerp_index + 1], lerp_time); | ||
return video::SColor(255, redVal, greenVal, blueVal); | ||
} |
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.
This function is called twice in two different ifs, those ifs seem identical and related only to the color logic, and not to the game mode itself. Pass the current and the maximum number of lives to this function, and let it do all the transformations with lerp_***
inside. Don't forget to put spaces around operators -*/
.
lerp is still repeated three times. Please move it into a separate function or lambda, e.g. return video::SColor(255, f(redGradient), f(greenGradient), f(blueGradient))
with
auto f = [=](const int* a) -> int {
return lerp(a[lerp_index], a[lerp_index + 1], new_lerp_time);
};
src/modes/three_strikes_battle.cpp
Outdated
case 0: | ||
color = video::SColor(255, 128, 128, 128); | ||
break; | ||
color = video::SColor(128,128,128,0); |
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.
Is this an intentionally semi-transparent yellow, or it should have been video::SColor(255, 128, 128, 128);
?
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 think i wrote that piece of code before noticing the alpha is the first parameter
(although that doesnt explain the 0)
{ | ||
if (r) | ||
r->addMessage(_("You can have at most 3 lives!"), k, 2.0f); | ||
r->addMessage(_("You can have at most %d lives!"), k, 2.0f); |
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'm not an expert but I suppose this would need a pluralized form. Wait until someone else's feedback please.
Description
adds a spinner widget (or rather, repurposes an existing one) and a checkbox
Issues
i made a mistake by not creating a branch until i already coded all of that in a couple of days ago.
even though i have checked all the modifications to see if i had accidentally removed something please check again just in case.
Agreement