Added: 4 months ago
From: TH3CHERNO
Views: 10,820
Sort by time | Sort by thread (beta)

Link to this comment:

Share to:

All Comments (218)

Sign In or Sign Up now to post a comment!
  • Eclipes is saying

    Graphics g = bs.getDrawGraphics();

    is an unreachable code

    PLZ HELP!

  • YESSSSSSSSSS I WORKED THANKS LOVIN THE TUTORIALS message me if you guys need help :P

  • Hey, I get everything right but the image wont show up on the screen

  • Eclipse keeps tellling me this:

    Graphics g = bs.getDrawGraphics();

    is unreachable code. Can someone please help, ive even tryed googling it but cant figure it out

  • can someone who got all this code right post it somewhere for us to check ours by? This is just frustrating as hell

  • hmmmm i only get blue and green pixels...

  • i have an error on render pixels pls help

    pixels[xPix + yPix * width] = pixels[x + y * render.width];

  • @666DemonThe so do I. does it say y cannot be a variable? and the same for x?

  • @666DemonThe That is an array index out of bound exception I'm assuming, I'm trying to figure that one out now.

  • I did everything you typed here and i get errors that i cannot change from boolean to int and there is no syntax for that. i keep getting errors with render. FUCK THIS.

  • I ment how do I manually import it? Cuz when I type that on the top it still has the red line under the ((DataBuffer stuff.

  • how do i manually import the DataBufferInt????? D: please help me

  • @47KGB Just type: "import java.awt.image.DataBufferInt;"­ at the top of the Display class where all your other imports are, just like I did. :)

  • I'm getting a problem. two of the times I've used the pixels code, it says I'm missing a variable.

  • myn wont start :S:S:S

  • public Display() {  screen = new Screen(WIDTH, HEIGHT); img = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_RGB); pixels = ((DataBufferInt)img.getRaster.­().getDataBuffer()).getData(); }

    for img.getRaster can't resolved or is not a field.

  • @Hedgoeg There is a "." between getRaster and the ()

  • For those of you have a grey window popping up with no sign of errors double check to make sure you put "thread.start();" after "thread = new Thread(this);" and it should fix the problem.

  • @notenoughclearance yes I did that but it don't work

  • @T3CHERNO

    I copied your code to what seems like verbatim, and I have two less warnings than you. I debug the program, and I find out that the program isn't drwaing any pixels; the form is completely blank. The warings that I have are at the lines where it says, "private Render render;" sayig "The field Display.render is never read locally"; and "private void stop() {" saying "The method stop() from the type Display is never used locally". I have no other warnings. What should I do to fix this?

  • There are an error when I trying to run it, it says:

    Exception in thread "Thread-3" java.lang.NullPointerException at com.sshoot.spaceshooter.Displa­y.render(Display.java:79) at com.sshoot.spaceshooter.Displa­y.run(Display.java:59) at java.lang.Thread.run(Unknown Source)

  • dous the game includes an multiplayer at the end ??

  • Exception in thread "main" java.lang.ArrayIndexOutOfBound­sException: 65536

  • haha, so happy i got here, i've done a run through of your videos twice, this time was perfect,

    thanks, and i'm definitely going to carry on until the bitter end!! :)

  • i can't fit my errors in the 500 char limit box :/ must of done something wrong

  • for those of you with the problem whereas you get nothing but a whiteish screen don't forget to call game.start in the main method.

  • I have a black screen :Z

  • OMG I GOT THE x wrong to y lol

  • Exception in thread "Thread-2" java.lang.ArrayIndexOutOfBound­sException: 65536 at com.mime.mineblock.graphics.Re­nder.draw(Render.java:21) at com.mime.mineblock.graphics.Sc­reen.render(Screen.java:19) at com.mime.mineblock.Display.ren­der(Display.java:72) at com.mime.mineblock.Display.run­(Display.java:57) at java.lang.Thread.run(Thread.ja­va:722)

  • Mine didn't work all I got was a black screen!

  • help!

    it doesnt draw and i get this error :(

    Exception in thread "Thread-3" java.lang.ArrayIndexOutOfBound­sException: 65536 at com.mime.TDGame.graphics.Rende­r.draw(Render.java:21) at com.mime.TDGame.graphics.Scree­n.render(Screen.java:19) at com.mime.TDGame.Display.render­(Display.java:73) at com.mime.TDGame.Display.run(Di­splay.java:58) at java.lang.Thread.run(Unknown Source)

  • mine isn't working.

    

  • been getting same problem no pixels these are the errors

    at com.mime.minefront.display.sta­rt(display.java:39) at com.mime.minefront.display.mai­n(display.java:97)

  • I have copied everything correctly but when i run i get blank screen w/ no pixels. I have no errors and 1 warning " The value of the field Display.render is not used" please help!

  • @SethBowdenn ok for those who are having issues getting the pixels to show once you run the program check your code for any misplaced "()" or ";"

    I found my issue was under "public void run() {" I put "while(running);{" the ";" after the word (running) does not belong because it is a while statement.

    only took an hour to notice that error.... got to love programming!!!

  • Could anyone help?

    I can't see the pixels, but only gray on the applet.

  • I seriously didn't understand NOTHING in this video :(

  • Real men put createBufferStrategy(10);

  • is there an HD version of the video

  • PLEASE SOMEONE HELP HIS TEXT QUALITY IS SHIT!

  • @TechnologyGeekify Do Control + It zooms in make sure your quality is at 720p!

  • dude, I cant see the text and I cant hear what your saying.

    I got the first class and All the code could have been simplified.

    ~official youtube critic

  • Exception in thread "Thread-2" java.lang.ArrayIndexOutOfBound­sException: 65536 at net.byo.src.Graphics.Ga.draw(G­a.java:36) at net.byo.src.Graphics.Gb.render­(Gb.java:19) at net.byo.src.A.render(A.java:77­) at net.byo.src.A.run(A.java:92) at java.lang.Thread.run(Unknown Source)

    Error I Get When Debugging

  • I have copyed the code and I just have the normal white screen without the pixels please help anyone :)

  • I'm having an issue with the DataBufferInt import. It's telling me to change the pixels type to DataBufferInt instead of int[]. My code is identical to yours, but I'm getting this error and you aren't. Help!? lol

  • @kevlam585 nvm, just needed an extra set of (). word.

  • Help i cant see the windows that opens. It just doesnt open :( Help me

  • when i click debug nothing even opens up i have the spinning loading circle next to my mouse but nothing opens up

  • why I get an error when I write: screen = new Screen(WIDTH, HEIGHT);

    12:30

  • hey please help i get a white screen is it because i set it in 2d how do i change it thanks

  • This code is already really messy, and quite flawed o.0

  • in render.java it says y cannot be resolved as a variable

  • Ummm... on Macintosh "img = new BufferedImage[WIDTH, HEIGHT, BufferedImage.TYPE_INT_RGB];" isn't working please help

  • its doesnt work for me, just a blank white screen.

  • at screen.render();

    it is saying i have a unreacheble code now i know what unreacheble code is but i do not know how to fix it!

  • Adding onto iemandmetgeenhoofd's comment(top comments), add thread.start(); in the private void start() method in Display. And a something cool, change pixels[i] = screen.pixels[i]; in the render method(not class) to pixels[i] = screen.pixels[1]; for a randomly colored screen :D

  • Comment removed

  • pls use another screen recorder..

  • I got a NullPointerException even though I copied ALL the code! HELLLLPPPPPP!

  • is that a 0 or O in g.drawImage cuz 0 works but O doesn't help?

  • can u put a download link, pls? :D

  • I GOT NO ERRORS,ALL I GOT WAS A WHITE SCREEN

  • Could you post the code somewhere so we could go back through it to check for mistakes?

  • ok, so i ifxed the pixels problem, but i keep getting a black scren?! help D=

  • in my Display.java it KEEP FREGGIN SAYING: pixels cannot be resolved to a variable, PLEEEEEEEEEEEEAAAAAAAASSSSSSSS­SSSEEEEEE help me -.-

  • HELP! : ok so on my Screen.class, dow under the super(width, height) it is saying that my:

    test.pixels(i) = BLAH has to be a variable, PLEASE HELP!!

  • @Quanose1 Are you sure it is (i) and not [i], because if it was (i), it should be [i].

  • Comment removed

  • help i'm having another problem. on line: "Graphics g = bs.getDrawGraphics();" it has the Unreachable Code" error! idk why!

  • @SilentAero7 hi i have the sam prob did u get a fix??

  • help i'm getting a problem with the code. on this line of code: "for (int 1 = 0; 1<WIDTH * HEIGHT; 1++) {" it says that the 1 after int has a "Syntax error on token "1", invalid VariableDeclaratorId" i don't know why!

  • @SilentAero7 You can't name an int variable 1. Rename it to some sort of letter.

    I think you might have mixed up the i and the 1 on the screen when he was typing it out.

  • @SilentAero7 You can not have a variable with a name starting with a number.

  • Hey, could you also send the code to me, cuz I have a problem in my code, but I don't know what. It's something with "render" and "stop". Thanks

  • @TH3CHERNO so I write all ur code and I start the program (their is no errors on screen besides the yellow caution things u have at the end of the video on the public void stop, public void start and private Render render) I don't understand y when I start it, it just shows the same window, it is still gray as it was when it was first created, no black screen or pixels what so ever! So please just post the file in the description for the code would be so much easier for all of us having problems

  • @imapenguin411 Did you make sure that in the Display class under the render method, that after the if(bufferedstategy == null) return;

    Make sure that you have this:

    screen.render();

  • If you don't, no pixels will ever initialize

  • i got the titel and no pixels

    i had an animation but when i did what you did it all went to shit

    so i got wrid of the new code adn wached all of the tuts and itt stil dont work

    can you PM me the codeor somethng

  • omg plz he;p im same as capnsquishy!!! i got no errors and im on mac eclipse!!!

    can u plz pm me a download of ur code so i can plz fix my errors?? and btw u dont know how much java ive learned from these 4 vids so far!! plz i cant go on till i fix problems!!!!! thx!

    - Finn

  • If there is any possiblility to get the code, to easier understand the wrongs in my code i would be very thankful... right now I have a hard time to see the wrongs I´ve checked through the comments and nothing off those wrongs is my wrongs... plz if u could be kind to pm me the code i would really help me out

  • Hey jerk! thanks for explaining how to get the frikkin grid maker plugin! I went all over Timbucktoo to find the thing... You should really mention how to get it in your videos

  • The point of this vid is to help u. If u dont know anything about visit java tutorial page in first vid or listen and try to understand how he explains it. You cant just ask him for the coding of his own game.

  • I also had a white screen. Inside your start() function make sure you make a call to run()

  • Can you put your code so far into a link please, cause ive just lost everything? @TH3CHERNO

  • I get an "Unreachable code" error at "Graphics g = bs.getDrawGraphics();"

    Any suggestions?

  • hello, i tried this it just gives me a blank screen can you message me the code for all three pages.

  • when I click debug, it suspends on: super(width, height); in Screen.java and test.pixels[i] = random.nextInt(); also in Screen.java

  • @DuckThom Same With Me!!

  • Guys, the solution is easy :) Underneath thread = new Thread(this); in your start method just write thread.start();

    I hope this works for you too :D

  • Comment removed

  • I have a question is it good when i get diagonal lines in different colors

  • Comment removed

  • check if you have thread.start(); I forgot this little line of code and had a blank screen!

  • Omg 8 hours of rewriting and I finally have PIXELS!!!

  • could you PM me the code plz its giving me a blank screen

  • I have zipped my working code while following the tutorial till this episode here files.nigel.jp/Minefront_4.zip goodluck

  • @Pindamann thanks a bunch.

  • Hi I have now watched the video through 3 times now, and I have written the same code as you have, and I don't get any render, only an empty frame. why is that ?

  • 15:30 Just a reminder for my self where i whas.. xD

  • i'm using the exact same program, I have the exact same code. I just get a frame with the game title and inside it blank. Please help!

  • on line 70 it jusr says that void is a invalid type for the variable main. can anybody help me?

  • EVERYONE WITH RENDERING PROBLEMS!

    Check the line that says img = new bufferedImage with all the parameters and make sure it says

    TYPE_INT_RGB

    not TYPE_INT_ARGB

    that fixed mine....

    and dont forget screen.render right after creating the buffer strategy

  • @Th3CHERNO I have copied the code exactly I have checked multiple times and can't figure out whats wrong I just have my white box from before but no pixels if you could help it would be great. P.S. Great tutorials so far =)

  • mine says "Cannot cast from WritableRaster to DataBufferInt" an the code underlined is "pixels = ((DataBufferInt)img.getRaster(­)).getData();" What is wrong?

  • @TheOriginalPentiva Never mind I changed it back to what it was before and refreshed Eclipse and that has worked

  • @TheOriginalPentiva pixels = ((DataBufferInt)img.getRaster(­).getDataBuffer()).getData();  not pixels = ((DataBufferInt)img.getRaster(­­)).getData();

  • Can someone please send me the source because I have tried everything and its still not working.

  • @mustardftw Yea me too, if anyone has a source code up to this point, THAT WORKS! Please send it to us. It would be greatly appreciated.

  • Also for test.pixels[i] = random.nextInt(); it says for the "i" in the "[]" "i cannot be resolved to a variable." Any idea?

  • Black screen, but only 1 pixel. :/

  • Hey, Everything wendt without any problems before this tutorial, I have looked trhrough and compared your andm ine code and cant find any differences and mine renders a diagonal line :( Plz help?

  • @THE3CHERNO Hey dude, I really need your help, I have everything you have in your video, however my Java screen isn't showing the pixels, please help, I really love your videos and I never will stop! Please help! Thanks.

  • Keep the hard work up!

  • @TH3CHERNO Could you take a look at my code? I took the video and paused it, checked the code line by line, and still a white screen.

  • I've no errors, just a white screen.

  • @TH3CHERNO Curious question, I'm running eclipse on my Macintosh and it doesn't render the pixels for me. Do they work differently?

  • @Capnsquishy Nope. Same code on Mac should be fine... make sure you have the EXACT code written down that I wrote!

  • @TH3CHERNO Could you send me the exact code you've written in a PM or something? :P

    My pixels won't generate either, I think I'm missing something so could I have your code?

  • woops! forgot to type game.start(); lol...

  • blah..... not working for me..... code check! just a suggestion... can u copy and paste the code into the description after each video? then it's easier to see something we can't see even on HD in the video. Thanks!

  • Why do I not get an answer on my question?

    Please, I realy want to know, what that means...

  • In your 4.5 video i put the System.out.println("x: " + x + " y: " + y); in the render class. but when it runs i still get a white screen and in the console it only says "running..." not the desired y and x coords. i think my render file isnt getting used in the display class. PLEASE HELP

  • Why is it yPix +xPix * height and not width * height?

    I don't get it..

  • Or do java.awt.image.*;  :3

  • Can you post me the code (PM ME) cuz when i run it, it comes up with the frame and the game name, WITHOUT the pixels :(

  • @47KGB i have the same problem

  • @youfun11 so do i

  • @47KGB same :(

  • @47KGB @TH3CHERNO Can u pm the the code you have so far in this video, please i get lots of errors and i dont know how i fix them

    Thanks

  • I just get "DataBufferInt cannot be resolved to a type" when i do ((DataBufferInt)img.getRaster(­).getDataBuffer());

  • @DecimateeGamingg you have to type ((DataBufferInt)img.getRaster(­­)).getDataBuffer();

  • @youfun11 ayh thanks :)#

  • help? my window just is white with no pixels on it please help i dont know whats wrong i get no errors

  • @DCodeMast3r Same here its being a tard

  • Cool. I initially had problems displaying the 256x256 colours, but after going through the video again scratching my head, i realised that I had not seen the portion which explains not to activate tick() and render() more than once by using "while (running) { tick() render() }. works now :-)

  • It is not giving me the pixel thingy instead it says: what does it mean? Please help

    Exception in thread "Thread-3" java.lang.ArrayIndexOutOfBound­sException: 1600 at com.games.Minergame.graphics.R­ender.draw(Render.java:20) at com.games.Minergame.graphics.S­creen.render(Screen.java:21) at com.games.Minergame.Display.re­nder(Display.java:75) at com.games.Minergame.Display.ru­n(Display.java:58) at java.lang.Thread.run(Unknown Source)

  • please help when i run it all i get is the window i dont get the pixels or anyblack areas? please help anyone thank you!

  • Sorry i don't know what when wrong, but i didn't even get a screen is it maybe that i'm using Eclipse EE? Please Reply!

  • Your render settings are a bit... wacky. All the things you do lag behind for a second or two and then pop into place...

  • On line 27 pixels = ((DataBufferInt) img.getRaster()).getData();

    it gives me an error saying

    "Cannot cast from WritableRaster to DataBufferInt"

    any help???

  • When i start mine the window changes color between black and white really fast like it's flickering and i cant see any pixels. any ide what im doing wrong?

  • when i debug i get com.mine.minefront.Dispaly.at localhost:####(may be out of synch) in desplay line 30 and line 90 i checked it over and over again looks exactly the same as urs... :/ any possible solutions i would like to continue

  • Oh, btw, its at the part where we typed createBufferStrategy(3);

  • I got an error. Here it is.

    Exception in thread "Thread-3" java.lang.IllegalStateExceptio­n: Component must have a valid peer

    Explain. 

  • Im getting an error with the Graphics g =bs.getDrawGraphics(); Watched the tutorial over and over again. Can't see what im doing wrong... I sent you an eMail, hope i can get help, nice tutorials btw :D

  • Awesome Video Tutorial! Can't believe Im done with Video 4 already. Only issue I had was that in the Display class I had: pixels[i] = screen.pixels(i); and it should have been pixels[i] = screen.pixels[i];

  • for your draw method, it is redundant to pass in a render object as a parameter. Each object of the Render class has it's own set of local variables. It's like saying:

    object.doSomeAction(object);

    Hope this will help future coding practices

  • remember to write the right code and excactly the same as in the video

  • @gfxchatforum cant see half the video :P

  • is this bit right i couldn't see it :/

    pixels = DataBufferImg(img.getRaster().­getDataBuffer().getData());

    it says there is an error but the video quality is bad

  • I get a blank screen! HELP!

  • @TH3CHERNO Getting Error:

    "Exception in thread "main" java.lang.Error: Unresolved compilation problems: Type mismatch: cannot convert from DataBufferInt to int[] The method getData() is undefined for the type DataBuffer"

    pls help

  • @TH3CHERNO Getting Error "Exception in thread "Thread-3" java.lang.ArrayIndexOutOfBound­sException: 2 at engine.running.graphics.Render­.draw(Render.java:19) at engine.running.graphics.Screen­.render(Screen.java:17) at engine.running.Display.render(­Display.java:66) at engine.running.Display.run(Dis­play.java:36) at java.lang.Thread.run(Thread.ja­va:662)

    " When attempting to run after this...

  • source code plz

  • Im not geting the full pixels im just geting one littel part plz help

  • i got it to run but not pixels render plz help

  • HEy, im getting an exception, a nullpointerexception, and as far as im aware, i have followed all instructions.

    I have checked that i have initialised the variable, and changed the names, then it redirects me to the Screen class.

  • Good videos, man.

  • if you get a black screen its probably because yo put > instead of < at the for loop in screen

    Thumbs up!

  • mine didn't work?

  • Yay I fixed my issue!

    I hadn't set up the threads properly.

  • For some reason on my mac and pc it doesn't render the pixels help!

  • do you like have to use canvas at all?