Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "graphics.h"
- #define X 640
- #define Y 320
- #define ScreenW 160
- int main( )
- {
- system("MODE 160, 300");
- initwindow(X, Y, "First Sample");
- readimagefile("world-map.bmp", 0, 0, X - 1, Y - 1);
- float x, y;
- x = X / ScreenW;
- y = x / 0.75f;
- char str[1024] = "";
- int h = 0; //bien chay
- int temp1 = 0; //bien dem so '!' lien tiep
- int temp2 = 0; //bien dem so ' ' lien tiep
- for (int i = 1; i < Y; i += y)
- {
- for (int j = 1; j < X; j += x)
- {
- if (getpixel(j, i) != WHITE)
- {
- if (temp2 != 0)
- {
- str[h++] = 64 + temp2;
- temp2 = 0;
- }
- temp1++;
- putchar('!');
- }
- else
- {
- if (temp1 != 0)
- {
- str[h++] = 64 + temp1;
- temp1 = 0;
- }
- temp2++;
- putchar(' ');
- }
- }
- if (temp1 != 0)
- str[h++] = '1';
- if (temp2 != 0)
- str[h++] = '0';
- temp1 = temp2 = 0;
- putchar('\n');
- }
- getch();
- str[h] = 0;
- puts(str);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement