Dance Dance Revolution Game - vb.net

http://i44.tinypic.com/znlvra.png
So I got this game like dance dance revo it wors Ok it says good and perfect when you hit an arrow i got a problem with the perfect hit it works depends on the speed on the arrows but I got an option easy, medium and hard basically easy is the slowest and hard is the fastest in the medium speed it I never ever hit a perfect so I'm asking if you guys have a better method to get the perfect or help me improve this code:
'Perfect Hit
If (RArrowDown.Top = ArrowDown.Top) And RArrowDown.Visible = True Then
TimerMain.Enabled = False
Hit += 1
Score += 20
RArrowDown.Visible = False
Perfect.Visible = True
TimerPerfect.Enabled = True
Combo_Counter += 1
RandomTime_1.Enabled = True
'End If
'Good Hit
ElseIf (RArrowDown.Top <= ArrowDown.Top + ArrowDown.Height) And (ArrowDown.Top <= RArrowDown.Top + RArrowDown.Height) And RArrowDown.Visible = True Then
TimerMain.Enabled = False
Hit += 1
Score += 10
RArrowDown.Visible = False
Good.Visible = True
TimerGood.Enabled = True
Combo_Counter += 1
RandomTime_1.Enabled = True
End If

I think a better way is to get a value indicating how far off from perfect the keypress is (I think it is very unliekly that someone actually gets it perfectly), then act on this value. You can then tweak the bands that give you a perfect or good hit:
Dim offset as Integer
If [Right Arrow Pressed]
offset = RarrowDown.Top - ArrowDown.Top
End If
Select Case offset
case is 0 to 3
'perfect
case 4 to 10
'good
case 11 to 20
'poor
case else
'missed
End Select

Related

Water rising and descending

im in a process of making a roblox game. I want to make the water rise and descend again down. I think i did something wrong with coding,(its my second day of coding and i cant find any video on it) im not sure what. So everytime i run roblox after 1st descending and starting of 2nd game, it freezes,water dissapears and it throws a error: Script timeout: exhausted allowed execution time. Here is my code:
wait(21)
t = 17
repeat
t = t-1
script.Parent.Position = script.Parent.Position + Vector3.new(0, 1, 0)
wait(2)
until
t == 0
wait(1)
t = 17
repeat
t = t-1
script.Parent.Position = script.Parent.Position + Vector3.new(0, -1, 0)
wait(0.5)
until
t == 0
wait(9)
t = 17
while true do
t = t-1
script.Parent.Position = script.Parent.Position + Vector3.new(0, 1, 0)
end
wait(2)
while false do
t = t-1
script.Parent.Position = script.Parent.Position + Vector3.new(0, -1, 0)
end
Script timeout: exhausted allowed execution time.
Because the code never stops looping here:
while true do
//...
end
This will continue to loop forever. (Well, for as long as true is true. And I can't think of a condition in which it wouldn't be.)
Contrast that with your loops above:
t = 17
repeat
t = t-1
//...
until
t == 0
In this case the loop explicitly repeats "until t equals 0", and each iteration of the loop brings t one step closer to 0.
Modify your later loops to have similar structures and conditions. For example:
t = 17
while t > 0 do
t = t-1
//...
end
Note also that this loop will never execute:
while false do
//...
end
Because false is never true. Now is a good time to take a step back and consider the logic of what you want these loops to do. Just like with your first two loops, modify your second two loops to indicate how many times they should repeat.

How to delay the opening of the next form in VISUAL BASIC

Here's my code. I just want to stop my form for a while so I can read the result first before it opens to the next form. Thank you!
play_win.Text = winner
com_win.Text = comwinner
If winner >= 3 Then
youarewinner.Show()
ElseIf comwinner >= 3 Then
youlose.Show()
End If
play_win.Text = winner
com_win.Text = comwinner
If CInt(winner) >= 3 Then
youarewinner.Show()
ElseIf CInt(comwinner) >= 3 Then
youlose.Show()
End If

