Author Topic: Ludo  (Read 5202 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
Ludo
« on: May 03, 2020, 01:54:09 pm »
Hi Gang,

After totally deleting and rewriting the CPU player code twice i finally have a playable version!

It needs some refinement and after my god daughters just played it they've suggested a few modifications but im quite happy with it as it stands.

Code: QB64: [Select]
  1. '// Ludo v.01 By John Onyon a.k.a Unseen Machine \\
  2.  
  3. REM $include:'Vqb\Vqb.bi'
  4.  
  5.  
  6. CONST White = 1, Green = 2, Yellow = 3, Red = 4, Blue = 5, Home = 6, Human = 1, CPU = 2, MainMenu = 1, InGame = 2
  7. CONST Attack = 1, Move = 2, GetOut = 3
  8.  
  9. DIM Mouse(1) AS MouseState, Kb(1) AS KeyBoardState, VQB_Mouse(1) AS MouseInfo
  10. DIM Board(14, 14) AS _BYTE, Board2(14, 14) AS _BIT, BoardBits(14, 14) AS _BYTE, BBHlp(2) AS _BYTE, PlyrMove(3, 57) AS INTEGER
  11. DIM Piece AS Sprite, D_Sprite AS Sprite, Num_Players AS _BYTE, Current_Plyr AS _BYTE
  12. DIM Player(3) AS Player, GameState AS _BYTE, Selected(1) AS _BYTE, Btn(3) AS Button, Dice AS _BYTE, Rolling AS _BYTE
  13. DIM SelectPiece AS _BYTE
  14.  
  15. GDK_Screen_SetRes MainScreen&, 800, 600
  16.  
  17. VQB_Button_New Btn(0), 300, 160, 200, 35, _RGB32(155, 155, 255), "One Player Game"
  18. VQB_Button_New Btn(1), 300, 210, 200, 35, _RGB32(155, 155, 255), "Two Player Game"
  19. VQB_Button_New Btn(2), 300, 260, 200, 35, _RGB32(155, 155, 255), "Three Player Game"
  20. VQB_Button_New Btn(3), 300, 310, 200, 35, _RGB32(155, 155, 255), "Four Player Game"
  21.  
  22. GDK_Sprite_New Piece, "Ludo\Tiles.png", 6, 3, 18, _RGB32(255, 0, 255)
  23. Piece.Scale = .8
  24. GDK_Sprite_New D_Sprite, "Ludo\Dice.png", 6, 1, 6, _RGB32(255, 0, 255)
  25. GDK_Sprite_SetRotationAsCenter D_Sprite
  26.  
  27. GameState = MainMenu
  28. Debug% = TRUE
  29.  
  30. '////////// Main Screen Setup \\\\\\\
  31.  
  32. RESTORE Blank_Board
  33. FOR k% = 0 TO 1
  34.  FOR j% = 0 TO 14
  35.   FOR i% = 0 TO 14
  36.    READ Piece%
  37.    IF k% = 0 THEN Board(i%, j%) = Piece% ELSE Board2(i%, j%) = Piece%
  38.   NEXT
  39.  
  40. VQB_Frame 5, 5, 790, 590, _RGB32(20, 70, 155)
  41. VQB_Frame 155, 55, 490, 490, _RGB32(50, 40, 85)
  42. VQB_Frame 300, 15, 200, 30, _RGB32(0, 0, 0)
  43. COLOR _RGB32(255, 255, 255)
  44. _PRINTSTRING (400 - (_PRINTWIDTH("LUDO v.01") / 2), 23), "LUDO v.01"
  45. y% = 60
  46. FOR j% = 0 TO 14
  47.  x% = 160
  48.  FOR i% = 0 TO 14
  49.   GDK_Sprite_DrawXY Piece, x%, y%, 0, Board(i%, j%)
  50.   IF Board2(i%, j%) THEN LINE (x%, y%)-(x% + 31, y% + 31), _RGB32(0, 0, 0), B
  51.   x% = x% + 32
  52.  y% = y% + 32
  53. BckGrnd& = VQB_StoreScreen&
  54.  
  55.  
  56. '///////////// Load Path Data \\\\\\\\\\\
  57.  
  58. FOR Plyr% = 0 TO 3
  59.  FOR Bit% = 0 TO 57
  60.   READ PlyrMove(Plyr%, Bit%)
  61.  
  62. '//////////////// Main Loop \\\\\\\\\\\\\
  63.  
  64.  _LIMIT 30
  65.  VQB_RestoreScreen BckGrnd&
  66.  
  67.  GDK_Mouse_GetState Mouse(0)
  68.  GDK_Keyboard_GetState Kb(0)
  69.  
  70.  Col% = (Mouse(0).X - 160) \ 32
  71.  Row% = (Mouse(0).Y - 60) \ 32
  72.  '// Ensure we cant get an out off bounds error by capping the array refs
  73.  IF Col% < 0 OR Col% > 14 OR Row% < 0 OR Row% > 14 THEN
  74.   Row% = 0
  75.   Col% = 0
  76.  
  77.  SELECT CASE GameState
  78.  
  79.   CASE MainMenu
  80.  
  81.    VQB_Mouse_GetInfo VQB_Mouse(0)
  82.  
  83.    VQB_Frame 255, 135, 290, 240, _RGB32(150, 40, 5)
  84.  
  85.    FOR i% = 0 TO 3
  86.     IF VQB_Button_Click(Btn(i%), VQB_Mouse(0)) THEN
  87.      Num_Players% = i% + 1
  88.      GameState = InGame
  89.      FOR j% = 0 TO 3
  90.       IF j% <= i% THEN
  91.        Player(j%).Control = Human
  92.       ELSE
  93.        Player(j%).Control = CPU
  94.        Player(j%).Persona = INT(RND * 3) + 1 '// randomize priority (a.i mode)
  95.       END IF
  96.      NEXT
  97.      Current_Plyr = 1
  98.      Rolling = TRUE
  99.      EXIT FOR
  100.     END IF
  101.     VQB_Button_Draw Btn(i%)
  102.    NEXT
  103.  
  104.   CASE InGame
  105.  
  106.    IF Rolling THEN
  107.     IF NumRolls% < 10 THEN
  108.      Dice = INT(RND * 6) + 1
  109.      NumRolls% = NumRolls% + 1
  110.     ELSE
  111.      '// Check to see if player has only one piece out and the distance fits up to home, if not then skip to next player
  112.      IF Player(Current_Plyr - 1).Num_Out = 1 THEN
  113.       FOR j% = 0 TO 14
  114.        FOR i% = 0 TO 14
  115.         IF BoardBits(i%, j%) = Current_Plyr THEN
  116.          ActualBlock% = (j% * 15) + i% + 1
  117.         END IF
  118.        NEXT
  119.       NEXT
  120.       Ref1% = -1
  121.       FOR i% = 0 TO 57
  122.        IF PlyrMove(Current_Plyr - 1, i%) = ActualBlock% THEN Ref1% = i%
  123.       NEXT
  124.       IF Ref1% = 57 - Dice THEN
  125.        Rolling = FALSE
  126.        SelectPiece = TRUE
  127.       ELSEIF Ref1% > 57 - Dice THEN
  128.        IF Current_Plyr < 4 THEN Current_Plyr = Current_Plyr + 1 ELSE Current_Plyr = 1
  129.        NumRolls% = 0
  130.       ELSE
  131.        Rolling = FALSE
  132.        SelectPiece = TRUE
  133.       END IF
  134.      ELSE
  135.       Rolling = FALSE
  136.       SelectPiece = TRUE
  137.      END IF
  138.      NumRolls% = 0
  139.     END IF
  140.    ELSE
  141.  
  142.     IF SelectPiece THEN
  143.  
  144.      SELECT CASE Current_Plyr
  145.       CASE 1
  146.        BBHlp(0) = 2
  147.        BBHlp(1) = 6
  148.        BBHlp(2) = 1
  149.       CASE 2
  150.        BBHlp(0) = 8
  151.        BBHlp(1) = 2
  152.        BBHlp(2) = 2
  153.       CASE 3
  154.        BBHlp(0) = 12
  155.        BBHlp(1) = 8
  156.        BBHlp(2) = 3
  157.       CASE 4
  158.        BBHlp(0) = 6
  159.        BBHlp(1) = 12
  160.        BBHlp(2) = 4
  161.      END SELECT
  162.  
  163.      IF Player(Current_Plyr - 1).Num_Home < 4 THEN '// Player still has availble bits to use (still in the game)
  164.       IF Player(Current_Plyr - 1).Num_Out = 0 OR NewBit% = TRUE THEN '// If the player has no bits out automatically place one if a six is rolled
  165.  
  166.        IF Dice = 6 THEN '// roll a six to start moving a bit
  167.         IF Player(Current_Plyr - 1).Num_Out + Player(Current_Plyr - 1).Num_Home < 4 THEN
  168.          IF BoardBits(BBHlp(0), BBHlp(1)) <> Current_Plyr THEN
  169.           IF BoardBits(BBHlp(0), BBHlp(1)) > 0 THEN
  170.            '// Kick who ever is there back home
  171.            Player(BoardBits(BBHlp(0), BBHlp(1)) - 1).Num_Out = Player(BoardBits(BBHlp(0), BBHlp(1)) - 1).Num_Out - 1
  172.           END IF
  173.           '// Allocate the square
  174.           BoardBits(BBHlp(0), BBHlp(1)) = BBHlp(2)
  175.           Player(Current_Plyr - 1).Num_Out = Player(Current_Plyr - 1).Num_Out + 1
  176.           IF Current_Plyr < 4 THEN Current_Plyr = Current_Plyr + 1 ELSE Current_Plyr = 1
  177.           Rolling = TRUE
  178.          END IF
  179.         END IF
  180.        ELSE
  181.         IF Current_Plyr < 4 THEN Current_Plyr = Current_Plyr + 1 ELSE Current_Plyr = 1
  182.         Rolling = TRUE
  183.        END IF
  184.  
  185.       ELSE '// Have pieces out on the board
  186.  
  187.        IF Player(Current_Plyr - 1).Control = Human THEN '// Human Player
  188.  
  189.         IF Dice = 6 THEN
  190.  
  191.          IF Player(Current_Plyr - 1).Num_Out + Player(Current_Plyr - 1).Num_Home < 4 THEN
  192.           SELECT CASE Current_Plyr
  193.            CASE 1
  194.             clr& = _RGB32(0, 255, 0)
  195.            CASE 2
  196.             clr& = _RGB32(255, 255, 0)
  197.            CASE 3
  198.             clr& = _RGB32(0, 0, 255)
  199.            CASE 4
  200.             clr& = _RGB32(255, 0, 0)
  201.           END SELECT
  202.  
  203.           Xpos% = 176 + (BBHlp(0) * 32)
  204.           Ypos% = 76 + (BBHlp(1) * 32)
  205.           CIRCLE (Xpos%, Ypos%), 6 + CSize%, clr&
  206.           PAINT STEP(0, 0), clr&, clr&
  207.           IF CSize% < 6 THEN CSize% = CSize% + 1 ELSE CSize% = 1
  208.  
  209.           IF Col% = BBHlp(0) AND Row% = BBHlp(1) THEN
  210.            IF Mouse(0).LB THEN
  211.             IF BoardBits(Col%, Row%) <> Current_Plyr THEN
  212.              IF BoardBits(Col%, Row%) > 0 THEN
  213.               Player(BoardBits(Col%, Row%) - 1).Num_Out = Player(BoardBits(Col%, Row%) - 1).Num_Out - 1
  214.              END IF
  215.              Player(Current_Plyr - 1).Num_Out = Player(Current_Plyr - 1).Num_Out + 1
  216.              BoardBits(Col%, Row%) = Current_Plyr
  217.              IF Current_Plyr < 4 THEN Current_Plyr = Current_Plyr + 1 ELSE Current_Plyr = 1
  218.              Rolling = TRUE
  219.             END IF
  220.            END IF
  221.           END IF
  222.          END IF
  223.         END IF
  224.  
  225.         IF Mouse(0).LB AND NOT Mouse(1).LB THEN
  226.          IF Board2(Col%, Row%) AND BoardBits(Col%, Row%) = Current_Plyr THEN '// Players bit
  227.           Selected(0) = Col%
  228.           Selected(1) = Row%
  229.           SelectPiece = FALSE
  230.          END IF
  231.         END IF
  232.  
  233.        ELSE '// CPU Player
  234.  
  235.         IF Player(Current_Plyr - 1).Num_Out > 0 THEN '// Player has active pieces
  236.          FOR Bit% = 0 TO Player(Current_Plyr - 1).Num_Out '// Cycle through all bits the player has out
  237.           ScanDir% = INT(RND * 2) + 1
  238.           IF ScanDir% = 1 THEN
  239.            Lp_Start% = 0
  240.            Lp_End% = 14
  241.            StepVal% = 1
  242.           ELSE
  243.            Lp_Start% = 14
  244.            Lp_End% = 0
  245.            StepVal% = -1
  246.           END IF
  247.           FOR j% = Lp_Start% TO Lp_End% STEP StepVal% '// Rows
  248.            FOR i% = Lp_Start% TO Lp_End% STEP StepVal% '// Columns
  249.  
  250.             IF Dice = 6 THEN
  251.              IF Player(Current_Plyr - 1).Num_Out + Player(Current_Plyr - 1).Num_Home < 4 THEN '// Have pieces left to put out
  252.               IF BoardBits(BBHlp(0), BBHlp(1)) <> Current_Plyr THEN '// Can place a new piece
  253.                NewPiece% = TRUE
  254.               END IF
  255.              END IF
  256.             END IF
  257.  
  258.             IF NewPiece% THEN
  259.  
  260.              IF BoardBits(BBHlp(0), BBHlp(1)) > 0 THEN '// Kick who ever is there back home
  261.               Player(BoardBits(BBHlp(0), BBHlp(1)) - 1).Num_Out = Player(BoardBits(BBHlp(0), BBHlp(1)) - 1).Num_Out - 1
  262.              END IF '// Allocate the square
  263.              BoardBits(BBHlp(0), BBHlp(1)) = BBHlp(2)
  264.              Player(Current_Plyr - 1).Num_Out = Player(Current_Plyr - 1).Num_Out + 1
  265.              IF Current_Plyr < 4 THEN Current_Plyr = Current_Plyr + 1 ELSE Current_Plyr = 1
  266.              Rolling = TRUE
  267.              NewPiece% = FALSE
  268.              GOTO Skip_Loops
  269.  
  270.             ELSE
  271.  
  272.              IF BoardBits(i%, j%) = Current_Plyr THEN '// Current players piece
  273.               '// Get Array ref's
  274.               ActualBlock% = (j% * 15) + i% + 1
  275.               FOR a% = 0 TO 57
  276.                IF PlyrMove(Current_Plyr - 1, a%) = ActualBlock% THEN Ref1% = a%
  277.               NEXT
  278.  
  279.               IF Ref1% + Dice < 57 THEN '// Move is within range
  280.                NewActual% = PlyrMove(Current_Plyr - 1, Ref1% + Dice)
  281.                NewRow% = (NewActual% - 1) \ 15
  282.                NewCol% = (NewActual% - 1) MOD 15
  283.                IF BoardBits(NewCol%, NewRow%) <> Current_Plyr THEN
  284.                 IF BoardBits(NewCol%, NewRow%) > 0 THEN
  285.                  Player(BoardBits(NewCol%, NewRow%) - 1).Num_Out = Player(BoardBits(NewCol%, NewRow%) - 1).Num_Out - 1
  286.                 END IF
  287.                 BoardBits(NewCol%, NewRow%) = Current_Plyr
  288.                 BoardBits(i%, j%) = 0
  289.                 IF Current_Plyr < 4 THEN Current_Plyr = Current_Plyr + 1 ELSE Current_Plyr = 1
  290.                 Rolling = TRUE
  291.                 GOTO Skip_Loops
  292.                ELSE
  293.                 IF Bit% = Player(Current_Plyr - 1).Num_Out THEN '// Last piece we could check so no valid moves at all - skip to next player
  294.                  IF Current_Plyr < 4 THEN Current_Plyr = Current_Plyr + 1 ELSE Current_Plyr = 1 '// Skip players who've won
  295.                  Rolling = TRUE
  296.                  GOTO Skip_Loops
  297.                 ELSE
  298.                  GOTO NextBit '// Skip to next player piece
  299.                 END IF
  300.                END IF
  301.               ELSEIF Ref1% + Dice = 57 THEN '// move to home
  302.                BoardBits(i%, j%) = 0
  303.                Rolling = TRUE
  304.                Player(Current_Plyr - 1).Num_Out = Player(Current_Plyr - 1).Num_Out - 1
  305.                Player(Current_Plyr - 1).Num_Home = Player(Current_Plyr - 1).Num_Home + 1
  306.                IF Player(crrent_plyr).Num_Home = 4 THEN '// Win event
  307.  
  308.  
  309.                 '// Ask if new game
  310.  
  311.                END IF
  312.                IF Current_Plyr < 4 THEN Current_Plyr = Current_Plyr + 1 ELSE Current_Plyr = 1
  313.                GOTO Skip_Loops
  314.               ELSE '// No valid move for this piece
  315.                IF Bit% = Player(Current_Plyr - 1).Num_Out THEN '// Last piece we could check so no valid moves at all - skip to next player
  316.                 IF Current_Plyr < 4 THEN Current_Plyr = Current_Plyr + 1 ELSE Current_Plyr = 1 '// Skip players who've won
  317.                 Rolling = TRUE
  318.                 GOTO Skip_Loops
  319.                END IF
  320.               END IF
  321.              END IF
  322.  
  323.             END IF
  324.            NEXT
  325.           NEXT
  326.           NextBit:
  327.          NEXT
  328.  
  329.         END IF
  330.  
  331.        END IF
  332.       END IF
  333.  
  334.      ELSE
  335.       IF Current_Plyr < 4 THEN Current_Plyr = Current_Plyr + 1 ELSE Current_Plyr = 1 '// Skip players who've won
  336.      END IF
  337.  
  338.      Skip_Loops:
  339.  
  340.     ELSE '// SET DESTINATION
  341.  
  342.      IF Player(Current_Plyr - 1).Control = Human THEN
  343.       IF Mouse(0).LB AND NOT Mouse(1).LB THEN
  344.        '// Calculate how many squares the move is (must be same as dice roll value)
  345.        ActualBlock% = (Selected(1) * 15) + Selected(0) + 1
  346.        NewActual% = (Row% * 15) + Col% + 1
  347.        Ref1% = -1: Ref2% = -1
  348.        '// Find origin and new point in array and get differance in position
  349.        FOR i% = 0 TO 57
  350.         IF PlyrMove(Current_Plyr - 1, i%) = ActualBlock% THEN Ref1% = i%
  351.         IF PlyrMove(Current_Plyr - 1, i%) = NewActual% THEN Ref2% = i%
  352.        NEXT
  353.        Distance% = Ref2% - Ref1%
  354.  
  355.        IF Distance% = Dice THEN
  356.         IF Board2(Col%, Row%) THEN '// Selected destination is allowed to be moved to
  357.          IF BoardBits(Col%, Row%) = Current_Plyr THEN '// Own piece, dependant on rule settings what happens here
  358.           SelectPiece = TRUE
  359.          ELSE '// Occupied by someone else, kick them home!
  360.           IF BoardBits(Col%, Row%) <> Current_Plyr AND BoardBits(Col%, Row%) > 0 THEN
  361.            Player(BoardBits(Col%, Row%) - 1).Num_Out = Player(BoardBits(Col%, Row%) - 1).Num_Out - 1
  362.           END IF
  363.           '// If dest was ok then move bit and change player
  364.           BoardBits(Selected(0), Selected(1)) = 0
  365.           BoardBits(Col%, Row%) = Current_Plyr
  366.           IF Current_Plyr < 4 THEN Current_Plyr = Current_Plyr + 1 ELSE Current_Plyr = 1
  367.           Rolling = TRUE
  368.          END IF
  369.         ELSEIF NewActual% = PlyrMove(Current_Plyr - 1, 57) THEN '// Home Square
  370.          BoardBits(Selected(0), Selected(1)) = 0
  371.          Player(Current_Plyr - 1).Num_Home = Player(Current_Plyr - 1).Num_Home + 1
  372.          Player(Current_Plyr - 1).Num_Out = Player(Current_Plyr - 1).Num_Out - 1
  373.          IF Current_Plyr < 4 THEN Current_Plyr = Current_Plyr + 1 ELSE Current_Plyr = 1
  374.          Rolling = TRUE
  375.         END IF
  376.        ELSE
  377.         IF Col% = Selected(0) AND Row% = Selected(1) THEN
  378.          SelectPiece = TRUE
  379.          Selected(0) = 0
  380.          Selected(1) = 0
  381.         END IF
  382.        END IF
  383.       END IF
  384.  
  385.      END IF
  386.     END IF
  387.    END IF
  388.  
  389.    '/////////////////// Draw Bits \\\\\\\\\\\\\\\\\\\\\\\\\\
  390.  
  391.    y% = 76
  392.    FOR j% = 0 TO 14
  393.     x% = 176
  394.     FOR i% = 0 TO 14
  395.      IF BoardBits(i%, j%) THEN
  396.       SELECT CASE BoardBits(i%, j%)
  397.        CASE 1
  398.         clr& = _RGB32(0, 255, 0)
  399.        CASE 2
  400.         clr& = _RGB32(255, 255, 0)
  401.        CASE 3
  402.         clr& = _RGB32(0, 0, 255)
  403.        CASE 4
  404.         clr& = _RGB32(255, 0, 0)
  405.       END SELECT
  406.       IF i% = Selected(0) AND j% = Selected(1) THEN
  407.        CIRCLE (x%, y%), 16, _RGB32(0, 0, 0)
  408.       ELSE
  409.        CIRCLE (x%, y%), 12, _RGB32(0, 0, 0)
  410.       END IF
  411.       PAINT STEP(0, 0), clr&, _RGB32(0, 0, 0)
  412.      END IF
  413.      x% = x% + 32
  414.     NEXT
  415.     y% = y% + 32
  416.    NEXT
  417.  
  418.    IF Rolling THEN Rot! = (RND * (8 * ATN(1))) ELSE Rot! = 0
  419.    GDK_Sprite_DrawXY D_Sprite, 720, 300, Rot!, Dice
  420.    GDK_Sprite_DrawXY Piece, 440, 550, 0, 10 + Current_Plyr
  421.    GDK_Sprite_DrawXY Piece, 340, 550, 0, 15
  422.    GDK_Sprite_DrawXY Piece, 372, 550, 0, 16
  423.    GDK_Sprite_DrawXY Piece, 404, 550, 0, 17
  424.  
  425.  
  426.  
  427.  '///////////////////
  428.  
  429.  Kb(1) = Kb(0)
  430.  Mouse(1) = Mouse(0)
  431.  VQB_Mouse(1) = VQB_Mouse(0)
  432.  
  433.  '///////////////////
  434.  IF Debug% THEN
  435.   NewActual% = (Row% * 15) + Col% + 1
  436.  
  437.   COLOR _RGB32(255, 255, 255)
  438.   LOCATE 1, 1: PRINT "Col/Row : "; Col%; Row%
  439.   PRINT "Last Dice Roll : "; Dice
  440.   PRINT "Distance calc : "; Distance%
  441.   PRINT "Select piece mode : "; SelectPiece
  442.   PRINT "Current Player : "; Current_Plyr
  443.   PRINT "Actual Block # : "; ActualBlock%
  444.   PRINT "New Block # : "; NewActual%
  445.   IF Current_Plyr THEN
  446.    PRINT "Player Num Out : "; Player(Current_Plyr - 1).Num_Out
  447.    PRINT "Player Num Home : "; Player(Current_Plyr - 1).Num_Home
  448.   END IF
  449.  '///////////////////
  450.  
  451.  
  452.  
  453. Blank_Board:
  454.  
  455. DATA 2,2,2,2,2,2,1,1,1,3,3,3,3,3,3
  456. DATA 2,1,2,2,1,2,1,3,3,3,1,3,3,1,3
  457. DATA 2,2,2,2,2,2,1,3,1,3,3,3,3,3,3
  458. DATA 2,2,2,2,2,2,1,3,1,3,3,3,3,3,3
  459. DATA 2,1,2,2,1,2,1,3,1,3,1,3,3,1,3
  460. DATA 2,2,2,2,2,2,1,3,1,3,3,3,3,3,3
  461. DATA 1,2,1,1,1,1,7,3,8,1,1,1,1,1,1
  462. DATA 1,2,2,2,2,2,2,6,5,5,5,5,5,5,1
  463. DATA 1,1,1,1,1,1,10,4,9,1,1,1,1,5,1
  464. DATA 4,4,4,4,4,4,1,4,1,5,5,5,5,5,5
  465. DATA 4,1,4,4,1,4,1,4,1,5,1,5,5,1,5
  466. DATA 4,4,4,4,4,4,1,4,1,5,5,5,5,5,5
  467. DATA 4,4,4,4,4,4,1,4,1,5,5,5,5,5,5
  468. DATA 4,1,4,4,1,4,4,4,1,5,1,5,5,1,5
  469. DATA 4,4,4,4,4,4,1,1,1,5,5,5,5,5,5
  470.  
  471. DATA 0,0,0,0,0,0,1,1,1,0,0,0,0,0,0
  472. DATA 0,0,0,0,0,0,1,1,1,0,0,0,0,0,0
  473. DATA 0,0,0,0,0,0,1,1,1,0,0,0,0,0,0
  474. DATA 0,0,0,0,0,0,1,1,1,0,0,0,0,0,0
  475. DATA 0,0,0,0,0,0,1,1,1,0,0,0,0,0,0
  476. DATA 0,0,0,0,0,0,1,1,1,0,0,0,0,0,0
  477. DATA 1,1,1,1,1,1,0,0,0,1,1,1,1,1,1
  478. DATA 1,1,1,1,1,1,0,0,0,1,1,1,1,1,1
  479. DATA 1,1,1,1,1,1,0,0,0,1,1,1,1,1,1
  480. DATA 0,0,0,0,0,0,1,1,1,0,0,0,0,0,0
  481. DATA 0,0,0,0,0,0,1,1,1,0,0,0,0,0,0
  482. DATA 0,0,0,0,0,0,1,1,1,0,0,0,0,0,0
  483. DATA 0,0,0,0,0,0,1,1,1,0,0,0,0,0,0
  484. DATA 0,0,0,0,0,0,1,1,1,0,0,0,0,0,0
  485. DATA 0,0,0,0,0,0,1,1,1,0,0,0,0,0,0
  486.  
  487. '// Player movement data, actual square numbers. I had to make another program just to make this!
  488. DATA 93,94,95,96,82,67,52,37,22,7,8,9,24,39,54,69,84,100,101,102,103,104,105,120,135,134,133,132,131,130,144,159,174,189,204,219,218,217,202,187,172,157,142,126,125,124,123,122,121,106,91,92,107,108,109,110,111,112
  489. DATA 39,54,69,84,100,101,102,103,104,105,120,135,134,133,132,131,130,144,159,174,189,204,219,218,217,202,187,172,157,142,126,125,124,123,122,121,106,91,92,93,94,95,96,82,67,52,37,22,7,8,9,24,23,38,53,68,83,98
  490. DATA 133,132,131,130,144,159,174,189,204,219,218,217,202,187,172,157,142,126,125,124,123,122,121,106,91,92,93,94,95,96,82,67,52,37,22,7,8,9,24,39,54,69,84,100,101,102,103,104,105,120,135,134,119,118,117,116,115,114
  491. DATA 187,172,157,142,126,125,124,123,122,121,106,91,92,93,94,95,96,82,67,52,37,22,7,8,9,24,39,54,69,84,100,101,102,103,104,105,120,135,134,133,132,131,130,144,159,174,189,204,219,218,217,202,203,188,173,158,143,128
  492.  
  493. TYPE Player
  494.  Control AS _BYTE
  495.  Num_Home AS _BYTE
  496.  Num_Out AS _BYTE
  497.  Persona AS _BYTE
  498.  
  499. REM $INCLUDE:'UnseenGDK.bm'
  500. REM $include:'Vqb\Vqb_lite.bm'
  501.  

Extract the files to your qb64 directory.

Thanks and happy coding,

Unseen
* Ludo.zip (Filesize: 68.11 KB, Downloads: 200)

Offline Ashish

  • Forum Resident
  • Posts: 630
  • Never Give Up!
    • View Profile
Re: Ludo
« Reply #1 on: May 04, 2020, 02:21:10 am »
What? I played 20 min and home all my pieces before CPU and get no winning message?

 
Screenshot_0.png


Also, dice continues to spin and game never ends with result.

I like the graphics of the game, and CPU part is good. When a piece is selected, I can't select another piece until I deselect it again.
It will be nice if you fix this. :)
if (Me.success) {Me.improve()} else {Me.tryAgain()}


