Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    Need help with video poker game

    General Discussion
    3
    3
    206
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • K
      kendog400 F last edited by Dave

      I have here a program that deals 5 random cards..That part works fine, but I would like to highlite two of the cards, and replace them with two new cards.
      I was wondering if anyone knows how I could go about this......
      I have an example of the program here :................

      clear(darkGreen)
      image = loadImage ("Kenney/boardgames")
      suits = ["clubs", "diamonds", "hearts", "spades"]
      array cards [52}
      getPack ( )
      shufflePack ( )
      
      for i = 0 to 5  loop   // this will flip the 5 cards to the screen
      sprite = cards [ i ]
      size = getSpriteSize (sprite)
      setSpriteLocation (sprite, i % 13 * (size.x + 30) +50, int (i / 13 ) * (size.y + 5) + 200)
      setSpriteVisibility(sprite, true)
      drawSprites ( )
      update ( )
      sleep(0.7)
      repeat
      
      function shufflePack ( )
         cardIndex1 =  random (52)
         cardIndex2 =  random (52)
         card1 = cards [cardIndex1]
         card2 = cards [cardIndex2]
         cards [cardIndex1] = card2
         cards [cardIndex2] = card1
        repeat
      return void
      
      function getPack ( )
      values = [ [0,"2"], [1,"3"], [2,"4"], [3,"5"], [4,"6"], [5,"7"], [6,"8"], [7,"9"], [8,"10"], [12,"A"], [9,"J"], [11,"K"], [10,"Q"], ]
      imageNo = 0
       for suitNo = 0 to 4 loop
         for valueNo = 0 to 13 loop
         cardNo = suitNo * 13 values[valueNo] [0]
         sprite = createSprite ( )
         cardImage = getImage (imageNo)
         setSpriteImage(sprite, cardImage)
         setSpriteVisibilty(sprite, false)
         setSpriteDepth(sprite, cardNo)
         size = getSpriteSize(sprite)
         setSprieOrgin(sprite, -size,x/2, -size.y/2)
         scale = 1.5
         setSpriteScale ( sprite, {scale, scale} )
           sprite.value = values [valueNo] [1]
           sprite.suit = suits [suitNo]
           sprite.imageNo = imageNo
           cards [cardNo] = sprite
           imageNo + = 1
           if imageNo = 39 then
           imageNo + = 1   endif
         repeat
        repeat
      return void
      
      function getImage (imageNo)
      cardImage = createImage(140, 190, false, image_rgb)
      setDrawTarget (cardImage)
      drawSheet(image, imageNo + 15, {0, 0, 140, 190} )
       update ( )
      return cardImage
      

      //..........................................................................

      1 Reply Last reply Reply Quote 0
      • Dave
        Dave Fuze Team last edited by

        Edited this post to use proper code formatting, as your indentation wasn't visible. For future, if you put (```) without the brackets, before and after a section of text, it will turn into code formatting.

        Will be taking a look at this shortly!

        1 Reply Last reply Reply Quote 2
        • R
          rdurbin F last edited by rdurbin

          The best way to do this is have an array that stores if the card is to be changed or not. Left and right can be used to point at a card. Button A can toggle if its held or not and button y can change all cards that are set to discard. In the array you can go with binary. 1 means held, 0 means discard and draw. You also need a variable that keeps track of the card your pointing at. Left and right will increase or decrease this variable. Make sure user cannot go before card 1 or after card 5 or at least make it wrap around

          Here an example to give you an idea

          card=0//current card for cursor
          cardheld=[0,0,0,0,0]//all card not held by def.
          j=controls(0)
          
          while !j.y loop//loops until y pushed
             j=controls(0)//check for btn pushed
          
             if j.left then//if left held
                card-=1//decrease current card
                sleep(.3)//small delay so cursor not fast
             endif
          
             if j.right then//if right held
                card+=1//increases current card
                sleep(.3)//delay again
             endif
          
             if card<0 then//move cursor to last card
                card=4
             endif
          
             if card>4 then//moves to first card
                card+=1
             endif
          
             if j.a then//if btn A pushed 
                if cardheld[card]==0 then
                   cardheld[card]=1//toggles held status 
                else
                   cardheld[card]=0
                endif
                sleep(.3)//delay so doesnt toggle fast
             endif
          
          repeat
          
          for z=0 to 5 loop
             if cardheld[z]==0 then
                Drawcard(z)//points to func. to draw card
             endif
          repeat
          

          I wouldnt just copy this and be done but should get you started. You still need the function that draws the card. Code included only applies to get this done internally. You should draw a cursor based on location of currently selected card and draw text based on if card held or not based on cardheld array

          1 Reply Last reply Reply Quote 3
          • First post
            Last post