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
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?
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);
}
}
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);
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);
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: Select all
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: Select all
gb.display.print(F("Chain Length:"));
gb.display.println(fchain);
gb.display.print(F("Chance of Shiny:\n"));
gb.display.print(chance*100);
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
Sorunome wrote:You could always just manually display your stuff, like
- Code: Select all
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
Return to Programming Questions
Users browsing this forum: No registered users and 4 guests