Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pong-public
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
noman.rafique
pong-public
Commits
1f4593a4
Commit
1f4593a4
authored
Aug 31, 2017
by
Carl Hetherington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Draw the ball and make it move.
parents
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
0 deletions
+52
-0
Pong.java
Pong.java
+47
-0
pong.sh
pong.sh
+5
-0
No files found.
Pong.java
0 → 100644
View file @
1f4593a4
import
processing.core.PApplet
;
import
java.util.Random
;
public
class
Pong
extends
PApplet
{
// x position of the ball
private
int
ballX
;
// y position of the ball
private
int
ballY
;
// Ball speed in the x direction
private
int
ballSpeedX
;
// Ball speed in the y direction
private
int
ballSpeedY
;
// Width of our window
final
private
int
width
=
640
;
// height of our window
final
private
int
height
=
480
;
public
static
void
main
(
String
[]
args
)
{
// Set up the processing library
PApplet
.
main
(
"Pong"
);
}
public
void
settings
()
{
// Set our window size
size
(
width
,
height
);
}
public
void
setup
()
{
// Create a random initial position and speed for the ball
Random
r
=
new
Random
();
ballX
=
r
.
nextInt
(
width
);
ballY
=
r
.
nextInt
(
height
);
ballSpeedX
=
r
.
nextInt
(
width
/
100
)
+
1
;
ballSpeedY
=
r
.
nextInt
(
height
/
100
)
+
1
;
}
public
void
draw
()
{
// Clear the background of the window
background
(
255
,
255
,
255
);
// Draw the ball
ellipse
(
ballX
,
ballY
,
32
,
32
);
// Move the ball
ballX
+=
ballSpeedX
;
ballY
+=
ballSpeedY
;
}
}
pong.sh
0 → 100755
View file @
1f4593a4
#!/bin/bash
#PROCESSING=/usr/share/java/processing-core.jar
PROCESSING
=
~/Downloads/processing-3.3.5/core/library/core.jar
javac
-cp
$PROCESSING
Pong.java
java
-cp
$PROCESSING
:. Pong
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment