0

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?

2
Contributors
2
Replies
12
Views
4 Years
Discussion Span
Last Post by schroaus
0

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.

Edited by Reverend Jim

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.