X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Fscroll.c;h=f511073ca76ad7735fe9f89b2106ea47a30f0f2f;hb=826bb2cb2cb8bf7397f2555b8a6b98eb0a838a3f;hp=bf91077220abb1bc7a5869b57b553fac89352460;hpb=8a8fb40308c7043fd3d8b18437dbffaff3a0b804;p=16.git diff --git a/src/scroll.c b/src/scroll.c index bf910772..f511073c 100644 --- a/src/scroll.c +++ b/src/scroll.c @@ -32,18 +32,17 @@ typedef struct { word dyThresh; //???? } map_view_t; -//TODO: make this into actor_t -struct { +typedef 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 triggerx; //player's trigger box tile position on the viewable map int triggery; //player's trigger box tile position on the viewable map - sword q; //loop variable - sword d; //direction + word q; //loop variable + word d; //direction int hp; //hitpoints of the player -} player; +} actor_t; map_t allocMap(int w, int h); @@ -55,8 +54,8 @@ 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); -sword dpad(sword keypressed); +void mapDrawCol(map_view_t *mv, int tx, int ty, word x); +sword dpad(actor_t *qd); void animatePlayer(map_view_t *src, map_view_t *dest, /*map_view_t *top, */short d1, short d2, int x, int y, int ls, int lp, bitmap_t *bmp); #define TILEWH 16 @@ -77,13 +76,11 @@ void main() { page_t screen, screen2, screen3; map_t map; map_view_t mv, mv2, mv3; - map_view_t *bg, *spri, *mask;//, *tmp; + map_view_t *bg, *spri, *mask;//, *tmp; byte *pal; - byte *ptr; - sword keypressed = 0; + byte *ptr; + actor_t player; - player.q=1; - player.d=0; /* save the palette */ pal = modexNewPal(); @@ -127,16 +124,17 @@ void main() { //mapGoTo(mask, 0, 0); //TODO: put player in starting position of spot - //default player position on the viewable map + //default player position on the viewable map player.tx = bg->tx + 10; player.ty = bg->ty + 8; player.x = player.tx*TILEWH; player.y = player.ty*TILEWH; player.triggerx = player.tx; player.triggery = player.ty+1; - //TODO: erase player initial draw + player.q=0; + player.d=0; modexDrawSpriteRegion(spri->page, player.x-4, player.y-TILEWH, 24, 64, 24, 32, &ptmp); - //temp draw trigger box + modexClearRegion(spri->page, player.triggerx*16, player.triggery*16, 16, 16, 1); modexClearRegion(bg->page, player.triggerx*16, player.triggery*16, 16, 16, 1); modexShowPage(spri->page); @@ -147,12 +145,12 @@ void main() { //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: make this better like rpg maker 2000 better - if(player.q == 1) + //TODO: make this better like rpg maker 2000 better + if(player.q <= 1) { - dpad(keypressed); - if(keypressed>1){ dpad(keypressed); } - keypressed = 0; + dpad(&player); + if(player.d>0) dpad(&player); + if(player.q<1) player.q++; } #define INC_PER_FRAME if(player.q&1) persist_aniframe++; if(persist_aniframe>4) persist_aniframe = 1; @@ -161,7 +159,6 @@ void main() { { if(bg->tx >= 0 && bg->tx+20 < MAPX && player.tx == bg->tx + 10 && !(player.tx+1 == TRIGGX && player.ty == TRIGGY)) { - //for(q=1; q<=(TILEWH/SPEED); q++) if(player.q<=(TILEWH/SPEED)) { INC_PER_FRAME; @@ -172,11 +169,10 @@ void main() { //mapScrollRight(mask, SPEED); modexShowPage(spri->page); player.q++; - } else { player.q = 1; player.d = 0; player.tx++; } + } else { player.q = 0; player.d = 0; player.tx++; } } else if(player.tx < MAPX && !(player.tx+1 == TRIGGX && player.ty == TRIGGY)) { - //for(q=1; q<=(TILEWH/SPEED); q++) if(player.q<=(TILEWH/SPEED)) { INC_PER_FRAME; @@ -185,7 +181,7 @@ void main() { animatePlayer(bg, spri, 1, 0, player.x, player.y, persist_aniframe, player.q, &ptmp); modexShowPage(spri->page); player.q++; - } else { player.q = 1; player.d = 0; player.tx++; } + } else { player.q = 0; player.d = 0; player.tx++; } } else { @@ -202,7 +198,6 @@ void main() { { if(bg->tx > 0 && bg->tx+20 <= MAPX && player.tx == bg->tx + 10 && !(player.tx-1 == TRIGGX && player.ty == TRIGGY)) { - //for(q=1; q<=(TILEWH/SPEED); q++) if(player.q<=(TILEWH/SPEED)) { INC_PER_FRAME; @@ -213,11 +208,10 @@ void main() { //mapScrollLeft(mask, SPEED); modexShowPage(spri->page); player.q++; - } else { player.q = 1; player.d = 0; player.tx--; } + } else { player.q = 0; player.d = 0; player.tx--; } } else if(player.tx > 1 && !(player.tx-1 == TRIGGX && player.ty == TRIGGY)) { - //for(q=1; q<=(TILEWH/SPEED); q++) if(player.q<=(TILEWH/SPEED)) { INC_PER_FRAME; @@ -226,7 +220,7 @@ void main() { animatePlayer(bg, spri, 3, 0, player.x, player.y, persist_aniframe, player.q, &ptmp); modexShowPage(spri->page); player.q++; - } else { player.q = 1; player.d = 0; player.tx--; } + } else { player.q = 0; player.d = 0; player.tx--; } } else { @@ -243,7 +237,6 @@ void main() { { if(bg->ty >= 0 && bg->ty+15 < MAPY && player.ty == bg->ty + 8 && !(player.tx == TRIGGX && player.ty+1 == TRIGGY)) { - //for(q=1; q<=(TILEWH/SPEED); q++) if(player.q<=(TILEWH/SPEED)) { INC_PER_FRAME; @@ -254,11 +247,10 @@ void main() { //mapScrollDown(mask, SPEED); modexShowPage(spri->page); player.q++; - } else { player.q = 1; player.d = 0; player.ty++; } + } else { player.q = 0; player.d = 0; player.ty++; } } else if(player.ty < MAPY && !(player.tx == TRIGGX && player.ty+1 == TRIGGY)) { - //for(q=1; q<=(TILEWH/SPEED); q++) if(player.q<=(TILEWH/SPEED)) { INC_PER_FRAME; @@ -267,7 +259,7 @@ void main() { animatePlayer(bg, spri, 2, 0, player.x, player.y, persist_aniframe, player.q, &ptmp); modexShowPage(spri->page); player.q++; - } else { player.q = 1; player.d = 0; player.ty++; } + } else { player.q = 0; player.d = 0; player.ty++; } } else { @@ -284,7 +276,6 @@ void main() { { if(bg->ty > 0 && bg->ty+15 <= MAPY && player.ty == bg->ty + 8 && !(player.tx == TRIGGX && player.ty-1 == TRIGGY)) { - //for(q=1; q<=(TILEWH/SPEED); q++) if(player.q<=(TILEWH/SPEED)) { INC_PER_FRAME; @@ -295,11 +286,10 @@ void main() { //mapScrollUp(mask, SPEED); modexShowPage(spri->page); player.q++; - } else { player.q = 1; player.d = 0; player.ty--; } + } else { player.q = 0; player.d = 0; player.ty--; } } else if(player.ty > 1 && !(player.tx == TRIGGX && player.ty-1 == TRIGGY)) { - //for(q=1; q<=(TILEWH/SPEED); q++) if(player.q<=(TILEWH/SPEED)) { INC_PER_FRAME; @@ -308,7 +298,7 @@ void main() { modexShowPage(spri->page); animatePlayer(bg, spri, 0, 0, player.x, player.y, persist_aniframe, player.q, &ptmp); player.q++; - } else { player.q = 1; player.d = 0; player.ty--; } + } else { player.q = 0; player.d = 0; player.ty--; } } else { @@ -452,7 +442,7 @@ mapScrollLeft(map_view_t *mv, byte offset) { if(mv->page->dx == 0) { /* go backward one tile */ mv->tx--; - + /* Snap the origin backward */ mv->page->data -= 4; mv->page->dx = mv->map->tiles->tileWidth; @@ -580,16 +570,41 @@ mapDrawCol(map_view_t *mv, int tx, int ty, word x) { i += mv->map->width; } } - -sword -dpad(sword keypressed) + +sword +dpad(actor_t *qd) { - if(keypressed>1) keypressed=0; - if(keyp(75) && !keyp(77)){ player.d = 4; keypressed++; } - if(keyp(80) && !keyp(72)){ player.d = 3; keypressed++; } - if(keyp(77) && !keyp(75)){ player.d = 2; keypressed++; } - if(keyp(72) && !keyp(80)){ player.d = 1; keypressed++; } - return keypressed; + if((keyp(75) && !keyp(77))) qd->d = 4; //left + if((keyp(80) && !keyp(72))) qd->d = 3; //down + if((keyp(77) && !keyp(75))) qd->d = 2; //right + if((keyp(72) && !keyp(80))) qd->d = 1; //up +/* if(qd->d==0) + { + //if((keyp(80) || keyp(72))) + //{ + if((keyp(72) && !keyp(80))&&qd->d==0) qd->d = 1; //up + if((keyp(80) && !keyp(72))&&qd->d==0) qd->d = 3; //down + //} + //if((keyp(75) || keyp(77))) + //{ + if((keyp(75) && !keyp(77))&&qd->d==0) qd->d = 4; //left + if((keyp(77) && !keyp(75))&&qd->d==0) qd->d = 2; //right + //} + } + else + { + if((qd->d==2 || qd->d==4)) + { + if(keyp(72) && !keyp(80)) qd->d = 1; //up + if(keyp(80) && !keyp(72)) qd->d = 3; //down + } + else if((qd->d==1 || qd->d==3)) + { + if(keyp(75) && !keyp(77)) qd->d = 4; //left + if(keyp(77) && !keyp(75)) qd->d = 2; //right + } + }*/ + return qd->d; } void