File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Pong

 
Daniel O'Neill
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, it might be a bit early in my learning to start this, but I thought I would go onto Pong as my next project.
There are a few things that I need to know that I don't already, so I am going to ask them here, then look around on the net and see if I can't find the answers before somebody replies.
I am making the game Pong, you know 2 paddles and a ball that you can't let get into your goal.
Anywho, I know nothing of graphics in Java, and I am going to need to open a fullscreen graphics mode, and draw white and black rectangles - sounds fairly ez to me - I think I got the rest of the code down pat, but if I find I am stuck I'll come back.
PS: I really don't know a hell of a lot about how graphics are handled these days last time I was programming top of the line graphics were 320x200 dual color or 160x200 with a selection of 4 colors from a palette of 16 - lol
Dan

Edit: Done some searching - I'm only a bit closer to understanding graphics, and I see FullScreen is a bit of a stich with Java, it being new and all, I really didn't want to use a window though, so if any1 could give me a rough idea of some code - even URL to a simply stating site. Another thing is that I have opened up GIMP and made some graphics for the game - so I am now hoping to make 2 versions of the game, one with white rectangles, and another with some nicer graphics - another thing I was thinking of, but I don't know how hard it will be - LAN multiplay - maybe, depends on how hard it is to implement - but then again - it is all learning stuff, and good to know

[ January 16, 2005: Message edited by: Daniel O'Neill ]

2ndEdit:
I have got the following code

It generates the following error with NetBeans - but I can't seem to find it in the code (??)

Is it something I have setup in NetBeans causing this?? what is the best way to open a new file using that IDE??
[ January 16, 2005: Message edited by: Daniel O'Neill ]
 
David Harkness
Ranch Hand
Posts: 1646
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like the project in NetBeans assumes the class with the main() method is called Pong, but in your case it's Test. There should be an option to set the main class to run when you execute the application.
 
Layne Lund
Ranch Hand
Posts: 3061
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to tell NetBeans that the "main" class (the one that contains the main() method) is called Test (instead of Pong). Which version of NetBeans are you using? I'm quite familiar with 3.6, but only just recently downloaded 4.0 and am still learning it's new quirks. I'll still be glad to help you out when I have a chance to figure out how to do this myself.

Layne
 
Daniel O'Neill
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using NetBeans3.6 - nice if you can tell me how, but I'll try and figure it myself in the meantime.
Dan

Edit: I renamed the project to Test, that worked, now it displays my 'Hello World!' text quite nicely, I am looking for info now on making rectangles - BRB

[ January 16, 2005: Message edited by: Daniel O'Neill ]

2nd Edit: I got the title screen happening now, I still got yet another question, how do you set RGB colors in Java, I can easy change to the predefined ones, ATM I am using the following code - but it don't work, so if someone could correct me pls...

i is an int that cycles through values using i++.

[ January 17, 2005: Message edited by: Daniel O'Neill ]

3rd Edit: I have looked around and found much information on color, however I am still having no luck - the title screen code is listed here...

the error is marked with a '<<<===', and the error message is...

I have fidled with this for almost an hour now, and am going to play some EQ2, if anybody could tell me where I am wrong...
Dan
[ January 17, 2005: Message edited by: Daniel O'Neill ]
 
Marco Davids II
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Daniel,

there is no color constructor that takes double arguments
either use int or float

Cheers
Marco
 
Daniel O'Neill
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok so I change it to float like so...

and now I get the following error instead...

??
 
Marco Davids II
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Daniel ,

you have to explicitly state that 0.01 is a float by doing the following
clr = clr + 0.01f

Keep on trying ...
You'll get it ...
[ January 18, 2005: Message edited by: Marco Davids II ]
 
Joel McNary
Bartender
Posts: 1824
Eclipse IDE Java Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This seems a little bit much for the beginner's forum, so I'm moving it to the Games forum.
 
Layne Lund
Ranch Hand
Posts: 3061
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Daniel O'Neill:
I am using NetBeans3.6 - nice if you can tell me how, but I'll try and figure it myself in the meantime.
Dan

I don't have NetBeans handy ATM, but as far as I remember, you select Project | Set Main Class from the main menu. Alternatively, I think you can right click on a source file in the File System view and select "Set as Main Class" or something similar. You may need to add the source file to the project first.

Sorry if this is incorrect. Hopefully it will help you figure out how to do this, though. If you have any more questions specific to NetBeans, you should mosey on over to the IDE forum.

Keep Coding!

Layne
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic