Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (843)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Newbie & Debugging Questions / Re: Moving away from a frame made of buttons(tic tac toe) on: 2012-02-21 04:50:34
I don't think my pre-calculus teacher would approve of me programming in class so that's a no-no Tongue

As for the Java course, I've already finished the work for this semester (we are only heading up to chapter 9 - which introduces how to use JComponent and a Frame to draw a circle - i've decided to move on and am approaching the end of chapter 12) That was the pinnacle of this course - took me 3 weeks to get there and now I'm bored (hence why I hopped on here - game programming is something I'm very interested in). The first 9 chapters are pretty much - the jvm, syntax, how to declare variables, an array and touching on class design. Pretty lame course.

The assignment due last week was something along he lines of storing two names and variables and outputting which person had the greater age - spent the entire time reading ahead in the book (it goes from 17:00-23:00) - Also have been looking into C++ to familiarize myself with the syntax of that language since I am required to take it next semester Tongue
2  Game Development / Newbie & Debugging Questions / Re: Moving away from a frame made of buttons(tic tac toe) on: 2012-02-21 03:25:22
Thank you for being so helpful, both of you.

Ra4king that is pretty much what I was trying to get at I just wasn't sure what to do :X

I'm stoked to check out Glass' site , I have 7 hours of free time between my first and second class tomorrow - what a great way to spend it! Hopefully I can become a bit more active around here - seriously I am loving this soooooooooooo much - maybe a bit to much. Staying in on Friday/Saturday nights so I can work through a java book ? Who needs to go out Tongue
3  Game Development / Newbie & Debugging Questions / Re: Moving away from a frame made of buttons(tic tac toe) on: 2012-02-21 01:53:38
It's a hint more complicated than you make it sound.

First, the act of painting is not done by you, it's handled by the Swing/AWT Gui thread. When you call 'Repaint', it will signal that a repaint is needed. If you call it, it guarantees that at some time in the future, the Component will be painted. That is, if you call repaint a hundred times before the GUI Thread gets priority, it will only paint once (Probably, correct me if I'm wrong).

However, fifteen lines to paint your Tic-Tac-Toe board? Probably not a big draw on your CPU.

As for only repainting one region? That gets a little more complicated, and is probably too much to worry about right now (Especially since you'll probably spend more time figuring out which portion to repaint, than repainting). Because if you only repaint when someone clicks, you're going to have several unplayable zones. Especially if you end up using anything else (Menus, etc.).

Since you sound like you're still trying to figure out how you're going to have your logic, you should leave it how it is (Since it works) and work on getting your logic working with what you've got. Especially if you're making a "play against the computer" version.

Aw bummer - alright. I was planning on implementing AI into the first version of my game - I guess I'll have to wait til I learn more about the Swing/Awt in next semester's course(this semester is a bit of a joke but it's a pre-req to the second level Java Programming) - unless you may be able to recommend a specific book ? I find the Sun tutorials to be thorough but not very noobie friendly - its more like straight information being thrown at me.
4  Game Development / Newbie & Debugging Questions / Re: Moving away from a frame made of buttons(tic tac toe) on: 2012-02-21 01:37:08
Eeek okay - I'm sorry for bug you guys again but I've spent about ~ 2 hours trying to figure this out and the Java API is still a bit confusing to me, I didn't want to come back and post again about the same issue but I am cvonfusing myself the further I investigate.

When I call paintComponent n my Board constructor - does this call only occur once? I ask because I use about ~15 lines of code to draw my Board (using 2DLine) and it seems like its a bit of a waste of memory/time if paintComponent is called every time I use repaint() - and if that is the case how would I be able to store freshly painted X's and O's if they are overridden each time by paintComponent(the method I am using to draw the board) ?

That being said... I can't figure out how to paint to only a particular area of the screen - I understand how to implement MouseListener and to get coordinates clicked but I don't understand how I can draw to only a specific region without being tedious.

For example : Player clicks @ (50,60) (the upper left spot) - is there a way to designate that spot (those upper left coordinates) to an object and then draw onto that object [by object I mean something to represent that upper left region on the jcomponent]? I'm trying to figure out how I would check win conditions etc if I have no way to organize the board. Should I use a JLabel or something of the sort and draw on there?

I'm not sure if I took your advice of JComponent to literally although I fear I have.

So far I have two classes - the TicTacToe class featuring main & extending frame - and the Board class which I hope to implement MouseListener, game logic and painting.

Well, he was going to have a JFrame, with something inside of it. JFrame is a Swing component (It's built on AWT, yes, but it's in the purview of Swing). And you don't want to have an AWT thinger inside of a Swing thinger.

Is there a way to do this without a JFrame ? I wasn't aware of there being other frames I could use.

5  Game Development / Newbie & Debugging Questions / Re: Moving away from a frame made of buttons(tic tac toe) on: 2012-02-20 21:01:11
Awesome thanks for the suggestions - i'll get to work right away!
6  Game Development / Newbie & Debugging Questions / Moving away from a frame made of buttons(tic tac toe) on: 2012-02-20 20:12:35
Hey what's up everyone I'm new to Java and programming in general and I would like to know if there is another way to do the following:

I followed a tutorial online to make a Tic Tac Toe game that is GUI based. The game composed of an array of JButton's and a JFrame - all held in the same class file. I know I can setIcon for the JButtons but I hope to eventually move into real graphics so I figure this is the simplest place I can start.

I wanted to expand my knowledge with the Java graphics library so instead of setting the text in the JButton to "X" or "O" I wanted to draw (on a JLabel maybe?) a Circles / X's.

Could anyone give me any pointers on what libraries I should look into or maybe any TicTacToe tutorial that does what I am hoping to do?

Thanks for any insight you can offer.

Pages: [1]
EgonOlsen (37 views)
2018-06-10 19:43:48

EgonOlsen (20 views)
2018-06-10 19:43:44

EgonOlsen (39 views)
2018-06-10 19:43:20

DesertCoockie (186 views)
2018-05-13 18:23:11

nelsongames (122 views)
2018-04-24 18:15:36

nelsongames (121 views)
2018-04-24 18:14:32

ivj94 (861 views)
2018-03-24 14:47:39

ivj94 (122 views)
2018-03-24 14:46:31

ivj94 (758 views)
2018-03-24 14:43:53

Solater (139 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!