Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (753)
Games in Android Showcase (228)
games submitted by our members
Games in WIP (842)
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] 2 3 ... 11
1  Game Development / Newbie & Debugging Questions / Re: making the JFrame a little more gamelike on: 2007-09-28 22:41:07
I'm a college student. I barely have time to program, let alone sift through large sets of documentation. That's why I ask for help from people who obviously have more time than I do.

Ouch! I think you just scored -5 points there.
2  Discussions / Miscellaneous Topics / Re: Difficult maths problem in a network game on: 2007-09-22 00:33:48
I don't get it. I have implemented a similar system once, doing exactly the same thing with either turning at max rate or simply setting the position exactly. I see no reason why something would be slower or faster in another framerate.
3  Java Game APIs & Engines / Java 2D / Re: Loading custom image format on: 2007-09-18 20:42:07
If you want them scaled up, just load the pngs and scale them up programmatically.
Tileset not viewable in browser? Nobody is going to look for them anyway. Worry about that when it becomes a problem.
4  Java Game APIs & Engines / Java 2D / Re: PaintComponent method on: 2007-09-18 20:34:16
paintComponent is only invoked when something happens that requires redrawing, such as things being dragged around, text changes, etc.

If you do not somehow manually call repaint(), then there is no explanation why it would have a framerate greater than 0. But how can you observe that the "call is done 20 times a second" without having called something that results in a repaint with that frequency?
5  Game Development / Newbie & Debugging Questions / Re: Drawing on a JPanel, repaint request ignored. on: 2007-09-12 23:04:04
First of all, about MVC: it wouldn't be necessary to use the controller for any communication between view and model. You will want the view to have direct access to the model, since the view is likely a graphical representation of (some of the) model. See the graph here: .

The controller should basically handle the way in which user input affects the model. E.g. when the user presses 'space', the controller adds a 'missle' object somewhere in the model, or something similar. Thus, the paintScreen() method would have something to do with the *view*, not the controller - something like view.drawGameBoard, view.drawFPS, etc. (The underscore, by the way, is against java naming conventions).

I notice that there are some extra arguments in the paintComponent method you listed. When a repaint event is resolved by swing, it will call paintComponent(Graphics), and any method with the name paintComponent which accepts a different set of parameters will NOT be invoked.

You could do something like

