X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=16%2Fmodex16%2Fscroll.c;h=8a960eee044d8c229344308a6c4e8dea79acb4c4;hb=ab2077438d043816a8c989293f56d198136ed7b5;hp=65ea027946030dc61b45cd373068e4b9082841cc;hpb=a19d7592507e5f7aa91f4a6b6611e021bd1a3e8d;p=16.git diff --git a/16/modex16/scroll.c b/16/modex16/scroll.c old mode 100644 new mode 100755 index 65ea0279..8a960eee --- a/16/modex16/scroll.c +++ b/16/modex16/scroll.c @@ -11,7 +11,7 @@ typedef struct { word tileWidth; unsigned int rows; unsigned int cols; - //unsigned int tilex,tiley; // tile position on the map + unsigned int tilex,tiley; // tile position on the map } tiles_t; @@ -26,18 +26,15 @@ typedef struct { typedef struct { map_t *map; page_t *page; - int tx; //appears to be the top left tile position on the viewable screen map - int ty; //appears to be the top left tile position on the viewable screen map + int tx; //???? appears to be the tile position on the viewable screen map + int ty; //???? appears to be the tile position on the viewable screen map word dxThresh; //???? word dyThresh; //???? } map_view_t; -struct { - int x; //player exact position on the viewable map - int y; //player exact position on the viewable map - int tx; //player tile position on the viewable map - int ty; //player tile position on the viewable map - int hp; //hitpoints of the player +struct { + int tx; //player position on the viewable map + int ty; //player position on the viewable map } player; @@ -50,200 +47,101 @@ void mapScrollDown(map_view_t *mv, byte offset); void mapGoTo(map_view_t *mv, int tx, int ty); void mapDrawTile(tiles_t *t, word i, page_t *page, word x, word y); void mapDrawRow(map_view_t *mv, int tx, int ty, word y); -void mapDrawCol(map_view_t *mv, int tx, int ty, word x); -void animatePlayer(map_view_t *mv, short d1, short d2, int x, int y, int ls, bitmap_t *bmp); +void mapDrawCol(map_view_t *mv, int tx, int ty, word x); #define TILEWH 16 -#define QUADWH (TILEWH/4) -#define SPEED 2 - -//place holder definitions -#define MAPX 40 -#define MAPY 30 -#define SWAP(a, b) tmp=a; a=b; b=tmp; +#define QUADWH (TILEWH/4) +//#define SWAP(a, b) tmp=a; a=b; b=tmp; void main() { - bitmap_t ptmp; // player sprite +// int show1=1; + int tx, ty; + int x, y; + //int ch=0x0; +// byte ch; int q=0; - page_t screen, screen2; + page_t screen;//,screen2; map_t map; - map_view_t mv, mv2; - map_view_t *draw, *spri, *tmp; + map_view_t mv;//, mv2; + map_view_t *draw;//, *show, *tmp; byte *ptr; + //default player position on the viewable map + player.tx = 10; + player.ty = 8; + setkb(1); /* create the map */ - map = allocMap(MAPX,MAPY); //20x15 is the resolution of the screen you can make maps smaller than 20x15 but the null space needs to be drawn properly + map = allocMap(160,120); //20x15 is the resolution of the screen you can make maps smaller than 20x15 but the null space needs to be drawn properly initMap(&map); - mv.map = ↦ - mv2.map = ↦ + mv.map = ↦ +// mv2.map = ↦ /* draw the tiles */ - ptr = map.data; - ptmp = bitmapLoadPcx("ptmp.pcx"); // load sprite - modexEnter(); - modexPalUpdate(ptmp.palette); + ptr = map.data; + modexEnter(); screen = modexDefaultPage(); screen.width += (TILEWH*2); mv.page = &screen; - screen2=modexNextPage(mv.page); - mv2.page = &screen2; - modexShowPage(mv.page); + mapGoTo(&mv, 16, 16); +// screen2=modexNextPage(mv.page); +// mv2.page = &screen2; +// mapGoTo(&mv2, 16, 16); +// modexShowPage(mv.page); /* set up paging */ +// show = &mv; +// draw = &mv2; draw = &mv; - spri = &mv2; -// draw = &mv; - -//TODO: LOAD map data and position the map in the middle of the screen if smaller then screen - mapGoTo(draw, 0, 0); - mapGoTo(spri, 0, 0); - - //TODO: put player in starting position of spot - //default player position on the viewable map - player.tx = draw->tx + 10; - player.ty = draw->ty + 8; - player.x = player.tx*TILEWH; - player.y = player.ty*TILEWH; - modexDrawSpriteRegion(draw->page, player.x-4, player.y-TILEWH, 24, 64, 24, 32, &ptmp); - - modexShowPage(draw->page); - while(!keyp(1)) - { - //top left corner & bottem right corner of map veiw be set as map edge trigger since maps are actually square + + //TODO: set player position data here according to the viewable map screen thingy + + while(!keyp(1)) { + //TODO: top left corner & bottem right corner of map veiw be set as map edge trigger since maps are actually square //to stop scrolling and have the player position data move to the edge of the screen with respect to the direction - //when player.tx or player.ty == 0 or player.tx == 20 or player.ty == 15 then stop because that is edge of map and you do not want to walk of the map - - //TODO: render the player properly with animation and sprite sheet - if(keyp(77)) - { - modexDrawSpriteRegion(draw->page, player.x-4, player.y-TILEWH, 24, 32, 24, 32, &ptmp); - if(draw->tx >= 0 && draw->tx+20 < MAPX && player.tx == draw->tx + 10) - { - for(q=0; q<(TILEWH/SPEED); q++) - { -// modexDrawBmp(draw->page, &bmp); - animatePlayer(draw, 1, 1, player.x, player.y, q, &ptmp); - mapScrollRight(draw, SPEED); - modexShowPage(draw->page); -// mapScrollRight(show, SPEED); -// SWAP(draw, show); - } - player.tx++; - } - else if(player.tx < MAPX) - { - for(q=0; q<(TILEWH/SPEED); q++) - { - player.x+=SPEED; -// modexDrawBmp(draw->page, player.x, player.y, &bmp); - animatePlayer(draw, 1, 0, player.x, player.y, q, &ptmp); - modexShowPage(draw->page); -// SWAP(draw, show); - } - player.tx++; - } + //when player.tx or player.ty == 0 or player.tx == 20 or player.ty == 15 then stop because that is edge of map and you do not want to walk of the map + if(keyp(77)){ +// for(q=0; qpage); +// mapScrollRight(draw, 1); +// SWAP(draw, show); +// } } - if(keyp(75)) - { - modexDrawSpriteRegion(draw->page, player.x-4, player.y-TILEWH, 24, 96, 24, 32, &ptmp); - if(draw->tx > 0 && draw->tx+20 <= MAPX && player.tx == draw->tx + 10) - { - for(q=0; q<(TILEWH/SPEED); q++) - { -// modexDrawBmp(draw->page, player.x-((q+1)*SPEED), player.y, &bmp); - animatePlayer(draw, 3, 1, player.x, player.y, q, &ptmp); - mapScrollLeft(draw, SPEED); - modexShowPage(draw->page); -// mapScrollLeft(show, SPEED); -// SWAP(draw, show); - } - player.tx--; - } - else if(player.tx > 1) - { - for(q=0; q<(TILEWH/SPEED); q++) - { - player.x-=SPEED; -// modexDrawBmp(draw->page, player.x, player.y, &bmp); - animatePlayer(draw, 3, 0, player.x, player.y, q, &ptmp); - modexShowPage(draw->page); -// SWAP(draw, show); - } - player.tx--; - } + if(keyp(75)){ +// for(q=0; qpage); +// mapScrollLeft(show, 1); +// SWAP(draw, show); +// } } - if(keyp(80)) - { - modexDrawSpriteRegion(draw->page, player.x-4, player.y-TILEWH, 24, 64, 24, 32, &ptmp); - if(draw->ty >= 0 && draw->ty+15 < MAPY && player.ty == draw->ty + 8) - { - for(q=0; q<(TILEWH/SPEED); q++) - { -// modexDrawBmp(draw->page, player.x, player.y+((q+1)*SPEED), &bmp); - animatePlayer(draw, 2, 1, player.x, player.y, q, &ptmp); - mapScrollDown(draw, SPEED); - modexShowPage(draw->page); -// mapScrollDown(show, SPEED); -// SWAP(draw, show); - } - player.ty++; - } - else if(player.ty < MAPY) - { - for(q=0; q<(TILEWH/SPEED); q++) - { - player.y+=SPEED; -// modexDrawBmp(draw->page, player.x, player.y, &bmp); - animatePlayer(draw, 2, 0, player.x, player.y, q, &ptmp); - modexShowPage(draw->page); -// SWAP(draw, show); - } - player.ty++; - } + if(keyp(80)){ +// for(q=0; qpage); +// mapScrollDown(show, 1); +// SWAP(draw, show); +// } } - if(keyp(72)) - { - modexDrawSpriteRegion(draw->page, player.x-4, player.y-TILEWH, 24, 0, 24, 32, &ptmp); - if(draw->ty > 0 && draw->ty+15 <= MAPY && player.ty == draw->ty + 8) - { - for(q=0; q<(TILEWH/SPEED); q++) - { -// modexDrawBmp(draw->page, player.x, player.y-((q+1)*SPEED), &bmp); - animatePlayer(draw, 0, 1, player.x, player.y, q, &ptmp); - mapScrollUp(draw, SPEED); - modexShowPage(draw->page); -// mapScrollUp(show, SPEED); -// SWAP(draw, show); - } - player.ty--; - } - else if(player.ty > 1) - { - for(q=0; q<(TILEWH/SPEED); q++) - { - player.y-=SPEED; -// modexDrawBmp(draw->page, player.x, player.y, &bmp); - animatePlayer(draw, 0, 0, player.x, player.y, q, &ptmp); - modexShowPage(draw->page); -// SWAP(draw, show); - } - player.ty--; - } + if(keyp(72)){ +// for(q=0; qpage); +// mapScrollUp(show, 1); +// SWAP(draw, show); +// } } + + //keyp(ch); + modexShowPage(draw->page); + } - + modexLeave(); - setkb(0); - printf("Project 16 scroll.exe\n"); - printf("tx: %d\n", draw->tx); - printf("ty: %d\n", draw->ty); - printf("player.x: %d\n", player.x); - printf("player.y: %d\n", player.y); - printf("player.tx: %d\n", player.tx); - printf("player.ty: %d\n", player.ty); + setkb(0); } @@ -463,46 +361,3 @@ mapDrawCol(map_view_t *mv, int tx, int ty, word x) { i += mv->map->width; } } - -void animatePlayer(map_view_t *mv, short d1, short d2, int x, int y, int ls, bitmap_t *bmp) -{ - int qq; - - if(d2==0) qq = 0; - else qq = ((ls+1)*SPEED); - switch (d1) - { - case 0: - //up - //if(ls==0) modexClearPlayer(mv->page, x-4, y-qq-TILEWH, 24, 32); - if(ls<1) { modexClearPlayer(mv->page, x-4, y-qq-TILEWH, 24, 32); modexDrawSpriteRegion(mv->page, x-4, y-qq-TILEWH, 24, 0, 24, 32, bmp); } - if(4>ls && ls>=1) { modexClearPlayer(mv->page, x-4, y-qq-TILEWH, 24, 32); modexDrawSpriteRegion(mv->page, x-4, y-qq-TILEWH, 48, 0, 24, 32, bmp); } - if(7>ls && ls>=4) { modexClearPlayer(mv->page, x-4, y-qq-TILEWH, 24, 32); modexDrawSpriteRegion(mv->page, x-4, y-qq-TILEWH, 0, 0, 24, 32, bmp); } - if(ls>=7) { modexClearPlayer(mv->page, x-4, y-qq-TILEWH, 24, 32); modexDrawSpriteRegion(mv->page, x-4, y-qq-TILEWH, 24, 0, 24, 32, bmp); } - break; - case 1: - // right - //if(ls==0) modexClearPlayer(mv->page, x+qq-4, y-TILEWH, 24, 32); - if(ls<1) { modexClearPlayer(mv->page, x+qq-4, y-TILEWH, 24, 32); modexDrawSpriteRegion(mv->page, x+qq-4, y-TILEWH, 24, 32, 24, 32, bmp); } - if(4>ls && ls>=1) { modexClearPlayer(mv->page, x+qq-4, y-TILEWH, 24, 32); modexDrawSpriteRegion(mv->page, x+qq-4, y-TILEWH, 48, 32, 24, 32, bmp); } - if(7>ls && ls>=4) { modexClearPlayer(mv->page, x+qq-4, y-TILEWH, 24, 32); modexDrawSpriteRegion(mv->page, x+qq-4, y-TILEWH, 0, 32, 24, 32, bmp); } - if(ls>=7) { modexClearPlayer(mv->page, x+qq-4, y-TILEWH, 24, 32); modexDrawSpriteRegion(mv->page, x+qq-4, y-TILEWH, 24, 32, 24, 32, bmp); } - break; - case 2: - //down - //if(ls==0) modexClearPlayer(mv->page, x-4, y+qq-TILEWH, 24, 32); - if(ls<1) { modexClearPlayer(mv->page, x-4, y+qq-TILEWH, 24, 32); modexDrawSpriteRegion(mv->page, x-4, y+qq-TILEWH, 24, 64, 24, 32, bmp); } - if(4>ls && ls>=1) { modexClearPlayer(mv->page, x-4, y+qq-TILEWH, 24, 32); modexDrawSpriteRegion(mv->page, x-4, y+qq-TILEWH, 48, 64, 24, 32, bmp); } - if(7>ls && ls>=4) { modexClearPlayer(mv->page, x-4, y+qq-TILEWH, 24, 32); modexDrawSpriteRegion(mv->page, x-4, y+qq-TILEWH, 0, 64, 24, 32, bmp); } - if(ls>=7) { modexClearPlayer(mv->page, x-4, y+qq-TILEWH, 24, 32); modexDrawSpriteRegion(mv->page, x-4, y+qq-TILEWH, 24, 64, 24, 32, bmp); } - break; - case 3: - //left - //if(ls==0) modexClearPlayer(mv->page, x-qq-4, y-TILEWH, 24, 32); - if(ls<1) { modexClearPlayer(mv->page, x-qq-4, y-TILEWH, 24, 32); modexDrawSpriteRegion(mv->page, x-qq-4, y-TILEWH, 24, 96, 24, 32, bmp); } - if(4>ls && ls>=1) { modexClearPlayer(mv->page, x-qq-4, y-TILEWH, 24, 32); modexDrawSpriteRegion(mv->page, x-qq-4, y-TILEWH, 48, 96, 24, 32, bmp); } - if(7>ls && ls>=4) { modexClearPlayer(mv->page, x-qq-4, y-TILEWH, 24, 32); modexDrawSpriteRegion(mv->page, x-qq-4, y-TILEWH, 0, 96, 24, 32, bmp); } - if(ls>=7) { modexClearPlayer(mv->page, x-qq-4, y-TILEWH, 24, 32); modexDrawSpriteRegion(mv->page, x-qq-4, y-TILEWH, 24, 96, 24, 32, bmp); } - break; - } -}