Created
August 24, 2015 23:29
-
-
Save sylvia43/8a4de941cea7c1408fe5 to your computer and use it in GitHub Desktop.
Scala vs. Java
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
import asciiPanel.AsciiPanel; | |
import game.screens.Screen; | |
import game.screens.StartScreen; | |
import java.awt.Color; | |
import java.awt.event.KeyEvent; | |
import java.awt.event.KeyListener; | |
import javax.swing.JFrame; | |
public class Window extends JFrame implements KeyListener { | |
private AsciiPanel terminal; | |
public Window() { | |
super(); | |
terminal = new AsciiPanel(); | |
add(terminal); | |
pack(); | |
addKeyListener(this); | |
repaint(); | |
} | |
@Override | |
public void repaint() { | |
terminal.clear(); | |
terminal.writeCenter("HELLO!!!1", 10); | |
super.repaint(); | |
} | |
@Override | |
public void keyPressed(KeyEvent e) { | |
screen = screen.respondToUserInput(e); | |
repaint(); | |
} | |
@Override | |
public void keyReleased(KeyEvent e) { } | |
@Override | |
public void keyTyped(KeyEvent e) { } | |
public static void main(String[] args) { | |
Window window = new Window(); | |
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | |
window.setVisible(true); | |
window.setBackground(Color.black); | |
window.setTitle("Dungeon Dive"); | |
} | |
} |
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
import java.awt.Color | |
import java.awt.event.{KeyEvent, KeyListener} | |
import javax.swing.JFrame | |
import asciiPanel.AsciiPanel | |
object Window extends JFrame() with KeyListener { | |
def main (args: Array[String]) { | |
Window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) | |
Window.setVisible(true) | |
Window.setBackground(Color.BLACK) | |
Window.setTitle("ScalaRL") | |
} | |
val terminal = new AsciiPanel() | |
add(terminal) | |
pack() | |
addKeyListener(this) | |
repaint() | |
println("created") | |
override def repaint(): Unit = { | |
println("repaint") | |
terminal.clear() | |
terminal.writeCenter("HELLO!!!1", 10) | |
super.repaint() | |
} | |
override def keyPressed(e: KeyEvent): Unit = { | |
} | |
override def keyTyped(e: KeyEvent): Unit = ??? | |
override def keyReleased(e: KeyEvent): Unit = ??? | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment