Also... Hallo nochmal.
Und wieder komme ich mit einem Anfänger-Problem.
Screenshot der orm
pokesturm.tc-central.de/images/posts/vb_paradise1.png
Jede figimg, figmask und bgimg ist auf Visible=False
und AutoRedrwa=True, picWorld ist auch auf
True bei AutoRedraw.
PreviewKey ist bei der Form auch auf True.
Screenshot zur Laufzeit
pokesturm.tc-central.de/images/posts/vb_paradise2.png
Code
Das Problem ist, dass die Variable FigureTop
bei Druck auf PfeilUnten zwar inkrementiert
wird, jedoch wird die picWorld nicht neu
gezeichnet.
Was mache ich da falsch?
// edit: Bei jeden Bildern handelt es sich um eine PictureBox.
Und wieder komme ich mit einem Anfänger-Problem.
Screenshot der orm
pokesturm.tc-central.de/images/posts/vb_paradise1.png
Jede figimg, figmask und bgimg ist auf Visible=False
und AutoRedrwa=True, picWorld ist auch auf
True bei AutoRedraw.
PreviewKey ist bei der Form auch auf True.
Screenshot zur Laufzeit
pokesturm.tc-central.de/images/posts/vb_paradise2.png
Code
Visual Basic-Quellcode
- Option Explicit
- Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
- Private Const SRCCOPY = &HCC0020
- Private Const SRCAND = &H8800C6
- Private Const SRCPAINT = &HEE0086
- Dim hRes As Long
- 'Figure - Position, Blickrichtung, Überschritt aus der Mitte
- Dim FigureLeft, FigureTop, FigureShow, FigureOsTop, FigureOsLeft As Integer
- 'Speichert die Tiles
- Dim Fields(1 To 150, 1 To 150) As Integer
- 'Zum Zwischenspeichern für die Schleifen
- Dim y As Integer
- Dim x As Integer
- Dim yT As Integer
- Dim xT As Integer
- Private Sub Form_Load()
- 'Schrittfelder initialisieren [Werden später vom Server abgerufen]
- For y = 1 To 150 Step 1
- For x = 1 To 150 Step 1
- Fields(y, x) = 1
- Next
- Next
- Fields(5, 5) = 2
- 'Position der Charaktere inizialisieren [Wird später vom Server abgerufen]
- FigureTop = 2
- FigureLeft = 8
- FigureShow = 10
- FigureOsTop = 0
- FigureOsLeft = 0
- Redraw
- End Sub
- Private Sub Redraw()
- 'Schrittfelder neu setzen
- For y = 1 To 9 Step 1
- For x = 1 To 15 Step 1
- yT = FigureTop - 5 + y
- xT = FigureLeft - 8 + x
- If yT < 1 Or xT > 150 Then
- hRes = BitBlt(picWorld.hDC, (x - 1) * 14, (y - 1) * 15, 14, 15, bgimg(0).hDC, 0, 0, SRCCOPY)
- Else
- hRes = BitBlt(picWorld.hDC, (x - 1) * 14, (y - 1) * 15, 14, 15, bgimg(Fields(yT, xT)).hDC, 0, 0, SRCCOPY)
- End If
- Next
- Next
- 'Figur neu setzen
- x = (7 + FigureOsLeft) * 14 - 4
- y = (4 + FigureOsTop) * 15 - 3
- hRes = BitBlt(picWorld.hDC, x, y, 22, 22, figmask(FigureShow).hDC, 0, 0, SRCPAINT)
- hRes = BitBlt(picWorld.hDC, x, y, 22, 22, figimg(FigureShow).hDC, 0, 0, SRCAND)
- End Sub
- Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
- If KeyCode = vbKeyDown Then
- FigureTop = FigureTop + 1
- Redraw
- End If
- End Sub
Das Problem ist, dass die Variable FigureTop
bei Druck auf PfeilUnten zwar inkrementiert
wird, jedoch wird die picWorld nicht neu
gezeichnet.
Was mache ich da falsch?
// edit: Bei jeden Bildern handelt es sich um eine PictureBox.
Dieser Beitrag wurde bereits 3 mal editiert, zuletzt von „weed“ ()