Page 1 of 1 1
Topic Options
#79975 - 2001-04-20 11:09 AM Characters and Colours
cj Offline
MM club member
*****

Registered: 2000-04-06
Posts: 1102
Loc: Brisbane, Australia

Minor 'bug' is the spelling of the COLOR command, it should be COLOUR

Instead of (or better still, as well as) the letters for colours, ie b, b+, n, w+ etc.. how about numbers: 0-15 for black, blue...through to white.

Also, I would like to be able to retreive colour information from the screen. Ie, the reverse of the AT and COLOR commands: Instead of just AT'ing to (1,1) and setting the COLOR, I would like to GET the current colour and even the current character on the screen at that position.

This would make it easier for me to move text around on the screen without having to re-draw it. (yes, related to the adventure game...)


thanks,

cj


Top
#79976 - 2001-04-20 05:05 PM Re: Characters and Colours
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Here you go, a solution to both your problems in one go, Colour spelled correctly and by numbers to boot...

code:
; Demo kix script to deliver colour by numbers

; Colours seem to be broken with the console (kix32c.exe) version, so run under console-less (kix32.exe)
; Background colours will show as high intensity rather than blinking in the console.

$Back=0
While $Back < 16
$Fore=0
While $Fore < 16
If $Back <> $Fore
Colour($Fore,$Back)
"(COLOR $Fore/$Back)"
EndIf
$Fore=$Fore+1
Loop
$Back=$Back+1
Loop

color w/n
? "Hit Return " gets $s

return

Function Colour($ForeGround,$BackGround)
$ExecString="color " + LookupColour($ForeGround) + "/" + LookupColour($BackGround)
$Result=Execute($ExecString)
EndFunction

Function LookupColour($ColourValue)
$LookupColour=rtrim(substr("n b g c r m y w n+b+g+c+r+m+y+w+",$ColourValue*2+1,2))
EndFunction


This is of course coded for Kix2001, you could convert is to a subroutine with a little effort.

NB This has uncovered a few bugs (I think - have to do real work now so I can't spend time on it).
1) The console-less mode gives really bizaare results for colours, I just gave up in the end.
2) The console mode is better but some of the "x+" colours for background show as black.
3) I initially used an array for the colour lookup, but the variable scope was a pain in the proverbials. A dimensioned array within a function is destroyed on exit, and a dimensioned array in the main script is not visible in the function. Now, a "static" keyword for function variables - that'd be cool.

------------------

Richard Howarth

Top
#79977 - 2001-04-20 06:03 PM Re: Characters and Colours
cj Offline
MM club member
*****

Registered: 2000-04-06
Posts: 1102
Loc: Brisbane, Australia
I tried every colour combination and while there is no Blinking mode, all the colours look ok...

k2Colours.k2k

code:

break on $=setascii("on") color w/n cls


$f=0 do
$b=0 do
$fc=substr("n b g c r m y w n+ b+ g+ c+ r+ m+ y+ w+ ",$f*3+1,3)
$bc=substr("n b g c r m y w n+ b+ g+ c+ r+ m+ y+ w+ ",$b*3+1,3)
$=execute("color $fc / $bc")


if instr(@kix, "3")<>0
substr($fc, 1, 2) "/" substr($bc, 1, 2) ; KiX 3.6x
else
if $f<10 "0" endif $f if $b<10 "0" endif $b ; KiX 2001
endif


$b=$b+1
until $b=16
?
$f=$f+1
until $f=16


color w/n ? get$


Notice that I am using your array, but with 3 chars instead of 2... KiX2k has trouble with strings with even chars but this is being fixed. This is why your script fails. I got the same error with consoleless version too...

cj


Top
#79978 - 2001-04-24 01:12 PM Re: Characters and Colours
Anonymous
Unregistered


There is a simple solution to the colour/color problem. Allow both spellings.
Top
Page 1 of 1 1


Moderator:  Lonkero, ShaneEP, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1452 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.053 seconds in which 0.025 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org