-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathother.java
More file actions
68 lines (60 loc) · 1.57 KB
/
other.java
File metadata and controls
68 lines (60 loc) · 1.57 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
package start;
import java.awt.*;
import javax.swing.JFrame;
import javax.swing.ImageIcon;
public class other extends JFrame {
/**
*
*/
private static final long serialVersionUID = 1L;
public static void main(String[]args) {
DisplayMode dm = new DisplayMode(800,600,16, DisplayMode.REFRESH_RATE_UNKNOWN);
other b = new other();
b.run(dm);
}
private screen screen;
private Image bg;
private Animation a;
// loads pictures from computer to java and adds scene
public void loadPics() {
bg = new ImageIcon("C:\\images.jpg").getImage();
Image face1 = new ImageIcon("C:\\laks.PNG").getImage();
Image face2 = new ImageIcon("C:\\meme4.PNG").getImage();
a = new Animation();
a.addScene(face1, 250);
a.addScene(face2, 250);
}
//main engine to run
public void run(DisplayMode d) {
screen = new screen();
try {
screen.setFullScreen(d, new JFrame());
loadPics();
movieLoop();
}finally {
screen.restoreScreen();
}
}
//main movie loop
public void movieLoop() {
long startingTime = System.currentTimeMillis();
long cumTime = startingTime;
while(cumTime - startingTime <5000) {
long timePassed = System.currentTimeMillis() - cumTime;
cumTime += timePassed;
a.update(timePassed);
Graphics g = screen.getFullScreenWindow().getGraphics();
draw(g);
g.dispose();
try {
Thread.sleep(20);
}catch(Exception e) {
}
}
}
//draw method
public void draw(Graphics g){
g.drawImage(bg, 0,0,null);
g.drawImage(a.getImage(), 0, 0, null);
}
}