Skip to content

Instantly share code, notes, and snippets.

@resba
Created January 25, 2012 19:04
Show Gist options
  • Save resba/1677931 to your computer and use it in GitHub Desktop.
Save resba/1677931 to your computer and use it in GitHub Desktop.
SimpleGame
package com.resbah.SimpleGame;
import java.applet.*;
import java.awt.Color;
import java.awt.Event;
import java.awt.Graphics;
import java.awt.Image;
/**
*
* THIS CODE IS SO WRONG BUT WHO CARES \o/
*
* @author matthew sowden
*
*/
public class SimpleGame extends Applet implements Runnable {
private static final long serialVersionUID = -6363298479261969104L;
Thread t;
int i;
Image offscreenImage;
Graphics offscr;
@SuppressWarnings("deprecation")
public void init() {
t = new Thread(this);
t.start();
i = 0;
}
public void paint(Graphics g)
{
g.drawString("i = "+i,10,20);
offscr.setColor(Color.black);
offscr.fillRect(0,0, size().width, size().height);
offscr.setColor(Color.blue);
offscr.fillArc(0,0,size().width,size().height,startAngle,arcAngle);
g.drawImage(offscreenImage, 0, 0, this);
}
public boolean keyDown(Event e, int key)
{
String message = "value = " + key;
return true;
}
public boolean keyUp(Event e, int key)
{
String message = "value = " + key;
return true;
}
public void run() {
while(true)
{
i++;
repaint();
try{
Thread.sleep(1000/30);
} catch (InterruptedException e) { ; }
}
}
public void update(Graphics g)
{
paint(g);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment