Jump to content

View more

Image of the Day

雑魚は多めにして、爽快感重視にしつつ・・・(´・ω・`)
早いとこ、ベースを作って、完成にもっていかないとね。
タイトルもまだ迷ってるだよなぁ。 
#indiedev  #indiegame #screenshotsaturday https://t.co/IwVbswGrhe
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Problem with Cannot Find Symbol

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
2 replies to this topic

#1 ThinkingsHard   Members   

236
Like
0Likes
Like

Posted 11 September 2012 - 12:14 PM

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[i] = 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.

#2 Deft   Members   

226
Like
1Likes
Like

Posted 11 September 2012 - 12:40 PM

private BufferedImage image = new BufferedImage(WIDTH, HEIGHT,BufferedImage.TYPE_INT_RBG);

May be you mean TYPE_INT_RGB or TYPE_INT_BGR? BufferedImage does not have TYPE_INT_RBG member.

#3 ThinkingsHard   Members   

236
Like
0Likes
Like

Posted 11 September 2012 - 12:52 PM

Oh my god. I've read that line 50 times and didn't catch that... I love you... A lot.




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.