Add a Pause in the code in VB

Dishdog

Fully Optimized
Messages
2,801
Ok, i'm making a RPG for programming in VB.

I have it after you deafeat an enemy it says you have defeated the enemy, and it tells you how much XP and gold you got. then it makes the img visible = false. then it goes back to the map.

I would like to give the user some time to read the text before it goes back to the map, so i was wondering if there is any "break" code. As in code that will pause the code for a given amount of time.

I could just enable a timer and then after so long have it switch forms but i would rather do it in the code.
 

root

Site Team
Staff member
Messages
8,181
Location
UK
how about making
img.visible=true (which you have anyway), then
timer1.enabled=true

then on timer one sub

timer1.enabled=false
img.visible=false

so the image is only visible for the duration of the timer.
 

Dishdog

Fully Optimized
Messages
2,801
That code would go by in a snap. I need atleast 3secs.

I was talking to someone in my class and they said there is code called "sleep" but he didn't know the code or how to use it. Anybody heard of this? I tried to access the MSDN libary at school but it was being stupid so it didn't help any.
 

Windwaker222

In Runtime
Messages
379
Dishdog said:
That code would go by in a snap. I need atleast 3secs.

I was talking to someone in my class and they said there is code called "sleep" but he didn't know the code or how to use it. Anybody heard of this? I tried to access the MSDN libary at school but it was being stupid so it didn't help any.
just set the length of the timer longer.. 1000 = 1 sec
 

Dishdog

Fully Optimized
Messages
2,801
Now Correct me if i'm wrong but as soon as i enable the timer it will do the code then, say i set the interval to 1000 it will do it again in 1 sec.

Anyways for that spot i have made a timer and put a counter in it so when the counter = 3 then it does the code. I have another spot where i need a brake and a timer will not do it(Well it could but it would be a lot simpler to just have a code for a break instead of a timer).

Code:
Public Function FightChar()
    If AttackChar = 1 Then
        MonsterCH = MonsterStat(1) - Stat(3)
        frmBattles.Label1 = MonsterStat(1)
        frmBattles.txtBattleInfo.Text = " Thouh Has Dealt " & Stat(3) & " To The " & MonsterName
        AttackChar = 2
        [B]Call FightMonster[/B]
    ElseIf AttackChar = 2 Then
        MonsterCH = MonsterCH - Stat(3)
        frmBattles.Label3 = MonsterCH
        frmBattles.txtBattleInfo.Text = " Thouh Has Dealt " & Stat(3) & " To The " & MonsterName
        [B]Call FightMonster[/B]
        If MonsterCH <= 0 Then
        Call Defeat
        End If
    End If
End Function
After i attack it calls up the monsters attack code and then i can attack again after it's all through. I have "A" as my action key, so basically if i fight all i have to do is hit A really fast and the battle ends fast. with the timer as the barake i would need to reset the values i bunch of times and it would make it harder to keep track of(theres more values i would have to changed then whats in that patch of code).
 

root

Site Team
Staff member
Messages
8,181
Location
UK
as soon as timer one is enabled, it'll count to the interval setting and then perform whatever action is in the timer1_sub...

just as a though...
you say three seconds, but that might grow to four, or shrink to 2, or you might even like the users to have some input...
you might want to declare a global integer called timer_int
and then when you start the timer user the code

timer1.interval = timer_int
timer1.enabled=true
img1.visible=true
 

Dishdog

Fully Optimized
Messages
2,801
ArrizX_MuziK said:
I wanna test the game :)
Well it's really far off from being done, even though it's do for a final project in 3 hours,lol. I have enough done though to get at least 70%.

When i finish i'm going to post it in social lounge for testing, i'll make sure i send you a PM when i do.
 
Top