Skip to content
Open
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
64 changes: 36 additions & 28 deletions assign1.pde
Original file line number Diff line number Diff line change
@@ -1,34 +1,42 @@
// reference : https://processing.org/examples/trianglestrip.html

/* please implement your assign1 code in this file. */
PImage fighterImg;
PImage bg1Img;
PImage bg2Img;
PImage enemyImg;
PImage hpImg;
PImage treasureImg;
int x;
int y;
float outsideRadius = 150;
float insideRadius = 100;
int a,b,c,d;

void setup() {
size(640, 360);
background(0);
x = width/2;
y = height/2;
void setup () {
size(640,480) ; // must use this size.
x=0;
fighterImg = loadImage("F:/1.03.arashi/processing-3.0/assign1/img/fighter.png");
bg1Img = loadImage("F:/1.03.arashi/processing-3.0/assign1/img/bg1.png");
bg2Img = loadImage("F:/1.03.arashi/processing-3.0/assign1/img/bg2.png");
enemyImg = loadImage("F:/1.03.arashi/processing-3.0/assign1/img/enemy.png");
hpImg = loadImage("F:/1.03.arashi/processing-3.0/assign1/img/hp.png");
treasureImg = loadImage("F:/1.03.arashi/processing-3.0/assign1/img/treasure.png");

a = floor(random(0,640));
b = floor(random(0,480));
c = floor(random(0,480));
d = floor(random(30,195));

// your code
}

void draw() {
background(0);

int numPoints = int(map(mouseX, 0, width, 6, 60));
float angle = 0;
float angleStep = 180.0/numPoints;

beginShape(TRIANGLE_STRIP);
for (int i = 0; i <= numPoints; i++) {
float px = x + cos(radians(angle)) * outsideRadius;
float py = y + sin(radians(angle)) * outsideRadius;
angle += angleStep;
vertex(px, py);
px = x + cos(radians(angle)) * insideRadius;
py = y + sin(radians(angle)) * insideRadius;
vertex(px, py);
angle += angleStep;
}
endShape();
image(bg1Img,0,0);
image(bg2Img,0,0);
image(fighterImg,580,200);
image(hpImg,30,20);
image(treasureImg,a,b);
image(enemyImg,x,c);

fill(255,0,0);
rect(45,30,d,10);
// your code
x +=2;
x%=480;
}