Don't Understand What's Happening Here...
Author |
Message |
Prince Pwn
|
Posted: Sun Jul 29, 2007 10:50 pm Post subject: Don't Understand What's Happening Here... |
|
|
This makes absolutely no sense to me. I'm working on a Pokemon game, and when I upload the .class file, I can see the NPC, but when I run it in Ready to Program, the NPC doesn't show! After like 30 seconds, it goes into the catch block and then flashingly paints the yellow block ! The direct applet can be found HERE. This is the block of code I have to make the NPC.
Java: |
public void drawNPC (int X, int Y, String file, Graphics g)
{
try
{
//mt = new MediaTracker (this);
//base = getDocumentBase ();
NPC = getImage (getDocumentBase (), "Images/NPC/" + file + ".gif");
mt.addImage (NPC, 1);
g.drawImage (NPC, X, Y, this);
// Barriers
// if (ashX < X + NPC.getWidth (null) && ashX + ashWidth > X && ashY > Y && ashY < Y + NPC.getHeight (null))
// {
// if (pressed == "up") // Your house
// ashY = Y + NPC.getHeight (null);
// if (pressed == "down")
// ashY = Y;
// if (pressed == "right")
// ashX = X - ashWidth;
// if (pressed == "left")
// ashX = X + NPC.getWidth (null);
// }
}
catch (Exception e)
{
g.setColor (Color.yellow);
g.fillRect (X, Y, ashDown.getWidth (null), ashDown.getHeight (null));
g.setColor (Color.black);
g.drawRect (X, Y, ashDown.getWidth (null), ashDown.getHeight (null));
}
}
|
Here are some screens comparing them, on the left RTP, on the right, uploaded Java applet on my site:
![Posted Image, might have been reduced in size. Click Image to view fullscreen. Posted Image, might have been reduced in size. Click Image to view fullscreen.](http://img171.imageshack.us/img171/152/readyvswebsg8.png) |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Dan
![](http://wiki.compsci.ca/images/archive/3/3c/20100325043407!Danspic.gif)
|
Posted: Sun Jul 29, 2007 11:01 pm Post subject: RE:Don\'t Understand What\'s Happening Here... |
|
|
Well is the image file aucatly there on your local mashen? Is it in /Images/NPC/ with the right captization? Is it a gif file and is it named right?
Is getDocumentBase() being set right on your local mashen?
Also i don't use RTP so i am not shure how it deals with applets localy, there code be some RTP only seting or issue as well. |
Computer Science Canada
Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more! |
|
|
|
![](images/spacer.gif) |
Prince Pwn
|
Posted: Sun Jul 29, 2007 11:18 pm Post subject: Re: Don't Understand What's Happening Here... |
|
|
It is the exact same file! After I run my source code in the RTP compiler, I copy and paste the .class file onto the server and then clear my cache, restart my browser, and go see if what I did in the compiler works in my browser(s).
If you look a few posts down at my Sun Fighters Compiler VS Upload, I had a minor problem where the mouths would get deformed on the site, but they'd be perfect in RTP. That is minor compared to the major problem I'm having now, where I can't see the pic in RTP but I can uploaded.
If you'd like I could zip up my full source code and images and send it to your email or something, so you can test it out.
PS I can't edit my first post, but I'd like to add when the image doesn't show and after 30 seconds my catch yellow block appears, and I uncomment the border part, I can walk through walls and bounce off at any time since the GIF isn't appearing. It's kinda hard to explain. I might make a quick youtbe video and upload it.
A 40 second video demonstration of me showing you the problem I encounter with the gif showing online, and not showing offline. |
|
|
|
|
![](images/spacer.gif) |
Dan
![](http://wiki.compsci.ca/images/archive/3/3c/20100325043407!Danspic.gif)
|
Posted: Mon Jul 30, 2007 12:48 am Post subject: RE:Don\'t Understand What\'s Happening Here... |
|
|
Wait, are you running it as an applet on your local computer?
What happens if you make an html file on your local comptuer like your one online and try to run it in a browser off your local computer.
I am not shure how you are loading the images but there could be a signifcat diffrences between runing it as an applet and runing it as an application (if that is what RTP is doing). |
Computer Science Canada
Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more! |
|
|
|
![](images/spacer.gif) |
Prince Pwn
|
Posted: Mon Jul 30, 2007 2:12 am Post subject: Re: Don't Understand What's Happening Here... |
|
|
OK, I have a directory on my computer which hosts all of my website, including the java files, html files, and class files. As soon as I modify my java files and run them in RTP, my class files are updated on the website. When I run it in RTP and upload it, it's basically the same file I'm working on, so there is no directory problems (trust me). Is there another Java compiler other than Ready that I could use (free or paid) to test the code out in with a built in compiler like Ready. That way I can troubleshoot. |
|
|
|
|
![](images/spacer.gif) |
Dan
![](http://wiki.compsci.ca/images/archive/3/3c/20100325043407!Danspic.gif)
|
Posted: Mon Jul 30, 2007 2:40 am Post subject: RE:Don\'t Understand What\'s Happening Here... |
|
|
RTP uses the real java complier, as i sdie in my last post the best way to test it is try to run the html page in a browser with the applet on your local computer (the files being on your local computer). |
Computer Science Canada
Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more! |
|
|
|
![](images/spacer.gif) |
wtd
|
Posted: Mon Jul 30, 2007 12:33 pm Post subject: RE:Don\'t Understand What\'s Happening Here... |
|
|
Is the image file uploaded to your site? Applets on a web server don't have access to your hard drive. |
|
|
|
|
![](images/spacer.gif) |
Prince Pwn
|
Posted: Mon Jul 30, 2007 3:12 pm Post subject: Re: Don't Understand What's Happening Here... |
|
|
Ok I opened the HTML file with Firefox (wouldnt work with IE, probly didnt have Java installed), and it worked. I still can't see it when I run it in RTP and it's driving me nuts, cause if you watch this: http://youtube.com/watch?v=JYx-yGToIuo you can see the image isn't showing up. I know it's the correct directory, I'll explain how I know the gif of "my mom" is in the right directory on my local hard drive:
I execute the code in RTP, and my mom isn't there. Butttt, after 30 seconds approximately after running, all of a sudden my catch statement kicks in, and then I see my Yellow Box appear in place of my mom, but the weird thing is the yellow box flickers until I re-run the program (or leave the room). If I give a false directory where there is no image, when I run the program in RTP, instead of waiting the 30 seconds to show the yellow box and flicker, the yellow box appears and there is no flickering.
If you could understand all of the above, basically I think RTP knows there is an image there, and it keeps attempting to draw it, but shows nothing. After the 30 seconds RTP goes "Ok I can't draw the image, but I'll continue to attempt to draw it, and I'll kick in the catch statement. Therefore I think it draws the Yellow block, then nothing (which is the gif that the program thinks is there), then loops.
Now I'll expand on how I upload my files. I'm on my wireless network with my laptop downstairs. Upstairs, I have a desktop which is my server hosting the website and all the files. Once I edit my Pokemon World game and wish to see it in action on the site, I copy and paste 1 folder called "Pokemon World" with all the image files, class files, and I only don't copy the source code so people can't travel to the directory and steal my source code. Therefore it is a direct 1/1 copy pretty much from my laptop (which I work on) to my desktop (which is my website server). Then, I run my source code on my laptop, and there is no mom! But when I travel to my website and run the .class file hosted upstairs, I see my mom!
I tested in these browsers on my website:
IE on Desktop : Saw mom
Firefox on Desktop : Saw mom
IE on Laptop : Don't have Java for IE
Firefox on Laptop : Saw mom
And by the way, I use the same techniques to create the image of my mom as I did the main character, using transparency and stuff in Photoshop. The only problem I am having is with mom, because the main character is created the exact same way! I am 90% sure it has to do with RTP not executing that block of code correctly, because I tried different images in there instead of mom. It HAS to do with the code that RTP can't display correctly.
The Bottom Line the way I see it
Why can't the same code I write in RTP and compile with RTP - display any pictures correctly in that block of code within RTP - but the same .class file generated with RTP can be viewed perfectly in a web browser offline/online?
I made a new video with further detail:
Video #1
Video #2 |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Dan
![](http://wiki.compsci.ca/images/archive/3/3c/20100325043407!Danspic.gif)
|
Posted: Mon Jul 30, 2007 4:08 pm Post subject: RE:Don\'t Understand What\'s Happening Here... |
|
|
I am prity shure this is the difrence between runing as an applet and runing as an application. I am thinking RTP adds in some code to run it as an application when you hit run in RTP rather then trying to run it as an applet.
Unfrontly i so not know enought about the RTP api to understand why this happens. Tho my guse whould be how it loads images.
I suggest testing your program in a local browser rather then in RTP as you are deloping it for the web and not RTP any how. Also you can get other IDEs for java like jcreator witch do not add there own code.
WTD: His problem is the other way around, it works online but not on his computer when runing it threw RTP. Tho it dose work on his computer when ran threw a brower localy acording to the above post. |
Computer Science Canada
Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more! |
|
|
|
![](images/spacer.gif) |
Prince Pwn
|
Posted: Mon Jul 30, 2007 4:14 pm Post subject: Re: Don't Understand What's Happening Here... |
|
|
Alright, I guess the best idea is to use RTP to type my code and F2 format it, compile it to generate the class file, then run the html code in Firefox. It is really inconvenient though because I have to F1 to compile in RTP to generate the .class, then run the HTML every time I make a minor change with the NPC method (which I do lots) and sometimes I have to clear the browsers cache. Thanks for everyones input. I might try that jcreator if it's as easy to use as RTP.
Oooo jcreator is cool. I like everything, except I'm not used to having both the html file and java file open in the same program and manually compiling before running the html file, and no F2 formatting. And I had to google to figure out you needed the html file open to run the code. I can see my mom in jcreator! |
|
|
|
|
![](images/spacer.gif) |
|
|