My Projects - https://github.com/AshishKingdom?tab=repositories
OpenGL tutorials - https://ashishkingdom.github.io/OpenGL-Tutorials

Offline Unseen Machine

  • Forum Regular
  • Posts: 158
  • Make the game not the engine!
    • View Profile
Re: Ludo
« Reply #2 on: May 04, 2020, 04:34:06 am »
Hi Ashish,

Firstly, thanks for playing it, i apologise that you had no satisfactory "You Win" message at the end of your game, it's one of the things left to implement.

Quote
When a piece is selected, I can't select another piece until I deselect it again.
It will be nice if you fix this. :)

Ok, i'll have a look into that, thanks for the feedback.

Unseen

Offline Unseen Machine

  • Forum Regular
  • Posts: 158
  • Make the game not the engine!
    • View Profile
Re: Ludo
« Reply #3 on: August 24, 2020, 05:26:57 am »
Hi Folks,

I FINISHED SOMETHING! Well, i got it to give you a win message! There are still many things i'd like to modify/give the option for but i won't be doing any of that any time soon.

Hopefully now i can finally get something posted in the GAMES forum! Whoppeeee!

Enjoy and i'd appreciate any feedback/bug reports.

Unseen
* Ludo.zip (Filesize: 68.3 KB, Downloads: 181)

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Ludo
« Reply #4 on: August 24, 2020, 04:40:55 pm »
Hi @Unseen Machine