How to make a pendulum move with a given, changing, velocity

I am currently stuck trying to figure out how I will make my pendulum move with its changing velocity, due to gravity. I attempted to do this:
Do Until StopProgram = True
Do Until Count = v
Application.DoEvents()
If DirectionNegative = False Then
Me.Refresh()
Count += 1
Angle += 1
RadianAngle = Angle * PlaceHolder
If Angle >= 51 Then
Angle = 49
DirectionNegative = True
End If
ElseIf DirectionNegative = True Then
Me.Refresh()
Count += 1
Angle -= 1
RadianAngle = Angle * PlaceHolder
If Angle <= -51 Then
Angle = -49
DirectionNegative = False
End If
End If
Loop
Count = 0
Loop
This makes the pendulum move with the v (Final velocity (Using SUVAT)) but currently this is working by making it run for however long v is, I would like the pendulum to swing X amount per second, where X changes depending on v. I have been told I should try this with multithreading but after researching this I am confused on the whole thing and I do not know where to begin with any of this, bar what I have.

number variable won't addition by 1 and display in a label everytime the timer counts 1000ms. - vb.net

Here is my code:
number = 1
If chkFN.Enabled = True Then
If ProgressBar1.Value < 100 Then
number += 1
lblFN2.Text = number
Else
lblFN2.Text = "0"
End If
End If
i have a checkbox, progressbar and a label.
when the progress bar is lower than 100 i want the number variable to + 1 every time the timer counts 1. I've tried "X = X + 1" - it worked to a point but i need to reset the variable to "0" when the progressbar hits 100% and when i click the stop button.
while I've been typing this i've also tried:
X = X + 1
If chkFN.Enabled = True Then
If ProgressBar1.Value < 100 Then
lblFN2.Text = X + 1
ElseIf AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsMediaEnded
Then
X = 0
lblFN2.Text = "0"
Else
X = 0
lblFN2.Text = "0"
End If
End If
But when you start the timer again it just resumes from it's last number e.g. "13" and doesn't reset to "0".
Thanks for the help guys :)
Use your first code, but add in
number += 1
to the Else condition. You need to reset the variable or it just increments it again.

How to Detect if Sprite is going Up or Down

I Use the following code to detect if a sprite should be going up or down and the response
If (pos.Y + 100) >= Sprite.BottomY Then
Going_up = True
pos.Y = Sprite.BottomY - 130
End If
If pos.Y <= Sprite.TopY Then
Going_up = False
pos.Y = Sprite.TopY - 1
Vel.Y = 3
End If
then
If Going_up Then
Vel.Y -= CSng(gameTime.ElapsedGameTime.TotalMilliseconds / 40)
pos.Y -= Vel.Y
Else
Vel.Y += CSng(gameTime.ElapsedGameTime.TotalMilliseconds / 40)
pos.Y += Vel.Y
End If
Sprite.velocity = Vel
Sprite.position = pos
but it's pretty terrible. It only works when the sprite starts at the top, and when I want to change the BottomY and TopY, it just starts glitching. What is a better to detect if the sprite should be going up or down?
Can you not just do:
If (Vel.Y > 0) Then
Going_up = True
' Do rest of up code
Else If (Vel.Y < 0) Then
Going_up = False
' Do rest of not going up code
End If
Something that might help is utilizing a getter and setter like this:
Essentially, you could create a tempX and tempY. Every 100ms compare the sprite's current properties with the temp variables.
Dim tempX As Double
Dim tempY As Double
While True
tempY = sprite.GetY()
If gameTime.ElapsedGameTime.TotalMilliseconds Mod 100 = 0 Then 'or something to sample the game time
If sprite.Vel.Y > tempY Then
Going_up = True
Else
Going_up = False
End If
End IF
End While
So you're sort of taking a sample of your game board to create approximate reference points that you can compare the actual value to. Hope that helps!
-sf