-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMain.java
More file actions
55 lines (42 loc) · 1.56 KB
/
Copy pathMain.java
File metadata and controls
55 lines (42 loc) · 1.56 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
package testing.sin;
import javagameengine.JavaGameEngine;
import javagameengine.Scene;
import javagameengine.components.CameraMovement;
import javagameengine.components.Component;
import javagameengine.components.GameObject;
import javagameengine.input.Input;
import javagameengine.input.Keys;
import javagameengine.msc.Vector2;
import java.awt.*;
public class Main extends JavaGameEngine {
public static void main(String[] args){
Scene s = new Scene();
s.getCamera().setPosition(new Vector2(0,200));
Component renderer = new Component(){
float magnitude = 50;
float periods = 0.1f;
@Override
public void update() {
super.update();
if(Input.isKeyDown(Keys.UPARROW)) magnitude++;
if(Input.isKeyDown(Keys.DOWNARROW)) magnitude--;
if(Input.isKeyDown(Keys.RIGHTARROW)) periods+=0.1f;
if(Input.isKeyDown(Keys.LEFTARROW)) periods-=0.1f;
}
@Override
public void render(Graphics2D g) {
super.render(g);
for(int i = -300;i<300;i++){
int y = (int) ((int) magnitude*Math.sin(Math.toRadians(i)*periods));
int y2 = (int) ((int) magnitude*Math.cos(Math.toRadians(i)*periods));
g.fillOval(y2,y,10,10);
g.fillOval(i,y2,10,10);
}
}
};
s.add(renderer);
s.getCamera().add(new CameraMovement());
setSelectedScene(s);
start();
}
}