Author Topic: Quake Chess  (Read 4964 times)

0 Members and 1 Guest are viewing this topic.

Offline Unseen Machine

  • Forum Regular
  • Posts: 158
  • Make the game not the engine!
    • View Profile
Quake Chess
« on: April 01, 2020, 05:32:59 pm »
Hi All,

Inspired by the DOS classic from my youth "Battle Chess" and using models from my favorite shoot em up "Quake" this is a Re-write of a program i made many years ago (never finished it) which i've lost.

For now all you can do is control the pawns (Opposite side i white and goes first)...but i did only start coding this morning...i'll need some help on CPU implementation when i get that far fellas...

Extract the files/folder to your QB64 Directory and load/compile QuakeChess01.bas

Thanks

Unseen
* Quake_Chess.rar (Filesize: 3.95 MB, Downloads: 244)

Offline Richard Frost

  • Seasoned Forum Regular
  • Posts: 316
  • Needle nardle noo. - Peter Sellers
    • View Profile
Re: Quake Chess
« Reply #1 on: April 01, 2020, 06:08:41 pm »
I'd like to see and run this program, but the only rar extractor I see is NCH Software, which
apparently has a shady past. 

Might you use a more common compression scheme that produces zip files?

Check my insane chess pieces (program posted today) with shift-z.    :)

It works better if you plug it in.

Offline Unseen Machine

  • Forum Regular
  • Posts: 158
  • Make the game not the engine!
    • View Profile
Re: Quake Chess
« Reply #2 on: April 01, 2020, 06:19:00 pm »
No problems, and sure ill have a look see at your program in the morning, im off to me bed now but i look forward to your feedback.

Thanks

Unseen

* QuakeChess.zip (Filesize: 3.96 MB, Downloads: 230)

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Quake Chess
« Reply #3 on: April 01, 2020, 06:27:43 pm »
Thanks for zip, Battle Chess brings back memories.

Offline Unseen Machine

  • Forum Regular
  • Posts: 158
  • Make the game not the engine!
    • View Profile
Re: Quake Chess
« Reply #4 on: April 03, 2020, 06:40:59 pm »
Hi gang,

Latest code update, should work with the previous file download.

Now you can move all the pieces as they should move.

I need to add piece swapping (when you get a pawn to the other side), castling, checking for check and a few other gameplay bits as well as the animations but you can play a two player game with it now.

