From: sparky4 Date: Sat, 22 Nov 2014 17:55:12 +0000 (-0600) Subject: new file: 16/modex16/ptmp.pcx X-Git-Url: http://4ch.mooo.com/gitweb/?a=commitdiff_plain;h=b852f11c4e5353371ae074f6e3b5e9dedcdbd8c7;p=16.git new file: 16/modex16/ptmp.pcx modified: 16/modex16/scroll.c modified: 16/modex16/scroll.exe working on scroll thingy i am confused --- diff --git a/16/modex16/ptmp.pcx b/16/modex16/ptmp.pcx new file mode 100644 index 00000000..879e70c2 Binary files /dev/null and b/16/modex16/ptmp.pcx differ diff --git a/16/modex16/scroll.c b/16/modex16/scroll.c index 55e2fe94..42655ffa 100644 --- 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; @@ -34,9 +34,11 @@ typedef struct { word dyThresh; //???? } map_view_t; -struct { - int tx; //player position on the viewable map - int ty; //player position on the viewable map +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 } player; @@ -56,15 +58,13 @@ void mapDrawCol(map_view_t *mv, int tx, int ty, word x); #define SPEED 2 //place holder definitions -#define MAPX 40 -#define MAPY 30 +#define MAPX 24 +#define MAPY 19 //#define SWAP(a, b) tmp=a; a=b; b=tmp; void main() { -// int show1=1; - int tx, ty; - int x, y; - //int ch=0x0; -// byte ch; + bitmap_t bmp; +// int tx, ty; +// int x, y; int q=0; page_t screen;//,screen2; map_t map; @@ -72,23 +72,17 @@ void main() { 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 initMap(&map); mv.map = ↦ - - //initiate bottem right edge trigger -// mv.ttx = mv.tx + 20; -// mv.tty = mv.ty + 15; // mv2.map = ↦ /* draw the tiles */ - ptr = map.data; + ptr = map.data; + bmp = bitmapLoadPcx("ptmp.pcx"); // load sprite + modexPalUpdate(bmp.palette); modexEnter(); screen = modexDefaultPage(); screen.width += (TILEWH*2); @@ -106,57 +100,113 @@ void main() { mapGoTo(draw, 0, 0); //TODO: set player position data here according to the viewable map screen thingy + //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; modexShowPage(draw->page); - while(!keyp(1)) { + 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 - if(keyp(77)){ - if(draw->tx >= 0 && draw->tx+20 < MAPX) - for(q=0; q<(TILEWH/SPEED); q++) { + //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)) + { + if(draw->tx >= 0 && draw->tx+20 <= MAPX && player.tx == draw->tx + 10) + { + for(q=0; q<(TILEWH/SPEED); q++) + { mapScrollRight(draw, SPEED); modexShowPage(draw->page); // mapScrollRight(draw, 1); // SWAP(draw, show); } - + } + else if(player.tx < draw->tx+20 && player.tx >= draw->tx + 10)// && player.tx <= draw->tx+10) + { + for(q=0; q<(TILEWH/SPEED); q++) + { + player.x+=SPEED; + modexDrawBmp(draw->page, player.x, player.y, &bmp); + modexShowPage(draw->page); + } + player.tx++; + } } if(keyp(75)){ - if(draw->tx > 0 && draw->tx+20 <= MAPX) - for(q=0; q<(TILEWH/SPEED); q++) { + if(draw->tx >= 0 && draw->tx+20 <= MAPX && player.tx == draw->tx + 10) + { + for(q=0; q<(TILEWH/SPEED); q++) + { mapScrollLeft(draw, SPEED); modexShowPage(draw->page); // mapScrollLeft(show, 1); // SWAP(draw, show); } - + } + else if(player.tx > 0 && player.tx <= draw->tx + 10)// && player.tx >= draw->tx+10) + { + for(q=0; q<(TILEWH/SPEED); q++) + { + player.x-=SPEED; + modexDrawBmp(draw->page, player.x, player.y, &bmp); + modexShowPage(draw->page); + } + player.tx--; + } } - if(keyp(80)){ - if(draw->ty >= 0 && draw->ty+15 < MAPY) - for(q=0; q<(TILEWH/SPEED); q++) { + if(keyp(80)) + { + if(draw->ty >= 0 && draw->ty+15 <= MAPY && player.ty == draw->ty + 8) + { + for(q=0; q<(TILEWH/SPEED); q++) + { mapScrollDown(draw, SPEED); modexShowPage(draw->page); // mapScrollDown(show, 1); // SWAP(draw, show); } - + } + else if(player.ty < draw->ty+15 && player.ty >= draw->ty + 8)// && player.ty <= draw->ty+8) + { + for(q=0; q<(TILEWH/SPEED); q++) + { + player.y+=SPEED; + modexDrawBmp(draw->page, player.x, player.y, &bmp); + modexShowPage(draw->page); + } + player.ty++; + } } - if(keyp(72)){ - if(draw->ty > 0 && draw->ty+15 <= MAPY) - for(q=0; q<(TILEWH/SPEED); q++) { + if(keyp(72)) + { + if(draw->ty >= 0 && draw->ty+15 <= MAPY && player.ty == draw->ty + 8) + { + for(q=0; q<(TILEWH/SPEED); q++) + { mapScrollUp(draw, SPEED); modexShowPage(draw->page); // mapScrollUp(show, 1); // SWAP(draw, show); } - + } + else if(player.ty > 0 && player.ty <= draw->ty + 8)// && player.ty >= draw->ty+8) + { + for(q=0; q<(TILEWH/SPEED); q++) + { + player.y-=SPEED; + modexDrawBmp(draw->page, player.x, player.y, &bmp); + modexShowPage(draw->page); + } + player.ty--; + } } - - //keyp(ch); + modexDrawBmp(draw->page, player.x, player.y, &bmp); //modexShowPage(draw->page); } @@ -166,8 +216,8 @@ void main() { printf("Project 16 scroll.exe\n"); printf("tx: %d\n", draw->tx); printf("ty: %d\n", draw->ty); - //printf("ttx: %d\n", draw->ttx); - //printf("tty: %d\n", draw->tty); + printf("player.tx: %d\n", player.tx); + printf("player.ty: %d\n", player.ty); } diff --git a/16/modex16/scroll.exe b/16/modex16/scroll.exe index 7b65f2fe..e8303da0 100755 Binary files a/16/modex16/scroll.exe and b/16/modex16/scroll.exe differ