I am checking out the current .zip you posted today and am getting this for opening screen:
 
Testing Ludo.PNG


I don't think this is what you intended.

The code from original post seems OK? Except I don't have a clue how to play it, no arrow keys or mouse click does anything except increase size of piece.

Oh click the piece it expands and then click dice amount of squares ahead, if roll 6 another piece comes out?

What's difference between this and Parcheesi?
« Last Edit: August 24, 2020, 04:52:15 pm by bplus »

Offline Unseen Machine

  • Forum Regular
  • Posts: 158
  • Make the game not the engine!
    • View Profile
Re: Ludo
« Reply #5 on: August 25, 2020, 03:15:37 am »
Errrr, well thats not right! Let me have a look see...

Looking......Looking and poof! I forgot to update the sprite sheet! Thank god not many people actually try my stuff! New attachment added with correct sprite sheet. Thanks for the heads up.

Quote
Oh click the piece it expands and then click dice amount of squares ahead, if roll 6 another piece comes out?
Yep, you got it!

Quote
What's difference between this and Parcheesi?

I wouldnt know having never heard of parchessi.

Thanks for trying it mate and for the feedback.

Unseen



* Ludo.zip (Filesize: 69.02 KB, Downloads: 196)

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Ludo
« Reply #6 on: August 25, 2020, 12:07:02 pm »
Yeah, I did some little Internet search and Ludo (I had never heard of before) turns out to be another name for pretty much same game under Traditional Board Race Games which includes Backgammon, Trouble, Sorry.

