Jump to content

Recommended Posts

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

Link to comment
https://forums.atariage.com/topic/351984-vertical-score-display/
Share on other sites

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.

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?

1 hour ago, Brian&#x27;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.

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 🥴

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.

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.

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?

 

 

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.

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!   

12 minutes ago, Brian&#x27;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.

 

 

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...