“sketch_130521a” by Matthew Soto
https://openprocessing.org/sketch/99861
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
sketch_130521a
Soto
xxxxxxxxxx
//Timer myTimer();
PImage myImage1;
PImage myImage2;
PImage myImage3;
PImage myImage4;
Bullet[] bullets= new Bullet[6];
Life[] life= new Life[3];
Target[] target= new Target[100];
void setup(){
size(800, 800);
myImage1=loadImage("background.jpg");
myImage2=loadImage("bullet.png");
myImage3=loadImage("crosshair.png");
myImage4=loadImage("target.png");
for(int i=0; i<bullets.length; i++){
bullets[i]= new Bullet(myImage2);
}
for(int i=0; i< life.length; i++){
life[i]= new Life();
}
for(int i=0; i<target.length; i++){
target[i]= new Target(myImage4);
}
}
void draw(){
image(myImage1, 0, 0, 800, 800);
for(int i=0; i<bullets.length; i++){
bullets[i].display();
}
for(int i=0; i<life.length; i++){
life[i].display();
}
for(int i=0; i<target.length; i++){
target[i].display();
}
noCursor();
image(myImage3, mouseX, mouseY, 50, 50);
}
class Bullet{
float xpos;
int ypos;
PImage myImage2;
Bullet(PImage _myImage2){
xpos=random(545,700);
ypos=570;
myImage2= _myImage2;
}
void display(){
image(myImage2, xpos, ypos, 70, 70);
}
}
class Life{
float xpos;
int ypos;
int w;
int h;
Life(){
xpos= random(545,700);
ypos=650;
w=50;
h=50;
}
void display(){
stroke(121, 2, 2);
fill(255,0,0);
rect(xpos, ypos, w, h);
}
}
class Target{
float xpos;
float ypos;
PImage myImage4;
Target(PImage _myImage4){
xpos=random(0,700);
ypos=random(0,470);
myImage4= _myImage4;
}
void display(){
image(myImage4, xpos, ypos, 80, 80);
}
}
See More Shortcuts