Brian's Man Cave Posted June 8, 2023 Share Posted June 8, 2023 Not sure if this is an obvious thing, and I can't find a thread on it. Currently I have my score set as an array #score(0), #score(1), #score(2) that is easy to print to the screen horizontal. But how would I go about displaying a score vertically? example) 1 0 0 0 0 0 0 Quote Link to comment https://forums.atariage.com/topic/351984-vertical-score-display/ Share on other sites More sharing options...
+DZ-Jay Posted June 8, 2023 Share Posted June 8, 2023 6 hours ago, Brian's Man Cave said: Not sure if this is an obvious thing, and I can't find a thread on it. Currently I have my score set as an array #score(0), #score(1), #score(2) that is easy to print to the screen horizontal. But how would I go about displaying a score vertically? example) 1 0 0 0 0 0 0 Isn't that just a simple PRINT AT? There is a function in the CONSTANTS.BAS file that converts column/row pairs to a BACKTAB address (screenaddrs). Just use that to print all digits on the same column, but increment the row. Something like: (untested) For I = 0 To (Digits - 1) Print At screenaddrs(BaseCol, BaseRow + I) <>#Score(I) Next Digits is number of digits, BaseCol and BaseRow are the column and row where you start the score. dZ. Quote Link to comment https://forums.atariage.com/topic/351984-vertical-score-display/#findComment-5266508 Share on other sites More sharing options...
Brian's Man Cave Posted June 8, 2023 Author Share Posted June 8, 2023 13 hours ago, DZ-Jay said: Isn't that just a simple PRINT AT? There is a function in the CONSTANTS.BAS file that converts column/row pairs to a BACKTAB address (screenaddrs). Just use that to print all digits on the same column, but increment the row. Something like: (untested) For I = 0 To (Digits - 1) Print At screenaddrs(BaseCol, BaseRow + I) <>#Score(I) Next Digits is number of digits, BaseCol and BaseRow are the column and row where you start the score. dZ. Interesting! I will give it a try. I assume that BaseCol would = 0 and BaseRow would = 0 if I wanted the score to start at the very top left and then go down from there? Quote Link to comment https://forums.atariage.com/topic/351984-vertical-score-display/#findComment-5266840 Share on other sites More sharing options...
+DZ-Jay Posted June 9, 2023 Share Posted June 9, 2023 1 hour ago, Brian's Man Cave said: Interesting! I will give it a try. I assume that BaseCol would = 0 and BaseRow would = 0 if I wanted the score to start at the very top left and then go down from there? Yes. Quote Link to comment https://forums.atariage.com/topic/351984-vertical-score-display/#findComment-5266860 Share on other sites More sharing options...
Brian's Man Cave Posted June 9, 2023 Author Share Posted June 9, 2023 On 6/8/2023 at 5:18 AM, DZ-Jay said: Isn't that just a simple PRINT AT? There is a function in the CONSTANTS.BAS file that converts column/row pairs to a BACKTAB address (screenaddrs). Just use that to print all digits on the same column, but increment the row. Something like: (untested) For I = 0 To (Digits - 1) Print At screenaddrs(BaseCol, BaseRow + I) <>#Score(I) Next Digits is number of digits, BaseCol and BaseRow are the column and row where you start the score. dZ. Can't seem to get this to work. I tried a few things but still nothing 🥴 Quote Link to comment https://forums.atariage.com/topic/351984-vertical-score-display/#findComment-5267277 Share on other sites More sharing options...
carlsson Posted June 9, 2023 Share Posted June 9, 2023 There are two similar macros in constants.bas: screenpos(aColumn, aRow) generates a relative position in BACKTAB, which is what you want to use. screenaddr(aColumn, aRow) does the same but adds BACKTAB_ADDR, making it suitable for POKE. Thus if you replace screenaddr with screenpos in DZ-Jay's example above, and of course include the comma before <>#Score(I), it should work. Quote Link to comment https://forums.atariage.com/topic/351984-vertical-score-display/#findComment-5267301 Share on other sites More sharing options...
+DZ-Jay Posted June 10, 2023 Share Posted June 10, 2023 2 hours ago, carlsson said: There are two similar macros in constants.bas: screenpos(aColumn, aRow) generates a relative position in BACKTAB, which is what you want to use. screenaddr(aColumn, aRow) does the same but adds BACKTAB_ADDR, making it suitable for POKE. Thus if you replace screenaddr with screenpos in DZ-Jay's example above, and of course include the comma before <>#Score(I), it should work. Sorry about that. It was off the top of my head. Thanks for correcting it. 👍 -dZ. Quote Link to comment https://forums.atariage.com/topic/351984-vertical-score-display/#findComment-5267351 Share on other sites More sharing options...
Brian's Man Cave Posted June 11, 2023 Author Share Posted June 11, 2023 On 6/9/2023 at 7:21 PM, carlsson said: There are two similar macros in constants.bas: screenpos(aColumn, aRow) generates a relative position in BACKTAB, which is what you want to use. screenaddr(aColumn, aRow) does the same but adds BACKTAB_ADDR, making it suitable for POKE. Thus if you replace screenaddr with screenpos in DZ-Jay's example above, and of course include the comma before <>#Score(I), it should work. Almost there!! I have some numbers showing up, but not the way I thought they would. Here is my code: #Score(0) = 1 #Score(1) = 123 For I = 0 To (1 - 1) Print At screenpos(0, 0 + I) color 3, <>#Score(0) Next For I = 0 To (3 - 1) Print At screenpos(0, 1+I) color 3, <>#Score(1) Next and I get this: 1 123 Does this mean that #score(x) can only have 1 digit? Quote Link to comment https://forums.atariage.com/topic/351984-vertical-score-display/#findComment-5267831 Share on other sites More sharing options...
+DZ-Jay Posted June 11, 2023 Share Posted June 11, 2023 8 hours ago, Brian's Man Cave said: Almost there!! I have some numbers showing up, but not the way I thought they would. Here is my code: #Score(0) = 1 #Score(1) = 123 For I = 0 To (1 - 1) Print At screenpos(0, 0 + I) color 3, <>#Score(0) Next For I = 0 To (3 - 1) Print At screenpos(0, 1+I) color 3, <>#Score(1) Next and I get this: 1 123 Does this mean that #score(x) can only have 1 digit? Sorry, it is not clear what you meant by this, Quote Currently I have my score set as an array #score(0), #score(1), #score(2) I thought you meant that you had the digits of the score split into an array. The code we provided was to display each digit on its own row. It seems that you are asking to print something like "123" as 1 2 3 Moreover, it looks like your Score() array contains not strings of digits, but numeric values. If so, that becomes a bit harder, since you will have to divide your number (which is stored as a binary value) into decimal digits. In other words, you will have to separate the units, tens, hundreds, thousands, etc., from the value and display them separately. This is expensive to do, but sort of easy: you do it in the same way you were taught to do it in primary school: by progressively dividing by powers of 10. Still, if each element is a score, what is in the array then? Could you provide more details on what you are trying to do? dZ. Quote Link to comment https://forums.atariage.com/topic/351984-vertical-score-display/#findComment-5267937 Share on other sites More sharing options...
Brian's Man Cave Posted June 11, 2023 Author Share Posted June 11, 2023 2 hours ago, DZ-Jay said: Sorry, it is not clear what you meant by this, I thought you meant that you had the digits of the score split into an array. The code we provided was to display each digit on its own row. It seems that you are asking to print something like "123" as 1 2 3 Moreover, it looks like your Score() array contains not strings of digits, but numeric values. If so, that becomes a bit harder, since you will have to divide your number (which is stored as a binary value) into decimal digits. In other words, you will have to separate the units, tens, hundreds, thousands, etc., from the value and display them separately. This is expensive to do, but sort of easy: you do it in the same way you were taught to do it in primary school: by progressively dividing by powers of 10. Still, if each element is a score, what is in the array then? Could you provide more details on what you are trying to do? dZ. Maybe I am not using the best method of capturing the score? The array Score is set up to store by millions, thousands, hundreds. So if the score is at 1,500,020, the array would be: #score(0) = 1 #score(1) = 500 #score(2) = 20 When the player scores points, I add everything into the hundreds first. If it goes over a thousand, I subtract 1000 and increment the thousands by 1 and so on... This makes it easy to display the score horizontally! Quote Link to comment https://forums.atariage.com/topic/351984-vertical-score-display/#findComment-5267977 Share on other sites More sharing options...
+DZ-Jay Posted June 11, 2023 Share Posted June 11, 2023 12 minutes ago, Brian's Man Cave said: Maybe I am not using the best method of capturing the score? The array Score is set up to store by millions, thousands, hundreds. So if the score is at 1,500,020, the array would be: #score(0) = 1 #score(1) = 500 #score(2) = 20 When the player scores points, I add everything into the hundreds first. If it goes over a thousand, I subtract 1000 and increment the thousands by 1 and so on... This makes it easy to display the score horizontally! Ah! Well, could you just store the power of ten? I mean, instead of 500, just 5; and instead of 20, just 2. That way, you are storing the number of units, tens, hundreds, and thousands. Then the code we provided would work. If you ever need to add up the score, you would need to do something like this: #Score = (Score(6) * 1000000) + (Score(5) * 100000) + (Score(4) * 10000) + (Score(3) * 1000) + (Score(2) * 100) + (Score(1) * 10) + Score(0) You could generalize that with a loop, but you would need a table of powers of ten, since IntyBASIC doesn't have a Pow() function. However, you only need to do that when you need to treat the value as a number, like for comparisons, etc. Presumably this would be more rare than displaying the score all the time. Alternatively, you could store both values at the same time: Along with the Score() array, you could add the increments to #Score directly as well. dZ. Quote Link to comment https://forums.atariage.com/topic/351984-vertical-score-display/#findComment-5267985 Share on other sites More sharing options...
carlsson Posted June 11, 2023 Share Posted June 11, 2023 Remember that an unsigned 16-bit variable only can hold values up to 65535 anyway so you might as well compare values digit by digit in your array than calculate the sum even for that purpose. Quote Link to comment https://forums.atariage.com/topic/351984-vertical-score-display/#findComment-5268240 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.