# Creating a game

I need some examples of codes of games. So that i can get an idea how to make a simple game like a character can collect coin and increase score And if touch any object like bomb its life will be deducted. Just some examples if you have any or from the internet. It will be a great help. i have written some code

``````int x;
int y=226;
boolean play = true;

void setup() {
size(800, 400);
background(0);

}

void draw() {
cave();
stone();
clumsy();
bomb();

}

void cave() {
noStroke();
fill(160);
rect(0,88,width,200);
}

void stone() {
color c[] = new color[3];
int n=0;
c[0]=color(255, 0, 0); // first color
c[1]=color(0, 255, 0); // second
c[2]=color(0, 0, 255); // third
for(int i=-2; i<width; i+=30){
strokeWeight(2);
stroke(0);
fill(c[n]);
rect(i,88,30,30);
rect(i,285,30,30);
n++;
if(n>2) n=0;
}
}

void clumsy(){
strokeWeight(1.5);
fill(0);
ellipse(x+30,y-5,80,45);
fill(#F3F156);
rect(x,y,58,58);
fill(#90F614);
rect(x+40,y+10,10,10);
fill(#EF1A1A);
rect(x+15,y+30,25,15);
if (play){
x++;
}
if(x>width){
x=0;}

}

void keyPressed() {

if (key == CODED) {
if (keyCode == UP) {
if (y == 226){
y-= 100;
}
}
}
if (keyCode == DOWN) {
if (y == 126){
y+= 100;
}
}

if (keyCode == ' ') {
play = !play;
}
}

void bomb(){

}
``````
1 Like

You can do a search for `game` in the forum and you can see some demos in the forum. I bet you can get some more hits if you do a google search like â€śgames in processingâ€ť. If you are looking for a game, suggestions: moonlander, pacman, asteroids.

Kf

1 Like

Sticks are for chumps. Itâ€™s all about catching monkeys in nets these days.

http://www.tfguy44.com/games/

2 Likes

I did those open sourced things that may interest you
http://captainlee.org/

2 Likes

Old forum section share your work

E.g.

2 Likes