The paddle of pong keeps shaking without staying at one position - java

Please look at the following structure of my pong game.
gameLoop(); method
//Only run this in another Thread!
private void gameLoop()
{
//This value would probably be stored elsewhere.
final double GAME_HERTZ = 30.0;
//Calculate how many ns each frame should take for our target game hertz.
final double TIME_BETWEEN_UPDATES = 1000000000 / GAME_HERTZ;
//At the very most we will update the game this many times before a new render.
//If you're worried about visual hitches more than perfect timing, set this to 1.
final int MAX_UPDATES_BEFORE_RENDER = 5;
//We will need the last update time.
double lastUpdateTime = System.nanoTime();
//Store the last time we rendered.
double lastRenderTime = System.nanoTime();
//If we are able to get as high as this FPS, don't render again.
final double TARGET_FPS = 60;
final double TARGET_TIME_BETWEEN_RENDERS = 1000000000 / TARGET_FPS;
//Simple way of finding FPS.
int lastSecondTime = (int) (lastUpdateTime / 1000000000);
while (running)
{
double now = System.nanoTime();
int updateCount = 0;
if (!paused)
{
//Do as many game updates as we need to, potentially playing catchup.
while( now - lastUpdateTime > TIME_BETWEEN_UPDATES && updateCount < MAX_UPDATES_BEFORE_RENDER )
{
updateGame();
lastUpdateTime += TIME_BETWEEN_UPDATES;
updateCount++;
}
//If for some reason an update takes forever, we don't want to do an insane number of catchups.
//If you were doing some sort of game that needed to keep EXACT time, you would get rid of this.
if ( now - lastUpdateTime > TIME_BETWEEN_UPDATES)
{
lastUpdateTime = now - TIME_BETWEEN_UPDATES;
}
//Render. To do so, we need to calculate interpolation for a smooth render.
float interpolation = Math.min(1.0f, (float) ((now - lastUpdateTime) / TIME_BETWEEN_UPDATES) );
//float interpolation = 1.0f;
drawGame(interpolation);
lastRenderTime = now;
//Yield until it has been at least the target time between renders. This saves the CPU from hogging.
while ( now - lastRenderTime < TARGET_TIME_BETWEEN_RENDERS && now - lastUpdateTime < TIME_BETWEEN_UPDATES)
{
Thread.yield();
//This stops the app from consuming all your CPU. It makes this slightly less accurate, but is worth it.
//You can remove this line and it will still work (better), your CPU just climbs on certain OSes.
//FYI on some OS's this can cause pretty bad stuttering. Scroll down and have a look at different peoples' solutions to this.
try {Thread.sleep(1);} catch(Exception e) {}
now = System.nanoTime();
}
}
}
}
updateGame(); method
if(p1_up){
if(player.equals("p1")){
p1.moveUp();
}
else
{
p2.moveUp();
}
}
else if(p1_down){
if(player.equals("p1")){
p1.moveDown();
}
else
{
p2.moveDown();
}
}
moveUp(); moveDown(); method of paddle
public void moveUp(){
last_y = y;
last_x = x;
y -= 50.0;
}
public void moveDown(){
last_y = y;
last_x = x;
y += 50.0;
}
drawGame(interpolation); method
public void paintComponent(Graphics g)
{
super.paintComponent(g);
for(int i=0;i<balls.size();i++){
paintBall(g, balls.get(i));
}
drawPaddle(g, p1);
drawPaddle(g, p2);
}
public void drawPaddle(Graphics g, Paddle p){
paddle_drawX = (int)((p.x - p.last_x)*interpolation + p.last_x);
paddle_drawY = (int)((p.y - p.last_y)*interpolation + p.last_y);
g.drawRect(paddle_drawX, paddle_drawY, 10, 50);
}
I am a beginner in game programming so i don't have a good idea about game loops. I found the above fixed time-step game loop in the internet and used it as the game loop for my game. The loop makes the ball move smoothly but the paddle isn't staying at one place when moved. When I move my paddle by pressing one down key stroke then the paddle keeps shaking
without stopping in one spot. The y coordinates of the paddle keeps changing like
33, 45, 20, 59, 34, 59, 34, 59, 33, 59, 34, 58
I know the problem is in interpolation value as it keeps changing value that will change the y coordinate of paddle in render. I have been thinking about this for a while and i don't know how to make the game loop work for any movements so i have come here for some help. I appreciate any suggestion/help!
Here is my full Paddle class.
public class Paddle
{
float x;
float y;
float last_y;
float last_x;
public Paddle(int x, int y)
{
this.x = x;
this.y = y;
this.last_x = x;
this.last_y = y;
}
public void setNewX(int d){
last_y = y;
last_x = x;
x = d;
}
public void setNewY(int d){
last_y = y;
last_x = x;
y = d;
}
public void moveUp(){
last_y = y;
last_x = x;
y -= 50.0;
}
public void moveDown(){
last_y = y;
last_x = x;
y += 50.0;
}
}
and i initiate the paddle position in the main class through global variable.
public Paddle p1 = new Paddle(10, 10);
public Paddle p2 = new Paddle(950, 10);
I have following event listeners for handling key strokes.
Action handle_up_action = new AbstractAction(){
public void actionPerformed(ActionEvent e){
p1_up = true;
}
};
Action handle_up_action_released = new AbstractAction(){
public void actionPerformed(ActionEvent e){
p1_up = false;
}
};
Action handle_down_action = new AbstractAction(){
public void actionPerformed(ActionEvent e){
p1_down = true;
}
};
Action handle_down_action_released = new AbstractAction(){
public void actionPerformed(ActionEvent e){
p1_down = false;
}
};

