forked from SACHSTech/ProcessingImageAnimationDemo
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSketch.java
More file actions
77 lines (50 loc) · 1.44 KB
/
Sketch.java
File metadata and controls
77 lines (50 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import processing.core.PApplet;
import processing.core.PImage; //import the PImage library
public class Sketch extends PApplet {
PImage imgMeteor; // declare a global image variable
PImage imgMissile;
PImage imgBackground;
//
float fltMeteorX = -100;
float fltMeteorY = 0;
float fltMissileX = 200;
float fltMissileY = 400-50;
float fltCirX = 100;
float fltCirY = width/10;
float fltCirSpeedX = 2;
float fltCirSpeedY = 1;
public void settings() {
size(400, 400);
}
public void setup() {
imgMeteor = loadImage("spaceMeteors_003.png"); // load the image into the program
//resize meteor
imgMeteor.resize(imgMeteor.width/4,imgMeteor.height/4);
// load missile
imgMissile = loadImage("spaceMissiles_006.png");
imgBackground = loadImage("spaceBack.jpeg");
// load rocket
// resize rocket
}
public void draw() {
background(128);
image(imgBackground, 0, 0);
// draw Meteor and move
image(imgMeteor,fltMeteorX,fltMeteorY);
fltMeteorX += 1;
//fltMeteorY += 1;
// draw circle and move
circle(fltCirX, fltCirY, 20);
fltCirX += fltCirSpeedX;
fltCirY += fltCirSpeedY;
if (fltCirX < 0+10 || fltCirX > width-10) {
fltCirSpeedX *= -1;
}
if (fltCirY < 0+10 || fltCirY > height-10) {
fltCirSpeedY *= -1;
}
// draw missle and move
image(imgMissile, fltMissileX, fltMissileY);
fltMissileY -= 0.5;
}
}