|
-
Nov 20th, 2013, 03:56 PM
#1
Thread Starter
Junior Member
[RESOLVED] Problems with drawing graphics
Hello, I am currently working on a Blackjack game for class, and it has gone smoothly up until now. I am having troubles with "Me.Creategraphics", as when I try to draw a card to the screen, it only draws a portion, no matter what I set the destination rectangle size to. I must be overlooking something, because I tried a to draw a card to the screen using the same exact code as I was using in my game with another project, and it worked fine. Below is my code for drawing the cards:
Code:
Dim cardSiz as New Size(168, 243)
Private Sub placeCard(ByVal plr As Short)
Dim pnt As New Point
Select Case plr
Case 1 'PLAYER
pnt = New Point((Me.Width / 2 - cardWid) + ((plr1Crd) * (cardWid / 2)), (Me.Height / 4) * 3)
dRect = New Rectangle(pnt, cardSiz)
Case 2 'CPU1, LEFT SIDE
pnt = New Point(20 + ((cpu1Crd) * (cardWid / 4)), (Me.Height / 4) * 3)
dRect = New Rectangle(pnt, cardSiz)
Case 3 'CPU2, TOP
pnt = New Point((Me.Width / 2 - cardWid) + ((cpu2Crd) * (cardWid / 4)), (Me.Height / 4))
dRect = New Rectangle(pnt, cardSiz)
Case 4 'CPU3, RIGHT SIDE
pnt = New Point((Me.Width - 20) - ((cpu3Crd) * (cardWid / 4)), (Me.Height / 4) * 3)
dRect = New Rectangle(pnt, cardSiz)
End Select
End Sub
Private Sub drawCard(ByVal plr As Short, ByVal num As Short, ByVal suit As Short)
Select Case plr
Case 1
Dim pnt As New Point(num * cardWid, suit * cardHgt)
sRect = New Rectangle(pnt, cardSiz)
Case Else
Dim pnt As New Point(2 * cardWid, 4 * cardHgt)
sRect = New Rectangle(pnt, cardSiz)
End Select
G.DrawImage(cardsImg, dRect, sRect, GraphicsUnit.Pixel)
End Sub
I know the dRect points are a little sloppy, but they still do lie on the screen. So what is my error? What am I missing? I have attatched the project in a .zip file if you want to take a look at that too, but I'm pretty sure this is all that needs to be looked at.
Also, it only seems to draw the portion of the card for player 3 (cpu 2), and I'm completely unsure as to why.
Thanks in advance,
- Dinosaurus
-
Nov 20th, 2013, 04:02 PM
#2
Re: [RESOLVED] Problems with drawing graphics
Ummm? Is this resolved or not?
My usual boring signature: Nothing
 
-
Nov 20th, 2013, 04:15 PM
#3
Thread Starter
Junior Member
Re: [RESOLVED] Problems with drawing graphics
Yes. I'm sorry for any confusion, I should've looked into this more before posting. I figured it out a few minutes after, the problem was that I was declaring my graphics object (G = Me.CreateGraphics) before the form loaded, causing it to do some weird stuff. It all works well now.
- Dinosaurus
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|