Skip to content
Snippets Groups Projects
Select Git revision
  • 6a2fdffd1d7b57f57860f9ee50af9a3e87826cf7
  • main default protected
  • variant
3 results

Position.class

Blame
  • Forked from COUETOUX Basile / FirefighterStarter
    Source project has a limited visibility.
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    Grid.java 1.21 KiB
    package engine;
    
    import pong.PongObject;
    
    import javax.swing.*;
    import java.awt.*;
    import java.io.IOException;
    //
    public class Grid extends JFrame implements Engine  {
    
    
        public Grid() throws IOException {
        }
    
        public void init(String title, int width, int height) throws IOException {
            // mainPanel.setBounds(850,500,122,124);
            this.setTitle(title);
            // this.setContentPane(mainPanel);
            this.setMinimumSize(new Dimension(width, height));
            // this.setContentPane(mainPanel);
            this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            this.setLocationRelativeTo(null);
            this.pack();
            this.setResizable(false);
            this.setVisible(true);
            this.setLayout(this.getLayout());
            this.revalidate();
        }
        public void draw(ImageComponent ic) throws IOException {
            getContentPane().add(ic);
        }
    
        @Override
        public void update(){
            for (PongObject po : Kernel.gameObjects
                 ) {
                try {
                    this.draw(new ImageComponent(po.getImage(), po.getPosition(), po.getWidth(), po.getHeight()));
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
    
            }
        }
    
    
    }