home *** CD-ROM | disk | FTP | other *** search
- package com.next.gt;
-
- import java.awt.Graphics;
- import java.awt.Image;
-
- public abstract class Actor {
- protected Image image;
- protected int numFrames;
- public int width;
- public int height;
- public int currentFrame = 0;
- protected int hFrames;
- // $FF: renamed from: x double
- public double field_0;
- // $FF: renamed from: y double
- public double field_1;
- public double x_old;
- public double y_old;
- public double velocity_x;
- public double velocity_y;
- public Gamelication owner;
- public boolean wrapAround = true;
-
- public void tick() {
- this.calculateCurrentFrame();
- this.calculateNewPosition();
- this.calculateNewVelocity();
- }
-
- protected void setImage(Image var1, int var2, int var3, int var4, int var5) {
- this.width = var2;
- this.height = var3;
- this.numFrames = var5;
- this.hFrames = var4;
- this.image = var1;
- }
-
- protected void setImage(Image var1) {
- int var2;
- do {
- var2 = var1.getHeight(this.owner);
- } while(var2 == -1);
-
- int var3;
- do {
- var3 = var1.getWidth(this.owner);
- } while(var3 == -1);
-
- this.setImage(var1, var3, var2, 1, 1);
- }
-
- protected void setImage(Image var1, int var2, int var3) {
- int var4;
- do {
- var4 = var1.getHeight(this.owner);
- } while(var4 == -1);
-
- int var5;
- do {
- var5 = var1.getWidth(this.owner);
- } while(var5 == -1);
-
- this.setImage(var1, var5 / var2, var4 / (int)Math.ceil((double)var3 / (double)var2), var2, var3);
- }
-
- protected void calculateNewPosition() {
- double var1 = this.owner.deltaTickTimeMillis() / (double)1000.0F;
- this.x_old = this.field_0;
- this.y_old = this.field_1;
- this.field_0 += this.velocity_x * var1;
- this.field_1 += this.velocity_y * var1;
- if (this.wrapAround) {
- this.checkForOutOfBounds();
- }
-
- }
-
- protected void calculateNewVelocity() {
- }
-
- protected void calculateCurrentFrame() {
- if (++this.currentFrame >= this.numFrames) {
- this.currentFrame = 0;
- }
-
- }
-
- protected void checkForOutOfBounds() {
- if (this.field_0 > (double)(this.owner.getSize().width + this.width + this.width)) {
- this.field_0 = (double)(-this.width);
- } else if (this.field_0 < (double)(-this.width)) {
- this.field_0 = (double)(this.owner.getSize().width + this.width + this.width);
- }
-
- if (this.field_1 > (double)(this.owner.getSize().height + this.height + this.height)) {
- this.field_1 = (double)(-this.height);
- } else {
- if (this.field_1 < (double)(-this.height)) {
- this.field_1 = (double)(this.owner.getSize().height + this.height + this.height);
- }
-
- }
- }
-
- public void draw(Graphics var1) {
- double var2 = (double)(-(this.currentFrame % this.hFrames) * this.width);
- double var4 = -Math.floor((double)(this.currentFrame / this.hFrames)) * (double)this.height;
- Graphics var6 = var1.create((int)this.field_0, (int)this.field_1, this.width, this.height);
- var6.drawImage(this.image, (int)var2, (int)var4, this.owner);
- var6.dispose();
- }
-
- protected void collideWithActor(Actor var1) {
- }
-
- public void bounceOff(Actor var1) {
- double var2 = (double)(this.width / 2) + this.x_old;
- double var4 = (double)(this.height / 2) + this.y_old;
- double var6 = (double)(var1.width / 2) + var1.field_0;
- double var8 = (double)(var1.height / 2) + var1.field_1;
- double var10 = (var4 - var8) / (var2 - var6);
- double var12 = var4 - var10 * var2;
- if (var1.field_0 >= var2) {
- double var14 = var10 * var1.field_0 + var12;
- if (var14 >= var1.field_1 && var14 <= var1.field_1 + (double)var1.height) {
- this.velocity_x = var1.velocity_x - this.velocity_x;
- this.field_0 = this.x_old;
- return;
- }
- } else if (var1.field_0 + (double)var1.width <= var2) {
- double var18 = var10 * (var1.field_0 + (double)var1.width) + var12;
- if (var18 >= var1.field_1 && var18 <= var1.field_1 + (double)var1.height) {
- this.velocity_x = var1.velocity_x - this.velocity_x;
- this.field_0 = this.x_old;
- return;
- }
- } else if (var1.field_1 >= var4) {
- double var16 = (var1.field_1 - var12) / var10;
- if (var16 >= var1.field_0 && var16 <= var1.field_0 + (double)var1.width) {
- this.velocity_y = var1.velocity_y - this.velocity_y;
- this.field_1 = this.y_old;
- return;
- }
- } else if (var1.field_1 + (double)var1.height <= var4) {
- double var19 = (var1.field_1 + (double)var1.height - var12) / var10;
- if (var19 >= var1.field_0 && var19 <= var1.field_0 + (double)var1.width) {
- this.velocity_y = var1.velocity_y - this.velocity_y;
- this.field_1 = this.y_old;
- }
- }
-
- }
- }
-