How To

How to get character's pixels (?) ?


G-9 2021-03-08 19:00 (Edited)

How to get (in the code) characters pixels ?

So for example to get the '@' :


The command (?) would be GetChar (5,2,c,)

Help me i'm unsure of this ...

Timo 2021-03-08 19:21 (Edited)

I recommend to check whole characters for collision stuff etc. To get pixels you need to do binary operations on bytes in the memory (PEEK). It's possible but there is no simple command.
For what do you want to use it?

was8bit 2021-03-08 20:21 (Edited)

I this sort of stuff here....

was8bit 2021-03-08 20:30 (Edited)


Is the array i use to store the pixel data for a character...
x pixels 0 to 7
Y pixels 0 to 7

Data in the array uses the same colors Character Editor uses, colors 0,1,2,3 in order top to bottom, #0 is clear, #1-3 are the 3 colors

As an array using #'s 0 to 3, you may read, edit, and change any one character you choose...

NOTE, this does NOT read either background, as backgrounds do NOT store pixel data, they only reference char#'s


Reads a single character and loads its pixel data into the array


If you have edited the array, then this will overwrite the pixel data of any character you choose...

These only change characters mid game, they will not permamently edit your character file...

was8bit 2021-03-08 20:34

Also, these are not designed for speed... they are designed to match the ease of the Chacter Designer, where you dont have to do binary maths to edit the data... rather, you may edit the data as easily as you edit any character as you do when using Character Designer

was8bit 2021-03-08 20:36 (Edited)

So, using your visual example, the info the pixel you marked with "@" is...


To check if that point is empty..


was8bit 2021-03-08 20:38 (Edited)

IF you are wanting to find points in random characters the screen, you will have to first identify the character, and then load that character into the array


Then you can check for points...

was8bit 2021-03-08 20:45

Pixel to pixel checks are best done between 2 sprites...

Assuming you are checking between 2 characters, or a sprite with a complicated charracter...

One trick could be to temporarily convert the character(s) into sprite(s), then check for collision berween the two...when done, remove the temporary sprite(s)....

Checks for colission done between sprites is a pixel to pixel check, its quick, and automatic... very eays to use :)

was8bit 2021-03-08 20:54 (Edited)

I did the temporary sprite trick with my Quad Ludo game here...

The BRICK OUT game uses characters with subsequently less "bricks" or lines in each character... i only only wanted a "brick" to register as "touched" if the TIP of then ball touched only ONE brick... since anynone character has more than one brick, or has lots of empty space, and only the ball and paddle were sprites, i was stuck..

So, each time the ball is moved, i add temporary sprites... one as a single point on top (or bottom) of the ball, and one for any character the ball in general MAY have hit... i do a single sprite check for each one character the ball point may have hit, and only do a hit IF the temporary ball point sprite registers a hit with a temporary character sprite...

I had to be sure the temporary character sprite was placed precisly on top of the existing sprite, but now it "LOOKS" like the ball is hitting and removing individual bricks...

I had to do it this way, as if you check there are 99 bricks, and we only get 64 sprites to use...

was8bit 2021-03-08 21:06 (Edited)

To see how the game is checking for colission in real time, goto the BRICK code and add the WAIT 30 you see below... you will see whole cells flash as it is checking to see if the ball hits a brick inside the character...
SPRITE 5 is a 2 pixel line placed on top of the ball
SPRITE 6 has the character (that the ball is near) loaded into the sprite to do the check

BG 1
BG 0
IF C>=16 AND C<=19 THEN
SPRITE 6,(CX\8)*8,(CY\8)*8,C

The end result isnt perfect, but as one is simultaneously playing 4 games at the same time, the occasional irregularities will not be easily caught ;)

G-9 2021-03-09 07:10

Thank u :3

was8bit 2021-03-09 07:12


G-9 2021-03-09 07:24

GETCHAR works well, thank u one more time

Char Detection.nx | Open in app
2021-03-09 07:24
Char Detection.nx | Open in app
2021-03-09 07:24

was8bit 2021-03-09 08:28

Glad i could help :)

Log in to reply.