Results 1 to 7 of 7

Thread: More than one line of code at a time?

Threaded View

  1. #1

    Thread Starter
    Lively Member VBNubcake's Avatar
    Join Date
    Feb 2008
    Location
    Caledon, Ontario, Canada
    Posts
    80

    More than one line of code at a time?

    Is it possible to have vb read and execute code from two different subs at the SAME time?

    By that i dont mean:
    execute first sub
    first sub finishes
    Call second sub
    execute second sub

    I mean:
    execute first sub & execute second sub (at the same time)

    What am I trying to do?
    -I'm working on an RPG, which includes a "battle form".
    -In the "battle form": there are multiple monsters
    -The monsters are being animated by using .Render
    -Each monster animation has its own public sub
    -Currently, one monster animates at a time (because VB only reads one sub at a time....one line at a time)

    Potential Solution
    -Merge all the subs into one giant sub (this will take alot of recoding, new variables, new calculations, new user-defined types...work involved...might not even work properly)

    If there is an API or anything else that can solve my problem, it would make my solution alot easier.

    any ideas?

    anyways, heres some code in my project, maybe this will help you guys understand what im trying to do:


    Code:
    '======================================================
    '====================SLIME_STANCE SUB==================
    '======================================================
    Public Sub SLIME_STANCE()
    'Draw FIRST frame
    picEnemy.Cls
    With BI.Images.BattleZone
        .Render picEnemy.hDC, 0, 0, 600, 400, ScaleX(10, vbPixels, vbHimetric), ScaleY(450, vbPixels, vbHimetric), ScaleX(600, vbPixels, vbHimetric), ScaleY(-400, vbPixels, vbHimetric), 0&
    End With
    With BI.ES.SLIME_STANCE(0)
        .Render picEnemy.hDC, 0, 0, ScaleX(.Width, vbHimetric, vbPixels), ScaleY(.Height, vbHimetric, vbPixels), 0, .Height, .Width, -.Height, 0&
    End With
    picEnemy.Refresh
    
    'Wait 50 Milliseconds
    Sleep 50
    'Draw SECOND frame
    picEnemy.Cls
    With BI.Images.BattleZone
        .Render picEnemy.hDC, 0, 0, 600, 400, ScaleX(10, vbPixels, vbHimetric), ScaleY(450, vbPixels, vbHimetric), ScaleX(600, vbPixels, vbHimetric), ScaleY(-400, vbPixels, vbHimetric), 0&
    End With
    With BI.ES.SLIME_STANCE(1)
        .Render picEnemy.hDC, 0, 0, ScaleX(.Width, vbHimetric, vbPixels), ScaleY(.Height, vbHimetric, vbPixels), 0, .Height, .Width, -.Height, 0&
    End With
    picEnemy.Refresh
    
    'Wait 50 Milliseconds
    Sleep 50
    'Draw THIRD frame
    picEnemy.Cls
    With BI.Images.BattleZone
        .Render picEnemy.hDC, 0, 0, 600, 400, ScaleX(10, vbPixels, vbHimetric), ScaleY(450, vbPixels, vbHimetric), ScaleX(600, vbPixels, vbHimetric), ScaleY(-400, vbPixels, vbHimetric), 0&
    End With
    With BI.ES.SLIME_STANCE(2)
        .Render picEnemy.hDC, 0, 0, ScaleX(.Width, vbHimetric, vbPixels), ScaleY(.Height, vbHimetric, vbPixels), 0, .Height, .Width, -.Height, 0&
    End With
    '======================================================
    '================END OF SLIME_STANCE SUB===============
    '======================================================
    This is a Public Sub called "SLIME_STANCE".
    This sub actually has alot more code (goes upto "Draw ELEVENTH frame") but the concept is still the same
    This Sub handles the animation of a "monster" called a "Slime" using the sleep API as well as the .Render to cycle sprites
    Spites for the Slime are stored in BI.ES.SLIME_STANCE()
    Once the sub is finished executing, it is then recalled to continue the animation

    My problem is:
    I need to execute "SLIME_STANCE" while a public sub called "CHARACTER_ATTACK" is also being executed. This allows my game to have the monster and the player's character animating at the same time.

    Right now when i call "CHARACTER_ATTACK", i have to wait for the "Slime" to stop animating (I have to wait for "SLIME_STANCE" to finish executing). Once the "Slime" stops animating, "CHARACTER_ATTACK" then begins to execute, and the player then animates. Once this sub is finished executing, "SLIME_STANCE" begins executing again (The "Slime" starts to animate again). What I need is the "Slime" to continue animating while the character attacks the "slime"
    Last edited by VBNubcake; Apr 30th, 2008 at 03:17 PM.

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