protected void paintComponent(Graphics g){
    int score = model.getScore();
    g.drawString(.... appropriate arguments ... )

You could also use an image as a buffer, true, but at present I think you should just get used to the way swing works and not care about the other stuff.
6  Game Development / Newbie & Debugging Questions / Re: Drawing on a JPanel, repaint request ignored. on: 2007-09-12 16:46:30
A call to the repaint method makes sure that a repaint request is appended to the swing event queue. Swing constantly dispatches events from the eventqueue, eventually reaching the repaint request. However, you draw the string right after the repaint call, meaning that the repainting will be performed AFTER you have drawn the string. This is your problem.

The solution involves making sure that no drawing operation (by drawing operations I mean method calls on Graphics objects, as opposed to, say, repaint() requests) takes place outside of the paintComponent method, which is the normal way to do things (unless you want to draw on an image buffer or something). Throwing Graphics2D objects around OUTSIDE the paintComponent method is sure to cause trouble. Also, for the sake of things being easy, just call repaint() without any argument. If the game gets sluggish, you can worry about limiting the repaint rectangle at some other time.

As for your last question, the JPanel might not need to know what the score is, but it could call a method which *returns* the score every time it is drawn, i.e. something like game.getScore(). That way the panel will just have to know one object which takes care of the game-related stuff such as scoring.
7  Games Center / Archived Projects / Re: Wires: rotate the tiles so they are all connected on: 2007-08-30 10:39:38
Okay, I don't think I would be able to even reach 150. Possibly on a lucky map though. But I'm afraid you are the official champion now, captain. *grumble*
8  Games Center / Archived Projects / Re: Wires: rotate the tiles so they are all connected on: 2007-08-29 18:15:14
82 seconds, cripes! But 179 on a torus here, first attempt. I'll just have to crank out some more difficult versions to keep having the edge. And now, perhaps I should stop using JGO as a high-score table Smiley (before someone beats me again, which will undoubtedly happen soon)
9  Games Center / Archived Projects / Re: Wires: rotate the tiles so they are all connected on: 2007-08-29 17:17:28
Uh-oh, I don't want to start remembering tile-lockedness in order to speed up, so I guess I'll have to concede this one. Congratulations indeed. But try some topologies that don't terminate on the edge! Smiley
10  Games Center / Archived Projects / Re: Wires: rotate the tiles so they are all connected on: 2007-08-23 23:57:31
Balance restored!

(of course, cheating would be indescribably easy. But we all trust each other here)
11  Game Development / Newbie & Debugging Questions / Re: Not getting 0.0f on: 2007-08-22 23:41:34
What exactly was the problem again? Something about 0.0f?
12  Games Center / Archived Projects / Re: Wires: rotate the tiles so they are all connected on: 2007-08-21 16:53:06

One second faster and I would have to play 16x10 plane all over again, just to reinstate order in the universe Smiley

The source is included in the jar (in one big jumble. But it was the way Netbeans liked it, and I didn't feel like messing around. And I didn't write proper comments. And the gui code is a mess. I'll have to get it sorted out sometime. Enough with the excuses). The game is under GPL, so you are free to tinker with it as long as long as modified versions use the same license.

I use the simplest generation algorithm I could conceive.

An edge candidate is a potential connection from one tile to one if its neighbours. Each tile thus has four edge candidates which are shared among tile neighbours (so candidate count = 2 * tile count).

Make one big list of all possible edge candidates, then shuffle that list.

For each edge candidate in the shuffled list, connect the two corresponding neighbouring tiles, UNLESS that connection would be "illegal".

Illegal means that the tiles are already connected somehow. Of course this means that we'll have to keep track of connected tiles, which we'll consider now.

Every tile is assigned a number, called its index. Whenever a tile is connected to another tile during map generation, the indices of both tiles is set to the lower of the two tile indices. Actually this is done by means of a recursive flood fill through all the thus interconnected tiles, so any body of connected tiles has the same index at all times. The criterion of not connecting tiles that are already interconnected is thus enforced by requiring that the two tiles have different index.

This always results in the lowest possible connection count, namely n vertices connected with n-1 edges. So not only does the generated map have no closed loops, there is indeed no solution at all with any closed loops, which can be quite a powerful criterion when solving difficult games. Also it is, not surprisingly, impossible to find any solution with any loose tile connections.
13  Games Center / Archived Projects / Re: Wires: rotate the tiles so they are all connected on: 2007-08-21 00:29:57
Thanks for the suggestion, CaptainJester. I may implement it at some time, assuming I do have time.

In the meantime, you can get the solution to the puzzle currently played by disabling the "shuffle" checkbox, enabling "custom seed" and then creating, since the value in the spinner is the seed of the current game. Of course, if you wanted to look at both boards simultaneously, then you would have to copy-paste the seed to another instance of the game, which is admittedly quite inconvenient.

By the way, I will recommend trying some of the more complicated topologies. The planar topology provides a large number of hints since no connections can touch the edges. But it can be quite a challenge to solve the entire thing without those - then one will have to discover all the interesting tricks, the existence of which I have hinted at previously. Of course I may have include an option to disfavour the generation of tetravalent tiles, to make things really difficult.
14  Games Center / Archived Projects / Re: Wires: rotate the tiles so they are all connected on: 2007-08-18 19:49:25
Wow, thanks for the comments. As much as I would like to, I cannot take credit for inventing the game. There are some rather similar games out there. There are quite a few tricks one can use under specialized circumstances, regarding e.g. multiple L-shaped tiles in a row. Part of the fun is to discover all these tricks. This is mostly relevant when you really get stuck, which is more likely when using wrapping or flipping topologies.

For the reference, I just completed 16x10 plane in 114 seconds.
15  Games Center / Archived Projects / Wires: rotate the tiles so they are all connected on: 2007-08-18 15:39:51
The objective is to connect all the tiles by rotating them, see screenshot.

The class files and source code can be found in this executable jar file:

Right now you use either the keyboard or the mouse (if you have a scroll wheel, that is). If anyone has suggestions then they are very much welcome.
16  Discussions / General Discussions / Re: Pearls of Wisdom on: 2006-10-31 16:51:22
Nice! I'll have to remember that comparison, Breakfast Smiley
17  Discussions / General Discussions / Re: Pearls of Wisdom on: 2006-10-27 19:37:39
29 print more pearls of wisdom
30 goto 29
18  Discussions / General Discussions / Re: Pearls of Wisdom on: 2006-10-26 01:03:43
Cool avoid combinations of parentheses and numbers that result in smileys instead of other things.

EDIT: Also, always read the thread properly
19  Game Development / Newbie & Debugging Questions / Re: Immutable BufferedImage on: 2006-09-29 19:46:27
The suggested method wouldn't make the image immutable, because after running the constructor you can still have other references to the argument image outside and thus alter it. A more correct way would be to create a new BufferedImage inside the constructor which is a copy of the argument. This could still be altered if the user subclasses Graphics and overrides the drawImage method before passing it to the grawImage method of ImmutableImage, but this is getting pretty far out.

Your initial question, however, shows concern regarding "copying" of images. Do you have any other reason than that to want an immutable implementation?
20  Game Development / Newbie & Debugging Questions / Re: ? in Java on: 2006-09-29 19:38:51
The word break is reserved, so you cannot use it. You cannot have seen the code in question in a working program.
21  Discussions / Miscellaneous Topics / Avast, me mateys! on: 2006-09-19 13:03:42
[size=20pt]Ahoy ye scurvy landlubbers![/size]

Today be ye International Talk like a Pirate Day!
So yer better start talking like the pirates ye are, or ye'll be made to walk the plank, then keelhauled. ARRR!!
22  Game Development / Newbie & Debugging Questions / Re: How to implement a Timer? on: 2006-09-14 12:54:45
Whats bad with nanoTime? I thought currentTimeMillis is bad...
Well for windows, currentTimeMillis only goes in steps of 50 ms.
So if you use the source you posted, I would get time passed: 0, 0, 50, 50, 50, 100, 100, 150... if you count time passed since beginning.


That would have to be an older version of Windows. I have observed a figure of around 10 ms on Windows XP, and it is said that on Windows 98 it degrades to around 35 which is reasonably close to the figure you quoted.
23  Java Game APIs & Engines / Java 2D / Re: Ghost movement on pacman game on: 2006-09-07 15:22:14
Wouldn't hurt to try.
24  Game Development / Networking & Multiplayer / Re: Applet Failing After First Load on: 2006-08-20 16:45:31
I guess this is another case of "don't use static variables" wisdom. It can be convenient to use a static variable once in a while for ease of reference, but really it's bad practice. Static variables should generally be final and fully immutable (like String). That aside, I still use bad static references sometimes  Roll Eyes
25  Java Game APIs & Engines / Java 2D / Re: architecture: best way to implement a color palette on: 2006-08-20 01:34:32
It is possible to design your own look-and-feel. I have not done this, but I believe it would be the proper way to solve the problem in general.  There's some interesting stuff at which allows you to globally control the appearance of components. Or perhaps you can do something with the Substance look-and-feel which someone mentioned in another thread (Commander Keith?).
26  Game Development / Newbie & Debugging Questions / Re: Not initializing again... on: 2006-08-18 01:26:22
My eyes! First of all, use the
tag. It's the button with a #.

Okay, first time you run StupidFunction() you do the following:

Polygon p=new Polygon();

This creates a new polygon (with no points!) and assigns the reference p to it.


This reassigns the reference p to the previously defined polygon (to which the reference "poly" points). This COMPLETELY DISCARDS the newly created polygon since there will now no longer be a reference to it. I.e. you have changed the REFERENCE. You have not changed the POLYGON object. In other words, this line DOES NOT COPY THE COORDINATES of the old polygon into the new polygon.
for(int j=0;j<p.npoints;j++)   

Now you loop through the points of your first polygon (remember that p points to THAT polygon now) and add one to some coordinates. This PERMANENTLY alters your polygon. Thus, the x values are incremented by one next time you call StupidFunction().
27  Discussions / General Discussions / Re: Java .class files safe? on: 2006-08-14 12:54:10
While piracy is not *legally* theft, it is *morally* equivalent

So if you sell a game, you would be just as unhappy if a particular person happened to make one illegal copy of it as you would be if someone stole your wallet? Maybe the price of your product is slightly higher than the cash content of your wallet. Blimey. Those pirates should be locked up. They are the WORST.
28  Discussions / General Discussions / Re: Java .class files safe? on: 2006-08-13 16:33:34
I am clear on what you are saying: Are you claiming that there is nothing wrong with Copyright infringement ?

I think it's pretty obvious that he isn't.
29  Discussions / General Discussions / Re: Java .class files safe? on: 2006-08-05 00:21:04
Just write your game in Malbolge instead of Java. Problem solved. Smiley
30  Game Development / Newbie & Debugging Questions / Re: Couple of Optimal Questions on: 2006-08-02 11:22:39
Are you sure these questions are really optimal?  (sorry)
Pages: [1] 2 3 ... 11
ivj94 (580 views)
2018-03-24 14:47:39

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

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

Solater (60 views)
2018-03-17 05:04:08

nelsongames (107 views)
2018-03-05 17:56:34

Gornova (147 views)
2018-03-02 22:15:33

buddyBro (690 views)
2018-02-28 16:59:18

buddyBro (90 views)
2018-02-28 16:45:17

xxMrPHDxx (492 views)
2017-12-31 17:17:51

xxMrPHDxx (728 views)
2017-12-31 17:15:51
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!