Jump to content
  • Advertisement
Sign in to follow this  
ThinkingsHard

Problem with Cannot Find Symbol

This topic is 2205 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!