Wiki "Parcheesi is a brand-name American adaptation of the Indian cross and circle board game Pachisi,.."
The boards are nearly identical with the ancient Indian game.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Ludo
« Reply #7 on: August 25, 2020, 11:59:49 pm »
Hi @Unseen Machine

RE: First impressions

Suggestion: show the players still waiting to go out in the 4 white squares provided on the game board.

Also it would be nice if you could list in the arrow heads at middle of board number of players in and retired. In my game Red suddenly wins as I am waiting to get my last piece in, unpleasant surprise. Dice rolls and pieces moved maybe a little too fast?

Plus I watched a 5 minute video of Ludo on You Tube, that game had a block option where a player can stack a piece atop of his other (as dice allow) and block incoming pieces. I tried that with my first game and no deal.

Oh you have that ugly (sorry) score board in top left corner, but I never looked at it. Wouldn't it be more elegant to just read the board? Where you could see the players still stuck at home and the number of players who ran the gauntlet and are finished. The total would always be 4, players home + player on track + players finished. A block could be the colored circle with a 2 in middle, number of players finished is white circle in center colored triangle with players color number 0 to 4.

I like games that play against computer like this, do you or have you thought of different AI strategies for the different colors?

Offline Unseen Machine

  • Forum Regular
  • Posts: 158
  • Make the game not the engine!
    • View Profile
