]> 4ch.mooo.com Git - 16.git/commitdiff
==== Ib CONTROL DONE./w.sh ./w.sh ==== \(^o^)/
authorsparky4 <sparky4@cock.li>
Sun, 13 Mar 2016 06:48:30 +0000 (00:48 -0600)
committersparky4 <sparky4@cock.li>
Sun, 13 Mar 2016 06:48:30 +0000 (00:48 -0600)
src/lib/16_in.c

index 038f8a263f3361f50e431d5568404dce919e6c70..4e32173bf7625674248da469551168054e0948b6 100755 (executable)
@@ -812,6 +812,7 @@ IN_ReadControl(int pn,player_t *player)
                        Motion          mx,my;\r
                        ControlType     type;\r
                        sword conpee;\r
+                       byte dir=DirTable[2];\r
 register       KeyboardDef     *def;\r
 \r
        dx = dy = 0;\r
@@ -874,7 +875,26 @@ register   KeyboardDef     *def;
                                {\r
                                        mx = motion_Right;\r
                                }\r
-                       }\r
+                       }else{  //2 keys pressed\r
+                                       switch (player[pn].pdir)\r
+                                       {\r
+                                               case 0:\r
+                                               case 4:\r
+                                                       if((inpu.Keyboard[def->left] && !inpu.Keyboard[def->right])) dir = DirTable[1];\r
+                                                       else if((inpu.Keyboard[def->right] && !inpu.Keyboard[def->left])) dir = DirTable[3];\r
+                                                       if(testcontrolnoisy > 0) printf("dir=%c ", dirchar(dir));\r
+                                               break;\r
+                                               case 1:\r
+                                               case 3:\r
+                                                       if((inpu.Keyboard[def->up] && !inpu.Keyboard[def->down])) dir = DirTable[0];\r
+                                                       else if((inpu.Keyboard[def->down] && !inpu.Keyboard[def->up])) dir = DirTable[4];\r
+                                                       if(testcontrolnoisy > 0) printf("dir=%c ", dirchar(dir));\r
+                                               break;\r
+                                               default:\r
+                                               break;\r
+                                       }\r
+                                       if(testcontrolnoisy > 0) printf("pdir=%c        ", dirchar(player[pn].pdir));\r
+                               }\r
                        }\r
                        //input from player\r
                        if (inpu.Keyboard[def->button0])\r
@@ -923,14 +943,15 @@ register  KeyboardDef     *def;
        player[pn].info.button2 = buttons & (1 << 2);\r
        player[pn].info.button3 = buttons & (1 << 3);\r
 //     player[pn].info.dir = DirTable[((my + 1) * 3) + (mx + 1)];\r
-       conpee=(((my + 1) * 2) + (mx + 1))-1; //if(conpee) conpee--;\r
+       conpee=(((my + 1) * 2) + (mx + 1))-1;\r
        player[pn].info.dir = DirTable[conpee];\r
 \r
        //TODO: overwriting direction must be added\r
        if(DirTable[conpee]!=2) player[pn].pdir=DirTable[conpee];\r
-       if(player[pn].q==1 && (mx!=motion_None || my!=motion_None))\r
+       if(player[pn].q==1 &&( dir!=2 || (mx!=motion_None || my!=motion_None)))\r
        {\r
-               player[pn].d = player[pn].info.dir;\r
+               if(dir==2) player[pn].d = player[pn].info.dir;\r
+               else player[pn].d = DirTable[dir];\r
        }\r
 \r
 #if DEMO0\r