Tue Jan 10, 2017 11:48 pm
Wed Jan 11, 2017 9:04 pm
IPaulasaurus wrote:Dude, I want this shiny chance program! That is really cool. I just got my shiny charm on Sun. So that'd be helpful
Wed Jan 11, 2017 9:07 pm
Sorunome wrote:I'm sorry it took so long to reply. I'm a bit confused right now as to what you are mean, would you mind posting your entire code that you are running currently?
Thu Jan 12, 2017 3:52 pm
Sorunome wrote:I'm sorry it took so long to reply. I'm a bit confused right now as to what you are mean, would you mind posting your entire code that you are running currently?
//imports the SPI library (needed to communicate with Gamebuino's screen)
#include <SPI.h>
//importe the Gamebuino library
#include <Gamebuino.h>
//creates a Gamebuino object named gb
Gamebuino gb;
//declare all the variables needed for the game :
int chain = 1;
float chance = 0;
int fchain = 1;
void setup() {
// put your setup code here, to run once:
// initialize the Gamebuino object
gb.begin();
// show the start menu
gb.titleScreen(F("Shiny Probability"));
//random values
pinMode(chain, OUTPUT);
}
void reCalcChance() {
if (chain <= 69) {
chance = chain / 4096.0;
}
if (chain >= 70) {
chance = chain / 1024.0;
}
if (chain >= 256) {
chain = 1;
}
}
void loop() {
// put your main code here, to run repeatedly:
if (gb.update()) {
//prints Chain length on the screen
if (gb.buttons.pressed(BTN_A)) {
chain = chain ++;
fchain = fchain ++;
reCalcChance();
}
if (gb.buttons.pressed(BTN_B)) {
chain = chain --;
fchain = fchain --;
reCalcChance();
}
gb.display.print(F("Chain Length:"));
gb.display.println(fchain);
gb.display.print(F("Chance of Shiny:"));
gb.display.println(chance*100);
}
}
Thu Jan 12, 2017 4:38 pm
Thu Jan 12, 2017 7:37 pm
Sorunome wrote:You have to do just "chain++;" or "chain--;", NOT "chain = chain++;"
gb.display.print(F("Chain Length:"));
gb.display.println(fchain);
gb.display.print(F("Chance of Shiny:"));
gb.display.println(chance*100);
gb.display.print(F("Chain Length:"));
gb.display.println(fchain);
gb.display.print(F("Chance of Shiny:"));
gb.display.print(chance*100);
Thu Jan 12, 2017 8:46 pm
gb.display.print(F("Chain Length:"));
gb.display.println(fchain);
gb.display.println(F("Chance of Shiny:"));
gb.display.print(chance*100);
gb.display.print(F("Chain Length:"));
gb.display.println(fchain);
gb.display.print(F("Chance of Shiny:\n"));
gb.display.print(chance*100);
Fri Jan 13, 2017 4:01 pm
Sorunome wrote:Yeah, the difference between println and print is that println will add a linebreak after printing your text.
So what you'll want is:
- Code:
gb.display.print(F("Chain Length:"));
gb.display.println(fchain);
gb.display.println(F("Chance of Shiny:"));
gb.display.print(chance*100);
EDIT: You can also add a linebreak with \n, so that you do like
- Code:
gb.display.print(F("Chain Length:"));
gb.display.println(fchain);
gb.display.print(F("Chance of Shiny:\n"));
gb.display.print(chance*100);
Sun Jan 15, 2017 5:34 pm
gb.display.print(chance * 100); // displays stuff before the comma and two decimals
gb.display.print(((uint32_t)(chance * 1000000)) % 100); // display next two decimals
gb.display.print(((uint32_t)(chance * 100000000)) % 100); // display next two decimals
Mon Jan 16, 2017 2:31 pm
Sorunome wrote:You could always just manually display your stuff, like
- Code:
gb.display.print(chance * 100); // displays stuff before the comma and two decimals
gb.display.print(((uint32_t)(chance * 1000000)) % 100); // display next two decimals
gb.display.print(((uint32_t)(chance * 100000000)) % 100); // display next two decimals
I think. The code is untested