]> 4ch.mooo.com Git - 16.git/commitdiff
new file: 16/modex16/ptmp.pcx
authorsparky4 <sparky4@cock.li>
Sat, 22 Nov 2014 17:55:12 +0000 (11:55 -0600)
committersparky4 <sparky4@cock.li>
Sat, 22 Nov 2014 17:55:12 +0000 (11:55 -0600)
modified:   16/modex16/scroll.c
modified:   16/modex16/scroll.exe
working on scroll thingy i am confused

16/modex16/ptmp.pcx [new file with mode: 0644]
16/modex16/scroll.c
16/modex16/scroll.exe

diff --git a/16/modex16/ptmp.pcx b/16/modex16/ptmp.pcx
new file mode 100644 (file)
index 0000000..879e70c
Binary files /dev/null and b/16/modex16/ptmp.pcx differ
index 55e2fe9465d205d90c21a657d43cafd3c10281d1..42655ffa6312ac67fd5fc66fea8b9293bb43a3ef 100644 (file)
@@ -11,7 +11,7 @@ typedef struct {
        word tileWidth;\r
        unsigned int rows;\r
        unsigned int cols;\r
-       unsigned int tilex,tiley; // tile position on the map\r
+       //unsigned int tilex,tiley; // tile position on the map\r
 } tiles_t;\r
 \r
 \r
@@ -34,9 +34,11 @@ typedef struct {
        word dyThresh; //????\r
 } map_view_t;\r
 \r
-struct {\r
-       int tx; //player position on the viewable map\r
-       int ty; //player position on the viewable map\r
+struct {
+       int x; //player exact position on the viewable map\r
+       int y; //player exact position on the viewable map\r
+       int tx; //player tile position on the viewable map\r
+       int ty; //player tile position on the viewable map\r
 } player;\r
 \r
 \r
@@ -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\r
+#define MAPX 24
+#define MAPY 19\r
 //#define SWAP(a, b) tmp=a; a=b; b=tmp;\r
 void main() {\r
-//     int show1=1;\r
-       int tx, ty;\r
-       int x, y;\r
-       //int ch=0x0;\r
-//     byte ch;\r
+       bitmap_t bmp;\r
+//     int tx, ty;\r
+//     int x, y;\r
        int q=0;\r
        page_t screen;//,screen2;\r
        map_t map;\r
@@ -72,23 +72,17 @@ void main() {
        map_view_t *draw;//, *show, *tmp;\r
        byte *ptr;\r
 \r
-       //default player position on the viewable map\r
-       player.tx = 10;\r
-       player.ty = 8;\r
-\r
        setkb(1);\r
        /* create the map */\r
        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\r
        initMap(&map);\r
        mv.map = &map;
-
-       //initiate bottem right edge trigger
-//     mv.ttx = mv.tx + 20;
-//     mv.tty = mv.ty + 15;\r
 //     mv2.map = &map;\r
 \r
        /* draw the tiles */\r
-       ptr = map.data;\r
+       ptr = map.data;
+       bmp = bitmapLoadPcx("ptmp.pcx"); // load sprite
+       modexPalUpdate(bmp.palette);\r
        modexEnter();\r
        screen = modexDefaultPage();\r
        screen.width += (TILEWH*2);\r
@@ -106,57 +100,113 @@ void main() {
        mapGoTo(draw, 0, 0);\r
 \r
        //TODO: set player position data here according to the viewable map screen thingy\r
+       //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);\r
-       while(!keyp(1)) {\r
+       while(!keyp(1))
+       {\r
        //TODO: top left corner & bottem right corner of map veiw be set as map edge trigger since maps are actually square\r
        //to stop scrolling and have the player position data move to the edge of the screen with respect to the direction\r
-       //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\r
-       if(keyp(77)){
-               if(draw->tx >= 0 && draw->tx+20 < MAPX)\r
-                       for(q=0; q<(TILEWH/SPEED); q++) {\r
+       //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)
+               {\r
+                       for(q=0; q<(TILEWH/SPEED); q++)
+                       {\r
                                mapScrollRight(draw, SPEED);\r
                                modexShowPage(draw->page);\r
 //             mapScrollRight(draw, 1);\r
 //             SWAP(draw, show);\r
                        }
-\r
+               }
+               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++;
+               }\r
        }\r
 \r
        if(keyp(75)){
-               if(draw->tx > 0 && draw->tx+20 <= MAPX)\r
-                       for(q=0; q<(TILEWH/SPEED); q++) {\r
+               if(draw->tx >= 0 && draw->tx+20 <= MAPX && player.tx == draw->tx + 10)
+               {\r
+                       for(q=0; q<(TILEWH/SPEED); q++)
+                       {\r
                                mapScrollLeft(draw, SPEED);\r
                                modexShowPage(draw->page);\r
 //             mapScrollLeft(show, 1);\r
 //             SWAP(draw, show);\r
                        }\r
-
+               }
+               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--;
+               }
        }\r
 \r
-       if(keyp(80)){
-               if(draw->ty >= 0 && draw->ty+15 < MAPY)\r
-                       for(q=0; q<(TILEWH/SPEED); q++) {\r
+       if(keyp(80))
+       {
+               if(draw->ty >= 0 && draw->ty+15 <= MAPY && player.ty == draw->ty + 8)
+               {\r
+                       for(q=0; q<(TILEWH/SPEED); q++)
+                       {\r
                                mapScrollDown(draw, SPEED);\r
                                modexShowPage(draw->page);\r
 //             mapScrollDown(show, 1);\r
 //             SWAP(draw, show);\r
                        }
-\r
+               }
+               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++;
+               }\r
        }\r
 \r
-       if(keyp(72)){
-               if(draw->ty > 0 && draw->ty+15 <= MAPY)\r
-                       for(q=0; q<(TILEWH/SPEED); q++) {\r
+       if(keyp(72))
+       {
+               if(draw->ty >= 0 && draw->ty+15 <= MAPY && player.ty == draw->ty + 8)
+               {\r
+                       for(q=0; q<(TILEWH/SPEED); q++)
+                       {\r
                                mapScrollUp(draw, SPEED);\r
                                modexShowPage(draw->page);\r
 //             mapScrollUp(show, 1);\r
 //             SWAP(draw, show);\r
                        }
-\r
+               }
+               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--;
+               }\r
        }\r
-\r
-       //keyp(ch);\r
+       modexDrawBmp(draw->page, player.x, player.y, &bmp);\r
        //modexShowPage(draw->page);\r
 \r
        }\r
@@ -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);
 }\r
 \r
 \r
index 7b65f2fe5ba4e7e60270ee9cff412a1624e6c84a..e8303da0321b9eaf4429a0758dfa0042874661fc 100755 (executable)
Binary files a/16/modex16/scroll.exe and b/16/modex16/scroll.exe differ