News:

Welcome to RetroCoders Community

Main Menu

Digital Numbers

Started by johnno56, Mar 21, 2023, 07:58 PM

Previous topic - Next topic

johnno56

Quick question.

Do you have a routine that draws chunk scores? (similar to the old digital clock numbers)

I am going back to basics (no pun intended) and converting an old Naalaa Pong game and figured that it could use an old style chunky score.

You cannot view this attachment.
May your journey be free of incident.  Live long and prosper.

CharlieJV

Sorry, that I do not have.

Too many interests, not enough hours in a day.  That would be fun to do.

johnno56

Thank you. I will try and do it "old school". Similar to making a platform "map". Read a text file of the the digits pattern then convert to pixels... maybe... could be fun!
May your journey be free of incident.  Live long and prosper.

johnno56

#3
Here is the first draft... Just the one digit... It's a start...

'	================================
' Big Digits
'	================================

xmax = 640
ymax = 480
_Title "BIG DIGITS"
SCREEN _NEWIMAGE(640,480,32)
cls

'	DIGIT Zero
zero:
data".XXXX."
data"X....X"
data"X...XX"
data"X.XX.X"
data"XX...X"
data"X....X"
data".XXXX."

restore zero
Dim digit0(6,7)

for row=1 to 7
	read r$
	print r$
	for col=1 to 6
		if mid$(r$,col,1)="X" then
			digit0(col,row)=1
			line(50+(col*4),row*4)-step(4,4),_rgb32(255,255,255),bf
		else
			digit0(col,row)=0
		end if
	next
next

_display

You cannot view this attachment.

The array does not need to be there for this example, but when more digits are added, storing in an array will mean only reading the data statements only once...

I suppose this method could be used for all printable ascii characters, although that would be a bit of a huge job, as long as the user really likes the "8 bit" look of the output... lol

Of course, the "size" of the font can be set, within reason... The data could possibly be stored in an external file if needs be... I am going to assume that the open/read/write/close commands will be similar to QB?

Anyway, let me know what you think and if it is worth going beyond just digits, I will try to tackle lower and uppercase characters... I hope that my coffee supply holds out... lol

J
May your journey be free of incident.  Live long and prosper.

johnno56

Aurel,

At the moment BAM does not have the ability to load or create fonts. The score would only have the default font. This exercise was purely to see if it could be done another way. I never said it would be efficient... lol  If it works for just the zero, then the next step would be, the remainder of the digits. If that works... then the alphabet... Moo Ha Ha Ha....  Could be fun!!
May your journey be free of incident.  Live long and prosper.

CharlieJV

#5
Quote from: johnno56 on Mar 22, 2023, 05:19 PMAt the moment BAM does not have the ability to load or create fonts. The score would only have the default font. This exercise was purely to see if it could be done another way. I never said it would be efficient... lol  If it works for just the zero, then the next step would be, the remainder of the digits. If that works... then the alphabet... Moo Ha Ha Ha....  Could be fun!!

There is something really cathartic about doing that.






johnno56

Interesting... I have never been a fan of 'internal squabbles' within forums. Usually, if I cannot provide a solution, I try to avoid them... I have seen forums fall apart because of "problems"... I hope that this will not happen here... I have always been a supporter of Basic and wish to continue to be so, but if problems are going to persist on 'this' site, then I will be compelled to look elsewhere...
May your journey be free of incident.  Live long and prosper.

CharlieJV

#7
Quote from: johnno56 on Mar 23, 2023, 12:08 AMInteresting... I have never been a fan of 'internal squabbles' within forums. Usually, if I cannot provide a solution, I try to avoid them... I have seen forums fall apart because of "problems"... I hope that this will not happen here... I have always been a supporter of Basic and wish to continue to be so, but if problems are going to persist on 'this' site, then I will be compelled to look elsewhere...

I'm not concerned at all about this forum.  Admin folk seem like really level-headed and healthy-minded folk.

Although BASIC 4 All was the weirdest experience I've ever had,  I'll give the administrator of the now-defunct BASIC 4 All the benefit of the doubt.

As a monitor of this sub-forum, though, I won't tolerate and will not have anybody tolerate what I suffered over there.

