At the moment I am making a simple pong game in my tenth grade high school class. It is already much more advanced than any of the other projects that people are working on and I will get an A no matter what, but I still have a problem that is annoying me. This is my general declaration code

Public Class Form1
    Dim compScore As Integer = 0
    Dim plrScore As Integer = 0
    Dim speed As Single = 21
    Dim rndInst As New Random()
    Dim xVel As Single = Math.Cos(rndInst.Next(5, 10)) * speed
    Dim yVel As Single = Math.Sin(rndInst.Next(5, 10)) * speed

I want to te be able to reset the angle after each time either the computer or the player scores. I can not figure out a way to do this without reseting my entire program. Any help?

Recommended Answers

All 2 Replies

I don't see a variable that contains the angle. I expected to see something like

Private Angle As Double

in which case whenever the scored code is executed you could reset Angle. By the way, you should be using Public or Private instead of Dim when declaring at the class level. It's little details like that that markers look for.

The xVel and the yVel are the angles that I am using. When the ball hits the top or bottom of the form it automatically becomes negative. If the ball hits a paddle the Xvel becomes negative. Thank you any way though, I think your answer will still work.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.