Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.c0decub.gtest;
- import java.awt.Canvas;
- import java.awt.Color;
- import java.awt.Dimension;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseListener;
- import java.awt.image.BufferStrategy;
- import java.awt.image.BufferedImage;
- import java.awt.image.DataBufferInt;
- import java.io.File;
- import java.io.IOException;
- import java.io.InputStream;
- import javax.imageio.ImageIO;
- import javax.swing.*;
- public class graphicsTest extends Canvas implements Runnable {
- public static final int GAME_WIDTH = 320;
- public static final int GAME_HEIGHT = 240;
- public static final int SCALE = 2;
- public static final int SCALE_IMG = 3;
- private Thread thread;
- private boolean running;
- public Graphics g;
- private static BufferedImage blood = Images.load("blood.png");
- public static void main(String[] args) {
- graphicsTest gObj = new graphicsTest();
- JFrame frame = new JFrame("graphics");
- frame.add(gObj);
- frame.pack();
- frame.setResizable(false);
- frame.setLocationRelativeTo(null);
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frame.setVisible(true);
- gObj.start();
- }
- public synchronized void start() {
- thread = new Thread(this);
- running = true;
- thread.start();
- }
- public synchronized void stop(){
- running = false;
- }
- public graphicsTest(){
- int w = GAME_WIDTH * SCALE;
- int h = GAME_HEIGHT * SCALE;
- setPreferredSize(new Dimension(w, h));
- setMaximumSize(new Dimension(w, h));
- setMinimumSize(new Dimension(w, h));
- // setBackground(Color.BLACK);
- }
- public void run() {
- while (running){
- render();
- }
- }
- public void render(){
- Images.load("blood.png");
- g.drawImage(blood, 0, 0, this);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement