Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Card Game ?

Card Game ?

Scheduled Pinned Locked Moved Visual Basic
game-devdata-structureshelptutorialquestion
3 Posts 3 Posters 0 Views 1 Watching
  • 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.
  • B Offline
    B Offline
    Bso_Cool
    wrote on last edited by
    #1

    What I am trying to do is make a card game but in the hand there is not always a set amount of cards I am using labels for this I got it to create the labels as needed but what I am trying to do now is get it to where if the click on the card it moves up a little to signify that it has been selected but I can't figure that part out on how to do it. Here is an ex. of the code I am using to create the first part of the hand. For N = 1 To 13 Label(N) = New Label Label(N).BorderStyle = BorderStyle.Fixed3D Label(N).BackColor = Color.Maroon 'PlayersHand is an Array with all the Card Numbers in them. Label(N).Text = Player1Hand(N) Label(N).Size = New Size(Label1.Width, Label1.Height) Label(N).Font = Label1.Font Label(N).TextAlign = ContentAlignment.MiddleCenter CardX = CardX + 50 Label(N).Left = CardX Label(N).Top = CardY Label(N).BringToFront() Me.Controls.Add(Label(N)) Next If anyone can help me I would really appreciate it. Thank You for looking!

    C M 2 Replies Last reply
    0
    • B Bso_Cool

      What I am trying to do is make a card game but in the hand there is not always a set amount of cards I am using labels for this I got it to create the labels as needed but what I am trying to do now is get it to where if the click on the card it moves up a little to signify that it has been selected but I can't figure that part out on how to do it. Here is an ex. of the code I am using to create the first part of the hand. For N = 1 To 13 Label(N) = New Label Label(N).BorderStyle = BorderStyle.Fixed3D Label(N).BackColor = Color.Maroon 'PlayersHand is an Array with all the Card Numbers in them. Label(N).Text = Player1Hand(N) Label(N).Size = New Size(Label1.Width, Label1.Height) Label(N).Font = Label1.Font Label(N).TextAlign = ContentAlignment.MiddleCenter CardX = CardX + 50 Label(N).Left = CardX Label(N).Top = CardY Label(N).BringToFront() Me.Controls.Add(Label(N)) Next If anyone can help me I would really appreciate it. Thank You for looking!

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Your approach is fundamentally broken. You should do this by creating graphics which you store as resources and draw to the screen ( or at least draw text right where you want it ). Moving labels and pictures boxes around is just a disaster.

      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

      1 Reply Last reply
      0
      • B Bso_Cool

        What I am trying to do is make a card game but in the hand there is not always a set amount of cards I am using labels for this I got it to create the labels as needed but what I am trying to do now is get it to where if the click on the card it moves up a little to signify that it has been selected but I can't figure that part out on how to do it. Here is an ex. of the code I am using to create the first part of the hand. For N = 1 To 13 Label(N) = New Label Label(N).BorderStyle = BorderStyle.Fixed3D Label(N).BackColor = Color.Maroon 'PlayersHand is an Array with all the Card Numbers in them. Label(N).Text = Player1Hand(N) Label(N).Size = New Size(Label1.Width, Label1.Height) Label(N).Font = Label1.Font Label(N).TextAlign = ContentAlignment.MiddleCenter CardX = CardX + 50 Label(N).Left = CardX Label(N).Top = CardY Label(N).BringToFront() Me.Controls.Add(Label(N)) Next If anyone can help me I would really appreciate it. Thank You for looking!

        M Offline
        M Offline
        Martin Smith
        wrote on last edited by
        #3

        In your FOR loop that is creating the labels, add an event handling function for the mouse click event, for example: AddHandler Label(N).MouseClick, AddressOf CardClickFct You will then need to create the CardClickFct, such as: Sub CardClickFct(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Dim TheCard as label = DirectCast(sender, Label) ' TODO: Add whatever you want the card to do when its been clicked End Sub What you must also remember to do is remove the event handler when the label is destroyed (by calling RemoveHandler).... You MUST ensure that your array variable "Label" is declared "WithEvents" for this to work!!! I hope this helps you out.... Regards, Martin

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups