Go Back   Computer Forums > General Computing > Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 01-23-2006, 09:29 PM   #1
Fully Optimized
 
Dishdog's Avatar
 
Join Date: Feb 2005
Posts: 2,801
Default Add a Pause in the code in VB

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.
__________________

__________________
CPU-Intel Pentium 4 630 3.0Ghz / 2MB Cache ~~OS Windows XP SP2
MOBO-Gigabyte 8I915P Duo Pro Intel Socket 775 (PCI-E)~~HDD-Western Digital 160GB(SATA)
PSU-Aspire 500W ATX~~RAM-1GB PC3200 DDR SDRAM (512x2 Dual Channel)
GPU-MSI GeForce 6600 GT(PCI Express)~~Monitor Viewsonic VA902B 19" 8ms~~ ATI TV Wonder Pro (TV Tuner)
~~Still to come~~: eVGA e-GeForce 7800 GT
Dishdog is offline   Reply With Quote
Old 01-24-2006, 04:27 PM   #2
Site Team
 
root's Avatar
 
Join Date: Mar 2004
Posts: 7,999
Default Re: Add a Pause in the code in VB

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.
__________________

__________________
I didn’t fight my way to the top of the food chain to be a vegetarian…
Im sick of people saying 'dont waste paper'. If trees wanted to live, they'd all carry guns.
"The inherent vice of capitalism is the unequal sharing of blessings; The inherent vice of socialism is the equal sharing of miseries."
root is offline   Reply With Quote
Old 01-24-2006, 10:29 PM   #3
Fully Optimized
 
Dishdog's Avatar
 
Join Date: Feb 2005
Posts: 2,801
Default Re: Add a Pause in the code in VB

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.
__________________
CPU-Intel Pentium 4 630 3.0Ghz / 2MB Cache ~~OS Windows XP SP2
MOBO-Gigabyte 8I915P Duo Pro Intel Socket 775 (PCI-E)~~HDD-Western Digital 160GB(SATA)
PSU-Aspire 500W ATX~~RAM-1GB PC3200 DDR SDRAM (512x2 Dual Channel)
GPU-MSI GeForce 6600 GT(PCI Express)~~Monitor Viewsonic VA902B 19" 8ms~~ ATI TV Wonder Pro (TV Tuner)
~~Still to come~~: eVGA e-GeForce 7800 GT
Dishdog is offline   Reply With Quote
Old 01-24-2006, 10:46 PM   #4
In Runtime
 
Windwaker222's Avatar
 
Join Date: Nov 2004
Posts: 351
Default Re: Add a Pause in the code in VB

Quote:
Originally Posted by Dishdog
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
__________________
AMD Phenom 9600 / 4GB OCZ Gold / nVidia 8800GT / ASUS Crosshair 4xPCI-E
Windwaker222 is offline   Reply With Quote
Old 01-25-2006, 12:06 AM   #5
Fully Optimized
 
Dishdog's Avatar
 
Join Date: Feb 2005
Posts: 2,801
Default Re: Add a Pause in the code in VB

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
        Call FightMonster
    ElseIf AttackChar = 2 Then
        MonsterCH = MonsterCH - Stat(3)
        frmBattles.Label3 = MonsterCH
        frmBattles.txtBattleInfo.Text = " Thouh Has Dealt " & Stat(3) & " To The " & MonsterName
        Call FightMonster
        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).
__________________
CPU-Intel Pentium 4 630 3.0Ghz / 2MB Cache ~~OS Windows XP SP2
MOBO-Gigabyte 8I915P Duo Pro Intel Socket 775 (PCI-E)~~HDD-Western Digital 160GB(SATA)
PSU-Aspire 500W ATX~~RAM-1GB PC3200 DDR SDRAM (512x2 Dual Channel)
GPU-MSI GeForce 6600 GT(PCI Express)~~Monitor Viewsonic VA902B 19" 8ms~~ ATI TV Wonder Pro (TV Tuner)
~~Still to come~~: eVGA e-GeForce 7800 GT
Dishdog is offline   Reply With Quote
Old 01-25-2006, 01:35 AM   #6
Golden Master
 
ArrizX's Avatar
 
Join Date: Apr 2005
Posts: 16,073
Send a message via MSN to ArrizX
Default Re: Add a Pause in the code in VB

I wanna test the game
__________________
. ()()()()
./l ,[_\_\ ],
l---L – ()lllllll()-
()_) ()_)--o-)_)
ArrizX is offline   Reply With Quote
Old 01-25-2006, 05:58 AM   #7
Site Team
 
root's Avatar
 
Join Date: Mar 2004
Posts: 7,999
Default Re: Add a Pause in the code in VB

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
__________________
I didn’t fight my way to the top of the food chain to be a vegetarian…
Im sick of people saying 'dont waste paper'. If trees wanted to live, they'd all carry guns.
"The inherent vice of capitalism is the unequal sharing of blessings; The inherent vice of socialism is the equal sharing of miseries."
root is offline   Reply With Quote
Old 01-25-2006, 09:10 AM   #8
Fully Optimized
 
Dishdog's Avatar
 
Join Date: Feb 2005
Posts: 2,801
Default Re: Add a Pause in the code in VB

Quote:
Originally Posted by ArrizX_MuziK
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.
__________________

__________________
CPU-Intel Pentium 4 630 3.0Ghz / 2MB Cache ~~OS Windows XP SP2
MOBO-Gigabyte 8I915P Duo Pro Intel Socket 775 (PCI-E)~~HDD-Western Digital 160GB(SATA)
PSU-Aspire 500W ATX~~RAM-1GB PC3200 DDR SDRAM (512x2 Dual Channel)
GPU-MSI GeForce 6600 GT(PCI Express)~~Monitor Viewsonic VA902B 19" 8ms~~ ATI TV Wonder Pro (TV Tuner)
~~Still to come~~: eVGA e-GeForce 7800 GT
Dishdog is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 06:33 PM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0