public static void Main(string[] args) { Window window = new Window(1200, 700, "RingPong", PixelFormat.RGB); //Definizione : Ring, Finestra del programma, Palla, Barra Player 1, Barra Player 2 Ring ring = new Ring(window); Ball ball = new Ball(); //Parametri Bar : Posizione X, Posizione Y, Comando per andare su, Comando per andare giù Bar bar1 = new Bar(window.width - 25, window.height / 2, KeyCode.Up, KeyCode.Down); Bar bar2 = new Bar(10, window.height / 2, KeyCode.W, KeyCode.S); //Inizio Gioco bool isGameRunning = true; while (isGameRunning) { //Pulizia della Finestra ring.Clear(window, 0, 0, 0); ring.Update(window, bar1, bar2, ball); window.Blit(); //Scrittura del punteggio if (bar1.GetPoints() == 15) { Console.WriteLine("Player 1 VINCE"); isGameRunning = false; } else if (bar2.GetPoints() == 15) { Console.WriteLine("Player 2 VINCE"); isGameRunning = false; } } }
public static void Main (string[] args) { Window window = new Window (1200, 700, "RingPong", PixelFormat.RGB); //Definizione : Ring, Finestra del programma, Palla, Barra Player 1, Barra Player 2 Ring ring = new Ring (window); Ball ball = new Ball (); //Parametri Bar : Posizione X, Posizione Y, Comando per andare su, Comando per andare giù Bar bar1= new Bar (window.width-25, window.height/2, KeyCode.Up, KeyCode.Down); Bar bar2 = new Bar (10, window.height/2, KeyCode.W, KeyCode.S); //Inizio Gioco bool isGameRunning = true; while (isGameRunning) { //Pulizia della Finestra ring.Clear(window, 0, 0, 0); ring.Update (window, bar1, bar2, ball); window.Blit(); //Scrittura del punteggio if (bar1.GetPoints () == 15) { Console.WriteLine ("Player 1 VINCE"); isGameRunning = false; } else if (bar2.GetPoints () == 15) { Console.WriteLine ("Player 2 VINCE"); isGameRunning = false; } } }
public void Update(Window window, Bar bar1, Bar bar2, Ball ball) { //Disegno parte superiore del Ring this.DrawRectFilled(window, 10, 10, 255, 255, 255, window.width - 20, 10); //Disegno parte inferiore del Ring this.DrawRectFilled(window, 10, window.height - 20, 255, 255, 255, window.width - 20, 10); //Disegno righe tratteggiate che separano il ring int k = 20; while (k < window.height - 20) { this.DrawRectFilled(window, window.width / 2, k, 255, 255, 255, 7, 30); k += 40; } //Disegno la Palla //this.DrawRectFilled (window, ball.GetX(), ball.GetY(), ball.GetR(), ball.GetG(), ball.GetB(), ball.GetWidht(), ball.GetHeight()); this.DrawCircle(window, ball.GetX(), ball.GetY(), ball.GetRaggio(), 255, 255, 255); //Disegno la barra del Player 1 this.DrawRectFilled(window, bar1.GetX(), bar1.GetY(), 255, 0, 0, bar1.GetWidht(), bar1.GetHeight()); //Disegno la Barra del Player 2 this.DrawRectFilled(window, bar2.GetX(), bar2.GetY(), 0, 255, 0, bar2.GetWidht(), bar2.GetHeight()); //Movimeto barra del Player 1 bar1.Move(window, ball); //Movimeto barra del Player 2 bar2.Move2(window, ball, window.height); //Movimeto della Palla ball.Update(window.height, window.width); numb1.CurrentResultDec(window, bar1.GetPoints()); numb2.CurrentResult(window, bar1.GetPoints()); numb3.CurrentResultDec(window, bar2.GetPoints()); numb4.CurrentResult(window, bar2.GetPoints()); }
public void Update(Window window, Bar bar1, Bar bar2, Ball ball) { //Disegno parte superiore del Ring this.DrawRectFilled (window, 10, 10, 255, 255, 255, window.width-20, 10); //Disegno parte inferiore del Ring this.DrawRectFilled (window, 10, window.height-20, 255, 255, 255, window.width-20, 10); //Disegno righe tratteggiate che separano il ring int k = 20; while(k < window.height-20) { this.DrawRectFilled(window, window.width/2, k, 255, 255, 255, 7, 30); k += 40; } //Disegno la Palla //this.DrawRectFilled (window, ball.GetX(), ball.GetY(), ball.GetR(), ball.GetG(), ball.GetB(), ball.GetWidht(), ball.GetHeight()); this.DrawCircle(window, ball.GetX(), ball.GetY(), ball.GetRaggio(), 255, 255, 255); //Disegno la barra del Player 1 this.DrawRectFilled (window, bar1.GetX(), bar1.GetY(), 255, 0, 0, bar1.GetWidht(), bar1.GetHeight()); //Disegno la Barra del Player 2 this.DrawRectFilled (window, bar2.GetX(), bar2.GetY(), 0, 255, 0, bar2.GetWidht(), bar2.GetHeight()); //Movimeto barra del Player 1 bar1.Move (window, ball); //Movimeto barra del Player 2 bar2.Move2 (window, ball, window.height); //Movimeto della Palla ball.Update (window.height, window.width); numb1.CurrentResultDec (window, bar1.GetPoints()); numb2.CurrentResult (window, bar1.GetPoints()); numb3.CurrentResultDec (window, bar2.GetPoints()); numb4.CurrentResult (window, bar2.GetPoints()); }