Skip to content

Commit 4b6c0e9

Browse files
committed
Avatar mask.
1 parent 2a71a89 commit 4b6c0e9

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/code_swarm.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public class code_swarm extends PApplet {
6363
int FRAME_RATE = 24;
6464
long UPDATE_DELTA = -1;
6565
String SPRITE_FILE = "particle.png";
66+
String MASK_FILE = "src/mask.png";
6667
String SCREENSHOT_FILE;
6768
int background;
6869

@@ -93,6 +94,7 @@ public class code_swarm extends PApplet {
9394
PFont font;
9495
PFont boldFont;
9596
PImage sprite;
97+
PImage avatarMask;
9698

9799
boolean paused = false;
98100

@@ -332,6 +334,8 @@ public void setup() {
332334
String SPRITE_FILE = cfg.getStringProperty(CodeSwarmConfig.SPRITE_FILE_KEY);
333335
// Create the file particle image
334336
sprite = loadImage(SPRITE_FILE);
337+
avatarMask = loadImage(MASK_FILE);
338+
avatarMask.resize(cfg.getPositiveIntProperty("AvatarSize"), cfg.getPositiveIntProperty("AvatarSize"));
335339
// Add translucency (using itself in this case)
336340
sprite.mask(sprite);
337341
}
@@ -1476,7 +1480,10 @@ class PersonNode extends Node {
14761480
mLastPosition.add(mPhysicsEngine.startVelocity(this));
14771481
mFriction = 0.99f;
14781482
String iconFile = avatarFetcher.fetchUserImage(name);
1479-
if (iconFile != null) icon = loadImage(iconFile, "unknown");
1483+
if (iconFile != null) {
1484+
icon = loadImage(iconFile, "unknown");
1485+
icon.mask(avatarMask);
1486+
}
14801487
}
14811488

14821489
/**

src/mask.png

2.96 KB
Loading

0 commit comments

Comments
 (0)