How to change the color of an individual character?

SYS 64738
FridtjofBjarturson
Member
Member
Posts: 2
Joined: Sun Apr 01, 2018 9:35 am

How to change the color of an individual character?

Post by FridtjofBjarturson » Sun Apr 01, 2018 10:44 am

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



merman
Member
Member
Posts: 145
Joined: Mon Apr 14, 2014 2:50 pm
Location: Skegness

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

Post by merman » Sun Apr 01, 2018 12:52 pm

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.

FridtjofBjarturson
Member
Member
Posts: 2
Joined: Sun Apr 01, 2018 9:35 am

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

Post by FridtjofBjarturson » 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.

User avatar
eslapion
Member
Member
Posts: 687
Joined: Mon Jul 20, 2015 10:11 am
Location: Canada

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

Post by eslapion » Sun Apr 01, 2018 2:20 pm

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.
Wealth, like happiness, is never attained directly. It comes as a by-product of providing a useful service. -Harland D. Sanders

User avatar
Gyro Gearloose
Member
Member
Posts: 126
Joined: Sun Nov 15, 2015 5:20 am

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

Post by Gyro Gearloose » Sun Apr 01, 2018 6:59 pm

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.
The price one pays for pursuing any profession, or calling, is an intimate knowledge of its ugly side.

User avatar
Gyro Gearloose
Member
Member
Posts: 126
Joined: Sun Nov 15, 2015 5:20 am

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

Post by Gyro Gearloose » Fri Apr 27, 2018 2:17 am

So was this just an April Fool's?
The price one pays for pursuing any profession, or calling, is an intimate knowledge of its ugly side.

Post Reply Previous topicNext topic