What are you trying to achieve with interpolation? From my understanding, it represents the percentage of time elapsed between previous previous and next "update time".
So it should progress continuously from 0 to 1 each 33.3 ms.
I don't know how you use this interpolation variable in the paintBall method, but for the paddles, it will draw your paddle at a "pseudo random position" between p.x;p.y and p.last_x;p.last_y (depending on the time between the two updateGame()).
In order to correct this, from your loop logic, you should understand that every game entity (balls, paddles, ...) must have two states (the positions):
- the logical state, which is updated only each TIME_BETWEEN_UPDATES
- the visual state, which can be updated anytime, at each render.
It is the same as if you have a set of points (which represent the logical states) and you want to interpolate anywhere between this points (reprensenting the visual state).
Your code is like this.
First solution
The simplest way to correct the paddle shaking, is to avoid the interpolation and use:
public void drawPaddle(Graphics g, Paddle p){
paddle_drawX = (int)p.x;
paddle_drawY = (int)p.y;
g.drawRect(paddle_drawX, paddle_drawY, 10, 50);
}
But your movement will look like this (visual position will be changed only each TIME_BETWEEN_UPDATES)
Second solution
You want p.x;p.y to be the logical position, but the visual position should be interpolated between p.last_x;p.last_y and the logical position if the rendering is done between the input processing and the next updateGame(): you must reset p.last_x;p.last_y when updateGame() is called. To achieve this, call the paddles' updateMovement() method inside updateGame().
public void updateMovement(){
last_y = y;
last_x = x;
}
You can have other solutions, such as to use a speed variable or a movement function, in order to have a smooth movement, accelerations, and so on. It is mainly a generalisation of second solution. It requires bigger changes, but it is more flexible and powerful. To achieve this, you may want to store in paddles the last "update position", and all movement-related variables, such as movement start date. Add a method to retrieve the "visual position" that can be called with any date between two updates, and a method to update the "logical position" called each updateGame().

Related

Remove enemy when bullet hits them

class Bullet {
float bulletX, bulletY;
float angle;
int x;
int y;
int score; // add a score variable
static final float BULLET_SPEED = 5; // define a constant for the bullet's speed
Bullet(float x, float y, float angle) {
this.bulletX = x;
this.bulletY = y;
this.angle = angle;
}
// Updates the position of the bullet based on its angle and speed.
void update() {
bulletX += cos(angle) * BULLET_SPEED;
bulletY += sin(angle) * BULLET_SPEED;
}
// Draws the bullet image on the screen.
void show() {
drawBullet();
}
// Draws the bullet image on the screen.
void drawBullet() {
image(Bulletimg, bulletX, bulletY);
Bulletimg.resize(30, 30);
}
//Returns true if the bullet is off screen, false otherwise.
boolean offScreen() {
return bulletX < 0 || bulletX > width || bulletY < 0 || bulletY > height;
}
//Checks if the bullet hits the enemy, and updates the score and enemy position accordingly.
// check for collision
void checkCollision(Enemy e) {
float distance = dist(bulletX, bulletY, e.x, e.y);
if (distance < e.x / 2) {
// assuming enemy.size is the radius of the
}
}
}
I tried changing around the check collision(enemy e) block and I'm not sure how i would go about removing an enemy object and also updating my score. i've tried messing about with the draw(); method but i cant seem to figure it out without breaking my entire game. any help with this class would be much appreciated.
You can use/create some attribute in your Enemy object to know/check if is alive or death.
For example in your check collision you can add
if (distance < e.x / 2) {
// assuming enemy.size is the radius of the
e.alive = false
}
Edit: I dont know how your manage the Enemy object and if it can be modified directly in the check collision method if this is not possible then you need to find a way to have access inside the method or use a return and manage that return outside.

