0 Members and 1 Guest are viewing this topic.
I know how to make a sprite now, but not maps.unsigned char homme[] = { 0b01111110, 0b11111111, 0b10100101, 0b10000001, 0b01111110, 0b10100101, 0b10111101, 0b01111110 };
What is the routine to call a tile map?
int tilemap_x; int tilemap_y; int lcd_x; int lcd_y; unsigned char* pSprite; unsigned char sprite_index; int key = 0, pUserx = 1, pUsery = 1; unsigned char map1[MAP_Y][MAP_X] = { {01,01,01,01,01,01,01,01,01,01,01,01,01,01,01,01,01,01,01,01}, {01,02,02,02,02,02,02,02,00,00,00,00,00,00,00,00,00,00,00,01}, {01,02,02,02,02,02,02,00,00,00,00,05,06,07,00,00,00,00,00,01}, {01,02,02,02,00,00,00,00,00,00,00,10,11,12,00,00,00,00,00,01}, {01,02,00,00,00,00,15,16,00,00,00,13,14,13,00,00,00,00,00,01}, {01,00,00,00,00,00,17,20,00,00,00,21,21,21,03,04,04,03,00,01}, {00,00,00,00,00,00,00,00,00,00,00,00,21,00,03,04,04,03,00,01}, {21,21,21,05,06,07,00,00,00,00,21,21,21,00,03,03,03,03,02,01}, {00,00,21,10,11,12,00,00,21,21,21,00,00,00,00,00,02,02,02,01}, {01,00,21,13,14,13,00,21,21,00,00,00,00,00,02,02,02,02,02,01}, {01,00,21,21,21,21,21,21,00,00,00,00,02,02,02,02,02,02,02,01}, {01,01,01,01,01,01,01,01,01,01,01,01,01,01,01,01,01,01,01,01}, }; ClrScr(); GrayOn(); while (key != KEY_ESC) { while (map1[pUsery][pUserx] != 14) { //Affichage //Gris clair GraySetAMSPlane(LIGHT_PLANE); lcd_y = 0; for (tilemap_y = 0; tilemap_y < MAP_Y; tilemap_y++) { lcd_x = 0; for (tilemap_x = 0; tilemap_x < MAP_X; tilemap_x++) { sprite_index = map1[tilemap_y][tilemap_x]; pSprite = &game_sprites_light[sprite_index][0]; Sprite8 (lcd_x, lcd_y, 8, vide, LCD_MEM, SPRT_AND); Sprite8 (lcd_x, lcd_y, 8, pSprite, LCD_MEM, SPRT_OR); lcd_x += 8; } lcd_y += 8; } //Gris foncé GraySetAMSPlane(DARK_PLANE); lcd_y = 0; for (tilemap_y = 0; tilemap_y < MAP_Y; tilemap_y++) { lcd_x = 0; for (tilemap_x = 0; tilemap_x < MAP_X; tilemap_x++) { sprite_index = map1[tilemap_y][tilemap_x]; pSprite = &game_sprites_dark[sprite_index][0]; Sprite8 (lcd_x, lcd_y, 8, pSprite, LCD_MEM, SPRT_OR); lcd_x += 8; } lcd_y += 8; } Sprite8 (pUserx * 8, pUsery * 8, 8, vide, LCD_MEM, SPRT_AND); Sprite8 (pUserx * 8, pUsery * 8, 8, mec, LCD_MEM, SPRT_OR); GraySetAMSPlane(LIGHT_PLANE); Sprite8 (pUserx * 8, pUsery * 8, 8, mec, LCD_MEM, SPRT_OR); //Demande de touche key = ngetchx(); if (key) { //Actualisation de la position de l'utilisateur pUserx += (key == KEY_RIGHT) - (key == KEY_LEFT); pUsery += (key == KEY_DOWN) - (key == KEY_UP); //Verification de sa position if (map1[pUsery][pUserx] == 1 || map1[pUsery][pUserx] == 3 || (map1[pUsery][pUserx] > 4 && map1[pUsery][pUserx] != 14 && map1[pUsery][pUserx] < 21) || pUserx == 21 || pUserx == -1 || pUsery == -1 || pUsery == 13) { pUserx -= (key == KEY_RIGHT) - (key == KEY_LEFT); pUsery -= (key == KEY_DOWN) - (key == KEY_UP); } if (key == KEY_ESC) return 0; } } } GrayOff(); return 0;}