Skip to content

Commit 0eaf2e9

Browse files
committed
deltas
1 parent c4708ff commit 0eaf2e9

15 files changed

+34
-49
lines changed

.vscode/launch.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
"configurations": [
77
{
88
"type": "java",
9-
"name": "Current File",
9+
"name": "Windows",
1010
"request": "launch",
11-
"mainClass": "${file}"
11+
"mainClass": "com.game.DesktopLauncher",
12+
"projectName": "spacerocks",
1213
},
1314
{
1415
"type": "java",
+7-14
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,20 @@
11
package com.game;
22

33
import com.badlogic.gdx.Game;
4-
import com.badlogic.gdx.Gdx;
5-
import com.badlogic.gdx.graphics.GL20;
6-
import com.badlogic.gdx.graphics.Texture;
7-
import com.badlogic.gdx.graphics.g2d.Batch;
8-
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
9-
import com.game.engine.Manager;
10-
import com.game.engine.systems.LocationSystem;
11-
import com.game.engine.systems.RenderingSystem;
4+
import com.game.screens.MainGameScreen;
125

136
public class SpaceRocks extends Game {
147

15-
8+
public static final MainGameScreen _mainGameScreen = new MainGameScreen();
169

1710
@Override
1811
public void create() {
19-
12+
setScreen(_mainGameScreen);
2013
}
2114

22-
public void render(){
23-
24-
25-
}
15+
@Override
16+
public void dispose(){
17+
_mainGameScreen.dispose();
18+
}
2619

2720
}

src/main/java/com/game/engine/components/GraphicsComponent.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22

33
import com.badlogic.gdx.graphics.Texture;
44
import com.badlogic.gdx.graphics.g2d.Batch;
5-
import com.badlogic.gdx.graphics.g2d.TextureRegion;
65
import com.badlogic.gdx.math.Vector2;
7-
import com.game.engine.entities.Entity;
86

97
public abstract class GraphicsComponent implements Component{
108

119
protected Texture _texture;
1210
protected Vector2 _currentPosition;
13-
public abstract void update(Entity entity, Batch batch, float delta);
11+
public abstract void update(Batch batch, float delta);
1412
}
13+

src/main/java/com/game/engine/components/laser/LaserGraphicsComponent.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import com.badlogic.gdx.graphics.g2d.Batch;
44
import com.game.engine.components.GraphicsComponent;
5-
import com.game.engine.entities.Entity;
65

76
public class LaserGraphicsComponent extends GraphicsComponent{
87

@@ -19,7 +18,7 @@ public void receiveMessage(String message) {
1918
}
2019

2120
@Override
22-
public void update(Entity entity, Batch batch, float delta) {
21+
public void update(Batch batch, float delta) {
2322
// TODO Auto-generated method stub
2423
throw new UnsupportedOperationException("Unimplemented method 'update'");
2524
}

src/main/java/com/game/engine/components/player/PlayerGraphicsComponent.java

+5-6
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,13 @@
66
import com.badlogic.gdx.graphics.g2d.Sprite;
77
import com.badlogic.gdx.math.Vector2;
88
import com.game.engine.components.GraphicsComponent;
9-
import com.game.engine.entities.Entity;
109

1110
public class PlayerGraphicsComponent extends GraphicsComponent {
1211

1312
Sprite sprite;
1413
public PlayerGraphicsComponent(){
1514
this._texture = new Texture(Gdx.files.internal("assets/spaceship.png"));
16-
this.sprite = new Sprite(this._texture);
1715
this._currentPosition = new Vector2(400,400);
18-
this.sprite.setPosition(this._currentPosition.x, this._currentPosition.y);
1916

2017
}
2118
@Override
@@ -27,13 +24,15 @@ public void dispose() {
2724
@Override
2825
public void receiveMessage(String message) {
2926
// TODO Auto-generated method stub
30-
throw new UnsupportedOperationException("Unimplemented method 'receiveMessage'");
27+
String[] string = message.split(MESSAGE_TOKEN);
3128
}
3229

3330
@Override
34-
public void update(Entity entity, Batch batch, float delta) {
31+
public void update(Batch batch, float delta) {
3532
// TODO Auto-generated method stub
36-
throw new UnsupportedOperationException("Unimplemented method 'update'");
33+
34+
batch.draw(this._texture, this._currentPosition.x, this._currentPosition.y);
35+
3736
}
3837

3938
}

src/main/java/com/game/engine/components/rock/RockGraphicsComponent.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import com.badlogic.gdx.graphics.g2d.Batch;
44
import com.game.engine.components.GraphicsComponent;
5-
import com.game.engine.entities.Entity;
65

76
public class RockGraphicsComponent extends GraphicsComponent {
87

@@ -19,7 +18,7 @@ public void receiveMessage(String message) {
1918
}
2019

2120
@Override
22-
public void update(Entity entity, Batch batch, float delta) {
21+
public void update( Batch batch, float delta) {
2322
// TODO Auto-generated method stub
2423
throw new UnsupportedOperationException("Unimplemented method 'update'");
2524
}

src/main/java/com/game/engine/entities/Entity.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public Entity(ControlComponent control, PhysicsComponent physics, GraphicsCompon
3535

3636
// public void setGraphics(){}
3737
public void update(Batch batch, float delta){
38-
_graphicsComponent.update(this, batch, delta);
38+
_graphicsComponent.update( batch, delta);
3939

4040
}
4141

src/main/java/com/game/screens/MainGameScreen.java

+14-19
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
import com.badlogic.gdx.graphics.Texture;
99
import com.badlogic.gdx.graphics.g2d.Batch;
1010
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
11-
import com.badlogic.gdx.math.Rectangle;
12-
import com.badlogic.gdx.scenes.scene2d.Stage;
13-
import com.badlogic.gdx.scenes.scene2d.ui.List;
1411
import com.game.engine.Manager;
1512
import com.game.engine.entities.Entity;
1613
import com.game.engine.entities.EntityFactory;
@@ -20,23 +17,25 @@
2017

2118
public class MainGameScreen implements Screen{
2219

23-
private Batch batch;
24-
private Texture space;
25-
private Manager manager;
20+
21+
private Batch _batch;
22+
private Texture _space;
23+
private Manager _manager;
2624
private Entity _player;
2725
private ArrayList<Entity> rocks;
2826

2927

3028
public MainGameScreen(){
31-
batch = new SpriteBatch();
32-
space = new Texture(Gdx.files.internal("assets/space.png"));
33-
manager = Manager.getInstance();
34-
manager.init(new RenderingSystem(), new LocationSystem());
29+
30+
_manager = Manager.getInstance();
31+
_manager.init(new RenderingSystem(), new LocationSystem());
3532
}
3633
@Override
3734
public void show() {
3835
_player = EntityFactory.createEntity(EntityType.PLAYER);
39-
manager.setPlayer(_player);
36+
_manager.setPlayer(_player);
37+
_batch = new SpriteBatch();
38+
_space = new Texture(Gdx.files.internal("assets/space.png"));
4039

4140
}
4241

@@ -46,42 +45,38 @@ public void render(float delta) {
4645
Gdx.gl.glClearColor(0,0,0, 1);
4746
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
4847

49-
batch.begin();
48+
_batch.begin();
5049

5150
// Call update methods
52-
batch.draw(space,0,0);
53-
batch.end();
51+
_batch.draw(_space,0,0);
52+
_player.update(_batch, delta);
53+
_batch.end();
5454

5555
}
5656

5757
@Override
5858
public void resize(int width, int height) {
5959
// TODO Auto-generated method stub
60-
throw new UnsupportedOperationException("Unimplemented method 'resize'");
6160
}
6261

6362
@Override
6463
public void pause() {
6564
// TODO Auto-generated method stub
66-
throw new UnsupportedOperationException("Unimplemented method 'pause'");
6765
}
6866

6967
@Override
7068
public void resume() {
7169
// TODO Auto-generated method stub
72-
throw new UnsupportedOperationException("Unimplemented method 'resume'");
7370
}
7471

7572
@Override
7673
public void hide() {
7774
// TODO Auto-generated method stub
78-
throw new UnsupportedOperationException("Unimplemented method 'hide'");
7975
}
8076

8177
@Override
8278
public void dispose() {
8379
// TODO Auto-generated method stub
84-
throw new UnsupportedOperationException("Unimplemented method 'dispose'");
8580
}
8681

8782

267 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-178 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)