Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private double angle;
- public Bullet(int xx, int yy, int x, int y,Gun gun, int id, double angle) {
- this.x = xx;
- this.y = yy;
- tx = x;
- ty = y;
- xorg = xx;
- yorg = yy;
- this.gun = gun;
- this.id = id;
- this.angle = angle;
- try {
- image = new MImage(ImageIO.read(new File("PATH")));
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- image.rotateBy((int)Math.toDegrees(angle));
- stopwatch.start();
- }
- private int speed = 3,time = 0;;
- public void update() {
- double speedy, speedx;
- speedy = speed * Math.sin(Math.toRadians(angle));
- speedx = speed * Math.cos(Math.toRadians(angle));
- y = (int) ((-5) * time * time + speedy * time + yorg);
- x = (int) (speedx * time + xorg);
- time++;
- System.out.println(y + " --- " + x);
- if(stopwatch.getElapsedTime() > 500) {
- terminate(id);
- }
- }
- public boolean shoot(int x, int y, int tx, int ty) {
- boolean worked = false;
- if(amo >= 0) {
- bullets.add(new Bullet(x,y,tx,ty,this,bullets.size(),Math.atan2(ty-y,tx-x)));
- amo --;
- worked = true;
- }
- return worked;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement