“Pac man” by Harry Attilio
https://openprocessing.org/sketch/93513
License CreativeCommons Attribution ShareAlike
https://creativecommons.org/licenses/by-sa/3.0
{{filePath}}
{{width}} x {{height}}
Report Sketch
Oh, that naughty sketch! Please let us know what the issue is below.
Apply Template
Applying this template will reset your sketch and remove all your changes. Are you sure you would like to continue?
Report Sketch
Report Comment
Please confirm that you would like to report the comment below.
We will review your submission and take any actions necessary per our Community Guidelines. In addition to reporting this comment, you can also block the user to prevent any future interactions.
Please report comments only when necessary. Unnecessary or abusive use of this tool may result in your own account being suspended.
Are you sure you want to delete your sketch?
Any files uploaded will be deleted as well.
Delete Comment?
This will also delete all the replies to this comment.
Delete this tab? Any code in it will be deleted as well.
Select a collection to submit your sketch
We Need Your Support
Since 2008, OpenProcessing has provided tools for creative coders to learn, create, and share over a million open source projects in a friendly environment.
Niche websites like ours need your continued support for future development and maintenance, while keeping it an ad-free platform that respects your data and privacy!
Please consider subscribing below to show your support with a "Plus" badge on your profile and get access to many other features!
CC Attribution ShareAlike
Pac man
Attilio
xxxxxxxxxx
int globalx = 150;
int globaly = 150;
int y = 30;
int speed = -10;
int speed2 = +10;
PImage myImage;
boolean bg = false;
void setup() {
size(700, 700);
myImage = loadImage("tumblr_lvcn67O5dN1qa1z8jo1_500.jpg");
}
//board
void draw() {
background(100, 200, 100);
if (bg == false) {
tint(255);
image(myImage, 0, 0, 700, 700);
}
if (bg == true) {
tint(44, 151, 255);
image(myImage, 0, 0, 700, 700);
}
display();
int x = 30;
while (x <= width) {
int y = 30;
while (y <= height) {
fill(255, 0, 0);
rect(x, y, 20, 20);
y= y + 70;
}
x = x + 70;
}
}
//pacman
void display() {
fill(222, 250, 20);
ellipse(globalx, globaly, 20, 20);
}
//conrolls
//right
void move() {
//globalx = globalx + speed;
globalx = globalx + speed2;
if (globalx==700) {
globalx = globalx + speed;
bg = false;
}
}
//left
void move2() {
globalx = globalx + speed;
if (globalx==0) {
globalx = globalx + speed2;
bg = false;
}
}
//down
void move3() {
globaly = globaly +speed2;
if (globaly==700) {
globaly = globaly + speed;
bg = true;
}
}
//up
void move4() {
globaly = globaly + speed;
if (globaly==0) {
globaly = globaly +speed2;
bg = true;
}
}
void keyPressed() {
/*w is up
s is down
a is left
d is right*/
if (key == 'w') {
move4();
}
if (key == 's') {
move3();
}
if (key == 'a') {
move2();
}
if (key == 'd') {
move();
}
}
See More Shortcuts