Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add files via upload #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions EatHotDog/EatHotDog.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// gzc exercise_wsc
PImage wsc;
PImage hotdog;
int hotdognumber=3;

//how many hotdogs[largest]
Hotdog[] hg = new Hotdog[200];

void setup(){
size(600,300);

wsc = loadImage("wsc.png");
hotdog = loadImage("hotdog.png");

//available hotdog_size
for(int i=0;i<hg.length;i++){
hg[i] = new Hotdog(45);
}
}

void mousePressed(){

if(mousePressed&&(mouseButton == LEFT)){
hotdognumber=hotdognumber+1;
}else if(mousePressed&&(mouseButton == RIGHT)){
hotdognumber=hotdognumber-1;
}
}

void draw(){
background(255);

hg[1].circle();
//wsc
image(wsc,50,mouseY,150,90);

for(int i=0;i<hotdognumber;i++){
hg[i].left();
hg[i].game();
hg[i].disappear();
}
}
40 changes: 40 additions & 0 deletions EatHotDog/Hotdog.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
class Hotdog{

float x;
float y;
float xspeed;
float hotdogsize;
int er = 5;

Hotdog(float tempD){
x=width;
y=random(height);
xspeed=random(2,6);
hotdogsize=tempD;
}

void circle(){
//ellipse
stroke(255);
ellipse(160,mouseY+40,er,er);
}

void left(){
x=x-xspeed;
}

void game(){
image(hotdog,x,y,hotdogsize,hotdogsize/2);
if(x < 0){
x = width;
}
}

void disappear(){
float d=dist(x,y,hotdogsize,160,mouseY+40,er);
if(d<hotdogsize+er){
x=(width);
y=random(height);
}
}
}
Binary file added EatHotDog/data/hotdog.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added EatHotDog/data/wsc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added EatHotDog/screen recording.mp4
Binary file not shown.