NaaLaa

Full Version: Card Suit Symbols
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
[attachment=588]

I’ve noticed an interesting quirk in my application: the card suit symbols (♥, ♦, ♣, ♠) render perfectly in the console, but they appear as empty spaces when running in windowed mode. Is there a way to correctly display these symbols using the chr() function for a windowed environment ?

Code:
'--------------
' CONSOLE MODE
'--------------
randomize time()

values = ["A ", "2 ", "3 ", "4 ", "5 ", "6 ", "7 ", "8 ", "9 ", "10", "J ", "Q ", "K "]

v = values[rnd(0,12)]
s = rnd(3,6)            'ASCII code 3=heart, 4=diamond, 5=club,  6=spade
card(5,4,v,s)
   
pln chr(7) 'bell sound
wait 1000


'--------------
' WINDOW MODE
'--------------
set window "cards",300,300,false

do 
    wln "My card is the "+v+" of "+chr(s)
    'ASCII code 3=heart, 4=diamond, 5=club,  6=spade
   
    do;wait 1;until keydown(KEY_ESCAPE,true)
    end
loop


'----------
' FUNCTION
'----------
function card(w,h,value,suit)
    'top border
    write chr(218) ; for i = 1 to w write chr(196) ; wln chr(191)
   
    'vertical border
    write chr(179)+value ; for i = 3 to w write chr(32) ; wln chr(179)
    for i = 1 to h-2
        write chr(179) ; for j = 1 to w write chr(32); wln chr(179)
    next
    write chr(179); for i = 1 to w-2 write chr(32) ; write chr(suit)+chr(32);wln chr(179)
   
    'bottom border         
    write chr(192); for i = 1 to w write chr(196) ; wln chr(217)
endfunc
(04-11-2026, 07:27 AM)1micha.elok Wrote: [ -> ]I’ve noticed an interesting quirk in my application: the card suit symbols (♥, ♦, ♣, ♠) render perfectly in the console, but they appear as empty spaces when running in windowed mode. Is there a way to correctly display these symbols using the chr() function for a windowed environment ?

Code:
'--------------
' CONSOLE MODE
'--------------
randomize time()

values = ["A ", "2 ", "3 ", "4 ", "5 ", "6 ", "7 ", "8 ", "9 ", "10", "J ", "Q ", "K "]

v = values[rnd(0,12)]
s = rnd(3,6)            'ASCII code 3=heart, 4=diamond, 5=club,  6=spade
card(5,4,v,s)
   
pln chr(7) 'bell sound
wait 1000


'--------------
' WINDOW MODE
'--------------
set window "cards",300,300,false

do 
    wln "My card is the "+v+" of "+chr(s)
    'ASCII code 3=heart, 4=diamond, 5=club,  6=spade
   
    do;wait 1;until keydown(KEY_ESCAPE,true)
    end
loop


'----------
' FUNCTION
'----------
function card(w,h,value,suit)
    'top border
    write chr(218) ; for i = 1 to w write chr(196) ; wln chr(191)
   
    'vertical border
    write chr(179)+value ; for i = 3 to w write chr(32) ; wln chr(179)
    for i = 1 to h-2
        write chr(179) ; for j = 1 to w write chr(32); wln chr(179)
    next
    write chr(179); for i = 1 to w-2 write chr(32) ; write chr(suit)+chr(32);wln chr(179)
   
    'bottom border         
    write chr(192); for i = 1 to w write chr(196) ; wln chr(217)
endfunc

No, sorry, naalaa only supports ascii.
Here it is the Blackjack (ASCII Edition) 
https://www.naalaa.com/forum/thread-385-...ml#pid2600
Very good - it's nice to see some console games. Thanks for sharing.....
Ahh... Gotta love the old ASCII games... Memories...