Java Oyun Programlama - Kurulum ve Graphics Buffering

package oyun1;
import javax.swing.JFrame;

public class Oyun1 extends JFrame{
    
    public Oyun1(){
        setVisible(true);
    }

    public static void main(String[] args) {
        new Oyun1();
      } 
}
import javax.swing.JFrame;
import java.awt.Graphics;

public class Oyun1 extends JFrame{
    
    public Oyun1(){
        setBounds(0,0,1000,800);
        setVisible(true);
    }
    
    public void paint(Graphics graphics){
        
    }
    
    public static void main(String[] args) {
        new Oyun1();
    } 
}
import javax.swing.JFrame;
import java.awt.Graphics;
import java.awt.Color;

public class Oyun1 extends JFrame{
    
    public Oyun1(){
        setBounds(0,0,1000,800);
        setVisible(true);
    }
    
    public void paint(Graphics graphics){
        super.paint(graphics);
        graphics.setColor(Color.red);
        //graphics.fillOval(x, y, WIDTH, HEIGHT);
        graphics.fillOval(200, 200, 50, 100);
    }
    
    public static void main(String[] args) {
        new Oyun1();
    } 
}
import javax.swing.JFrame;
import java.awt.Graphics;
import java.awt.Color;
import java.awt.Canvas;

public class Oyun1 extends JFrame{
    
    private Canvas canvas = new Canvas();
    
    public Oyun1(){
        //Makes our program shutdown when we exit out.
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        
        //set the position and size of our frame.
        setBounds(0,0,1000,800);
        
        //put our frame in the center of the screen.
        setLocationRelativeTo(null);
        
        //Make our frame visible
        add(canvas);
        setVisible(true);
    }
    /*
    public void paint(Graphics graphics){
        super.paint(graphics);
        graphics.setColor(Color.red);
        //graphics.fillOval(x, y, WIDTH, HEIGHT);
        graphics.fillOval(200, 200, 50, 100);
    }*/
    
    public static void main(String[] args) {
        new Oyun1();
    } 
}
package oyun1;
import java.awt.image.BufferStrategy;
import javax.swing.JFrame;
import java.awt.Graphics;
import java.awt.Color;
import java.awt.Canvas;


public class Oyun1 extends JFrame{
    
    private Canvas canvas = new Canvas();
    
    public Oyun1(){
        //Makes our program shutdown when we exit out.
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        
        //set the position and size of our frame.
        setBounds(0,0,1000,800);
        
        //put our frame in the center of the screen.
        setLocationRelativeTo(null);
        
        //Add our graphics component
        add(canvas);
  
 //Make our frame visible
        setVisible(true);
        
        //Create our object for buffer strategy. 
        canvas.createBufferStrategy(3);
        BufferStrategy bufferStrategy = canvas.getBufferStrategy();
        

        
        while(true){
            bufferStrategy = canvas.getBufferStrategy();
            Graphics graphics = bufferStrategy.getDrawGraphics();
        }
    }
    /*
    public void paint(Graphics graphics){
        super.paint(graphics);
        graphics.setColor(Color.red);
        //graphics.fillOval(x, y, WIDTH, HEIGHT);
        graphics.fillOval(200, 200, 50, 100);
    }*/
    
    public static void main(String[] args) {
        new Oyun1();
    } 
}

Hiç yorum yok:

Yorum Gönder