Results 1 to 5 of 5

Thread: [General] - i need some advices\Sugestions

  1. #1

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,961

    [General] - i need some advices\Sugestions

    what a Sprite struture have besides Position and Size?
    i have 2 strutures(Sprite and Images(mask image inclued). and more 3 functions: LoadImage(), DrawImage() and DestroyObjects(). i wanted some sugestions for connet these all and be more easy to use.
    VB6 2D Sprite control

    To live is difficult, but we do it.

  2. #2
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: [General] - i need some advices\Sugestions

    A sprite structure can have whatever you desire. Its not limited to just whats proper. Its anything you want! Thats the beauty of programming. If its an RPG it can have Strength, Agility, Intellect, Dexterity, Spirit, Health, Mana, etc etc. If its a platformer, fighting game, or even an rpg (which ever genre has animation), it can have animation states such as standing, walking, running, shooting, falling, dieing, etc. The only limit is your imagination.

  3. #3

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,961

    Re: [General] - i need some advices\Sugestions

    Quote Originally Posted by Jacob Roman View Post
    A sprite structure can have whatever you desire. Its not limited to just whats proper. Its anything you want! Thats the beauty of programming. If its an RPG it can have Strength, Agility, Intellect, Dexterity, Spirit, Health, Mana, etc etc. If its a platformer, fighting game, or even an rpg (which ever genre has animation), it can have animation states such as standing, walking, running, shooting, falling, dieing, etc. The only limit is your imagination.
    but honestly i need more than that info, but that's.
    i think that for LoadImage(), DrawImage(), DeleteObjects() i can do a class
    thanks
    VB6 2D Sprite control

    To live is difficult, but we do it.

  4. #4
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: [General] - i need some advices\Sugestions

    When it comes to Game Programming in vb6, you should never ever use a class where subs/functions get called over and over in the main loop and I'll explain why. I have done a number of tests in the past for how long it takes to execute 10,000,000 cycles using a very simple test. Here is the source code to that test:

    vb Code:
    1. Option Explicit
    2.  
    3. Private Declare Function GetTickCount Lib "kernel32" () As Long
    4.  
    5. Dim Start As Long
    6. Dim Finish As Long
    7. Dim I As Long
    8.  
    9. Dim A As Long
    10. Dim B As Long
    11. Dim C As Long
    12.  
    13. Private Sub Command1_Click()
    14.    
    15.     Start = GetTickCount
    16.     For I = 1 To 10000000
    17.         'Your Test Here
    18.     Next I
    19.     Finish = GetTickCount
    20.    
    21.     Debug.Print (Finish - Start)
    22. End Sub

    Now were going to use a test subroutine:
    Code:
    Sub Test()
    
    End Sub
    I did this test 10 times to receive 10 different values knowing that sometimes its fast and sometimes its not (although the values will be around that range), then divided by 10 to obtain an average. And these are the results I received:

    Empty Subroutine with Public, no Call statement and no arguements called in same Form: 887.5 ms
    Empty Subroutine with Public, with Call statement and no arguements called in same form: 889.5 ms (hardly a difference using a Call statement)

    Empty Subroutine with Public, no Call statement, and no arguements in a Module called in a Form: 755 ms (faster to do subs in a regular module)
    Empty Subroutine with Public, with Call statement, and no arguements in a Module called in a Form: 744.4 ms (hardly a difference using a Call statement)

    Empty Subroutine with Public, no Call statement, and no arguements in a Class Module called in a Form: 1246.7 ms (*** too slow to use a class module)

    I also found If statements being false are much much slower than If statements being true (you'd think it would be the opposite), and you should never use IIF() functions:


    If Statements
    ----------------------------
    False If Statement Block checking if Long variable has value: 246.6
    If A Then
    End If

    True If Statement Block checking if Long variable has value: 230.8
    If A Then
    End If

    False If Statement Block checking if Long variable > 0: 290
    If A > 0 Then
    End If

    True If Statement Block checking if Long variable > 0: 245.2
    If A > 0 Then
    End If


    False If Statement Block checking if Long variable > Long variable: 290.1
    If A > B Then
    End If

    False If Statement in no block checking if Long variable has value then A = B: 243.6
    If A Then A = B

    If Then Else Block with no conditions checking if Long variable has value: 259.1
    If A Then
    Else
    End If

    If Then Else Block with conditions checking if Long variable has value then change its value: 424.5
    If A Then
    A = 0
    Else
    A = 1
    End If

    If Then Else Block with conditions checking if Long variable has value then change another Long variables values: 358.7
    If A Then
    B = 1
    Else
    B = 0
    End If

    ----------------------------



    Select Case Statements
    ----------------------------
    False Select Case Long variable with one arguement checking if 0: 324.5
    Select Case A
    Case 1
    End Select

    True Select Case Long variable with one arguement checking if 0: 312.1
    Select Case A
    Case 0
    End Select
    ----------------------------




    IIf Statements
    ----------------------------
    IIf Statement to see if Long variable has value: 1865.6
    A = IIf(A, 1, 0)

    Theres a bunch more tests I need to do but it gives you an idea.

  5. #5

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,961

    Re: [General] - i need some advices\Sugestions

    i understand that... but in my case it's more diferent and i don't need code... just advices
    - my class Image do: Load(), Draw() and Destroy().
    - the Sprite structure have the position and size and Visible;
    - the Images structure have the HBitmap, Bitmap, HDC, and for the mask: HBitmap, Bitmap, HDC.
    i wanted combine these in Sprite(for be more easy to use). anyone can give more advices?
    thanks for all
    VB6 2D Sprite control

    To live is difficult, but we do it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width