To me, this is a place for sharing some fun and brain-age-game-type learning of new tricks.

CharlieJV

Quote from: johnno56 on Mar 22, 2023, 05:44 AMHere is the first draft... Just the one digit... It's a start...

'	================================
' Big Digits
'	================================

xmax = 640
ymax = 480
_Title "BIG DIGITS"
SCREEN _NEWIMAGE(640,480,32)
cls

'	DIGIT Zero
zero:
data".XXXX."
data"X....X"
data"X...XX"
data"X.XX.X"
data"XX...X"
data"X....X"
data".XXXX."

restore zero
Dim digit0(6,7)

for row=1 to 7
	read r$
	print r$
	for col=1 to 6
		if mid$(r$,col,1)="X" then
			digit0(col,row)=1
			line(50+(col*4),row*4)-step(4,4),_rgb32(255,255,255),bf
		else
			digit0(col,row)=0
		end if
	next
next

_display

You cannot view this attachment.

The array does not need to be there for this example, but when more digits are added, storing in an array will mean only reading the data statements only once...

I suppose this method could be used for all printable ascii characters, although that would be a bit of a huge job, as long as the user really likes the "8 bit" look of the output... lol

Of course, the "size" of the font can be set, within reason... The data could possibly be stored in an external file if needs be... I am going to assume that the open/read/write/close commands will be similar to QB?

Anyway, let me know what you think and if it is worth going beyond just digits, I will try to tackle lower and uppercase characters... I hope that my coffee supply holds out... lol

J

That is some fun and good looking code.


CharlieJV

Totally silly, just playing around wondering how I would go about it.

I like the use of a TYPE, but it does make things pretty wordy.

For the giggles, I fattened up the zero just a little.

TYPE tCharacter
  sROW1 as string
  sROW2 as string
  sROW3 as string
  sROW4 as string
  sROW5 as string
  sROW6 as string
  sROW7 as string
END TYPE

DIM as tCharacter JohnFontChar(0 to 9)

sub ReadChar(i%)
  read JohnFontChar(i%).sROW1
  read JohnFontChar(i%).sROW2
  read JohnFontChar(i%).sROW3
  read JohnFontChar(i%).sROW4
  read JohnFontChar(i%).sROW5
  read JohnFontChar(i%).sROW6
  read JohnFontChar(i%).sROW7
end sub

sub PutCharLine(x%, y%, line$)
  for i = 0 to len(line$) - 1
	  if mid$(line$, i+1, 1) = "X" then pset(x% + i, y%),15
	next i
end sub

sub PutChar(x%, y%, i%)
  PutCharLine(x%, y%, JohnFontChar(i%).sRow1)
  PutCharLine(x%, y%+1, JohnFontChar(i%).sRow2)
  PutCharLine(x%, y%+2, JohnFontChar(i%).sRow3)
  PutCharLine(x%, y%+3, JohnFontChar(i%).sRow4)
  PutCharLine(x%, y%+4, JohnFontChar(i%).sRow5)
  PutCharLine(x%, y%+5, JohnFontChar(i%).sRow6)
  PutCharLine(x%, y%+6, JohnFontChar(i%).sRow7)
end sub

screen _newimage(40,32,0)
restore zero
ReadChar(0)

PutChar(0,0,0)

end

zero:
  data"..XXXXXX.."
  data"XX......XX"
  data"XX....XXXX"
  data"XX..XX..XX"
  data"XXXX....XX"
  data"XX......XX"
  data"..XXXXXX.."

johnno56

Here is the next iteration. Uses all 10 digits (0 to 9). I have also added a size variable. Using 640x480 the maximum size should be no more than 6.

The array is not used. This will purely read and translate the data statements to the screen. It may be possible to create a function that will incorporate which digit, size, colour and co-ordinates, to display that digit. The goal is to be able to use this "font" to create a multiple digit score display. At the moment, I have no idea as to how but, with some research I may be able to come up with something.... no promises... Could be fun!!

'	================================
' Big Digits
'	================================

xmax = 640
ymax = 480
_Title "BIG DIGITS"
SCREEN _NEWIMAGE(640,480,32)
cls

