package game;

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.rms.*;
import javax.microedition.media.*;
import javax.microedition.media.control.*;
import java.io.*;
import java.util.*;
import javax.microedition.rms.*;

public class MainCanvas extends Canvas implements Runnable {
    
    GameMidlet mid;
    int x;
    int y;
    int screen_width;
    int screen_height;
    
    public MainCanvas(GameMidlet m) {
        mid = m;
        this.setFullScreenMode(true);
        new Thread(this).start();
        x = 0;
        y = 0;
        screen_width = this.getWidth();
        screen_height = this.getHeight();
    }
    
    public void run() {
        while(true) {
            update();
            
            this.repaint();
            long nexttime = System.currentTimeMillis() + 30; // set your framerate here
            while(System.currentTimeMillis() < nexttime)Thread.yield();
        }
    }
    
    
    public void update() {
        x++;
        y++;
    }
    
    
    public void keyPressed(int key) {
        
    }
    
    public void keyReleased(int key) {
        
    }
    
    public void paint(Graphics g) {
        g.setColor(0x000000);
        g.fillRect(0,0,screen_width,screen_height);
        g.setColor(0xffff00);
        g.fillRect(x,y,10,10);
    }
    
    protected void hideNotify() {
        
    }
    
    protected void showNotify() {
        
    }
}

