![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
Professional Programmer
|
That tetris game is done in flash, so it doesn't matter what drawing methods it uses.
And I think you could accomplish that using Java's drawing methods, but if you want to use .jpeg's it's up to you. |
|
|
|
|
|
#12 |
|
Battle Programmer
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 747
Rep Power: 3
![]() |
What about Graphics.draw3DRect and Graphics.fill3DRect?
|
|
|
|
|
|
#13 | |
|
Hobbyist Programmer
Join Date: Feb 2006
Posts: 214
Rep Power: 0
![]() |
Quote:
__________________
Death smiles at us all. All a man can do is smile back. |
|
|
|
|
|
|
#14 |
|
Expert Programmer
|
Read this article.
|
|
|
|
|
|
#15 |
|
Newbie
Join Date: May 2008
Posts: 2
Rep Power: 0
![]() |
Re: 2-d graphics
Yi I really need a help here please I want to know how to draw lines which draw from all the corners.
![]() ![]() |
|
|
|
|
|
#16 |
|
Hobbyist Programmer
|
Re: 2-d graphics
[delete me]
__________________
Who said i couldn't program sarcasm = raw_input('Type in a sarcastic remark: ')
|
|
|
|
|
|
#17 |
|
Newbie
Join Date: May 2008
Posts: 2
Rep Power: 0
![]() |
Re: 2-d graphics
hi ever body i have a question i just want to know to make menu that provide for user an option to select random shpaes like rectangle, oval and lines and that should have two class???
|
|
|
|
|
|
#18 |
|
Java Game Programmer
Join Date: Jun 2008
Location: U.S.
Posts: 10
Rep Power: 0
![]() |
Re: 2-d graphics
k Eric, im going to trt to tackle as many problems as possible.
first, the "flicker problem." what you need to do is create a buffered image. aquire a Graphics2D object that paints onto the buffered image, then set the paint method. import java.awt.image.BufferedImage;//import statement
BufferedImage bi = new BufferedImage(xDimension,Ydimension,BufferedImage.TYPE_INT_RGB);//make a back buffer. the 3'ed parameter is just a constent, just copy that word for word
Graphics2D g2d = bi.createGraphics();//where your painting on to
public void paint(Graphics g)
{
g2d.drawImage(image,x,y,this);//draw your image on to the buffered image
g.drawImage(bi,0,0,this);//draw the buffered image onto the screen
}just tying to throw some ideas your way to make coding easier. if u need anymore help im happy to share ideas and code. |
|
|
|
|
|
#19 |
|
Newbie
Join Date: Jul 2008
Posts: 1
Rep Power: 0
![]() |
Re: 2-d graphics
The best approach I can come up with to is to generate the different shapes by building them from images in runtime. You should a have an image from a square, and then you could paint 4 times this square in a particular way, for example the I-shape would be 4 drawImage() with an ofsset on the X-axis.
If you use a JPanel to paint I think that you wouldn't have any flickering problems, and is also easy to use. I've find flickering problems when using Canvas. to paint an image, a good way to do it is: Image image;
void loadImage(String filePath){
try{
image = javax.imageio.ImageIO.read(new File(filePath));
}catch(Exception e){}
}
void paint (Graphics g){
g.drawImage(image, x, y, null);
}This works for me. I did a tetris game once, and it was very easy to have a int[][] where you logically mark the squares where there is a tetromino, and then in the paint you just paint the images according to this grid. I do think using images is the best approach because it will allow you to change the look of your game anytime you want to without changing the code. Last edited by seigiac; Jul 3rd, 2008 at 11:06 AM. Reason: correcting code |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|