-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Code Cleanup and updated finish message
- Loading branch information
1 parent
18a4e04
commit 2c64526
Showing
5 changed files
with
210 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.bongo; | ||
|
||
import javax.swing.*; | ||
import java.awt.*; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
class Canvas extends JComponent { | ||
public void paintComponent(Graphics g){ | ||
g.clearRect(0, 0, Main.window.getWidth(), Main.window.getHeight()); | ||
for(int i=0;i<Main.bongos.length;i++){ | ||
Renderer.Bongo bongo = Main.bongos[i]; | ||
if(bongo!=null){ | ||
if (TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()) - 1 > bongo.getLastSecondValue()) { | ||
Main.bongos[i] = null; | ||
} else { | ||
g.drawImage(bongo.getNote().getCpatch().getAsset(), bongo.getX(), bongo.getY(), this); | ||
g.drawImage(Renderer.get_lhand(bongo.isL_hand()), bongo.getX(), bongo.getY(), this); | ||
g.drawImage(Renderer.get_rhand(bongo.isR_hand()), bongo.getX(), bongo.getY(), this); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.bongo; | ||
|
||
import javax.swing.*; | ||
import java.awt.*; | ||
|
||
class FinishAnimation implements Icon { | ||
private Boolean lhand = true; | ||
private Boolean rhand = false; | ||
|
||
FinishAnimation() { | ||
final Thread renderThread = new Thread(new Runnable() { | ||
@Override | ||
public void run() { | ||
while (true){ | ||
try { | ||
Thread.sleep(200); | ||
} catch (Exception e) { | ||
JOptionPane.showMessageDialog(Main.window, e.getMessage(), "Rendering thread error", JOptionPane.ERROR_MESSAGE); | ||
break; | ||
} | ||
if (component != null) component.repaint(); | ||
} | ||
} | ||
}); | ||
renderThread.start(); | ||
} | ||
|
||
public void paintIcon(Component c, Graphics g, int x, int y) { | ||
if (FinishAnimation.component == null) FinishAnimation.component = c; | ||
g.clearRect(0,0, c.getWidth(), c.getHeight()); | ||
g.drawImage(Renderer.Instr_Categ.Bongo.getAsset(), x, y, c); | ||
g.drawImage(Renderer.get_lhand(lhand), x, y, c); | ||
g.drawImage(Renderer.get_rhand(rhand), x, y, c); | ||
lhand=!lhand; | ||
rhand=!rhand; | ||
} | ||
|
||
private static Component component; | ||
|
||
public int getIconWidth() { | ||
return 380; | ||
} | ||
|
||
public int getIconHeight() { | ||
return 264; | ||
} | ||
} |
Oops, something went wrong.