Trying to figure how to make a fan to Rotate in Processing

I'm completely new to Java Processing and I am trying to figure out a way to deign a fan which will rotate and increase the speed when press the plus(+) button and decrease when press the negative(-) button. As well as a way to display the speed which the fan is rotating.
final int coverSize=250;
final int centralDiskSize=30;
final int rectSize=50;
final int bladeSize=30;
float xPos=0, yPos=0;
float angle=250;
float bladePosX=0, bladePosY=0;
boolean button = false;
void setup(){
size(500,500);
bladePosX=width/2+coverSize;
bladePosY=height/2;
}
void draw(){
//rotateFan();
drawFan();
btton();
}
void drawFan(){
background(200);
strokeWeight(2);
noFill();
ellipse(xPos+250,yPos+250,coverSize,coverSize);
ellipse(xPos+250,yPos+250,coverSize-40,coverSize-40);
ellipse(xPos+250,yPos+250,coverSize-90,coverSize-90);
ellipse(xPos+250,yPos+250,coverSize-130,coverSize-130);
ellipse(xPos+250,yPos+250,coverSize-180,coverSize-180);
fill(0);
ellipse(xPos+250,yPos+250,centralDiskSize,centralDiskSize);
noFill();
rect(xPos+175,yPos+375,rectSize,rectSize);
rect(xPos+225,yPos+375,rectSize,rectSize);
rect(xPos+275,yPos+375,rectSize,rectSize);
}
void rotateFan(){
background(200);
ellipse(bladePosX,bladePosY,bladeSize,bladeSize);
bladePosX=width/2+coverSize*cos(angle);
bladePosY=height/2+coverSize*sin(angle);
angle=angle+(PI/90);
ellipse(bladePosX,bladePosY,bladeSize,bladeSize);
//ellipse(xPos+250,yPos+250,centralDiskSize,centralDiskSize);
//buttons();
}
void btton(){
if(button){
background(255);
stroke(0);
if (button){
void mousePressed (){
if (mouseX > xPos && mouseX < xPos+rectSize && mouseY > yPos && mouseY < yPos+rectSize){
button = !button;
}
}
Based on the code you posted, I'm guessing that you want to draw a fan, as opposed to having a sprite. The code below is a minimal example of the functionality you want. I highly suggest you familiarize yourself with the translate() and rotate() methods.
The position and rotation of the fan are handled by the translate and rotate methods respectively. By applying these transformations to the entire canvas, we can draw the desired fan with simple statements, without too much math. You can adapt the complexity of the graphic according to your needs, but this is a minimal example.
The rotation speed is expressed in degrees per second, to be intuitive. Thus, when calculating the angle of the fan, the elapsed time between frames must be taken into account. You could use the global time (e.g. millis) instead of the delta time (time between frames), but you would eventually run into overflow problems.
Finally, you can change the speed by adding (a positive or negative) number of degrees per second to the existing fan speed, for every frame the relevant keys are pressed.
You can easily adapt the code to more complex control mechanics, better graphics, using sprites instead of manually drawing the fan etc.
Fan fan;
void setup(){
size(500, 500);
fan = new Fan(width/2, height/2, 50, 360);
}
void draw(){
background(255);
fan.display();
if (keyPressed && key == '+') fan.changeSpeed(1);
if (keyPressed && key == '-') fan.changeSpeed(-1);
}
class Fan {
int x, y;
int size;
float speed; // in degrees per second
private long lastUpdate; // in milliseconds
private float angle; // in degrees
Fan(int x, int y, int size, float speed){
this.x = x;
this.y = y;
this.size = size;
this.speed = speed;
lastUpdate = 0;
angle = 0;
}
void display(){
translate(x, y);
// Update the fan's angle
angle += speed*(millis()-lastUpdate)/1000 % 360;
rotate(radians(angle));
lastUpdate = millis();
// Draw red blade
fill(255, 0, 0);
triangle(0, 0, -size, -3*size, size, -3*size);
// Draw blue blade
rotate(radians(120));
fill(0, 255, 0);
triangle(0, 0, -size, -3*size, size, -3*size);
// Draw green blade
rotate(radians(120));
fill(0, 0, 255);
triangle(0, 0, -size, -3*size, size, -3*size);
translate(-x, -y);
}
void changeSpeed(float amount){
speed += amount;
}
}

moving ball app with acceleration sensor does not look smooth and continuous

I'm trying to learn making games with android using sensors. What I'm trying to do is to make a ball moving in the screen using acceleration sensor. Actually, I did some part of it. The ball moves in the screen when acceleration of x and y changes. But my problem is that it does not look smooth. It looks like the ball is not drawn on the screen in continuous paths. I use the SurfaceView class for this app and I made the drawing on different thread than the main thread.
Below part of code is from my MainActivity class and it is the sensor related part:
#Override
public void onSensorChanged(SensorEvent event) {
// TODO Auto-generated method stub
if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
long actualTime = System.currentTimeMillis();
long delta_t = actualTime - lastUpdate;
lastUpdate = actualTime;
ax = event.values[0];
ay = event.values[1];
if (ax > 0) {
isleft = true;
delta_x = (float) (0.005 * ax * delta_t * delta_t);
}
if (ax < 0) {
isleft = false;
delta_x = (float) (-0.005 * ax * delta_t * delta_t);
}
if (ay > 0) {
isdown = true;
delta_y = (float) (0.005 * ay * delta_t * delta_t);
}
if (ay < 0) {
isdown = false;
delta_y = (float) (-0.005 * ay * delta_t * delta_t);
}
getBallPos();
}
}
private void getBallPos() {
delta_x /= 10000;
delta_y /= 10000;
for (int i = 1; i <= 10000; i++) {
if (isleft)
ballview.setX_loc(ballview.getX_loc() - delta_x);
if (!isleft)
ballview.setX_loc(ballview.getX_loc() + delta_x);
if (isdown)
ballview.setY_loc(ballview.getY_loc() + delta_y);
if (!isdown)
ballview.setY_loc(ballview.getY_loc() - delta_y);
}
}
Below part of code is from my BallGame class that extends SurfaceView and I do the drawings on a different thread:
#Override
public void run() {
// TODO Auto-generated method stub
while (isItOk) {
if (!holder.getSurface().isValid()) {
continue;
}
canvas = holder.lockCanvas();
canvas.drawARGB(255, 150, 150, 10);
// canvas.drawLine(lineStartX, lineStartY, lineEndX, lineEndY,
// paint);
checkBoundaries();
canvas.drawBitmap(ball, x_loc, y_loc, null);
holder.unlockCanvasAndPost(canvas);
}
}
private void checkBoundaries() {
if (x_loc > canvas.getWidth() - ballWidth) {
x_loc = canvas.getWidth() - ballWidth;
}
if (y_loc > canvas.getHeight() - ballHeight) {
y_loc = canvas.getHeight() - ballHeight;
}
if (x_loc < 0) {
x_loc = 0;
}
if (y_loc < 0) {
y_loc = 0;
}
}
Thank you in advance.
I think that there are two problems:
First is, that you are updating the ball position in onSensorChanged method. This method is called by the system and it is not guaranteed that the calling is done in constant frequency. In this case is ball movement depended on these calls. I think the better way would be to store the last ax and ay as a variables which would be accessible by both onSensorChanged method for writing values and drawing thread for reading. Then you can compute ball position in drawing thread, which could redraw canvas with constant frequency.
This brings us to the second problem which is drawing thread while loop. It is not controlled how often is the canvas redrawn. It is big load for system. Better way is to choose the refresh rate (for example 50 frames per second) and update the drawing at this frequency. It could be done at the end of the while loop, where Thread.sleep() function can be called. You can measure when the frame drawing started long frameStartTime = System.currentTimeMillis() at the start of the while loop and then call at the end of the while loop:
long sleepTime = refreshInterval-(System.currentTimeMillis()-frameStartTime );
if (sleepTime > 0) {
Thread.sleep(sleepTime);
}
(for 50 fps is refreshInterval = 1000/50 = 20 ms).
This calling sleeps the thread for the time of frame refresh interval minus time which was used to draw the ball. When you select adequate refresh rate system load will be lower and will have more time for redrawing.

Java 2d game - Issues with delta time and collision

I'm trying to make a java 2d game, and it seems to work out fine in general. The only problem is, that I can't figure out how to place my "delta" time, to make the movements move the same on 30 FPS as on 1000 FPS.
This is my code for the Entity class:
import java.awt.Rectangle;
import map.Tile;
import graphics.Sprite;
public class Entity {
private String name;
private float positionx, positiony; // Current coordinate
private int targetx,targety; // Target coordinate
private double vx, vy; // Current vector
private double lx, ly; // Last vector
private float speed;
private Sprite sprite;
public Entity(String name, int x, int y, Sprite sprite){
this.name = name;
this.speed = 1f;
this.positionx = x;
this.positiony = y;
this.sprite = sprite;
main.Main.e.addEntity(this); // These kind of calls are ugly, and should be fixed.
}
public void remove(){
main.Main.e.removeEntity(this);
sprite.remove();
}
public void setVector(double vx, double vy){
this.vx = vx;
this.vy = vy;
}
public void update(long delta){
//Multiply modifier to make it act the same on 30 fps as 1000 fps.
vx = vx*delta;
vy = vy*delta;
// Calculate vector
double distance = Math.sqrt((vx * vx) + (vy * vy));
if(distance > 0){ // Have we reached the target yet?
vx = ((vx / distance));
vy = ((vy / distance));
}else{
vx = 0;
vy = 0;
}
//Check collision with objects:
Rectangle rx = new Rectangle((int) (vx+positionx), (int)positiony, 32, 32);
Rectangle ry = new Rectangle((int) positionx, (int)(vy+positiony), 32, 32);
for(Entity e : main.Main.e.getEntities()){
if(this != e){
if(isIntersecting(rx, e.getBounds())){
vx = 0; // Disallow x direction.
}
if(isIntersecting(ry, e.getBounds())){
vy = 0; // Disallow y direction.
}
}
}
//Check tiles:
for(Tile t : main.Main.m.getNeighbours(positionx,positiony)){
if(t.isBlocking()){
if(isIntersecting(rx, t.getBounds())){
vx = 0;
}
if(isIntersecting(ry, t.getBounds())){
vy = 0;
}
}
}
//Update the position:
positionx += vx*speed;
positiony += vy*speed;
//Animate:
animate(vx, vy);
}
public boolean isIntersecting(Rectangle r1, Rectangle r2){
return r1.intersects(r2);
}
public Rectangle getBounds(){
return new Rectangle((int) positionx,(int) positiony,32,32);
}
public void setMoveTo(int x, int y){
this.targetx = x;
this.targety = y;
}
//This function is used by the bots, and not on players (they are setting the vector and use update directly):
public void moveTo(long delta){
setVector((targetx-positionx),(targety-positiony));
update(delta);
}
public void animate(double dx, double dy){
sprite.setPosition((int)positionx, (int)positiony);
if(dx > 0){
sprite.setAnimation(0, 7, 100); // Walk right.
}else if(dx < 0){
sprite.setAnimation(1, 7, 100); // Walk left.
}else{
if(lx > 0){
sprite.setAnimation(2, 3, 200); // Stand right.
}else if(lx < 0){
sprite.setAnimation(3, 3, 200); // Stand left.
}
}
lx = dx;
ly = dy;
}
}
The two problems, that I always run into:
1# The game runs differently on 60FPS than on 500FPS.
2# The game runs the same on 60FPS as 500FPS, but my collision screws up, and I can't move closer than 15px from the other object. I think I need to implement something like: If I can't get 10px closer, then move it 10px closer, but I don't know how to implement it.
How can I implement it correctly? That would help a lot!
The easiest way would be to consider that if you want a constant displacement with a constant velocity you can scale all the deltas relative to the delta of 30 FPS like so:
So if you run at 60 FPS but want the same displacement as on 30FPS alpha would be (1/30)/(1/60) = 2
So
Remove vx = vx*delta;
vy = vy*delta;
and change your position update to
alpha = (1.0/30)*delta;
positionx += alpha*vx*speed;
positiony += alpha*vy*speed;
This is only a crude solution, let me know how it works, I will drop in later and update for a more correct solution (taking into account that delta is not always 1/FPS due to rendering and computation taking some time).
Edit: Variable delta will come later. But some optimizations:
You don't need to construct a rectangle in both Y and X for collisiondetection, try drawing two rectangles, if they intersect they do so on both axis. Just create a rectangle from vx + posx, vy+posy and check for intersection with this.
The above should half your collisionchecks. For further optimization consider using a QuadTree an implementation can be found here.
For the problem of "blocky" collision testing (where you stop X pixels from the blocking object). You can do the following, in pseudocode:
if(new position will make this colide)
while(this.position is more than one pixel away from blocking object)
keep moving one pixel
This will make you stop 1px from the target.

How can I delay each bullet? (Java -Slick2d - Game)

(The event listener is in another class) When Game.render = true, i get a constant stream of bullets that look more like a laser-beam, i want there to be gaps. What I mean is that I would like the bullets to be generated as if they were being fired from a machine gun. I know i should add a time or something, but I'm not sure how to do that, to get the effect I want. Any help would be greatly appreciated because I've been trying to get this to work for about an hour now.
import java.util.ArrayList;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;
public class Bullet {
// ArrayList
#SuppressWarnings("unchecked")
static ArrayList<Bullet> arrL = new ArrayList();
public Bullet(int x , int y) throws SlickException{
}
public static void update(GameContainer gc, int u) throws SlickException{
// when the left mouse button is clicked Game.fire = true, the key listener is in another class
if(Game.fire){
Bullet b = new Bullet(5,5);
arrL.add(b);
reloaded = false;
} if(!reloaded){
}
}
public static void renderBullets(GameContainer gc, Graphics g, int x, int y) {
// draws a new bullet for every 'bullet object' in the ArrayList called arrL
for(Bullet b : arrL){
g.drawRect(x,y,10,10);
x++;
}
}
}
What I do most frequently in this kind of situation is add a time variable that I subtract the delta (the variable you have as u) from every update until it goes below 0, at which point I reset it:
// Set this to whatever feels right for the effect you're trying to achieve.
// A larger number will mean a longer delay.
private static int default_bullet_delay = 500;
private static int time = 0;
public static void update (GameContainer gc, int u) throws SlickException {
time -= u;
if (time <= 0 && Game.fire) {
fireBullet(); // Replace this with your code for firing the bullet
time = default_bullet_delay; // Reset the timer
}
// The rest of the update loop...
}
Basically, even if Game.fire is true the bullet won't fire until the timer counts down. Once that happens, the timer is set and the next bullet can't fire until the timer counts down again. If you set this to something reasonably small then there should be a bit of a gap between each bullet.
This is how I did this:
boolean reloaded = false; // Start with a reload becouse weapon not reload itself
float reloadTime = 100; // This is the "timer" (the value doesnt matter)
float startReloadTime = 100; // This is the actual reload time
private void shoot(int delta, float screenWidth, float screenHeight) {
// reload if not reloaded
if (!reloaded) {
reloadTime -= 0.5f * delta; // As I said, this is the timer
// If the reload finished, set the timer back to the reload time
if (reloadTime <= 0) {
reloaded = true; // reloaded, we can shoot
reloadTime = startReloadTime;
}
}
// Shoot only if reloaded
if (reloaded) {
// This is some direction calculating, ignore for now
float mouseWorldX = (x + (mouseX - screenWidth / 2));
float mouseWorldY = (y + (mouseY - screenHeight / 2));
float randomX = (float) Math.random() * (2000 / mouseWorldX);
float randomY = (float) Math.random() * (2000 / mouseWorldY);
mouseWorldX += randomX;
mouseWorldY += randomY;
// Add a new bullet element to the world (where will be rendered)
world.add(new Shot(world, camera, x + width / 2, y + height / 2, mouseWorldX - 2.5f, mouseWorldY - 2.5f, 5, 5, new Color(1, 0, 0, 1f)));
// We need to reload
reloaded = false;
}
}

Categories