X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=scroll.c;h=057a5ee549df0a0edba744805f4e9c7b445d15fd;hb=223378457fa5f386bc056f7162bba6c523d6164f;hp=fdfd4e9f7b105cdb8741cb20d09b4389d31fd6ec;hpb=d7c52e3abe4c0bad23c11f5da38aa35a934eb96c;p=16.git diff --git a/scroll.c b/scroll.c index fdfd4e9f..057a5ee5 100644 --- a/scroll.c +++ b/scroll.c @@ -63,7 +63,7 @@ void animatePlayer(map_view_t *src, map_view_t *dest, short d1, short d2, int x, #define SWAP(a, b) tmp=a; a=b; b=tmp; void main() { bitmap_t ptmp; // player sprite - int q=0; + int q=1; page_t screen, screen2; map_t map; map_view_t mv, mv2; @@ -72,7 +72,7 @@ void main() { 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 bgn properly + 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 initMap(&map); mv.map = ↦ mv2.map = ↦ @@ -118,7 +118,7 @@ void main() { { if(bg->tx >= 0 && bg->tx+20 < MAPX && player.tx == bg->tx + 10) { - for(q=0; q<(TILEWH/SPEED); q++) + for(q=1; q<=(TILEWH/SPEED); q++) { animatePlayer(bg, spri, 1, 1, player.x, player.y, q, &ptmp); mapScrollRight(bg, SPEED); @@ -129,7 +129,7 @@ void main() { } else if(player.tx < MAPX) { - for(q=0; q<(TILEWH/SPEED); q++) + for(q=1; q<=(TILEWH/SPEED); q++) { player.x+=SPEED; animatePlayer(bg, spri, 1, 0, player.x, player.y, q, &ptmp); @@ -149,7 +149,7 @@ void main() { { if(bg->tx > 0 && bg->tx+20 <= MAPX && player.tx == bg->tx + 10) { - for(q=0; q<(TILEWH/SPEED); q++) + for(q=1; q<=(TILEWH/SPEED); q++) { animatePlayer(bg, spri, 3, 1, player.x, player.y, q, &ptmp); @@ -161,7 +161,7 @@ void main() { } else if(player.tx > 1) { - for(q=0; q<(TILEWH/SPEED); q++) + for(q=1; q<=(TILEWH/SPEED); q++) { player.x-=SPEED; animatePlayer(bg, spri, 3, 0, player.x, player.y, q, &ptmp); @@ -181,7 +181,7 @@ void main() { { if(bg->ty >= 0 && bg->ty+15 < MAPY && player.ty == bg->ty + 8) { - for(q=0; q<(TILEWH/SPEED); q++) + for(q=1; q<=(TILEWH/SPEED); q++) { animatePlayer(bg, spri, 2, 1, player.x, player.y, q, &ptmp); mapScrollDown(bg, SPEED); @@ -192,7 +192,7 @@ void main() { } else if(player.ty < MAPY) { - for(q=0; q<(TILEWH/SPEED); q++) + for(q=1; q<=(TILEWH/SPEED); q++) { player.y+=SPEED; animatePlayer(bg, spri, 2, 0, player.x, player.y, q, &ptmp); @@ -212,7 +212,7 @@ void main() { { if(bg->ty > 0 && bg->ty+15 <= MAPY && player.ty == bg->ty + 8) { - for(q=0; q<(TILEWH/SPEED); q++) + for(q=1; q<=(TILEWH/SPEED); q++) { animatePlayer(bg, spri, 0, 1, player.x, player.y, q, &ptmp); mapScrollUp(bg, SPEED); @@ -223,7 +223,7 @@ void main() { } else if(player.ty > 1) { - for(q=0; q<(TILEWH/SPEED); q++) + for(q=1; q<=(TILEWH/SPEED); q++) { player.y-=SPEED; animatePlayer(bg, spri, 0, 0, player.x, player.y, q, &ptmp); @@ -238,7 +238,7 @@ void main() { modexShowPage(spri->page); } } - + } modexLeave(); @@ -308,7 +308,7 @@ initMap(map_t *map) { void mapScrollRight(map_view_t *mv, byte offset) { - word x, y; /* coordinate for bging */ + word x, y; /* coordinate for drawing */ /* increment the pixel position and update the page */ mv->page->dx += offset; @@ -322,7 +322,7 @@ mapScrollRight(map_view_t *mv, byte offset) { mv->page->dx = mv->map->tiles->tileWidth; - /* bg the next column */ + /* draw the next column */ x= SCREEN_WIDTH + mv->map->tiles->tileWidth; mapDrawCol(mv, mv->tx + 20 , mv->ty-1, x); } @@ -331,7 +331,7 @@ mapScrollRight(map_view_t *mv, byte offset) { void mapScrollLeft(map_view_t *mv, byte offset) { - word x, y; /* coordinate for bging */ + word x, y; /* coordinate for drawing */ /* increment the pixel position and update the page */ mv->page->dx -= offset; @@ -345,7 +345,7 @@ mapScrollLeft(map_view_t *mv, byte offset) { mv->page->data -= 4; mv->page->dx = mv->map->tiles->tileWidth; - /* bg the next column */ + /* draw the next column */ mapDrawCol(mv, mv->tx-1, mv->ty-1, 0); } } @@ -353,7 +353,7 @@ mapScrollLeft(map_view_t *mv, byte offset) { void mapScrollUp(map_view_t *mv, byte offset) { - word x, y; /* coordinate for bging */ + word x, y; /* coordinate for drawing */ /* increment the pixel position and update the page */ mv->page->dy -= offset; @@ -367,7 +367,7 @@ mapScrollUp(map_view_t *mv, byte offset) { mv->page->dy = mv->map->tiles->tileHeight; - /* bg the next row */ + /* draw the next row */ y= 0; mapDrawRow(mv, mv->tx-1 , mv->ty-1, y); } @@ -376,7 +376,7 @@ mapScrollUp(map_view_t *mv, byte offset) { void mapScrollDown(map_view_t *mv, byte offset) { - word x, y; /* coordinate for bging */ + word x, y; /* coordinate for drawing */ /* increment the pixel position and update the page */ mv->page->dy += offset; @@ -390,7 +390,7 @@ mapScrollDown(map_view_t *mv, byte offset) { mv->page->dy = mv->map->tiles->tileHeight; - /* bg the next row */ + /* draw the next row */ y= SCREEN_HEIGHT + mv->map->tiles->tileHeight; mapDrawRow(mv, mv->tx-1 , mv->ty+15, y); } @@ -413,7 +413,7 @@ mapGoTo(map_view_t *mv, int tx, int ty) { mv->dxThresh = mv->map->tiles->tileWidth * 2; mv->dyThresh = mv->map->tiles->tileHeight * 2; - /* bg the tiles */ + /* draw the tiles */ modexClearRegion(mv->page, 0, 0, mv->page->width, mv->page->height, 0); py=0; i=mv->ty * mv->map->width + mv->tx; @@ -472,11 +472,11 @@ mapDrawCol(map_view_t *mv, int tx, int ty, word x) { void animatePlayer(map_view_t *src, map_view_t *dest, short d1, short d2, int x, int y, int ls, bitmap_t *bmp) -{ +{ short dire=32*d1; short qq; short lo = ((TILEWH / SPEED) / 3); - short loo = (ls + lo); + short loo = (ls + lo); if(d2==0) qq = 0; else qq = ((ls+1)*SPEED); @@ -502,13 +502,15 @@ animatePlayer(map_view_t *src, map_view_t *dest, short d1, short d2, int x, int x=x-qq-4; y=y-TILEWH; break; - } //TODO: make flexible animation thingy - if(2>ls && ls>=0) { modexCopyPageRegion(dest->page, src->page, x-2, y-4, x-2, y-4, 28, 40); - modexDrawSpriteRegion(dest->page, x, y, 48, dire, 24, 32, bmp); modexWaitBorder(); }else - if(4>ls && ls>=2) { modexCopyPageRegion(dest->page, src->page, x-2, y-4, x-2, y-4, 28, 40); - modexDrawSpriteRegion(dest->page, x, y, 24, dire, 24, 32, bmp); modexWaitBorder(); }else - if(6>ls && ls>4) { modexCopyPageRegion(dest->page, src->page, x-2, y-4, x-2, y-4, 28, 40); - modexDrawSpriteRegion(dest->page, x, y, 0, dire, 24, 32, bmp); modexWaitBorder(); }else - if(8>ls && ls>6) { modexCopyPageRegion(dest->page, src->page, x-2, y-4, x-2, y-4, 28, 40); - modexDrawSpriteRegion(dest->page, x, y, 24, dire, 24, 32, bmp); modexWaitBorder(); }else ls-=ls; + } + //TODO: make flexible animation thingy + if(2>ls && ls>=1) { modexCopyPageRegion(dest->page, src->page, x-2, y-4, x-2, y-4, 28, 40); + modexDrawSpriteRegion(dest->page, x, y, 48, dire, 24, 32, bmp); }else + if(3>ls && ls>=2) { modexCopyPageRegion(dest->page, src->page, x-2, y-4, x-2, y-4, 28, 40); + modexDrawSpriteRegion(dest->page, x, y, 24, dire, 24, 32, bmp); }else + if(4>ls && ls>=3) { modexCopyPageRegion(dest->page, src->page, x-2, y-4, x-2, y-4, 28, 40); + modexDrawSpriteRegion(dest->page, x, y, 0, dire, 24, 32, bmp); }else + if(5>ls && ls>=4) { modexCopyPageRegion(dest->page, src->page, x-2, y-4, x-2, y-4, 28, 40); + modexDrawSpriteRegion(dest->page, x, y, 24, dire, 24, 32, bmp); } + modexWaitBorder(); }