# UPDATED: Creating a Game: Just need a kick in the right direction

**URL:** <https://discourse.processing.org/t/updated-creating-a-game-just-need-a-kick-in-the-right-direction/43287>\
**Category:** Coding Questions\
**Created:** [November 23, 2023, 4:07am UTC](https://discourse.processing.org/t/updated-creating-a-game-just-need-a-kick-in-the-right-direction/43287 "2023-11-23T04:07:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![beginn](https://avatars.discourse-cdn.com/v4/letter/b/f9ae1b/32.png) [@beginn](https://discourse.processing.org/u/beginn)\
**Post date:** [November 23, 2023, 4:07am UTC](https://discourse.processing.org/t/updated-creating-a-game-just-need-a-kick-in-the-right-direction/43287/1 "2023-11-23T04:07:07Z")

</div>

Hopefully I formatted this right… So this is the code I have so far on making a somewhat pong game but also that game where you bounce the ball off the bar (rect) (like that game where you break bricks with the ball). I got the bar (rect) moving like I want it to, but I need help getting the ball to bounce off the bar itself. Maybe new int. or some codes that would achieve that? Not worried about the win or lose part yet.

```auto
float ballX;             
float ballY;              
float xspeed = random (-100, 100); 
float yspeed = random (-100, 100); 
int playerA, playerB; 

void setup (){          
size (800, 500);       
ballX = 0; 
ballY = 0;  
playerA = width; 
playerB = height; 

}

void draw() {    
background (0);  
drawBall (); 
drawPlayer (); 
}
void drawBall () { 
fill (255);
ellipse (ballX, ballY, 20, 20);   
ballX = ballX + xspeed;    
ballY = ballY + yspeed;    

if (ballX > width) {    
xspeed = -10;    
}
if (ballX < 0){ 
xspeed = 10;
}    
if (ballY > height) { 
yspeed = -10;
}    
if (ballY < 0) {  
yspeed = 10;
}   
}

void drawPlayer () { 
  fill (235, 23, 54); 
  rect (mouseX, playerB/2+140, 100, 20); // x, y coordinates of top left corner then width, then height 
}   

```

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [November 23, 2023, 6:06am UTC](https://discourse.processing.org/t/updated-creating-a-game-just-need-a-kick-in-the-right-direction/43287/2 "2023-11-23T06:06:43Z")

</div>

try: rect(mouseX, ,100,20);
