Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 15th, 2006, 8:16 PM   #11
andro
Professional Programmer
 
Join Date: Oct 2005
Location: California
Posts: 294
Rep Power: 3 andro is on a distinguished road
Send a message via AIM to andro
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.
andro is offline   Reply With Quote
Old May 15th, 2006, 8:21 PM   #12
Jimbo
Battle Programmer
 
Jimbo's Avatar
 
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 754
Rep Power: 3 Jimbo is on a distinguished road
What about Graphics.draw3DRect and Graphics.fill3DRect?
Jimbo is offline   Reply With Quote
Old May 15th, 2006, 10:38 PM   #13
Eric the Red
Hobbyist Programmer
 
Eric the Red's Avatar
 
Join Date: Feb 2006
Posts: 214
Rep Power: 0 Eric the Red is an unknown quantity at this point
Quote:
Originally Posted by Jimbo
What about Graphics.draw3DRect and Graphics.fill3DRect?
i need faded rects like the one in the example i gave u.. can fillrect do that?
__________________
Death smiles at us all. All a man can do is smile back.
Eric the Red is offline   Reply With Quote
Old May 15th, 2006, 10:53 PM   #14
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 843
Rep Power: 3 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
Read this article.
titaniumdecoy is offline   Reply With Quote
Old May 18th, 2008, 2:04 AM   #15
mona singh
Newbie
 
Join Date: May 2008
Posts: 2
Rep Power: 0 mona singh is on a distinguished road
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.
mona singh is offline   Reply With Quote
Old May 18th, 2008, 4:15 AM   #16
Freaky Chris
Hobbyist Programmer
 
Freaky Chris's Avatar
 
Join Date: Dec 2007
Location: England
Posts: 169
Rep Power: 1 Freaky Chris is on a distinguished road
Send a message via MSN to Freaky Chris
Re: 2-d graphics

[delete me]
__________________
Who said i couldn't program
sarcasm = raw_input('Type in a sarcastic remark: ')
print sarcasm
Freaky Chris is offline   Reply With Quote
Old Jun 9th, 2008, 12:55 AM   #17
mona singh
Newbie
 
Join Date: May 2008
Posts: 2
Rep Power: 0 mona singh is on a distinguished road
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???
mona singh is offline   Reply With Quote
Old Jun 22nd, 2008, 1:33 AM   #18
MGSneak
Java Game Programmer
 
Join Date: Jun 2008
Location: U.S.
Posts: 10
Rep Power: 0 MGSneak is on a distinguished road
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
}
as far as the image over createing all the squares. if you want to use you images the only problem is... they're rectangles, not wacky shapes. you would have to make the polygon points to represent the collisions. the thing that would be easiest is to construct a 2d array that holds int's to represent one type of shape, then over time would transpose itself down.

just tying to throw some ideas your way to make coding easier. if u need anymore help im happy to share ideas and code.
MGSneak is offline   Reply With Quote
Old Jul 3rd, 2008, 11:02 AM   #19
seigiac
Newbie
 
seigiac's Avatar
 
Join Date: Jul 2008
Posts: 1
Rep Power: 0 seigiac is on a distinguished road
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
seigiac is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:14 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC