P
Pb4ugo69
Guest
Hello everyone,
As an aspiring game developer, I have decided to recreate the classic virtual tennis game Pong in Visual Studio using the C# language and GDIDrawer.
The problem with this is that I have very little programming experience. This is all I have at the moment: (but I still need to create a three sided border and a paddle for the ball to bounce off) any help or tips and tricks on how to complete what is missing would be greatly appreciated.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using GDIDrawer;
using System.Drawing;
namespace ping pong practice mode
{
class Program
{
static void Main(string[] args)
{
//x ball position
int iX = 0;
//y ball position
int iY = 0;
//amount ball moves in x direction for every loop
int iXVelocity = 5;
//amount ball moves in y direction for every loop
int iYVelocity = 5;
//create a drawer window with a scale of 10
CDrawer Canvas = new CDrawer();
Canvas.Scale = 5;
//loop until the ball leaves the visible window
while ((iX < 160) || (iX > 0))
{
//erase the old ball
Canvas.Clear();
//draw the new ball
Canvas.AddEllipse(iX, iY, 1, 1);
//time delay to slow down the ball
System.Threading.Thread.Sleep(150);
//calculate the ball's new position
iX += iXVelocity;
iY += iYVelocity;
//check for bouncing off of the lower edge of the window
if ((iY > 120) || (iY < 0))
//reverse the y velocity (ball goes up)
iYVelocity = -iYVelocity;
}
}
}
}
Continue reading...
As an aspiring game developer, I have decided to recreate the classic virtual tennis game Pong in Visual Studio using the C# language and GDIDrawer.
The problem with this is that I have very little programming experience. This is all I have at the moment: (but I still need to create a three sided border and a paddle for the ball to bounce off) any help or tips and tricks on how to complete what is missing would be greatly appreciated.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using GDIDrawer;
using System.Drawing;
namespace ping pong practice mode
{
class Program
{
static void Main(string[] args)
{
//x ball position
int iX = 0;
//y ball position
int iY = 0;
//amount ball moves in x direction for every loop
int iXVelocity = 5;
//amount ball moves in y direction for every loop
int iYVelocity = 5;
//create a drawer window with a scale of 10
CDrawer Canvas = new CDrawer();
Canvas.Scale = 5;
//loop until the ball leaves the visible window
while ((iX < 160) || (iX > 0))
{
//erase the old ball
Canvas.Clear();
//draw the new ball
Canvas.AddEllipse(iX, iY, 1, 1);
//time delay to slow down the ball
System.Threading.Thread.Sleep(150);
//calculate the ball's new position
iX += iXVelocity;
iY += iYVelocity;
//check for bouncing off of the lower edge of the window
if ((iY > 120) || (iY < 0))
//reverse the y velocity (ball goes up)
iYVelocity = -iYVelocity;
}
}
}
}
Continue reading...