A
A
Alexey Kryazhev2019-04-15 10:33:48
Graphic arts
Alexey Kryazhev, 2019-04-15 10:33:48

Can you explain how the drawings and animations are encoded in the tamagotchi hexadecimal code?

So that I can code mine too...
gist.github.com/aerospark/80c60e801398fd961e3f

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Andrew, 2019-04-15
@Aassians2

A 32x32 matrix is ​​used, the values ​​are encoded in it.
This class is responsible for the animation:

class AnimationFrame {
    int[] framedata;
    
    public AnimationFrame(int[] framedata){
        this.framedata = framedata;
    }
    public AnimationFrame(byte[][] drawmatrix){
        framedata = new int[32];
        for(int i = 0; i < 32; i++){
            int shift = 0;
            for(int e = 31; e > -1; e--){
                byte b = drawmatrix[i][e];
                shift = (shift<<1) | b;
            }
            framedata[i] = shift;
        }
    }
}

This is an example coding:
And this is what the result looks like after compiling this code:
5cb4557e088f1968430083.png

R
Ronald McDonald, 2019-04-15
@Zoominger

I've been trying to get into it for a long time, but without a hint it's hard. Options:
1. Ask the author of the code;
2. Give an example of a picture, then it will be possible to compare the picture and the code.
So far it seems to me that the coordinate of the shaded pixel on the 32x32 matrix is ​​indicated there.

S
SagePtr, 2019-04-15
@SagePtr

Yes, judging by the drawing code, there is a bitmap of pixels:

public void renderComponent(Graphics2D g, AnimationFrame fr, int xo, int yo){
    for(int x = 0; x < 32; x++){
        int v = fr.framedata[x];
        for(int y = 0; y < 32; y++){
            int bv = (v & (1 << y-1));
            if(bv != 0)
                g.setColor(PIXEL_COLOR);
            else
                g.setColor(NONPIXEL_COLOR);
            g.drawLine(y+xo,x+yo,y+xo,x+yo);
        }
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question