Skip to content

First Release

Compare
Choose a tag to compare
@nathanwood1 nathanwood1 released this 15 Feb 00:04
· 11 commits to master since this release

To show (almost) everything in this build:

import java.awt.Graphics2D;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.Color;
import javax.swing.JFrame;

import sjcc.SJCC;

public class TestWindow extends SJCC {

  public static void main(String[] args) {
    TestWindow t = new TestWindow();
    t.WIDTH = 800; //Example
    t.HEIGHT = 600;
    t.TITLE = "Test Window";
    t.POSITION = null; //null = centre
    t.RESIZEABLE = false;
    t.ON_CLOSE = JFrame.EXIT_ON_CLOSE;
    t.start();
  }

  @Override
  public void render(Graphics2D g, double delta) {
    if (getMouseWheel() != 0) {
      System.out.println("Mouse wheel moved!");
    }
    if (getKey(KeyEvent.VK_SPACE) == 0) {
      System.out.println("Space just pressed!");
    }
    if (mousePressed()) {
      if (mouseButton() == MouseEvent.BUTTON1) {
        System.out.println("Left mouse button pressed at " + 
        clickMousePoint().x + ", " + clickMousePoint().y);
      }
    }
    if (mouseDown()) {
      g.setColor(Color.WHITE);
      g.drawLine(clickMousePoint().x, clickMousePoint().y, currentMousePoint().x, currentMousePoint().y);
    }
  }

}