Problem with Cannot Find Symbol

Started by
1 comment, last by ThinkingsHard 11 years, 7 months ago
import java.awt.Graphics;
import java.awt.Dimension;
import java.awt.Canvas;
import java.awt.image.BufferStrategy;
import java.awt.image.BufferedImage;
import java.awt.image.DataBufferInt;
import java.util.Random;

import javax.swing.JFrame;

// Creates a class called Game that uses the Canvas and implements Runnable
public class Game extends Canvas implements Runnable {

public static final long serialVersionUID = 1L;

// Sets the Height Width and Scale of the frame to unchangeable integers
public static final int HEIGHT = 120;
public static final int WIDTH = 120;
public static final int SCALE = 15;


// Sets NAME to Zuthion ( For use in the JFrame)
public static final String NAME = "Zuthion";



// Buffers all the pixels within the game
private BufferedImage image = new BufferedImage(WIDTH, HEIGHT,BufferedImage.TYPE_INT_RBG);
private int[] pixels = ((DataBufferInt) image.getRaster().getDataBuffer()).getData();

Random random = new Random();

private boolean running = false;
public void start(){
running = true;
new Thread(this).start();
}

// Since this is a boolean, you don't need to set it to = true to make this true, if I wanted to set this to false,
// I could type while(!running)
public void run(){
while(running){
tick();
render();
}
}

public void stop(){
running = false;
}

public void render(){
BufferStrategy bs = getBufferStrategy();
if(bs == null){
createBufferStrategy(3);
requestFocus();
return;
}

Graphics g = bs.getDrawGraphics();
g.drawImage(image, 0, 0, null);
g.dispose();
bs.show();
}

public void tick(){
for (int i = 0; i < pixels.length; i++){
pixels = random.nextInt();
}
}

public static void main(String[] args){

Game game = new Game();

game.setPreferredSize(new Dimension(WIDTH * SCALE, HEIGHT* SCALE));
game.setMaximumSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE));
game.setMinimumSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE));

JFrame frame = new JFrame(NAME);
frame.add(game);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
frame.setResizable(true);

game.start();

}

}


Hey. I was going to college taking a bit of first year Java until I was unfortunately unable to continue going to college (Lack of motivations on top of actual phsyical barriers, like my car dieing, and my internet going out for 2 weeks(which dropped me from straight A's to C's and below, because of when it hit)) anyway, I've been trying to learn Java on my own, as I still have my college textbook, and a desire to learn.

I've been reading Tutorials, and looking around for information, Oracle is amazing. Anyway. Here's the Compiler error.

Game.java:32: error: cannot find symbol
private BufferedImage image = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_RBG);
^
symbol: variable TYPE_INT_RBG
location: class Game
1 error



I'm not sure why I'm getting this error, and I feel like I either forgot to import something, or I am missing something from my java libraries. If anyone could help with this, I would greatly appreciate it.
Advertisement
private BufferedImage image = new BufferedImage(WIDTH, HEIGHT,BufferedImage.TYPE_INT_RBG);[/quote]
May be you mean TYPE_INT_RGB or TYPE_INT_BGR? BufferedImage does not have TYPE_INT_RBG member.
Oh my god. I've read that line 50 times and didn't catch that... I love you... A lot.

This topic is closed to new replies.

Advertisement