File tree Expand file tree Collapse file tree 9 files changed +18
-20
lines changed
Expand file tree Collapse file tree 9 files changed +18
-20
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ public class GameWorld extends JPanel{
2020 This is where the main game world where we draw everything
2121 we also gets all the inpus from here
2222 */
23+ public static String fps = "0" ;
2324 public GameWorld () {
2425 /*
2526 Key keyboard inputs
@@ -119,6 +120,7 @@ private void drawUi(Graphics g){
119120 private void drawComponents (Graphics g ){
120121 for (Component c : ComponentHandler .getObjects ()){
121122 (c ).draw (g );
123+ g .drawString (fps ,0 ,10 );
122124 }
123125 }
124126}
Original file line number Diff line number Diff line change @@ -28,13 +28,8 @@ private LinkedList<Component> UpdateObjects()
2828 {
2929
3030 for (Component component : ComponentHandler .getObjects ()) {
31- if ((component ).getTag ()!="player" ){
32- component .setCameraPosition (UpdateThread .camera .getPosition ());
33- }
34- else {
35- component .setCameraPosition (UpdateThread .camera .getPosition ().devide (4 ));
36- }
3731
32+ //component.setCameraPosition(UpdateThread.camera.getPosition().devide(4));
3833 component .update ();
3934 }
4035 return ComponentHandler .getObjects ();
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ public class GameObject extends Component{
1515 * this is the method that draws the GameObject
1616 */
1717
18- private Color color ;
18+ private Color color = Color . darkGray ;
1919
2020 public void setColor (Color color ) {
2121 this .color = color ;
Original file line number Diff line number Diff line change 11package JavaGameEngine .Components .Physics ;
22
33import JavaGameEngine .Components .Component ;
4+ import JavaGameEngine .JavaGameEngine ;
45import JavaGameEngine .msc .Vector2 ;
56
67public class PhysicsBody extends Component {
Original file line number Diff line number Diff line change 11package JavaGameEngine .Components .Physics ;
22
3+ import JavaGameEngine .JavaGameEngine ;
34import JavaGameEngine .msc .Vector2 ;
45
56public class PhysicsWorld {
67
7- public static Vector2 gravityAcceleration =new Vector2 (0 ,0.0982f );
8+ public static Vector2 gravityAcceleration =new Vector2 (0 ,9.82f * JavaGameEngine . DELAY / 10000 );
89
910
1011 public static Vector2 getGravityAcceleration () {
Original file line number Diff line number Diff line change 1111
1212public class JavaGameEngine {
1313
14- public static final int DELAY = 16 ;
14+ public static int DELAY = 3 ;
1515 public static GameWorld GAMEWORLD = new GameWorld ();
1616 static JFrame frame ;
1717 private static float start ;
@@ -61,11 +61,7 @@ private static void startGame(){
6161 timer .schedule (new TimerTask () {
6262 @ Override
6363 public void run () {
64-
65-
6664 calcThread .Update ();
67-
68-
6965 }
7066 }, DELAY ,DELAY );
7167 Timer timer1 = new Timer ();
@@ -77,9 +73,11 @@ public void run() {
7773 previous = current ;
7874 // Debug.log(totalElapsed);
7975 GAMEWORLD .repaint ();
80- Toolkit .getDefaultToolkit ().sync (); // so it does not lag on linuxddddd
76+ Toolkit .getDefaultToolkit ().sync (); // so it does not lag on linux
8177 totalElapsed += deltaTime ;
78+
8279 if ((totalElapsed /1000000000 )>1 ){
80+ GameWorld .fps = String .valueOf (fps );
8381 totalElapsed = 0 ;
8482 fps = 0 ;
8583 }
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ public Coin() {
2020 paths [i ] = ("/Free Platform Game Assets/Platform Game Assets/Coin Animation/png/2x/image " +(i +1 )+".png" );
2121 }
2222 sprite .loadAnimation (paths );
23- sprite .setTimer (4 );
23+ sprite .setTimer (20 );
2424
2525 setScale (new Vector2 (16 ,16 ));
2626 addChild (sprite );
@@ -47,7 +47,7 @@ public void update() {
4747 if (getPosition ().getY ()>mindown ){
4848 setRotation (Vector2 .up );
4949 }
50- setPosition (getPosition ().add (getRotation ().multiply (1 )));
50+ setPosition (getPosition ().add (getRotation ().multiply (0.2f )));
5151
5252 }
5353}
Original file line number Diff line number Diff line change @@ -51,16 +51,17 @@ public void update() {
5151 super .update ();
5252
5353 if (Input .isKeyDown ((Keys .D ))){
54- movePosition (getPosition ().add (Vector2 .right .multiply (2 )));
54+ movePosition (getPosition ().add (Vector2 .right .multiply (1.2f )));
5555 //UpdateThread.camera.setX(UpdateThread.camera.getX()+2);
5656 }
5757 if (Input .isKeyDown ((Keys .A ))){
58- movePosition (getPosition ().add (Vector2 .left .multiply (2 )));
58+ movePosition (getPosition ().add (Vector2 .left .multiply (1.2f )));
5959
6060 //UpdateThread.camera.setX(UpdateThread.camera.getX()-2);
6161 }
6262 if (Input .isKeyPressed (Keys .SPACE )){
63- physicsBody .addForce (Vector2 .up ,300 );
63+
64+ physicsBody .addForce (Vector2 .up ,60 );
6465 }
6566 //UpdateThread.camera = this.getPosition();
6667 }
You can’t perform that action at this time.
0 commit comments