Exemplo n.º 1
0
void drawScene()
{

    /*
    tiny3d_Project3D();
    tiny3d_SetProjectionMatrix(NULL);

	DrawBackground3D(0xffff00ff) ; // yellow
   */

    tiny3d_Project2D(); // change to 2D context (remember you it works with 848 x 512 as virtual coordinates)

    // fix Perspective Projection Matrix

    DrawBackground2D(0x0040ffff) ; // light blue 


    SetFontSize(16, 24);
    SetFontColor(0xffffffff, 0x0);

    SetFontAutoCenter(1);
    DrawString(0, (512 - 24)/2 - 64, "Use LEFT/RIGHT/UP/DOWN to adjust the screen");

    DrawFormatString(0, (512 - 24)/2, "Video Scale X: %i Y: %i", videoscale_x, videoscale_y);

    DrawString(0, (512 - 24)/2 + 64, "Press 'X' to exit");
    SetFontAutoCenter(0);
  
    
}
Exemplo n.º 2
0
void drawScene()
{
	float x, y;
    tiny3d_Project2D(); // change to 2D context (remember you it works with 848 x 512 as virtual coordinates)
    DrawBackground2D(0x0040ffff) ; // light blue 

    SetFontSize(12, 24);
    
    x= 0.0; y = 0.0;

    SetCurrentFont(1);
    SetFontColor(0xffffffff, 0x0);
    x = DrawString(x,y, "Hello World!. My nick is ");
    SetFontColor(0x00ff00ff, 0x0);
    SetCurrentFont(0);
    x = DrawString(x,y, "Hermes ");
    SetCurrentFont(1);
    SetFontColor(0xffffffff, 0x0);
    x = DrawString(x,y, "and this is one sample working with\nfonts.");

    SetCurrentFont(2);
    
    x= 0; y += 64;
    SetCurrentFont(1);
    DrawString(x, y, "I am using 3 fonts:");
    
    SetCurrentFont(0);
    y += 64;
    SetFontColor(0xffffffff, 0x00a000ff);
    DrawString(x, y, "Font 0 is one array of 224 chars 16 x 32 pix and 2 bit depth");

    SetCurrentFont(1);
    y += 64;
    SetFontColor(0xffffffff, 0xa00000ff);
    DrawString(x, y, "Font 1 is one array of 224 chars 16 x 32 pix and 2 bit depth");

    SetCurrentFont(2);
    y += 64;
    SetFontColor(0x000000ff, 0xffff00ff);
    DrawString(x, y, "Font 2 is one array of 255 chars 8 x 8 pix and 1 bit depth");

    y += 64;
    SetCurrentFont(1);
    SetFontSize(32, 64);
    SetFontColor(0xffffffff, 0x000000ff);
    SetFontAutoCenter(1);
    DrawString(0, y, "You can resize letters");
    SetFontAutoCenter(0);

    SetFontSize(12, 24);
    SetFontColor(0xffffffff, 0x00000000);
    y += 72;
    DrawString(0, y, "change the color, background color and center the text\nwith SetFontAutoCenter()");
    y += 72;

    SetFontColor(0x00ff00ff, 0x00000000);
    DrawFormatString(0, y, "Here %s font 0 uses %i bytes as texture", "using DrawFormatString()", 224*(16*2/8)*32);

}
Exemplo n.º 3
0
void drawScene()
{
	int i;

    static int count_frames =0;

    static float rotZ = 0.0f;

    static int rotar =0;

    if(!rotar && (rand() & 255)==1) rotar = 180;

    rotZ += 0.1f;

    tiny3d_Project2D(); // change to 2D context (remember you it works with 848 x 512 as virtual coordinates)

    // fix Perspective Projection Matrix

    DrawBackground2D(0x0040ffff) ; // light blue 

    count_frames++;

    for(i = 0; i < 4; i++) {
        
        int cur_text = ghost[i].frame; // get current texture index for frame

        // Load sprite texture
        tiny3d_SetTexture(0, texture_ghost_offset[cur_text], texture_ghost[cur_text].width,
            texture_ghost[cur_text].height, texture_ghost[cur_text].wpitch,  
            TINY3D_TEX_FORMAT_A8R8G8B8, 1);

        if(!rotar) {
            
            // draw sprite
            DrawSprites2D(ghost[i].x, ghost[i].y, (float) i, 64, 64, ghost[i].color);
        
        }
        else {

            // draw with rotation
            DrawSpritesRot2D(ghost[i].x, ghost[i].y, (float) i, 64, 64, ghost[i].color, rotZ);
        }

        // update frame
        if(count_frames>8) {
            
            ghost[i].frame = ((ghost[i].frame + 1) & 3) | (ghost[i].frame & 4); 
        }
        
        // update position
        ghost[i].x += ghost[i].dx; 
        ghost[i].y += ghost[i].dy;

        // test the limits
        if(ghost[i].x <= 0.0f || ghost[i].x >= (847.0f - 64.0f)) {
            
            ghost[i].x  = (ghost[i].x <= 0.0f) ? 0 : (847.0f - 64.0f);
            ghost[i].dx = -ghost[i].dx;
            
        }

        if(ghost[i].y <= 0.0f || ghost[i].y >= (511.0f - 64.0f)) {
            
            ghost[i].y  = (ghost[i].y <= 0.0f) ? 0 : (511.0f - 64.0f);
            ghost[i].dy = -ghost[i].dy;
        }

        // change frames to left - right

        if(ghost[i].dx >= 0.0f) ghost[i].frame |= 4; else ghost[i].frame &= ~4;
        
    }

    if(rotar) rotar--; else rotZ = 0.0f;

    if(count_frames > 8) count_frames = 0;
}