[java] My first java game ready (almost)
I finally finished this game and it works OK in IE5.5 but when I tried it in Netscape 4.7 it didn't work (it's even on the same computer)
Can you test it for me and check out if it works.
just click on the applet and press 'n'. Use arrow keys
Tetris
Thanks
Gunnar Steinn
Edited by - GunnarSteinn on 11/7/00 7:40:04 AM
Gunnar,
It looks pretty good... I couldn''t get it to run in Netscape from your site , but I downloaded it and it ran fine...
You might want to double-buffer it so it doesn''t flash...
Other than that it looks really good!
-Nate
It looks pretty good... I couldn''t get it to run in Netscape from your site , but I downloaded it and it ran fine...
You might want to double-buffer it so it doesn''t flash...
Other than that it looks really good!
-Nate
looks good, I also can''t get it to run in Netscape .. it does run but it doesn''t show (paint) the blocks, like Nate said try and double-buffer to get rid of the flicker and that might also fix the problem.
JP.
==============================================
I feel like a kid in some kind of store...
==============================================
www.thejpsystem.com
JP.
==============================================
I feel like a kid in some kind of store...
==============================================
www.thejpsystem.com
==============================================I feel like a kid in some kind of store... ============================================== www.thejpsystem.com
OK thank guys.
I''ll double buffer the thing (just have to find out what that is, how it''s done and then do it )
I''ll double buffer the thing (just have to find out what that is, how it''s done and then do it )
Double buffering works like this (basically)
1 Create an image the size of you screen
2 Use getGraphics to pull the graphics context off of it.
3 Draw all You pictures etc onto this graphics object
4 Then draw the image to the screen.
Simple ex.
public void Paint(Graphics g){
Image off = createImage(200,200); // Create off screen image
Graphics gOff = off.getGraphics(); // Get graphics.
img = this.getToolkit().getImage("test.gif"); // Draw something
gOff.drawImage(img,0,0,50,50,this); // to off screen image
g.drawImage(off,0,0,200,200,this); // Copy off screen image to // screen
}
I haven''t tested this or anything..but it should work okay.
Toddhau@yahoo.com.au
1 Create an image the size of you screen
2 Use getGraphics to pull the graphics context off of it.
3 Draw all You pictures etc onto this graphics object
4 Then draw the image to the screen.
Simple ex.
public void Paint(Graphics g){
Image off = createImage(200,200); // Create off screen image
Graphics gOff = off.getGraphics(); // Get graphics.
img = this.getToolkit().getImage("test.gif"); // Draw something
gOff.drawImage(img,0,0,50,50,this); // to off screen image
g.drawImage(off,0,0,200,200,this); // Copy off screen image to // screen
}
I haven''t tested this or anything..but it should work okay.
Toddhau@yahoo.com.au
November 08, 2000 07:09 PM
I don''t know if it is different for applets but for applications to double buffer you have to override the update method. Something like this:
BufferedImage b;
update(Graphics g)
{
if (b is not the same size as the window)
remake b;
else
paint(b.getGraphics());
g.drawImage(b);
}
So you have b stand in for the screen, then you have your paint method draw to b. Then draw b to the screen. Actually wait, let me bring up the code. I stole it straight from Sun''s site
Image offScreenBuffer;
public void update(Graphics g)
{
Graphics gr;
if (offScreenBuffer==null || (! (offScreenBuffer.getWidth(this) == this.size().width && offScreenBuffer.getHeight(this) == this.size().height)))
offScreenBuffer = this.createImage(size().width, size().height);
gr = offScreenBuffer.getGraphics();
paint(gr);
g.drawImage(offScreenBuffer, 0, 0, this);
}
BufferedImage b;
update(Graphics g)
{
if (b is not the same size as the window)
remake b;
else
paint(b.getGraphics());
g.drawImage(b);
}
So you have b stand in for the screen, then you have your paint method draw to b. Then draw b to the screen. Actually wait, let me bring up the code. I stole it straight from Sun''s site
Image offScreenBuffer;
public void update(Graphics g)
{
Graphics gr;
if (offScreenBuffer==null || (! (offScreenBuffer.getWidth(this) == this.size().width && offScreenBuffer.getHeight(this) == this.size().height)))
offScreenBuffer = this.createImage(size().width, size().height);
gr = offScreenBuffer.getGraphics();
paint(gr);
g.drawImage(offScreenBuffer, 0, 0, this);
}
Looks pretty good. One problem: Running at 800x600 in Internet Explorer its gets cut off by the menu bars at the top. You may want to decrease the height a bit.
- DanielMy homepage
quote: Original post by deakin
Looks pretty good. One problem: Running at 800x600 in Internet Explorer its gets cut off by the menu bars at the top. You may want to decrease the height a bit.
I have the res set to 12XX x 10XX something so that didn''t happen to me. I think I don''t have the time to fix that so I''ll just leave it like that (ps. if you want to play the game in 800x600 you can go fullscreen in IE by pressing F11)
Thank you all for your responce. I''ll try that tonight if I have time.
Gunnar Steinn
I tried this but it is even worse, here's the code
What's wrong with that? Instead of induvidual blocks flicker, now all of them flicker at once
(you can see it at http://www.hi.is/~gsm/tetris
Edited by - GunnarSteinn on November 10, 2000 5:50:42 AM
public void paint (Graphics page){ Image off = createImage(380,500); Graphics back_buffer = off.getGraphics(); drawBlocks(back_buffer); drawInterface(back_buffer); page.drawImage(off, GAME_X_OFFSET, GAME_Y_OFFSET,this);} // end paint()
What's wrong with that? Instead of induvidual blocks flicker, now all of them flicker at once
(you can see it at http://www.hi.is/~gsm/tetris
Edited by - GunnarSteinn on November 10, 2000 5:50:42 AM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement