forked from nestorvc/funJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunThread.java
More file actions
82 lines (69 loc) · 2.44 KB
/
funThread.java
File metadata and controls
82 lines (69 loc) · 2.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
78
79
80
81
82
package fun_v01;
/**
* Ésta clase define el Thread principal (y de momento único) que loopea el funGame
* @author Marvin Gonzalez, Kevin Gutierrez, Néstor Villalobos
*/
public class funThread implements Runnable{
//*******************************ATRIBUTOS*******************************//
//***********************************************************************//
//***********************************************************************//
private funGame padre;
private Thread runner;
//******************************CONSTRUCTOR******************************//
//***********************************************************************//
//***********************************************************************//
/**
* El constructor de funThread.
* @param padre El funGame que controla.
*/
public funThread(funGame padre) {
setPadre(padre);
setRunner(new Thread(this));
getRunner().start();
}
//*****************************OTROS MÈTODOS*****************************//
//***********************************************************************//
//***********************************************************************//
/**
* La función principal de éste thread es correr el método actualizar()
* de su padre, que a la vez llama a todos los de los otros objetos.
*/
@Override
public void run() {
while(true){
getPadre().actualizar();
try {
Thread.currentThread().sleep(getPadre().getFps());
} catch (InterruptedException e) {
System.out.println("NOTIFICACIÓN: Error con el framerate del juego: "+ e);
}
}
}
//******************************GETS-&-SETS******************************//
//***********************************************************************//
//***********************************************************************//
/**
* @return the padre
*/
public funGame getPadre() {
return padre;
}
/**
* @param padre the padre to set
*/
public void setPadre(funGame padre) {
this.padre = padre;
}
/**
* @return the runner
*/
public Thread getRunner() {
return runner;
}
/**
* @param runner the runner to set
*/
public void setRunner(Thread runner) {
this.runner = runner;
}
}