Re: Ludo
« Reply #8 on: August 26, 2020, 04:02:21 am »
Hi @bplus

Now thats what i call positive feedback, i appreciate it mate.

Quote
show the players still waiting to go out in the 4 white squares provided on the game board.
I agree, i'll implement that one.

Quote
Also it would be nice if you could list in the arrow heads at middle of board number of players in and retired.
  Again, i agree so that will get added too.

Quote
Dice rolls and pieces moved maybe a little too fast?
Yep, i can see that, i'm thinking im gonna make it so that the pieces glide to their new spots rather than jumping. Also, to negate the need for being able to switch selected pieces without having to deselect first (@Asish suggested this improvement) i'm gonna make it so that when you click on a piece it automatically moves to the right tile.

Quote
Plus I watched a 5 minute video of Ludo on You Tube, that game had a block option where a player can stack a piece atop of his other (as dice allow) and block incoming pieces. I tried that with my first game and no deal.
There are many different variations on the rules, african rules let you move backwards! Also some rules use two dice, these are both options i might implement as optional rules in the future.

Quote
Oh you have that ugly (sorry) score board in top left corner, but I never looked at it.
Lol, thats the debug readout, it shouldnt appear anymore as i turned it off.

Quote
I like games that play against computer like this, do you or have you thought of different AI strategies for the different colors?
Me too, and as for AI I did have that idea from the get go. If you look in the UDT for the players youll see a Persona variable...previously i attempted to give them 3 different traits but failed and ended up with the basic movement it currently has.

Thanks again for the feedback, it's inspired me to improve it.

Unseen
« Last Edit: August 26, 2020, 04:03:42 am by Unseen Machine »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Ludo
« Reply #9 on: August 26, 2020, 11:58:31 am »
@Unseen Machine

Yeah I didn't think I wandered too far from intentions you already had. ;-))

But the potential of creating AI's to compete is what peaks my interest, that is why I found the blocking option interesting.

Offline Unseen Machine

  • Forum Regular
  • Posts: 158
  • Make the game not the engine!
    • View Profile
Re: Ludo
« Reply #10 on: August 26, 2020, 06:30:21 pm »
@bplus

Quote
But the potential of creating AI's to compete is what peaks my interest, that is why I found the blocking option interesting.

Yeah i suppose so, maybe i should just have a CPU only game s you can just watch the computer try to beat its self! I'm working on the updates slowly, mainly cause i figured the best way to implement the things that have been suggested is to change the way the bits are handled, previously they were just in 2d array but this ment that you wouldnt be able to to do blocking and the gliding movement would have been irriating to implement, so now i've been working on ripping out all of that and changing the pieces to be handled by their own type.

Thanks again for the feedback,

Unseen