restore digits
' Dim digit0(6,7)

'	Resolution of 640x480 - sizes up to 6 works best
size = 4 ' 

for number = 0 to 9
	for row=1 to 8
		read r$
		' print r$
		for col=1 to 8
			if mid$(r$,col,1)="X" then
				' digit0(col,row)=1
				line((number*(size*10))+col*size,100+(row*size))-step(size,size),_rgb32(255,255,255),bf
			' else
			'	digit0(col,row)=0
			end if
		next
	next
next

_display

digits:
data " XXXXX  "
data "XX   XX "
data "XX  XXX "
data "XX X XX "
data "XXX  XX "
data "XX   XX "
data " XXXXX  "
data "        "
data "   XX   "
data "  XXX   "
data "   XX   "
data "   XX   "
data "   XX   "
data "   XX   "
data " XXXXXX "
data "        "
data "  XXXX  "
data " XX  XX "
data "     X  "
data "  XXXX  "
data " XX     "
data " XX  XX "
data " XXXXXX "
data "        "
data "  XXXX  "
data " X   XX "
data "     XX "
data "   XXX  "
data "     XX "
data " XX  XX "
data "  XXXX  "
data "        "
data "   XX   "
data "  XXX   "
data " X XX   "
data "X  XX   "
data "XXXXXXX "
data "   XX   "
data "  XXXX  "
data "        "
data " XXXXXX "
data " XX   X "
data " XX     "
data "  XXXX  "
data "     XX "
data " XX  XX "
data "  XXXX  "
data "        "
data "  XXXX  "
data " XX  XX "
data " XX     "
data " XXXXX  "
data " XX  XX "
data " XX  XX "
data "  XXXX  "
data "        "
data " XXXXXX "
data " X   XX "
data "     XX "
data "    XX  "
data "   XX   "
data "   XX   "
data "   XX   "
data "        "
data "  XXXX  "
data " XX  XX "
data " XX  XX "
data "  XXXX  "
data " XX  XX "
data " XX  XX "
data "  XXXX  "
data "        "
data "  XXXX  "
data " XX  XX "
data " XX  XX "
data "  XXXXX "
data "     XX "
data " XX  XX "
data "  XXXX  "
data "        "

Quick question. The default font for BAM, does it use a standard web font, or is it a font built into BAM itself? I doubt that it would be a system-based font mainly because font styles between operating systems are not standardised. (eg: Windows, Mac and Linux)

May your journey be free of incident.  Live long and prosper.

CharlieJV

Quote from: johnno56 on Mar 23, 2023, 07:29 AMQuick question. The default font for BAM, does it use a standard web font, or is it a font built into BAM itself? I doubt that it would be a system-based font mainly because font styles between operating systems are not standardised. (eg: Windows, Mac and Linux)

That is very neat and super fun code.

wwwBASIC.js has a hard-coded / built-in font.  To allow for alternative fonts, I yanked the font out of the javascript library and put it in a dedicated "tiddler" (i.e. wiki page), which gets dynamically reincluded into the javascript library at runtime.

This allows us to use alternative fonts of our own creation.

Here is the wiki page containing the original wwwBASIC font: https://basicanywheremachine.neocities.org/BAM_IDE#wwwBASIC%20Font

I cloned that wikipage to create an alternative font that is a bit more like the Commodore PET:
https://basicanywheremachine.neocities.org/BAM_IDE#wwwBASIC%20Font%20-%20Thin

We can add new fonts by cloning any already existing "font" wikipage (giving that page a useful new name).

Also, if you want a little more sharpness and don't mind blocky pixels, make sure to turn off the "Enable Image Smoothing" in the program execution properties (project menu).

CharlieJV

Quote from: johnno56 on Mar 23, 2023, 12:08 AMInteresting... I have never been a fan of 'internal squabbles' within forums. Usually, if I cannot provide a solution, I try to avoid them... I have seen forums fall apart because of "problems"... I hope that this will not happen here... I have always been a supporter of Basic and wish to continue to be so, but if problems are going to persist on 'this' site, then I will be compelled to look elsewhere...

I sent you two private messages.