2,255 bytes. That’s how big my 4K entry is so far and all it does is open a double buffered window and listen for mouse and keyboard input.
How the hell do you guys get so much into 4K???
Cas
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.awt.image.BufferStrategy;
import java.awt.image.BufferedImage;
/**
* 4k entry
*/
/**
* @author foo
*/
public class G implements MouseMotionListener, MouseListener, KeyListener, WindowListener{
static Frame w;
static G g;
static BufferStrategy s;
public static void main(String[] a) {
g = new G();
// Create our frame
w = new Frame("4k");
w.addWindowListener(g);
w.addKeyListener(g);
w.addMouseListener(g);
w.addMouseMotionListener(g);
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
w.setBounds((d.width - 320) / 2, (d.height - 320) / 2, 320, 320);
w.setCursor(Toolkit.getDefaultToolkit().createCustomCursor(new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB), new Point(0, 0), ""));
// Show our window
w.setVisible(true);
// Create a general double-buffering strategy
w.createBufferStrategy(2);
s = w.getBufferStrategy();
// Main loop
for (;;) {
long t = System.nanoTime();
// Render single frame
do {
do {
// Get a new graphics context every time through the loop
// to make sure the strategy is validated
Graphics g = s.getDrawGraphics();
// Draw background
g.setColor(Color.black);
g.fillRect(0, 0, 320, 320);
// Dispose the graphics
g.dispose();
// Repeat the rendering if the drawing buffer contents
// were restored
} while (s.contentsRestored());
// Display the buffer
s.show();
// Repeat the rendering if the drawing buffer was lost
} while (s.contentsLost());
// Sync to frame rate, always sleep at least 1ms
long n = t + 1;
while (n > t && (n - t) < 2000000) {
try {
Thread.sleep(1);
} catch (InterruptedException e) {
}
n = System.nanoTime();
}
}
}
public void mouseDragged(MouseEvent e) {
}
public void mouseMoved(MouseEvent e) {
mouseDragged(e);
}
public void mouseClicked(MouseEvent e) {
}
public void mousePressed(MouseEvent e) {
}
public void mouseReleased(MouseEvent e) {
}
public void mouseEntered(MouseEvent e) {
}
public void mouseExited(MouseEvent e) {
}
public void keyTyped(KeyEvent e) {
}
public void keyPressed(KeyEvent e) {
}
public void keyReleased(KeyEvent e) {
}
public void windowOpened(WindowEvent e) {
}
public void windowClosing(WindowEvent e) {
System.exit(0);
}
public void windowClosed(WindowEvent e) {
}
public void windowIconified(WindowEvent e) {
}
public void windowDeiconified(WindowEvent e) {
}
public void windowActivated(WindowEvent e) {
}
public void windowDeactivated(WindowEvent e) {
}
}