FredTheFred Posted August 19, 2015 Share Posted August 19, 2015 Hello all, I've got another problem, a strange problem. I use two variables. The first for a score and the second for some potion. There are identical by the type. But score can increase and potion stay to 0... What's wrong ? /* DEFINIE VARIABLES HERE */ unsigned int score; unsigned int potion; ... /*POTION*/ void findpotion() { cls (); // Clear Screen show_score(); center_string (3,"YOU FIND A POTION"); center_string (17,"YOU WIN 200 pts"); center_string (23,"PRESS FIRE"); delay (50); pause(); score = score + 200; potion = potion + 1; engine(); } ... /* SHOW SCORE & POTION*/ void show_score() { print_at(0,0,"Score"); put_at(6,0,str(score),5); print_at(14,0,"Potion"); put_at(21,0,str(potion),1); } ... void main() { /* DEFINE SCREEN MODE */ screen_mode_2_text(); // DEFINE SCREEN MODE fill_vram0(0x2000,0x1800,0xf0); /* DEFINE ASCII TEXT */ upload_default_ascii(NORMAL); duplicate_pattern(); /* ASSIGNATION POTION 1 IN BEGINNING GAME */ potion =1; /* START NEXT FUNCTION HERE */ splashscreen (); // CALL SPLASHSCREEN FUNCTION } Quote Link to comment Share on other sites More sharing options...
Pixelboy Posted August 19, 2015 Share Posted August 19, 2015 You forgot to include the splashscreen() function in your posted code. But anyway, I think I see your problem: The last parameter of put_at() is the byte size of the string, and you're passing weird values for that parameter in your code. You should use "print_at(6,0,str(score));" and "print_at(21,0,str(potion));". Quote Link to comment Share on other sites More sharing options...
youki Posted August 19, 2015 Share Posted August 19, 2015 if you write : put_at(21,0,str(potion),5); instead of put_at(21,0,str(potion),1); I think you will see your potion increase. You can try also : put_at(21,0,str(potion)+4,1); Quote Link to comment Share on other sites More sharing options...
AtariTexas Posted August 19, 2015 Share Posted August 19, 2015 Quote Link to comment Share on other sites More sharing options...
Kiwi Posted August 19, 2015 Share Posted August 19, 2015 put_at(21,0,str(potion),1); will only print 0. Because the full string is 00001, and it only going to print 1 character. If he have it put_at(21,0,str(potion),5); then it'll show 00001 potion. If you want a single digit to print for your potion, then put_char(x,y,potion+48); will work 0-9. It points at the tileset. Double digit needs a MOD of 10 and division of 10 to a temporary variable and then 2 put_char() side by side to show double digit. Quote Link to comment Share on other sites More sharing options...
Pixelboy Posted August 19, 2015 Share Posted August 19, 2015 Or you can just use print_at(x, y, str(value)), like I stated above. Quote Link to comment Share on other sites More sharing options...
youki Posted August 19, 2015 Share Posted August 19, 2015 put_at(21,0,str(potion),1); will only print 0. Because the full string is 00001, and it only going to print 1 character. If he have it put_at(21,0,str(potion),5); then it'll show 00001 potion. If you want a single digit to print for your potion, then put_char(x,y,potion+48); will work 0-9. It points at the tileset. Double digit needs a MOD of 10 and division of 10 to a temporary variable and then 2 put_char() side by side to show double digit. For double digit, i think you can do also simply that : put_at(21,0,str(potion)+3,2); 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.