Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.fundynamic.d2tm.game.entities.EntityType;
import com.fundynamic.d2tm.game.types.EntityData;
import com.fundynamic.d2tm.math.Coordinate;
import com.fundynamic.d2tm.math.Random;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.SpriteSheet;
Expand All @@ -17,10 +18,12 @@ public class Particle extends Entity implements Destructible {
private float sprite = 0;
private float animationSpeed;
private float alpha = 1.0f;
private float scale = 1.0f;

public Particle(Coordinate coordinate, SpriteSheet spriteSheet, EntityData entityData, EntityRepository entityRepository) {
super(coordinate, spriteSheet, entityData, null, entityRepository);
animationSpeed = entityData.animationSpeed;
// scale += Math.random() * 3;
}

@Override
Expand All @@ -32,9 +35,13 @@ public EntityType getEntityType() {
public void render(Graphics graphics, int x, int y) {
if (graphics == null) throw new IllegalArgumentException("Graphics must be not-null");
Image sprite = getSprite();

sprite.setImageColor(1, 1, 1, alpha);
graphics.drawImage(sprite, x, y);
sprite.draw(x, y, scale);
sprite.setImageColor(1, 1, 1, 1);

graphics.resetTransform();
graphics.scale(1f,1f);
}

public Image getSprite() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,24 @@ public void render(Graphics graphics, int x, int y) {
Image sprite = getSprite();

if (height > 0) {
drawShadowImage(graphics, x, y, sprite);
int shadowX = x + Math.round(height / 8);

float shadowTransparancy = 0.5f;
shadowTransparancy -= (0.4f * (height/entityData.maxAscensionHeight));
shadowTransparancy = Math.max(shadowTransparancy, 0f);
sprite.setImageColor(0, 0, 0, shadowTransparancy); // set color of image to black, transparent

float shadowScale = 1.0f + (0.25f * (height/entityData.maxAscensionHeight));
float scale = 1.0f + (0.5f * (height/entityData.maxAscensionHeight));

graphics.setAntiAlias(true);
sprite.draw(shadowX, y, shadowScale);
graphics.setAntiAlias(false);
sprite.setImageColor(1, 1, 1, 1); // restore drawing to opaque
sprite.draw(x, (y - height), scale);
} else {
graphics.drawImage(sprite, x, (y - height));
}

graphics.drawImage(sprite, x, (y - height));
}

public void drawShadowImage(Graphics graphics, int x, int y, Image sprite) {
sprite.setImageColor(0, 0, 0, 0.5f); // set color of image to black, transparent
int shadowX = x + Math.round(height / 8);
graphics.drawImage(sprite, shadowX, y);
sprite.setImageColor(1, 1, 1, 1); // restore drawing to opaque
}

public Image getSprite() {
Expand Down