Code: QB64: [Select]
  1. '// Quake Chess V.01
  2. '// By John Onyon a.k.a Unseen Machine
  3. '// Created 01/04/2020
  4. '// Last Update 03/04/2020
  5.  
  6. CONST FP = 1, Fixed = 2, Action = 3
  7.  
  8. REM $include:'GDK_GL\GDK_GL.bi'
  9.  
  10. DIM SHARED Init AS _BYTE, Model(5) AS MODEL, Allow_GL AS _BYTE, CamVec AS VECTOR_GL, Floor(1) AS LONG, Flr_Lst AS _UNSIGNED LONG
  11. DIM SHARED CamMode AS _BYTE, Debug%, Limit(3) AS INTEGER, MouseCol%, MouseRow%, Select_Piece%, Plyr%, Selected(1) AS _BYTE, CPU AS _BYTE
  12. DIM SHARED Board(1 TO 8, 1 TO 8) AS Square '// T1: Pawn = 1, Rook = 2, knight = 3, Bishop = 4, King = 5, Queen = 6 / Team 2 = same + 6
  13. DIM Mouse(1) AS MouseState, KB(1) AS KeyBoardState
  14.  
  15. FOR j% = 1 TO 4
  16.   FOR i% = 1 TO 8
  17.     READ Piece%
  18.     SELECT CASE j%
  19.       CASE 1
  20.         Board(i%, 2).PieceID = Piece%
  21.       CASE 2
  22.         Board(i%, 1).PieceID = Piece%
  23.       CASE 3
  24.         Board(i%, 7).PieceID = Piece%
  25.       CASE 4
  26.         Board(i%, 8).PieceID = Piece%
  27.     END SELECT
  28.   NEXT
  29.  
  30. RadHelp# = (4 * ATN(1)) / 180
  31.  
  32. SCREEN _NEWIMAGE(800, 600, 32)
  33. _FPS 30
  34. _MOUSEMOVE 400, 300
  35. GDK_Mouse_GetState Mouse(0)
  36. Mouse(1) = Mouse(0)
  37. CamMode = Fixed
  38. CamVec.Rot.X = 270
  39. CamVec.Rot.Y = 180
  40. CamVec.Pos.Y = 400
  41. Debug% = True
  42. COLOR _RGB32(255, 0, 0), _RGBA32(0, 0, 0, 0)
  43. Select_Piece% = True
  44. Plyr% = 1
  45.  
  46. '// Limit (x,xx,y,yy) 134, 664, 34, 564  '// step 66.25
  47. Limit(0) = 134
  48. Limit(1) = 664
  49. Limit(2) = 34
  50. Limit(3) = 564
  51.  
  52. Allow_GL = True
  53.  
  54.  
  55.   _LIMIT 30
  56.  
  57.   GDK_Keyboard_GetState KB(0)
  58.   GDK_Mouse_GetState Mouse(0) '// Get the mouse state
  59.  
  60.   SELECT CASE CamMode
  61.  
  62.     CASE FP
  63.       CamVec.Rot.X = CamVec.Rot.X + (Mouse(0).Y - Mouse(1).Y)
  64.       CamVec.Rot.Y = CamVec.Rot.Y + (Mouse(0).X - Mouse(1).X)
  65.       IF CamVec.Rot.Y > 360 THEN CamVec.Rot.Y = CamVec.Rot.Y - 360
  66.       StrafeY# = (CamVec.Rot.Y + 90) * RadHelp#
  67.       StrafeX# = (CamVec.Rot.X + 90) * RadHelp#
  68.       IF KB(0).Left THEN
  69.         CamVec.Pos.X = CamVec.Pos.X + SIN(StrafeY#)
  70.         CamVec.Pos.Z = CamVec.Pos.Z - COS(StrafeY#)
  71.       ELSEIF KB(0).Right THEN
  72.         CamVec.Pos.X = CamVec.Pos.X - SIN(StrafeY#)
  73.         CamVec.Pos.Z = CamVec.Pos.Z + COS(StrafeY#)
  74.       END IF
  75.       YSin# = SIN(CamVec.Rot.Y * RadHelp#) * 5
  76.       YCos# = COS(CamVec.Rot.Y * RadHelp#) * 5
  77.       XSin# = SIN(CamVec.Rot.X * RadHelp#) * 5
  78.       IF KB(0).Down THEN
  79.         CamVec.Pos.X = CamVec.Pos.X - YSin#
  80.         CamVec.Pos.Y = CamVec.Pos.Y - XSin#
  81.         CamVec.Pos.Z = CamVec.Pos.Z + YCos#
  82.       ELSEIF KB(0).Up THEN
  83.         CamVec.Pos.X = CamVec.Pos.X + YSin#
  84.         CamVec.Pos.Y = CamVec.Pos.Y + XSin#
  85.         CamVec.Pos.Z = CamVec.Pos.Z - YCos#
  86.       END IF
  87.  
  88.     CASE Fixed
  89.  
  90.       CamVec.Rot.X = 270
  91.       CamVec.Pos.Y = 300
  92.  
  93.       IF Mouse(0).X >= Limit(0) AND Mouse(0).X <= Limit(1) THEN
  94.         IF Mouse(0).Y >= Limit(2) AND Mouse(0).Y <= Limit(3) THEN
  95.           MX% = Mouse(0).X - Limit(0)
  96.           MY% = Mouse(0).Y - Limit(2)
  97.           MouseCol% = 1 + (MX% \ 66.25)
  98.           MouseRow% = 1 + (MY% \ 66.25)
  99.           IF Mouse(0).LB AND NOT Mouse(1).LB THEN '// Selecting a piece to move
  100.             IF Select_Piece% THEN
  101.               IF Plyr% = 1 THEN '// White
  102.                 IF Board(MouseCol%, MouseRow%).PieceID < 7 AND Board(MouseCol%, MouseRow%).PieceID > 0 THEN
  103.                   Selected(0) = MouseCol%
  104.                   Selected(1) = MouseRow%
  105.                   Select_Piece% = False
  106.                 END IF
  107.               ELSEIF Plyr% = 2 THEN '// Black
  108.                 IF CPU = False THEN
  109.                   IF Board(MouseCol%, MouseRow%).PieceID >= 7 THEN
  110.                     Selected(0) = MouseCol%
  111.                     Selected(1) = MouseRow%
  112.                     Select_Piece% = False
  113.                   ELSE '// CPU MOVE
  114.  
  115.                   END IF
  116.                 END IF
  117.               END IF
  118.             ELSE '// Setting destination
  119.  
  120.               SELECT CASE Board(Selected(0), Selected(1)).PieceID
  121.  
  122.                 CASE 1, 7 '// Pawn
  123.  
  124.                   IF MouseCol% <> Selected(0) THEN '// Diagonal attack
  125.                     IF Plyr% = 1 THEN
  126.                       IF MouseRow% = Selected(1) + 1 THEN
  127.                         IF MouseCol% = Selected(0) - 1 OR MouseCol% = Selected(0) + 1 THEN
  128.                           IF Board(MouseCol%, MouseRow%).PieceID >= 7 THEN '// valid attack
  129.                             SWAP Board(MouseCol%, MouseRow%), Board(Selected(0), Selected(1))
  130.                             Board(Selected(0), Selected(1)).PieceID = 0
  131.                             Board(Selected(0), Selected(1)).First_Move = False
  132.                             Plyr% = 2
  133.                           END IF
  134.                         END IF
  135.                       END IF
  136.                     ELSEIF Plyr% = 2 THEN
  137.                       IF CPU = False THEN
  138.                         IF MouseRow% = Selected(1) - 1 THEN
  139.                           IF MouseCol% = Selected(0) - 1 OR MouseCol% = Selected(0) + 1 THEN
  140.                             IF Board(MouseCol%, MouseRow%).PieceID <= 6 AND Board(MouseCol%, MouseRow%).PieceID > 0 THEN '// valid attack
  141.                               SWAP Board(MouseCol%, MouseRow%), Board(Selected(0), Selected(1))
  142.                               Board(Selected(0), Selected(1)).PieceID = 0
  143.                               Board(Selected(0), Selected(1)).First_Move = False
  144.                               Plyr% = 1
  145.                             END IF
  146.                           END IF
  147.                         END IF
  148.                       END IF
  149.                     END IF
  150.                   ELSE
  151.                     IF Board(MouseCol%, MouseRow%).PieceID = 0 THEN
  152.                       IF Plyr% = 1 THEN
  153.                         IF Board(Selected(0), Selected(1)).First_Move = False THEN
  154.                           IF MouseRow% = 3 OR MouseRow% = 4 THEN
  155.                             Board(Selected(0), Selected(1)).First_Move = True
  156.                             SWAP Board(MouseCol%, MouseRow%), Board(Selected(0), Selected(1))
  157.                             Plyr% = 2
  158.                           END IF
  159.                         ELSE
  160.                           IF MouseRow% = Selected(1) + 1 THEN
  161.                             SWAP Board(MouseCol%, MouseRow%), Board(Selected(0), Selected(1))
  162.                             Plyr% = 2
  163.                           END IF
  164.                         END IF
  165.  
  166.                       ELSEIF Plyr% = 2 THEN
  167.                         IF CPU = False THEN
  168.                           IF Board(Selected(0), Selected(1)).First_Move = False THEN
  169.                             IF MouseRow% = 5 OR MouseRow% = 6 THEN
  170.                               Board(Selected(0), Selected(1)).First_Move = True
  171.                               SWAP Board(MouseCol%, MouseRow%), Board(Selected(0), Selected(1))
  172.                               Plyr% = 1
  173.                             END IF
  174.                           ELSE
  175.                             IF MouseRow% = Selected(1) - 1 THEN
  176.                               SWAP Board(MouseCol%, MouseRow%), Board(Selected(0), Selected(1))
  177.                               Plyr% = 1
  178.                             END IF
  179.                           END IF
  180.                         END IF
  181.                       END IF
  182.                     END IF
  183.                   END IF
  184.  
  185.                 CASE 2, 8 '// rook
  186.  
  187.                   IF MouseCol% = Selected(0) THEN '// Vertical move
  188.                     IF MouseRow% > Selected(1) THEN StepVal% = 1 ELSE IF MouseRow% < Selected(1) THEN StepVal% = -1 ELSE GOTO Skip_Case
  189.  
  190.                     FOR Row% = Selected(1) + StepVal% TO MouseRow% STEP StepVal%
  191.                       IF Board(Selected(0), Row%).PieceID > 0 THEN
  192.                         IF Row% = MouseRow% THEN '// Attacking move
  193.                           IF Plyr% = 1 THEN
  194.                             IF Board(Selected(0), Row%).PieceID <= 6 THEN GOTO Skip_Case
  195.                           ELSEIF Plyr% = 2 THEN
  196.                             IF Board(Selected(0), Row%).PieceID >= 7 THEN GOTO Skip_Case
  197.                           END IF
  198.                           Board(MouseCol%, MouseRow%).PieceID = 0
  199.                           Board(MouseCol%, MouseRow%).First_Move = False
  200.                           SWAP Board(Selected(0), Selected(1)), Board(MouseCol%, MouseRow%)
  201.                         ELSE '// Invalid move
  202.                           GOTO Skip_Case
  203.                         END IF
  204.                       ELSE
  205.                         IF Row% = MouseRow% THEN SWAP Board(Selected(0), Selected(1)), Board(MouseCol%, MouseRow%)
  206.                       END IF
  207.                     NEXT
  208.  
  209.                     IF Plyr% = 1 THEN Plyr% = 2 ELSE Plyr% = 1
  210.  
  211.                   ELSEIF MouseRow% = Selected(1) THEN '// Horizontal move
  212.                     IF MouseCol% > Selected(0) THEN StepVal% = 1 ELSE IF MouseCol% < Selected(0) THEN StepVal% = -1 ELSE GOTO Skip_Case
  213.  
  214.                     FOR Col% = Selected(0) + StepVal% TO MouseCol% STEP StepVal%
  215.                       IF Board(Col%, Selected(1)).PieceID > 0 THEN
  216.                         IF Row% = MouseRow% THEN '// Attacking move
  217.                           IF Plyr% = 1 THEN
  218.                             IF Board(Col%, Selected(1)).PieceID <= 6 THEN GOTO Skip_Case
  219.                           ELSEIF Plyr% = 2 THEN
  220.                             IF Board(Col%, Selected(1)).PieceID >= 7 THEN GOTO Skip_Case
  221.                           END IF
  222.                           Board(MouseCol%, MouseRow%).PieceID = 0
  223.                           Board(MouseCol%, MouseRow%).First_Move = False
  224.                           SWAP Board(Selected(0), Selected(1)), Board(MouseCol%, MouseRow%)
  225.                         ELSE '// Invalid move
  226.                           GOTO Skip_Case
  227.                         END IF
  228.                       ELSE
  229.                         IF Col% = MouseCol% THEN SWAP Board(Selected(0), Selected(1)), Board(MouseCol%, MouseRow%)
  230.                       END IF
  231.                     NEXT
  232.  
  233.                     IF Plyr% = 1 THEN Plyr% = 2 ELSE Plyr% = 1
  234.  
  235.                   END IF
  236.  
  237.                 CASE 3, 9 '// bishop
  238.  
  239.                   IF MouseRow% > Selected(1) THEN
  240.                     RowDif% = MouseRow% - Selected(1)
  241.                     Y_Inc% = 1
  242.                   ELSEIF MouseRow% < Selected(1) THEN
  243.                     RowDif% = Selected(1) - MouseRow%
  244.                     Y_Inc% = -1
  245.                   END IF
  246.  
  247.                   IF MouseCol% > Selected(0) THEN
  248.                     ColDif% = MouseCol% - Selected(0)
  249.                     X_Inc% = 1
  250.                   ELSEIF MouseCol% < Selected(0) THEN
  251.                     ColDif% = Selected(0) - MouseCol%
  252.                     X_Inc% = -1
  253.                   END IF
  254.  
  255.                   IF RowDif% = ColDif% THEN '// Might be a valid move, check for stuff in the way
  256.  
  257.                     Row% = Selected(1) + Y_Inc%
  258.                     FOR Col% = Selected(0) + X_Inc% TO MouseCol% STEP X_Inc%
  259.                       IF Board(Col%, Row%).PieceID > 0 THEN '// Something on the square
  260.                         IF Col% = MouseCol% THEN
  261.                           IF Plyr% = 1 THEN
  262.                             IF Board(Col%, Row%).PieceID > 6 THEN
  263.                               Board(Col%, Row%).PieceID = 0
  264.                               Board(Col%, Row%).First_Move = False
  265.                               SWAP Board(Col%, Row%), Board(Selected(0), Selected(1))
  266.  
  267.                               IF Plyr% = 1 THEN Plyr% = 2 ELSE Plyr% = 1
  268.  
  269.                             ELSE
  270.                               GOTO Skip_Case
  271.                             END IF
  272.                           ELSE
  273.                             IF Board(Col%, Row%).PieceID <= 6 THEN
  274.                               Board(Col%, Row%).PieceID = 0
  275.                               Board(Col%, Row%).First_Move = False
  276.                               SWAP Board(Col%, Row%), Board(Selected(0), Selected(1))
  277.  
  278.                               IF Plyr% = 1 THEN Plyr% = 2 ELSE Plyr% = 1
  279.  
  280.                             ELSE
  281.                               GOTO Skip_Case
  282.                             END IF
  283.                           END IF
  284.                         ELSE
  285.                           GOTO Skip_Case '// illegal move
  286.                         END IF
  287.                       ELSE
  288.                         IF Col% = MouseCol% THEN
  289.                           SWAP Board(Col%, Row%), Board(Selected(0), Selected(1))
  290.  
  291.                           IF Plyr% = 1 THEN Plyr% = 2 ELSE Plyr% = 1
  292.  
  293.                         END IF
  294.                       END IF
  295.                       Row% = Row% + Y_Inc%
  296.                     NEXT
  297.                   ELSE
  298.                     GOTO Skip_Case
  299.                   END IF
  300.  
  301.                 CASE 4, 10 '// knight
  302.  
  303.                   IF MouseRow% > Selected(1) THEN
  304.                     RowDif% = MouseRow% - Selected(1)
  305.                   ELSEIF MouseRow% < Selected(1) THEN
  306.                     RowDif% = Selected(1) - MouseRow%
  307.                   ELSE
  308.                     GOTO Skip_Case '// Invalid move
  309.                   END IF
  310.  
  311.                   IF MouseCol% > Selected(0) THEN
  312.                     ColDif% = MouseCol% - Selected(0)
  313.                   ELSEIF MouseCol% < Selected(0) THEN
  314.                     ColDif% = Selected(0) - MouseCol%
  315.                   ELSE
  316.                     GOTO Skip_Case '// Invalise move
  317.                   END IF
  318.  
  319.                   IF (RowDif% = 2 AND ColDif% = 1) OR (RowDif% = 1 AND ColDif% = 2) THEN
  320.                     IF Plyr% = 1 THEN
  321.                       IF Board(MouseCol%, MouseRow%).PieceID = 0 OR Board(MouseCol%, MouseRow%).PieceID > 6 THEN
  322.                         Board(MouseCol%, MouseRow%).PieceID = 0
  323.                         Board(MouseCol%, MouseRow%).First_Move = False
  324.                         SWAP Board(Selected(0), Selected(1)), Board(MouseCol%, MouseRow%)
  325.  
  326.                         IF Plyr% = 1 THEN Plyr% = 2 ELSE Plyr% = 1
  327.  
  328.                       ELSE '// invalid move - own piece on that space
  329.                         GOTO Skip_Case
  330.                       END IF
  331.                     ELSE
  332.                       IF Board(MouseCol%, MouseRow%).PieceID = 0 OR Board(MouseCol%, MouseRow%).PieceID < 7 THEN
  333.                         Board(MouseCol%, MouseRow%).PieceID = 0
  334.                         Board(MouseCol%, MouseRow%).First_Move = False
  335.                         SWAP Board(Selected(0), Selected(1)), Board(MouseCol%, MouseRow%)
  336.  
  337.                         IF Plyr% = 1 THEN Plyr% = 2 ELSE Plyr% = 1
  338.  
  339.                       ELSE '// invalid move - own piece on that space
  340.                         GOTO Skip_Case
  341.                       END IF
  342.  
  343.                     END IF
  344.                   ELSE
  345.                     GOTO Skip_Case '// Invalid move
  346.                   END IF
  347.  
  348.  
  349.                 CASE 5, 11 '// King
  350.  
  351.                   IF MouseRow% > Selected(1) THEN
  352.                     RowDif% = MouseRow% - Selected(1)
  353.                   ELSEIF MouseRow% < Selected(1) THEN
  354.                     RowDif% = Selected(1) - MouseRow%
  355.                   ELSE
  356.                     RowDif% = 0
  357.                   END IF
  358.  
  359.                   IF MouseCol% > Selected(0) THEN
  360.                     ColDif% = MouseCol% - Selected(0)
  361.                   ELSEIF MouseCol% < Selected(0) THEN
  362.                     ColDif% = Selected(0) - MouseCol%
  363.                   ELSE
  364.                     ColDif% = 0
  365.                   END IF
  366.  
  367.                   IF ColDif% <= 1 AND RowDif% <= 1 THEN
  368.                     IF Plyr% = 1 THEN
  369.                       IF Board(MouseCol%, MouseRow%).PieceID = 0 OR Board(MouseCol%, MouseRow%).PieceID > 6 THEN
  370.                         Board(MouseCol%, MouseRow%).PieceID = 0
  371.                         Board(MouseCol%, MouseRow%).First_Move = False
  372.                         SWAP Board(Selected(0), Selected(1)), Board(MouseCol%, MouseRow%)
  373.  
  374.                         IF Plyr% = 1 THEN Plyr% = 2 ELSE Plyr% = 1
  375.  
  376.                       ELSE
  377.                         GOTO Skip_Case
  378.                       END IF
  379.                     ELSE
  380.                       IF Board(MouseCol%, MouseRow%).PieceID = 0 OR Board(MouseCol%, MouseRow%).PieceID < 7 THEN
  381.                         Board(MouseCol%, MouseRow%).PieceID = 0
  382.                         Board(MouseCol%, MouseRow%).First_Move = False
  383.                         SWAP Board(Selected(0), Selected(1)), Board(MouseCol%, MouseRow%)
  384.                         IF Plyr% = 1 THEN Plyr% = 2 ELSE Plyr% = 1
  385.  
  386.                       ELSE
  387.                         GOTO Skip_Case
  388.                       END IF
  389.                     END IF
  390.                   ELSE
  391.                     GOTO Skip_Case
  392.                   END IF
  393.  
  394.                 CASE 6, 12 '// queen '// Mixture of rook and bishop movement
  395.  
  396.                   IF MouseCol% = Selected(0) THEN '// Vertical move
  397.                     IF MouseRow% > Selected(1) THEN StepVal% = 1 ELSE IF MouseRow% < Selected(1) THEN StepVal% = -1 ELSE GOTO Skip_Case
  398.  
  399.                     FOR Row% = Selected(1) + StepVal% TO MouseRow% STEP StepVal%
  400.                       IF Board(Selected(0), Row%).PieceID > 0 THEN
  401.                         IF Row% = MouseRow% THEN '// Attacking move
  402.                           IF Plyr% = 1 THEN
  403.                             IF Board(Selected(0), Row%).PieceID <= 6 THEN GOTO Skip_Case
  404.                           ELSEIF Plyr% = 2 THEN
  405.                             IF Board(Selected(0), Row%).PieceID >= 7 THEN GOTO Skip_Case
  406.                           END IF
  407.                           Board(MouseCol%, MouseRow%).PieceID = 0
  408.                           Board(MouseCol%, MouseRow%).First_Move = False
  409.                           SWAP Board(Selected(0), Selected(1)), Board(MouseCol%, MouseRow%)
  410.                         ELSE '// Invalid move
  411.                           GOTO Skip_Case
  412.                         END IF
  413.                       ELSE
  414.                         IF Row% = MouseRow% THEN SWAP Board(Selected(0), Selected(1)), Board(MouseCol%, MouseRow%)
  415.                       END IF
  416.                     NEXT
  417.  
  418.                     IF Plyr% = 1 THEN Plyr% = 2 ELSE Plyr% = 1
  419.  
  420.                   ELSEIF MouseRow% = Selected(1) THEN '// Horizontal move
  421.                     IF MouseCol% > Selected(0) THEN StepVal% = 1 ELSE IF MouseCol% < Selected(0) THEN StepVal% = -1 ELSE GOTO Skip_Case
  422.  
  423.                     FOR Col% = Selected(0) + StepVal% TO MouseCol% STEP StepVal%
  424.                       IF Board(Col%, Selected(1)).PieceID > 0 THEN
  425.                         IF Row% = MouseRow% THEN '// Attacking move
  426.                           IF Plyr% = 1 THEN
  427.                             IF Board(Col%, Selected(1)).PieceID <= 6 THEN GOTO Skip_Case
  428.                           ELSEIF Plyr% = 2 THEN
  429.                             IF Board(Col%, Selected(1)).PieceID >= 7 THEN GOTO Skip_Case
  430.                           END IF
  431.                           Board(MouseCol%, MouseRow%).PieceID = 0
  432.                           Board(MouseCol%, MouseRow%).First_Move = False
  433.                           SWAP Board(Selected(0), Selected(1)), Board(MouseCol%, MouseRow%)
  434.                         ELSE '// Invalid move
  435.                           GOTO Skip_Case
  436.                         END IF
  437.                       ELSE
  438.                         IF Col% = MouseCol% THEN SWAP Board(Selected(0), Selected(1)), Board(MouseCol%, MouseRow%)
  439.                       END IF
  440.                     NEXT
  441.  
  442.                     IF Plyr% = 1 THEN Plyr% = 2 ELSE Plyr% = 1
  443.  
  444.                   ELSE '// Diagonal move
  445.  
  446.                     IF MouseRow% > Selected(1) THEN
  447.                       RowDif% = MouseRow% - Selected(1)
  448.                       Y_Inc% = 1
  449.                     ELSEIF MouseRow% < Selected(1) THEN
  450.                       RowDif% = Selected(1) - MouseRow%
  451.                       Y_Inc% = -1
  452.                     END IF
  453.  
  454.                     IF MouseCol% > Selected(0) THEN
  455.                       ColDif% = MouseCol% - Selected(0)
  456.                       X_Inc% = 1
  457.                     ELSEIF MouseCol% < Selected(0) THEN
  458.                       ColDif% = Selected(0) - MouseCol%
  459.                       X_Inc% = -1
  460.                     END IF
  461.  
  462.                     IF RowDif% = ColDif% THEN '// Might be a valid move, check for stuff in the way
  463.  
  464.                       Row% = Selected(1) + Y_Inc%
  465.                       FOR Col% = Selected(0) + X_Inc% TO MouseCol% STEP X_Inc%
  466.                         IF Board(Col%, Row%).PieceID > 0 THEN '// Something on the square
  467.                           IF Col% = MouseCol% THEN
  468.                             IF Plyr% = 1 THEN
  469.                               IF Board(Col%, Row%).PieceID > 6 THEN
  470.                                 Board(Col%, Row%).PieceID = 0
  471.                                 Board(Col%, Row%).First_Move = False
  472.                                 SWAP Board(Col%, Row%), Board(Selected(0), Selected(1))
  473.  
  474.                                 IF Plyr% = 1 THEN Plyr% = 2 ELSE Plyr% = 1
  475.  
  476.                               ELSE
  477.                                 GOTO Skip_Case
  478.                               END IF
  479.                             ELSE
  480.                               IF Board(Col%, Row%).PieceID <= 6 THEN
  481.                                 Board(Col%, Row%).PieceID = 0
  482.                                 Board(Col%, Row%).First_Move = False
  483.                                 SWAP Board(Col%, Row%), Board(Selected(0), Selected(1))
  484.  
  485.                                 IF Plyr% = 1 THEN Plyr% = 2 ELSE Plyr% = 1
  486.  
  487.                               ELSE
  488.                                 GOTO Skip_Case
  489.                               END IF
  490.                             END IF
  491.                           ELSE
  492.                             GOTO Skip_Case '// illegal move
  493.                           END IF
  494.                         ELSE
  495.                           IF Col% = MouseCol% THEN
  496.                             SWAP Board(Col%, Row%), Board(Selected(0), Selected(1))
  497.  
  498.                             IF Plyr% = 1 THEN Plyr% = 2 ELSE Plyr% = 1
  499.  
  500.                           END IF
  501.                         END IF
  502.                         Row% = Row% + Y_Inc%
  503.                       NEXT
  504.                     ELSE
  505.                       GOTO Skip_Case
  506.                     END IF
  507.                   END IF
  508.  
  509.  
  510.               END SELECT
  511.  
  512.               Select_Piece% = True
  513.  
  514.             END IF
  515.           END IF
  516.         END IF
  517.       END IF
  518.  
  519.     CASE Action
  520.  
  521.  
  522.   Skip_Case:
  523.  
  524.  
  525.   IF Debug% THEN
  526.     CLS
  527.     LOCATE 1, 1
  528.     PRINT "MOUSE (X,Y) : "; Mouse(0).X; Mouse(0).Y
  529.     PRINT "Col/Row : "; MouseCol%; MouseRow%
  530.     PRINT "Selected Col/Row : "; Selected(0); Selected(1)
  531.   END IF
  532.  
  533.   KB(1) = KB(0)
  534.   Mouse(1) = Mouse(0)
  535.  
  536.  
  537.  
  538. DATA 1,1,1,1,1,1,1,1
  539. DATA 2,4,3,6,5,3,4,2
  540. DATA 7,7,7,7,7,7,7,7
  541. DATA 8,10,9,12,11,9,10,8
  542.  
  543.  
  544. REM $include:'GDK_GL\GDK_GL.bm'
  545. REM $include:'UnseenGDK.bm'
  546.  
  547.  
  548. TYPE Square
  549.   PieceID AS _BYTE
  550.   Anim AS ANIMATION
  551.   Destination AS STRING * 2 '// If > 0 then destination square is col, row
  552.   First_Move AS _BYTE
  553.  
  554.  
  555. SUB _GL
  556.  
  557.   IF Allow_GL THEN
  558.  
  559.     _glClearColor 0, 0, 0, 1
  560.     _glEnable _GL_DEPTH_TEST
  561.     _glEnable _GL_TEXTURE_2D
  562.     _glMatrixMode _GL_PROJECTION
  563.     _gluPerspective 80, 800 / 600, 1, 2000
  564.     _glMatrixMode _GL_MODELVIEW
  565.     _glViewport 0, 0, 800, 600
  566.  
  567.     IF Init = False THEN
  568.  
  569.       IF NOT GDK_GL_MODEL_LOAD(Model(0), "GDK_Gl\QuakeChess\zombie.mdl") THEN PRINT "Failed to load model." '// Pawn
  570.       IF NOT GDK_GL_MODEL_LOAD(Model(1), "GDK_Gl\QuakeChess\ogre.mdl") THEN PRINT "Failed to load model." '// Rook
  571.       IF NOT GDK_GL_MODEL_LOAD(Model(2), "GDK_Gl\QuakeChess\wizard.mdl") THEN PRINT "Failed to load model." '// Bishop
  572.       IF NOT GDK_GL_MODEL_LOAD(Model(3), "GDK_Gl\QuakeChess\knight.mdl") THEN PRINT "Failed to load model." '// Knight
  573.       IF NOT GDK_GL_MODEL_LOAD(Model(4), "GDK_Gl\QuakeChess\soldier.mdl") THEN PRINT "Failed to load model." '// King
  574.       IF NOT GDK_GL_MODEL_LOAD(Model(5), "GDK_Gl\QuakeChess\demon.mdl") THEN PRINT "Failed to load model." '// Queen
  575.  
  576.       Floor(0) = GDK_GL_LOAD_TEXTURE("GDK_GL\QuakeChess\FloorRed.png")
  577.       Floor(1) = GDK_GL_LOAD_TEXTURE("GDK_GL\QuakeChess\FloorWhite.png")
  578.  
  579.       Flr_Lst = _glGenLists(1)
  580.       _glNewList Flr_Lst, _GL_COMPILE
  581.       FloorZ% = -200
  582.       FloorY% = 20
  583.       FOR j% = 1 TO 8
  584.         FloorX% = -200
  585.         FOR i% = 1 TO 8
  586.           IF White% THEN
  587.             GDK_GL_SET_TEXTURE Floor(1)
  588.             White% = False
  589.           ELSE
  590.             GDK_GL_SET_TEXTURE Floor(0)
  591.             White% = True
  592.           END IF
  593.           _glBegin _GL_QUADS
  594.           _glTexCoord2f 0, 0: _glVertex3f FloorX%, FloorY% - 50, FloorZ%
  595.           _glTexCoord2f 0, 1: _glVertex3f FloorX% + 50, FloorY% - 50, FloorZ%
  596.           _glTexCoord2f 1, 1: _glVertex3f FloorX% + 50, FloorY% - 50, FloorZ% + 50
  597.           _glTexCoord2f 1, 0: _glVertex3f FloorX%, FloorY% - 50, FloorZ% + 50
  598.           _glEnd
  599.           FloorX% = FloorX% + 50
  600.         NEXT
  601.         FloorZ% = FloorZ% + 50
  602.         IF White% THEN White% = False ELSE White% = True
  603.       NEXT
  604.       _glEndList
  605.  
  606.       Init = True
  607.  
  608.     ELSE
  609.  
  610.       GDK_GL_CLS
  611.  
  612.       '// Set the view to the cameras position
  613.       GDK_GL_VECTOR_APPLY_RT CamVec
  614.  
  615.       _glCallList Flr_Lst
  616.  
  617.       FloorZ% = -175
  618.       FloorY% = -55
  619.       FOR j% = 1 TO 8
  620.         FloorX% = 175
  621.         FOR i% = 1 TO 8
  622.           _glPushMatrix
  623.           _glTranslatef FloorX%, FloorY%, FloorZ%
  624.           _glRotatef 180, 0, 0, 1
  625.           IF Board(i%, j%).PieceID < 7 THEN _glRotatef 270, 0, 1, 0 ELSE _glRotatef 90, 0, 1, 0
  626.  
  627.           _glRotatef 270, 1, 0, 0
  628.  
  629.           SELECT CASE Board(i%, j%).PieceID
  630.             CASE 1, 7 '// Pawns
  631.               GDK_GL_MODEL_DRAW Model(0), 1
  632.             CASE 2, 8 '// Rook
  633.               GDK_GL_MODEL_DRAW Model(1), 1
  634.             CASE 3, 9 '// Bishop
  635.               GDK_GL_MODEL_DRAW Model(2), 1
  636.             CASE 4, 10 '// Knight
  637.               GDK_GL_MODEL_DRAW Model(3), 1
  638.             CASE 5, 11 '// King
  639.               GDK_GL_MODEL_DRAW Model(4), 1
  640.             CASE 6, 12 '// Queen
  641.               GDK_GL_MODEL_DRAW Model(5), 1
  642.           END SELECT
  643.           _glPopMatrix
  644.           FloorX% = FloorX% - 50
  645.         NEXT
  646.         FloorZ% = FloorZ% + 50
  647.       NEXT
  648.     END IF
  649.   END IF
  650.  
  651.  
  652.  
  653.  

Thanks

Unseen

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Quake Chess
« Reply #5 on: April 03, 2020, 07:26:03 pm »
Hi Unseen
fine vision from above the chessboard.
But I don't know why I cannot move any piece.... Yes mouse cohordinates and detection is good but no movement of pieces.

---------
in Kubuntu I got a system error for parameters for GDK_GL_NewVector ... it is because QB64 IDE doesn't recognize the code of the file .BI included into the .BM file that is included into  source code. So under kubuntu I cannot compile it!
Programming isn't difficult, only it's  consuming time and coffee

Offline Unseen Machine

  • Forum Regular
  • Posts: 158
  • Make the game not the engine!
    • View Profile
Re: Quake Chess
« Reply #6 on: April 03, 2020, 07:38:46 pm »
Quote
But I don't know why I cannot move any piece.... Yes mouse cohordinates and detection is good but no movement of pieces.

Yeah mouse input is a bit dodgy..i dunno why though right now. The top set of pieces must move first, once youve selected a piece the debug read out should tell you the selected column/row its on.

As for linux, i dunno my man...im making this on an old XP laptop!

Thanks for trying it though and i appreaiate the feedback.

Unseen
QuakeChess.PNG
* QuakeChess.PNG (Filesize: 810.13 KB, Dimensions: 806x632, Views: 326)
« Last Edit: April 03, 2020, 07:43:01 pm by Unseen Machine »

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Quake Chess
« Reply #7 on: April 04, 2020, 06:02:52 pm »
Hi Unseen

I try again with a second compiling and now I am able to move pieces.
I'll follow the further developing , very interesting the structure for object graphic routines.

Programming isn't difficult, only it's  consuming time and coffee

Offline Unseen Machine

  • Forum Regular
  • Posts: 158
  • Make the game not the engine!
    • View Profile
Re: Quake Chess
« Reply #8 on: April 07, 2020, 06:42:35 pm »
Hi all,

Here's the latest update. Now has standing and walking animations, dont move the knights yet though as they need a bit more code to make them work properly. Once ive done that bit ill be adding fight scenes and then attempting vs CPU....

Should still work with the files from the first post...

Code: QB64: [Select]
  1. '// Quake Chess V.01
  2. '// By John Onyon a.k.a Unseen Machine
  3. '// Created 01/04/2020
  4. '// Last Update 07/04/2020
  5.  
  6. REM $include:'GDK_GL\GDK_GL.bi'
  7.  
  8. CONST FP = 1, Fixed = 2, Action = 3, Battle = 4
  9. CONST Standing = 1, Walking = 2, Attack = 3, BeingHit = 4, Falling = 5 '// Animation ref constants
  10. CONST North = 270, NE = 315, East = 360, SE = 45, South = 90, SW = 135, West = 180, NW = 225 '// Rotation Direction Constants
  11.  
  12. DIM SHARED Init AS _BYTE, Model(5) AS MODEL, Allow_GL AS _BYTE, CamVec AS VECTOR_GL, Floor(1) AS LONG, Flr_Lst AS _UNSIGNED LONG
  13. DIM SHARED CamMode AS _BYTE, Debug%, Limit(3) AS INTEGER, MouseCol%, MouseRow%, Select_Piece%, Plyr%, Selected(1) AS _BYTE, CPU AS _BYTE
  14. DIM SHARED Board(1 TO 8, 1 TO 8) AS Square '// T1: Pawn = 1, Rook = 2, knight = 3, Bishop = 4, King = 5, Queen = 6 / Team 2 = same + 6
  15. DIM SHARED Anim(5, 1 TO 5) AS ANIMATION '// Standing, Walking, Running, Attacking, Falling
  16. DIM Mouse(1) AS MouseState, KB(1) AS KeyBoardState
  17. DIM SHARED Moving AS _BYTE '// If true destination then something is moving
  18. DIM SHARED Blank_Square AS Square '// Used for easily resetting squares
  19.  
  20. RadHelp# = (4 * ATN(1)) / 180
  21.  
  22. SCREEN _NEWIMAGE(800, 600, 32)
  23. _FPS 30
  24.  
  25. CamMode = Fixed
  26. CamVec.Rot.X = 270: CamVec.Rot.Y = 180: CamVec.Pos.Y = 400
  27. Debug% = True
  28. COLOR _RGB32(255, 0, 0), _RGBA32(0, 0, 0, 0)
  29. Select_Piece% = True
  30. Plyr% = 1
  31.  
  32. '// Limit (x,xx,y,yy) 134, 664, 34, 564  '// step 66.25
  33. Limit(0) = 134: Limit(1) = 664: Limit(2) = 34: Limit(3) = 564
  34.  
  35. Allow_GL = True
  36.  
  37.   _LIMIT 30
  38.  
  39.   GDK_Keyboard_GetState KB(0)
  40.   GDK_Mouse_GetState Mouse(0) '// Get the mouse state
  41.  
  42.   SELECT CASE CamMode
  43.  
  44.     CASE FP
  45.       CamVec.Rot.X = CamVec.Rot.X + (Mouse(0).Y - Mouse(1).Y)
  46.       CamVec.Rot.Y = CamVec.Rot.Y + (Mouse(0).X - Mouse(1).X)
  47.       IF CamVec.Rot.Y > 360 THEN CamVec.Rot.Y = CamVec.Rot.Y - 360
  48.       StrafeY# = (CamVec.Rot.Y + 90) * RadHelp#
  49.       StrafeX# = (CamVec.Rot.X + 90) * RadHelp#
  50.       IF KB(0).Left THEN
  51.         CamVec.Pos.X = CamVec.Pos.X + SIN(StrafeY#)
  52.         CamVec.Pos.Z = CamVec.Pos.Z - COS(StrafeY#)
  53.       ELSEIF KB(0).Right THEN
  54.         CamVec.Pos.X = CamVec.Pos.X - SIN(StrafeY#)
  55.         CamVec.Pos.Z = CamVec.Pos.Z + COS(StrafeY#)
  56.       END IF
  57.       YSin# = SIN(CamVec.Rot.Y * RadHelp#) * 5
  58.       YCos# = COS(CamVec.Rot.Y * RadHelp#) * 5
  59.       XSin# = SIN(CamVec.Rot.X * RadHelp#) * 5
  60.       IF KB(0).Down THEN
  61.         CamVec.Pos.X = CamVec.Pos.X - YSin#
  62.         CamVec.Pos.Y = CamVec.Pos.Y - XSin#
  63.         CamVec.Pos.Z = CamVec.Pos.Z + YCos#
  64.       ELSEIF KB(0).Up THEN
  65.         CamVec.Pos.X = CamVec.Pos.X + YSin#
  66.         CamVec.Pos.Y = CamVec.Pos.Y + XSin#
  67.         CamVec.Pos.Z = CamVec.Pos.Z - YCos#
  68.       END IF
  69.  
  70.     CASE Fixed
  71.  
  72.       CamVec.Rot.X = 270
  73.       CamVec.Pos.Y = 300
  74.  
  75.       IF Mouse(0).X >= Limit(0) AND Mouse(0).X <= Limit(1) THEN
  76.         IF Mouse(0).Y >= Limit(2) AND Mouse(0).Y <= Limit(3) THEN
  77.           MX% = Mouse(0).X - Limit(0)
  78.           MY% = Mouse(0).Y - Limit(2)
  79.           MouseCol% = 1 + (MX% \ 66.25)
  80.           MouseRow% = 1 + (MY% \ 66.25)
  81.           IF Mouse(0).LB AND NOT Mouse(1).LB THEN '// Selecting a piece to move
  82.             IF Select_Piece% THEN
  83.               IF Plyr% = 1 THEN '// White
  84.                 IF Board(MouseCol%, MouseRow%).PieceID < 7 AND Board(MouseCol%, MouseRow%).PieceID > 0 THEN
  85.                   Selected(0) = MouseCol%
  86.                   Selected(1) = MouseRow%
  87.                   Select_Piece% = False
  88.                 END IF
  89.               ELSEIF Plyr% = 2 THEN '// Black
  90.                 IF CPU = False THEN
  91.                   IF Board(MouseCol%, MouseRow%).PieceID >= 7 THEN
  92.                     Selected(0) = MouseCol%
  93.                     Selected(1) = MouseRow%
  94.                     Select_Piece% = False
  95.                   ELSE '// CPU MOVE
  96.  
  97.                   END IF
  98.                 END IF
  99.               END IF
  100.             ELSE '// Setting destination
  101.  
  102.               SELECT CASE Board(Selected(0), Selected(1)).PieceID
  103.  
  104.                 CASE 1, 7 '// Pawn
  105.  
  106.                   IF MouseCol% <> Selected(0) THEN '// Diagonal attack
  107.                     IF Plyr% = 1 THEN
  108.                       IF MouseRow% = Selected(1) + 1 THEN
  109.                         IF MouseCol% = Selected(0) - 1 OR MouseCol% = Selected(0) + 1 THEN
  110.                           IF Board(MouseCol%, MouseRow%).PieceID >= 7 THEN Moving = True
  111.                         END IF
  112.                       END IF
  113.                     ELSEIF Plyr% = 2 THEN
  114.                       IF CPU = False THEN
  115.                         IF MouseRow% = Selected(1) - 1 THEN
  116.                           IF MouseCol% = Selected(0) - 1 OR MouseCol% = Selected(0) + 1 THEN
  117.                             IF Board(MouseCol%, MouseRow%).PieceID <= 6 AND Board(MouseCol%, MouseRow%).PieceID > 0 THEN Moving = True
  118.                           END IF
  119.                         END IF
  120.                       END IF
  121.                     END IF
  122.                   ELSE
  123.                     IF Board(MouseCol%, MouseRow%).PieceID = 0 THEN
  124.                       IF Plyr% = 1 THEN
  125.                         IF Board(Selected(0), Selected(1)).First_Move = False THEN
  126.                           IF MouseRow% = 3 OR MouseRow% = 4 THEN Moving = True
  127.                         ELSE
  128.                           IF MouseRow% = Selected(1) + 1 THEN Moving = True
  129.                         END IF
  130.                       ELSEIF Plyr% = 2 THEN
  131.                         IF CPU = False THEN
  132.                           IF Board(Selected(0), Selected(1)).First_Move = False THEN
  133.                             IF MouseRow% = 5 OR MouseRow% = 6 THEN Moving = True
  134.                           ELSE
  135.                             IF MouseRow% = Selected(1) - 1 THEN Moving = True
  136.                           END IF
  137.                         ELSE '// Vs Cpu Game
  138.  
  139.                         END IF
  140.                       END IF
  141.                     END IF
  142.                   END IF
  143.  
  144.                 CASE 2, 8 '// rook
  145.  
  146.                   IF MouseCol% = Selected(0) THEN '// Vertical move
  147.                     IF MouseRow% > Selected(1) THEN StepVal% = 1 ELSE IF MouseRow% < Selected(1) THEN StepVal% = -1 ELSE GOTO Skip_Case
  148.  
  149.                     FOR Row% = Selected(1) + StepVal% TO MouseRow% STEP StepVal%
  150.                       IF Board(Selected(0), Row%).PieceID > 0 THEN
  151.                         IF Row% = MouseRow% THEN '// Attacking move
  152.                           IF Plyr% = 1 THEN
  153.                             IF Board(Selected(0), Row%).PieceID <= 6 THEN GOTO Skip_Case
  154.                           ELSEIF Plyr% = 2 THEN
  155.                             IF Board(Selected(0), Row%).PieceID >= 7 THEN GOTO Skip_Case
  156.                           END IF
  157.                           Moving = True
  158.                         ELSE '// Invalid move
  159.                           GOTO Skip_Case
  160.                         END IF
  161.                       ELSE
  162.                         IF Row% = MouseRow% THEN Moving = True
  163.                       END IF
  164.                     NEXT
  165.  
  166.                   ELSEIF MouseRow% = Selected(1) THEN '// Horizontal move
  167.                     IF MouseCol% > Selected(0) THEN StepVal% = 1 ELSE IF MouseCol% < Selected(0) THEN StepVal% = -1 ELSE GOTO Skip_Case
  168.  
  169.                     FOR Col% = Selected(0) + StepVal% TO MouseCol% STEP StepVal%
  170.                       IF Board(Col%, Selected(1)).PieceID > 0 THEN
  171.                         IF Row% = MouseRow% THEN '// Attacking move
  172.                           IF Plyr% = 1 THEN
  173.                             IF Board(Col%, Selected(1)).PieceID <= 6 THEN GOTO Skip_Case
  174.                           ELSEIF Plyr% = 2 THEN
  175.                             IF Board(Col%, Selected(1)).PieceID >= 7 THEN GOTO Skip_Case
  176.                           END IF
  177.                           Moving = True
  178.                         ELSE '// Invalid move
  179.                           GOTO Skip_Case
  180.                         END IF
  181.                       ELSE
  182.                         IF Col% = MouseCol% THEN Moving = True
  183.                       END IF
  184.                     NEXT
  185.  
  186.                   END IF
  187.  
  188.                 CASE 3, 9 '// bishop
  189.  
  190.                   IF MouseRow% > Selected(1) THEN
  191.                     RowDif% = MouseRow% - Selected(1)
  192.                     Y_Inc% = 1
  193.                   ELSEIF MouseRow% < Selected(1) THEN
  194.                     RowDif% = Selected(1) - MouseRow%
  195.                     Y_Inc% = -1
  196.                   END IF
  197.  
  198.                   IF MouseCol% > Selected(0) THEN
  199.                     ColDif% = MouseCol% - Selected(0)
  200.                     X_Inc% = 1
  201.                   ELSEIF MouseCol% < Selected(0) THEN
  202.                     ColDif% = Selected(0) - MouseCol%
  203.                     X_Inc% = -1
  204.                   END IF
  205.  
  206.                   IF RowDif% = ColDif% THEN '// Might be a valid move, check for stuff in the way
  207.  
  208.                     Row% = Selected(1) + Y_Inc%
  209.                     FOR Col% = Selected(0) + X_Inc% TO MouseCol% STEP X_Inc%
  210.                       IF Board(Col%, Row%).PieceID > 0 THEN '// Something on the square
  211.                         IF Col% = MouseCol% THEN
  212.                           IF Plyr% = 1 THEN
  213.                             IF Board(Col%, Row%).PieceID > 6 THEN Moving = True ELSE GOTO Skip_Case
  214.                           ELSE
  215.                             IF Board(Col%, Row%).PieceID <= 6 THEN Moving = True ELSE GOTO Skip_Case
  216.                           END IF
  217.                         ELSE
  218.                           GOTO Skip_Case '// illegal move
  219.                         END IF
  220.                       ELSE
  221.                         IF Col% = MouseCol% THEN Moving = True
  222.                       END IF
  223.                       Row% = Row% + Y_Inc%
  224.                     NEXT
  225.                   ELSE
  226.                     GOTO Skip_Case
  227.                   END IF
  228.  
  229.                 CASE 4, 10 '// knight
  230.  
  231.                   IF MouseRow% > Selected(1) THEN
  232.                     RowDif% = MouseRow% - Selected(1)
  233.                   ELSEIF MouseRow% < Selected(1) THEN
  234.                     RowDif% = Selected(1) - MouseRow%
  235.                   ELSE
  236.                     GOTO Skip_Case '// Invalid move
  237.                   END IF
  238.  
  239.                   IF MouseCol% > Selected(0) THEN
  240.                     ColDif% = MouseCol% - Selected(0)
  241.                   ELSEIF MouseCol% < Selected(0) THEN
  242.                     ColDif% = Selected(0) - MouseCol%
  243.                   ELSE
  244.                     GOTO Skip_Case '// Invalid move
  245.                   END IF
  246.  
  247.                   IF (RowDif% = 2 AND ColDif% = 1) OR (RowDif% = 1 AND ColDif% = 2) THEN
  248.                     IF Plyr% = 1 THEN
  249.                       IF Board(MouseCol%, MouseRow%).PieceID = 0 OR Board(MouseCol%, MouseRow%).PieceID > 6 THEN Moving = True ELSE GOTO Skip_Case
  250.                     ELSE
  251.                       IF Board(MouseCol%, MouseRow%).PieceID = 0 OR Board(MouseCol%, MouseRow%).PieceID < 7 THEN Moving = True ELSE GOTO Skip_Case
  252.                     END IF
  253.                   ELSE
  254.                     GOTO Skip_Case '// Invalid move
  255.                   END IF
  256.  
  257.  
  258.                 CASE 5, 11 '// King
  259.  
  260.                   IF MouseRow% > Selected(1) THEN
  261.                     RowDif% = MouseRow% - Selected(1)
  262.                   ELSEIF MouseRow% < Selected(1) THEN
  263.                     RowDif% = Selected(1) - MouseRow%
  264.                   ELSE
  265.                     RowDif% = 0
  266.                   END IF
  267.  
  268.                   IF MouseCol% > Selected(0) THEN
  269.                     ColDif% = MouseCol% - Selected(0)
  270.                   ELSEIF MouseCol% < Selected(0) THEN
  271.                     ColDif% = Selected(0) - MouseCol%
  272.                   ELSE
  273.                     ColDif% = 0
  274.                   END IF
  275.  
  276.                   IF ColDif% <= 1 AND RowDif% <= 1 THEN
  277.                     IF Plyr% = 1 THEN
  278.                       IF Board(MouseCol%, MouseRow%).PieceID = 0 OR Board(MouseCol%, MouseRow%).PieceID > 6 THEN Moving = True ELSE GOTO Skip_Case
  279.                     ELSE
  280.                       IF Board(MouseCol%, MouseRow%).PieceID = 0 OR Board(MouseCol%, MouseRow%).PieceID < 7 THEN Moving = True ELSE GOTO Skip_Case
  281.                     END IF
  282.                   ELSE
  283.                     GOTO Skip_Case
  284.                   END IF
  285.  
  286.                 CASE 6, 12 '// queen '// Mixture of rook and bishop movement
  287.  
  288.                   IF MouseCol% = Selected(0) THEN '// Vertical move
  289.                     IF MouseRow% > Selected(1) THEN StepVal% = 1 ELSE IF MouseRow% < Selected(1) THEN StepVal% = -1 ELSE GOTO Skip_Case
  290.  
  291.                     FOR Row% = Selected(1) + StepVal% TO MouseRow% STEP StepVal%
  292.                       IF Board(Selected(0), Row%).PieceID > 0 THEN
  293.                         IF Row% = MouseRow% THEN '// Attacking move
  294.                           IF Plyr% = 1 THEN
  295.                             IF Board(Selected(0), Row%).PieceID <= 6 THEN GOTO Skip_Case
  296.                           ELSEIF Plyr% = 2 THEN
  297.                             IF Board(Selected(0), Row%).PieceID >= 7 THEN GOTO Skip_Case
  298.                           END IF
  299.                           Moving = True
  300.                         ELSE '// Invalid move
  301.                           GOTO Skip_Case
  302.                         END IF
  303.                       ELSE
  304.                         IF Row% = MouseRow% THEN Moving = True
  305.                       END IF
  306.                     NEXT
  307.  
  308.                   ELSEIF MouseRow% = Selected(1) THEN '// Horizontal move
  309.                     IF MouseCol% > Selected(0) THEN StepVal% = 1 ELSE IF MouseCol% < Selected(0) THEN StepVal% = -1 ELSE GOTO Skip_Case
  310.  
  311.                     FOR Col% = Selected(0) + StepVal% TO MouseCol% STEP StepVal%
  312.                       IF Board(Col%, Selected(1)).PieceID > 0 THEN
  313.                         IF Row% = MouseRow% THEN '// Attacking move
  314.                           IF Plyr% = 1 THEN
  315.                             IF Board(Col%, Selected(1)).PieceID <= 6 THEN GOTO Skip_Case
  316.                           ELSEIF Plyr% = 2 THEN
  317.                             IF Board(Col%, Selected(1)).PieceID >= 7 THEN GOTO Skip_Case
  318.                           END IF
  319.                           Moving = True
  320.                         ELSE '// Invalid move
  321.                           GOTO Skip_Case
  322.                         END IF
  323.                       ELSE
  324.                         IF Col% = MouseCol% THEN Moving = True
  325.                       END IF
  326.                     NEXT
  327.  
  328.                   ELSE '// Diagonal move
  329.  
  330.                     IF MouseRow% > Selected(1) THEN
  331.                       RowDif% = MouseRow% - Selected(1)
  332.                       Y_Inc% = 1
  333.                     ELSEIF MouseRow% < Selected(1) THEN
  334.                       RowDif% = Selected(1) - MouseRow%
  335.                       Y_Inc% = -1
  336.                     END IF
  337.  
  338.                     IF MouseCol% > Selected(0) THEN
  339.                       ColDif% = MouseCol% - Selected(0)
  340.                       X_Inc% = 1
  341.                     ELSEIF MouseCol% < Selected(0) THEN
  342.                       ColDif% = Selected(0) - MouseCol%
  343.                       X_Inc% = -1
  344.                     END IF
  345.  
  346.                     IF RowDif% = ColDif% THEN '// Might be a valid move, check for stuff in the way
  347.                       Row% = Selected(1) + Y_Inc%
  348.                       FOR Col% = Selected(0) + X_Inc% TO MouseCol% STEP X_Inc%
  349.                         IF Board(Col%, Row%).PieceID > 0 THEN '// Something on the square
  350.                           IF Col% = MouseCol% THEN
  351.                             IF Plyr% = 1 THEN
  352.                               IF Board(Col%, Row%).PieceID > 6 THEN Moving = True ELSE GOTO Skip_Case
  353.                             ELSE
  354.                               IF Board(Col%, Row%).PieceID <= 6 THEN Moving = True ELSE GOTO Skip_Case
  355.                             END IF
  356.                           ELSE
  357.                             GOTO Skip_Case '// illegal move
  358.                           END IF
  359.                         ELSE
  360.                           IF Col% = MouseCol% THEN Moving = True
  361.                         END IF
  362.                         Row% = Row% + Y_Inc%
  363.                       NEXT
  364.                     ELSE
  365.                       GOTO Skip_Case
  366.                     END IF
  367.                   END IF
  368.  
  369.               END SELECT
  370.  
  371.               Select_Piece% = True
  372.  
  373.             END IF
  374.           END IF
  375.         END IF
  376.       END IF
  377.  
  378.       '/////////////////////////////////////////
  379.  
  380.       IF Moving = True THEN '// If any pieces have been set to move then do stuff here
  381.  
  382.         IF NOT Board(Selected(0), Selected(1)).PieceID = 4 AND NOT Board(Selected(0), Selected(1)).PieceID = 10 THEN
  383.           '// Calculate rotation
  384.           IF Selected(0) <> MouseCol% THEN
  385.             IF Selected(1) <> MouseRow% THEN '// Diagonal movement
  386.               IF MouseCol% > Selected(0) THEN
  387.                 IF MouseRow% < Selected(1) THEN
  388.                   Board(Selected(0), Selected(1)).Rotation = SE
  389.                 ELSE
  390.                   Board(Selected(0), Selected(1)).Rotation = NE
  391.                 END IF
  392.               ELSEIF MouseCol% < Selected(0) THEN
  393.                 IF MouseRow% < Selected(1) THEN
  394.                   Board(Selected(0), Selected(1)).Rotation = SW
  395.                 ELSE
  396.                   Board(Selected(0), Selected(1)).Rotation = NW
  397.                 END IF
  398.               END IF
  399.             ELSE '// Horizontal movement only
  400.               IF MouseCol% > Selected(0) THEN
  401.                 Board(Selected(0), Selected(1)).Rotation = East
  402.               ELSEIF MouseCol% < Selected(0) THEN
  403.                 Board(Selected(0), Selected(1)).Rotation = West
  404.               END IF
  405.             END IF
  406.           ELSE '// Vertical movement only
  407.             IF MouseRow% < Selected(1) THEN
  408.               Board(Selected(0), Selected(1)).Rotation = South
  409.             ELSE
  410.               Board(Selected(0), Selected(1)).Rotation = North
  411.             END IF
  412.           END IF
  413.         ELSE '// a knight - rotation calculated on the fly
  414.           IF MouseCol% > Selected(0) THEN
  415.             XVal% = MouseCol% - Selected(0)
  416.           ELSE
  417.             XVal% = Selected(0) - MouseCol%
  418.           END IF
  419.  
  420.           IF MouseRow% > Selected(1) THEN
  421.             YVal% = MouseRow% - Selected(1)
  422.           ELSE
  423.             YVal% = Selected(1) - MouseRow%
  424.           END IF
  425.  
  426.           Board(Selected(0), Selected(1)).Rotation = atan2(XVal%, YVal%) + 315
  427.  
  428.         END IF
  429.  
  430.         '// calculate relative x/y offset per animation frame for moving
  431.         IF Board(Selected(0), Selected(1)).PieceID >= 7 THEN
  432.           PieceId% = Board(Selected(0), Selected(1)).PieceID - 6
  433.         ELSE
  434.           PieceId% = Board(Selected(0), Selected(1)).PieceID
  435.         END IF
  436.  
  437.         Frames% = Anim(PieceId% - 1, Walking).ResetFrame - Anim(PieceId% - 1, Walking).StartFrame
  438.  
  439.         IF MouseCol% < Selected(0) THEN
  440.           Board(Selected(0), Selected(1)).X_Inc = 3
  441.         ELSEIF MouseCol% > Selected(0) THEN
  442.           Board(Selected(0), Selected(1)).X_Inc = -3
  443.         ELSE
  444.           Board(Selected(0), Selected(1)).X_Inc = 0
  445.         END IF
  446.  
  447.         IF MouseRow% < Selected(1) THEN
  448.           Board(Selected(0), Selected(1)).Z_Inc = -3
  449.         ELSEIF MouseRow% > Selected(1) THEN
  450.           Board(Selected(0), Selected(1)).Z_Inc = 3
  451.         ELSE
  452.           Board(Selected(0), Selected(1)).Z_Inc = 0
  453.         END IF
  454.  
  455.         Board(Selected(0), Selected(1)).Anim = Anim(PieceId% - 1, Walking)
  456.  
  457.         '// Switch cam mode to action view
  458.         CamMode = Action
  459.  
  460.       END IF
  461.  
  462.     CASE Action '// Action camera used for movement animations  /////////////////////////////////////////
  463.  
  464.       IF Board(Selected(0), Selected(1)).X_Offset < 0 THEN
  465.         Rel_Col% = Selected(0) - (Board(Selected(0), Selected(1)).X_Offset / 66.25)
  466.       ELSE
  467.         Rel_Col% = Selected(0) + (Board(Selected(0), Selected(1)).X_Offset / -66.25)
  468.       END IF
  469.  
  470.       IF Board(Selected(0), Selected(1)).Z_Offset < 0 THEN
  471.         Rel_Row% = Selected(1) - (Board(Selected(0), Selected(1)).Z_Offset / -66.25)
  472.       ELSE
  473.         Rel_Row% = Selected(1) + (Board(Selected(0), Selected(1)).Z_Offset / 66.25)
  474.       END IF
  475.  
  476.       IF Rel_Col% = MouseCol% AND Rel_Row% = MouseRow% THEN
  477.         '// At the end of movement - trigger battle if needed then swap/clear sqaures
  478.         Board(MouseCol%, MouseRow%) = Blank_Square
  479.         IF Board(Selected(0), Selected(1)).First_Move = False THEN Board(Selected(0), Selected(1)).First_Move = True
  480.         SWAP Board(MouseCol%, MouseRow%), Board(Selected(0), Selected(1))
  481.         Board(MouseCol%, MouseRow%).X_Offset = 0
  482.         Board(MouseCol%, MouseRow%).Z_Offset = 0
  483.  
  484.         IF Board(MouseCol%, MouseRow%).PieceID >= 7 THEN
  485.           PieceId% = Board(MouseCol%, MouseRow%).PieceID - 6
  486.         ELSE
  487.           PieceId% = Board(MouseCol%, MouseRow%).PieceID
  488.         END IF
  489.  
  490.         Board(MouseCol%, MouseRow%).Anim = Anim(PieceId% - 1, Standing)
  491.  
  492.         IF Plyr% = 1 THEN Plyr% = 2 ELSE Plyr% = 1
  493.         Moving = False
  494.         CamMode = Fixed
  495.  
  496.       ELSE
  497.         Board(Selected(0), Selected(1)).X_Offset = Board(Selected(0), Selected(1)).X_Offset + Board(Selected(0), Selected(1)).X_Inc
  498.         Board(Selected(0), Selected(1)).Z_Offset = Board(Selected(0), Selected(1)).Z_Offset + Board(Selected(0), Selected(1)).Z_Inc
  499.       END IF
  500.  
  501.     CASE Battle '// Fighting animations /////////////////////////////////////////
  502.  
  503.  
  504.   Skip_Case: '// get sent here by doing an invalid move
  505.  
  506.   '////////////// DEBUG ////////////////////
  507.   IF Debug% THEN
  508.     CLS
  509.     LOCATE 1, 1
  510.     PRINT "MOUSE (X,Y) : "; Mouse(0).X; Mouse(0).Y
  511.     PRINT "Col/Row : "; MouseCol%; MouseRow%
  512.     PRINT "Selected Col/Row : "; Selected(0); Selected(1)
  513.     PRINT "Rel_Col/Rel_Row : "; Rel_Col%; Rel_Row%
  514.   END IF
  515.   '/////////////////////////////////////////
  516.  
  517.   KB(1) = KB(0)
  518.   Mouse(1) = Mouse(0)
  519.  
  520.  
  521.  
  522. Default_Board:
  523.  
  524. DATA 1,1,1,1,1,1,1,1
  525. DATA 2,4,3,6,5,3,4,2
  526. DATA 7,7,7,7,7,7,7,7
  527. DATA 8,10,9,12,11,9,10,8
  528.  
  529. '//////////////////////////////////
  530.  
  531. REM $include:'GDK_GL\GDK_GL.bm'
  532. REM $include:'UnseenGDK.bm'
  533.  
  534. '//////////////////////////////////
  535.  
  536. TYPE Square
  537.   PieceID AS _BYTE
  538.   Anim AS ANIMATION '// Current animation
  539.   First_Move AS _BYTE '// If the piece has moved before or not
  540.   X_Offset AS INTEGER '// Position offsets for movement animations
  541.   Z_Offset AS INTEGER
  542.   X_Inc AS _BYTE '// Position offset increments (per animation frame)
  543.   Z_Inc AS _BYTE
  544.   Rotation AS INTEGER
  545.  
  546. '//////////////////////////////////
  547.  
  548. SUB _GL
  549.  
  550.   IF Allow_GL THEN
  551.  
  552.     _glClearColor 0, 0, 0, 1
  553.     _glEnable _GL_DEPTH_TEST
  554.     _glEnable _GL_TEXTURE_2D
  555.     _glMatrixMode _GL_PROJECTION
  556.     _gluPerspective 80, 800 / 600, 1, 2000
  557.     _glMatrixMode _GL_MODELVIEW
  558.     _glViewport 0, 0, 800, 600
  559.  
  560.     IF Init = False THEN
  561.  
  562.       IF NOT GDK_GL_MODEL_LOAD(Model(0), "GDK_Gl\QuakeChess\zombie.mdl") THEN PRINT "Failed to load model." '// Pawn
  563.       IF NOT GDK_GL_MODEL_LOAD(Model(1), "GDK_Gl\QuakeChess\ogre.mdl") THEN PRINT "Failed to load model." '// Rook
  564.       IF NOT GDK_GL_MODEL_LOAD(Model(2), "GDK_Gl\QuakeChess\wizard.mdl") THEN PRINT "Failed to load model." '// Bishop
  565.       IF NOT GDK_GL_MODEL_LOAD(Model(3), "GDK_Gl\QuakeChess\knight.mdl") THEN PRINT "Failed to load model." '// Knight
  566.       IF NOT GDK_GL_MODEL_LOAD(Model(4), "GDK_Gl\QuakeChess\soldier.mdl") THEN PRINT "Failed to load model." '// King
  567.       IF NOT GDK_GL_MODEL_LOAD(Model(5), "GDK_Gl\QuakeChess\demon.mdl") THEN PRINT "Failed to load model." '// Queen
  568.  
  569.  
  570.       '// Zombie animations - Pawns
  571.       GDK_ANIMATION_NEW Anim(0, Standing), 1, 1, 14, .1, TIMER(.001)
  572.       GDK_ANIMATION_NEW Anim(0, Walking), 34, 34, 51, .05, TIMER(.001)
  573.       GDK_ANIMATION_NEW Anim(0, Attack), 52, 52, 90, .1, TIMER(.001)
  574.       GDK_ANIMATION_NEW Anim(0, BeingHit), 131, 131, 149, .1, TIMER(.001)
  575.       GDK_ANIMATION_NEW Anim(0, Falling), 163, 163, 173, .1, TIMER(.001)
  576.  
  577.       '// Ogre animations - Rooks
  578.       GDK_ANIMATION_NEW Anim(1, Standing), 1, 1, 8, .1, TIMER(.001)
  579.       GDK_ANIMATION_NEW Anim(1, Walking), 9, 9, 24, .05, TIMER(.001)
  580.       GDK_ANIMATION_NEW Anim(1, Attack), 33, 33, 60, .1, TIMER(.001)
  581.       GDK_ANIMATION_NEW Anim(1, BeingHit), 131, 131, 149, .1, TIMER(.001) '// Not set yet
  582.       GDK_ANIMATION_NEW Anim(1, Falling), 112, 112, 125, .1, TIMER(.001)
  583.  
  584.       '// Wizard animation - Bishops
  585.       GDK_ANIMATION_NEW Anim(2, Standing), 1, 1, 14, .1, TIMER(.001)
  586.       GDK_ANIMATION_NEW Anim(2, Walking), 15, 15, 28, .05, TIMER(.001)
  587.       GDK_ANIMATION_NEW Anim(2, Attack), 29, 29, 41, .1, TIMER(.001)
  588.       GDK_ANIMATION_NEW Anim(2, BeingHit), 131, 131, 149, .1, TIMER(.001) '// Not set yet
  589.       GDK_ANIMATION_NEW Anim(2, Falling), 42, 42, 53, .1, TIMER(.001)
  590.  
  591.       '// Knight animations - Knight
  592.       GDK_ANIMATION_NEW Anim(3, Standing), 1, 1, 8, .1, TIMER(.001)
  593.       GDK_ANIMATION_NEW Anim(3, Walking), 53, 53, 66, .05, TIMER(.001)
  594.       GDK_ANIMATION_NEW Anim(3, Attack), 42, 42, 52, .1, TIMER(.001)
  595.       GDK_ANIMATION_NEW Anim(3, BeingHit), 28, 28, 41, .1, TIMER(.001)
  596.       GDK_ANIMATION_NEW Anim(3, Falling), 86, 86, 97, .1, TIMER(.001)
  597.  
  598.       '// Demon animations - King
  599.       GDK_ANIMATION_NEW Anim(4, Standing), 1, 1, 7, .1, TIMER(.001)
  600.       GDK_ANIMATION_NEW Anim(4, Walking), 90, 90, 114, .05, TIMER(.001)
  601.       GDK_ANIMATION_NEW Anim(4, Attack), 81, 81, 89, .1, TIMER(.001)
  602.       GDK_ANIMATION_NEW Anim(4, BeingHit), 46, 46, 60, .1, TIMER(.001)
  603.       GDK_ANIMATION_NEW Anim(5, Falling), 9, 9, 17, .1, TIMER(.001)
  604.  
  605.       '// Soldier animations - Queen
  606.       GDK_ANIMATION_NEW Anim(5, Standing), 1, 1, 12, .1, TIMER(.001)
  607.       GDK_ANIMATION_NEW Anim(5, Walking), 13, 13, 20, .05, TIMER(.001)
  608.       GDK_ANIMATION_NEW Anim(5, Attack), 54, 54, 69, .1, TIMER(.001)
  609.       GDK_ANIMATION_NEW Anim(5, BeingHit), 131, 131, 149, .1, TIMER(.001) '// Not set yet
  610.       GDK_ANIMATION_NEW Anim(5, Falling), 44, 44, 53, .1, TIMER(.001)
  611.  
  612.       RESTORE Default_Board
  613.       FOR j% = 1 TO 4
  614.         FOR i% = 1 TO 8
  615.           READ Piece%
  616.           IF Piece% >= 7 THEN AnimRef% = Piece% - 7 ELSE AnimRef% = Piece% - 1
  617.  
  618.           SELECT CASE j%
  619.             CASE 1
  620.               Board(i%, 2).PieceID = Piece%
  621.               Board(i%, 2).Anim = Anim(AnimRef%, Standing)
  622.             CASE 2
  623.               Board(i%, 1).PieceID = Piece%
  624.               Board(i%, 1).Anim = Anim(AnimRef%, Standing)
  625.             CASE 3
  626.               Board(i%, 7).PieceID = Piece%
  627.               Board(i%, 7).Anim = Anim(AnimRef%, Standing)
  628.             CASE 4
  629.               Board(i%, 8).PieceID = Piece%
  630.               Board(i%, 8).Anim = Anim(AnimRef%, Standing)
  631.           END SELECT
  632.  
  633.         NEXT
  634.       NEXT
  635.  
  636.       Floor(0) = GDK_GL_LOAD_TEXTURE("GDK_GL\QuakeChess\FloorRed.png")
  637.       Floor(1) = GDK_GL_LOAD_TEXTURE("GDK_GL\QuakeChess\FloorWhite.png")
  638.  
  639.       Flr_Lst = _glGenLists(1)
  640.       _glNewList Flr_Lst, _GL_COMPILE
  641.       FloorZ% = -200
  642.       FloorY% = 20
  643.       FOR j% = 1 TO 8
  644.         FloorX% = -200
  645.         FOR i% = 1 TO 8
  646.           IF White% THEN
  647.             GDK_GL_SET_TEXTURE Floor(1)
  648.             White% = False
  649.           ELSE
  650.             GDK_GL_SET_TEXTURE Floor(0)
  651.             White% = True
  652.           END IF
  653.           _glBegin _GL_QUADS
  654.           _glTexCoord2f 0, 0: _glVertex3f FloorX%, FloorY% - 50, FloorZ%
  655.           _glTexCoord2f 0, 1: _glVertex3f FloorX% + 50, FloorY% - 50, FloorZ%
  656.           _glTexCoord2f 1, 1: _glVertex3f FloorX% + 50, FloorY% - 50, FloorZ% + 50
  657.           _glTexCoord2f 1, 0: _glVertex3f FloorX%, FloorY% - 50, FloorZ% + 50
  658.           _glEnd
  659.           FloorX% = FloorX% + 50
  660.         NEXT
  661.         FloorZ% = FloorZ% + 50
  662.         IF White% THEN White% = False ELSE White% = True
  663.       NEXT
  664.       _glEndList
  665.  
  666.       Init = True
  667.  
  668.     ELSE
  669.  
  670.       GDK_GL_CLS
  671.  
  672.       '// Set the view to the cameras position
  673.       GDK_GL_VECTOR_APPLY_RT CamVec
  674.  
  675.       SELECT CASE CamMode
  676.  
  677.         CASE Fixed, Action '// Very similar so easier to adda fe IF's over a whole case block
  678.  
  679.           _glCallList Flr_Lst
  680.  
  681.           FloorZ% = -175
  682.           FloorY% = -55
  683.           FOR j% = 1 TO 8
  684.             FloorX% = 175
  685.             FOR i% = 1 TO 8
  686.               _glPushMatrix
  687.               _glTranslatef FloorX% + Board(i%, j%).X_Offset, FloorY%, FloorZ% + Board(i%, j%).Z_Offset
  688.               _glRotatef 180, 0, 0, 1
  689.  
  690.               IF Moving = False THEN '// Normal view
  691.                 IF Board(i%, j%).PieceID < 7 THEN _glRotatef 270, 0, 1, 0 ELSE _glRotatef 90, 0, 1, 0
  692.               ELSE '// Action view
  693.                 IF i% = Selected(0) AND j% = Selected(1) THEN
  694.                   _glRotatef Board(i%, j%).Rotation, 0, 1, 0
  695.                 ELSE
  696.                   IF Board(i%, j%).PieceID < 7 THEN _glRotatef 270, 0, 1, 0 ELSE _glRotatef 90, 0, 1, 0
  697.                 END IF
  698.               END IF
  699.  
  700.               _glRotatef 270, 1, 0, 0
  701.  
  702.               GDK_ANIMATION_UPDATE Board(i%, j%).Anim
  703.  
  704.               SELECT CASE Board(i%, j%).PieceID
  705.                 CASE 1, 7 '// Pawns
  706.                   GDK_GL_MODEL_DRAW Model(0), Board(i%, j%).Anim.Frame
  707.                 CASE 2, 8 '// Rook
  708.                   GDK_GL_MODEL_DRAW Model(1), Board(i%, j%).Anim.Frame
  709.                 CASE 3, 9 '// Bishop
  710.                   GDK_GL_MODEL_DRAW Model(2), Board(i%, j%).Anim.Frame
  711.                 CASE 4, 10 '// Knight
  712.                   GDK_GL_MODEL_DRAW Model(3), Board(i%, j%).Anim.Frame
  713.                 CASE 5, 11 '// King
  714.                   GDK_GL_MODEL_DRAW Model(4), Board(i%, j%).Anim.Frame
  715.                 CASE 6, 12 '// Queen
  716.                   GDK_GL_MODEL_DRAW Model(5), Board(i%, j%).Anim.Frame
  717.               END SELECT
  718.               _glPopMatrix
  719.  
  720.               FloorX% = FloorX% - 50
  721.             NEXT
  722.             FloorZ% = FloorZ% + 50
  723.           NEXT
  724.  
  725.         CASE Battle
  726.  
  727.  
  728.       END SELECT
  729.  
  730.     END IF
  731.   END IF
  732.  
  733.  
  734.  

I look forward to you feedback,

Thanks and happy coding.
Unseen

Offline STxAxTIC

  • Library Staff
  • Forum Resident
  • Posts: 1091
  • he lives
    • View Profile
Re: Quake Chess
« Reply #9 on: April 07, 2020, 10:23:37 pm »
Hey Unseen,

Always been a huge quake fan, this look fun - I can imagine if you get all the quake sounds involved it'll be super badass.

I have some trouble selecting and moving pieces, seems to finally make a move when I spam the mouse randomly. Am I being too hasty?
You're not done when it works, you're done when it's right.

Offline Unseen Machine

  • Forum Regular
  • Posts: 158
  • Make the game not the engine!
    • View Profile
Re: Quake Chess
« Reply #10 on: April 08, 2020, 04:34:09 am »
Hey StxAxTIC,,

Yes sounds are planned for aswellas cinematic style fight scenes.

As for moude input, I agree, it's far from good, ill have to lookinto my routines to see if i can get it working better. For now the top team is white and moves forwards.

When you do finally manage to select a piece its col/row is printed onscreen as part of the debug info.  PRINT "Selected Col/Row : "; Selected(0); Selected(1)

Thanks for trying, and just out of interest what PC did you run it on? Mines really old and i assumed that could be the reason for the FPSlag and dodgy mouse input.

Thanks

Unseen