1 Replies - 271 Views - Last Post: 06 February 2013 - 04:07 PM Rate Topic: -----

#1 Genella  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 06-February 13

poke walk

Posted 06 February 2013 - 06:43 AM

Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHieght As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal yScr As Long, ByVal dwRop As Long) As Long
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
Dim Xpos As Integer
Dim Ypos As Integer
Dim Lstand As String
Dim Cmove As String
Dim Col As Integer
Dim Tickz As Integer
Dim cWidth As Integer
Dim cHeight As Integer
Dim Xaxis As Integer
Dim Yaxis As Integer
Dim Frames As Integer
Private Function GetKey(lngKey As Long) As Boolean
'GetKeyState yung ginawa mong private declare function
If GetKeyState(lngKey&) < 0 Then
  'private function inirereturn nya yung val as boolean
  GetKey = True
  Else
  GetKey = False
End If
End Function
Private Sub dMap()
'dito dinadraw nya yung map
BitBlt Form1.hDC, 0, 0, picBack.Width, picBack.Height, picBack.hDC, 0, 0, vbSrcCopy

End Sub
Private Sub Form_Load()

'str for start position ng character
Lstand$ = "down"
'str for move naman ng character
Cmove$ = "stand"

' for yaxis position of the character
Ypos = 110
' for xaxis position of the character
Xpos = 220
End Sub
Private Sub Timer1_Timer()

dMap
'pic.Width default value
cWidth = 19
'pic.Height default value
cHeight = 32
'key for up
If GetKey(vbKeyW) Then
   Ypos = Ypos - 1
   Yaxis = Yaxis - 1
   Cmove$ = "up"
   Lstand$ = "up"
   
End If
' key for down
If GetKey(vbKeyS) Then
   Ypos = Ypos + 1
   Yaxis = Yaxis + 1
   Cmove$ = "down"
   Lstand$ = "down"
End If
' key for left
If GetKey(vbKeyA) Then
   Xpos = Xpos - 1
   Xaxis = Xaxis - 1
   Cmove$ = "left"
   Lstand$ = "left"
End If
' key for right
If GetKey(vbKeyD) Then
   Xpos = Xpos + 1
   Xaxis = Xaxis + 1
   Cmove$ = "right"
   Lstand = "right"
End If
' kapag nag false lahat si cmove$ ay mag eequal sa "stand"
' tapos hanapin nya ngayon yung conditon para kay cmove$
If GetKey(vbKeyW) = False And GetKey(vbKeyS) = False And GetKey(vbKeyA) = False And GetKey(vbKeyD) = False Then
  Cmove$ = "stand"
End If
' Make sure the character can't go offscreen.
If Xpos < 5 Then
    Xpos = 5
End If
If Xpos > 415 Then
    Xpos = 415
End If
If Ypos < 5 Then
    Ypos = 5
End If
If Ypos > 195 Then
    Ypos = 195
End If


' eto yung nested if para kay cmove$ kapag nag equal siya sa string na "stand" then hanapin nya yung conditon string
' si lstand$ yung mga gagawin nya
 If Cmove$ = "stand" Then
    If Lstand$ = "up" Then
      
      BitBlt Form1.hDC, Xpos, Ypos, cWidth, cHeight, uPic2.hDC, 0, 0, vbSrcAnd
      BitBlt Form1.hDC, Xpos, Ypos, cWidth, cHeight, uPic1.hDC, 0, 0, vbSrcPaint
      
    End If
    If Lstand$ = "down" Then
      
      BitBlt Form1.hDC, Xpos, Ypos, cWidth, cHeight, dPic2.hDC, 0, 0, vbSrcAnd
      BitBlt Form1.hDC, Xpos, Ypos, cWidth, cHeight, dPic1.hDC, 0, 0, vbSrcPaint
    
    End If
    If Lstand$ = "left" Then
      
      BitBlt Form1.hDC, Xpos, Ypos, cWidth, cHeight, lPic2.hDC, 0, 0, vbSrcAnd
      BitBlt Form1.hDC, Xpos, Ypos, cWidth, cHeight, lPic1.hDC, 0, 0, vbSrcPaint
      
    End If
    If Lstand$ = "right" Then
    
      BitBlt Form1.hDC, Xpos, Ypos, cWidth, cHeight, rPic2.hDC, 0, 0, vbSrcAnd
      BitBlt Form1.hDC, Xpos, Ypos, cWidth, cHeight, rPic1.hDC, 0, 0, vbSrcPaint
      
    End If
 End If
 'eto naman yung conditon kay cmove$
 ' yung Tickz ay xSrc
 If Cmove$ = "up" Then
     
     BitBlt Form1.hDC, Xpos, Ypos, cWidth, cHeight, uPic2.hDC, Tickz, 0, vbSrcAnd
     BitBlt Form1.hDC, Xpos, Ypos, cWidth, cHeight, uPic1.hDC, Tickz, 0, vbSrcPaint
     
 End If
 If Cmove$ = "down" Then
     
     BitBlt Form1.hDC, Xpos, Ypos, cWidth, cHeight, dPic2.hDC, Tickz, 0, vbSrcAnd
     BitBlt Form1.hDC, Xpos, Ypos, cWidth, cHeight, dPic1.hDC, Tickz, 0, vbSrcPaint
     
 End If
 If Cmove$ = "left" Then
     
     BitBlt Form1.hDC, Xpos, Ypos, cWidth, cHeight, lPic2.hDC, Tickz, 0, vbSrcAnd
     BitBlt Form1.hDC, Xpos, Ypos, cWidth, cHeight, lPic1.hDC, Tickz, 0, vbSrcPaint
     
 End If
 If Cmove$ = "right" Then
     
     BitBlt Form1.hDC, Xpos, Ypos, cWidth, cHeight, rPic2.hDC, Tickz, 0, vbSrcAnd
     BitBlt Form1.hDC, Xpos, Ypos, cWidth, cHeight, rPic1.hDC, Tickz, 0, vbSrcPaint
     
 End If
 Frames = Frames + 1
 
End Sub

Private Sub Timer2_Timer()
Col = Col + 1
If Col = 4 Then
 Col = 0
End If
If Col = 0 Then
 Tickz = 0
End If
If Col = 1 Then
 Tickz = 18
End If
If Col = 2 Then
 Tickz = 36
End If
If Col = 3 Then
 Tickz = 54
End If
End Sub
Private Sub Timer3_Timer()

' Print the Frame Rate and stuff.
Me.Caption = "Frame Rate : " & Frames
' Reset the Frame Rate.
Frames = 0
Label1.Caption = "X Position : " & " " & Xaxis & " " & "Y Position: " & " " & Yaxis
End Sub



this is my code for walking characters using biblt but i don't know how truely what it means my character blinks and try to analyze my code what's wrong ?

This post has been edited by modi123_1: 06 February 2013 - 07:12 AM
Reason for edit:: please use code tags.


Is This A Good Question/Topic? 0
  • +

Replies To: poke walk

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 5957
  • View blog
  • Posts: 23,226
  • Joined: 23-August 08

Re: poke walk

Posted 06 February 2013 - 04:07 PM

This is NOT VB6 code, it's VB.NET code.

Please learn what language you are developing in and post in the proper forum.

Moved to VB.NET.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1