Page 1 of 1

How to change the color of an individual character?

Posted: Sun Apr 01, 2018 10:44 am
by FridtjofBjarturson
Howdy Y'all, I need help changing the color of an individual letter/character. I'm not sure if this is possible, as I was totally unable to find anything on this forum at all, or on the C64 Wiki.
This is my little lame code, I'm trying to make a text adventure thing.
Image
This is what it looks like after running the list. I have some things as an example of what characters I'd like changed.
Obviously, you can see labeled with pink box/arrow.
This I what I want changed. I'd like to have it grey like the line I typed across the screen.
Image

It might be really late and I'll have to check this thread tomorrow, but I need help with this. Hopefully someone's up to respond to this garb.
Also, excuse me if I broke any rules. I made this account just now to post this thread. That, and thank you all. :P :P

Re: How to change the color of an individual character?

Posted: Sun Apr 01, 2018 12:52 pm
by merman
The simplest way is to use the control codes inside the quotation marks.

So you type the line as PRINT, then SHIFT+2 to open quotes then press CTRL and a number key 1-8 or COMMODORE and 1-8 to get a colour. Onscreen you will see a reversed symbol. But when the program runs it will change the cursor colour and print the characters in that colour.

You can have multiple colour changes in a line, as long as the BASIC line is less than 80 characters.

So to get that grey colour you would press COMMODORE and 4 inside the quotes.

The colour names are printed on the side of the keys.

Re: How to change the color of an individual character?

Posted: Sun Apr 01, 2018 1:34 pm
by FridtjofBjarturson
I'll probably just give up. I cant change the color while editing text, and I'm unable to change the color permanently by pressing enter on the line of code after changing its color.

Re: How to change the color of an individual character?

Posted: Sun Apr 01, 2018 2:20 pm
by eslapion
FridtjofBjarturson wrote: Sun Apr 01, 2018 1:34 pm I'll probably just give up. I cant change the color while editing text, and I'm unable to change the color permanently by pressing enter on the line of code after changing its color.
I am completely baffled by your reaction. Changing the color of text on the VIC-20 and C64 is an incredibly simple thing to do.

Using POKE646,x is probably to most cryptic approach. There is a reason why you see BLK, WHT, RED and other color names on the numbers 1 to 8 on the VIC-20 and C64 keyboard and that's because pressing CTRL with one of these numbers changes the following characters to the chosen colors.

Specifically on the C64, pressing the Commodore key (lower left corner of the keyboard) and a number from 1 to 8 gives you an additional 8 colors.

You can also use CHR$ codes listed on page 141 of the original C64 user manual.

Try Something like:

Code: Select all

10 PRINT CHR$(30);"MY NAME IS";CHR$(28);" FRANCOIS";CHR$(158);" LEVEILLE"
The CHR$ codes are as follows:

5 - White
28 - Red
30- Green
31- Blue
129- Orange
144- Black
149- Brown
150- Light Red
151- Dark Gray
152- Gray
153- Light Green
154- Light Blue
155- Light Gray
156- Purple
158- Yellow
159- Cyan

The easiest way remains pressing CTRL or C= with the quote mode activated as stated in the previous post by merman.

Re: How to change the color of an individual character?

Posted: Sun Apr 01, 2018 6:59 pm
by Gyro Gearloose
FridtjofBjarturson wrote: Sun Apr 01, 2018 1:34 pm I'll probably just give up. I cant change the color while editing text, and I'm unable to change the color permanently by pressing enter on the line of code after changing its color.
Calm down. You have to RUN the code. You are using "print" codes, they don't actually change the color RIGHT THERE, they work when the string in quotes is printed back by the BASIC interpreter when running the code.

Re: How to change the color of an individual character?

Posted: Fri Apr 27, 2018 2:17 am
by Gyro Gearloose
So was this just an April Fool's?