Java-Gaming.org Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (803)
Games in Android Showcase (237)
games submitted by our members
Games in WIP (867)
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 ... 19
1  Game Development / Newbie & Debugging Questions / Re: html question on: 2011-07-23 19:39:07
1  
2  
3  
4  
5  
<table cellspacing="0" cellpadding="2" class="box" width="300"> 
 <tr bgcolor="#ffffff"><td>Test msg. bla bla bla.
  <br align="right"><a href="index.jsp?user=M77">M77</a> <font class="small_font">x sec ago</font> <a href="index.jsp?reply=1">reply</a></br>
  </td></tr>
</table>


doesn't work
see result here
I don't think you're supposed to use the br tag that.  br is for a line break.  You don't put stuff inside it and should never have any reason to use /br.

I could be wrong here, but I can't see any way that would do anything.

Edit: Looking back on this topic, I see that my original post wouldn't have solved your problem anyways.
2  Discussions / General Discussions / Re: Why You Might Want To Consider Java For Your Next Project on: 2011-07-14 17:39:21
I used to try to program games in C++.  I scorned Java because it was an interpreted language.  I viewed it as a language for sissies.

There was a problem with the games I programmed in C++: by and large, I couldn't get them to work.  I programmed some garbage for DOS in high school, but DOS was already becoming obsolete by that point.  When I switched to Windows programming, I was wholly baffled.  I kept trying to make a game, when I really needed to figure out the basics of Windows programming first.

Then I was forced to learn Java in a programming class.  I tried to program a game in Java because I was fed up with C++.  It sort of worked.

So, in short, I use Java because I can make games that actually work in Java.

Knowing what I know now, I could probably buy some books about C++ game programming and figure out how to write games in C++ instead.  But how would that help me?  I don't have performance problems or know of anything I could do with C++ that I can't do with Java.  I don't see the point in using C++ to do what I'm doing, though it would probably be instructive to do more exploration with using other programming languages.

Edit: I mean that using other languages would probably help enhance my programming skills in general, not that I expect to find out that some other language is superior to Java.
3  Game Development / Newbie & Debugging Questions / Re: Scripting for dummies? on: 2011-07-14 17:27:07
I used to use something similar that let you use a Java-like scripting language within Java.  I thought it was way too complex.

Now, I'm using my own scripting language that looks vaguely like HTML.  It's not as powerful as XML, but it's a little easier to work with because it's designed to only include the sorts of stuff I need.  It's very limited at this point, but I'm confident that I can expand it to be what I need.

Java includes some kind of scripting support, but I haven't investigated it.  Instead, I read the book "Writing Compilers and Interpreters 2nd Edition" by Ronald Mak.  There is a 3rd edition available that uses Java instead of C and is available as a Kindle ebook.  The 2nd edition was sufficient, though I will most likely buy the 3rd edition before the next time I move.

In any case, my point is that people often program their own very limited scripting languages.  I think this produces a superior map editor because I no longer have to mess around with a bunch of features that I don't need and have everything integrated in a sensible way.  It does require some time and effort, and the custom scripting language doesn't have many of the features included in a general purpose scripting language.  I don't want to use my map editor's scripts to sort arrays or do math - only to execute a simple set of commands for displaying dialogue, opening doors, etc.
4  Game Development / Newbie & Debugging Questions / Re: html question on: 2011-07-14 17:14:22
You could have a table within the table, which you don't want to do.  Actually, it doesn't have to be a table: it could just be another block tag, such as p.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
<table>
<tr>
<td><p align="left">slajf ljlsjdf las</p>

<tr>
<td><p align="left">sljfals djfl askd</p>

<tr>
<td><p align="right">sfasdfsdf</p>
</table>


I think that should work, but I haven't tested it.
5  Game Development / Game Play & Game Design / Re: Naming a Rogue-like on: 2011-06-08 12:55:32
Why don't you want to include a plot? Setting seems interestng and fresh...

Anyway i would add something unique to a mythical name, just to avoid competing with wikipedia on google search.

Something like "Canaan Carnage", or "Uwe (the hero) whips the Ugarits"
I'm saving the plot for the 2nd game.  The 1st game is really just a prototype of sorts, but I'm going to make it open source and give it away for free.

The 2nd game will be the same basic engine + character animation, real artwork, and a plot.  The 1st game is pretty much a test run for various features and an opportunity for me to make a game with random dungeon generation.
6  Game Development / Game Play & Game Design / Re: Naming a Rogue-like on: 2011-06-06 01:59:25
The main reason I was leaning towards Ugarit over Canaan was that someone on another forum said that Canaan sounded biblical.

I plan on focusing on some of the more obscure characters in Canaanite myth.  In the first game, I think you'll be able to pick between Athtar and a female who I haven't chosen.  In the second game, it will be Elihu (one of the sons of Keret, who might not actually have been a god) and probably Qetesh.

The first game is more of a prototype for the second game than anything else.  It won't have much of a plot and will be similar in spirit to Angband, though it will have actual graphics (albeit poorly drawn and unanimated graphics) and will be much more modern.

I want to add RL to the name to separate it from the 2nd game, which will be a more standard RPG.

The 2nd game will kind of be a mish-mash of the Legend of Keret and the beginning of the Baal Cycle.  Since it will contain the end of one myth and the beginning of another, I don't see any way to name it after one or the other.

Do you have a website for your game yet?  I'm interested in keeping tabs on it since we both seem to have the same general idea, even though our two games might be completely different.
7  Game Development / Game Play & Game Design / Naming a Rogue-like on: 2011-06-04 17:16:39
I'm working ever-so-slowly on an open source Rogue-like.  It is based upon Canaanite myth, but I'm making the Canaanite gods look like angels (though somewhat more bird-like).  I was calling it Angelband, but it's not an actual Angband variant.  So it seems like somewhat of a misnomer.

This might be pointless because all you can do in the "game" right now is walk around and open door.  But I figured I'd post this anyways.

And then I arbitrarily starting changing references to the game to "UgaritRL", a name I had chosen.  Then I heard from one guy that "Angelband" is better.  I'm looking for some feedback about the following possible names:

Angelband
Canaanband
CanaanRL
Canaan Testament
Tablets of Destiny (is actually from Sumerian myth)
Testament Rogue
The Canaangate Scandal
The Ugarit Conspiracy
The Ugarit Scandal
Ugaritband
UgaritRL
Ugarit Testament

All the *bands sound like Angband, so I think they're a little bit inappropriate.  The "Rogue" entries might be equally inappropriate because it's not a variant of Rogue, but I think it's more generic (though also perhaps confusing).  "RL" stands for "Rogue-like".  "Canaan" is the country the myths come from, and "Ugarit" is the city the myths were found in.

The Rogue-like won't have much of a plot, but it's sort of a prototype for a more normal RPG, which will have a plot.  Unfortunately, I can't just name the game after the myths because I'm blending them together with eachother, adding some background material from the Book of Enoch, and adding aliens, robots, demons, and the kitchen sink.

Again, at this point, all you can do in the game is walk and open a door.
8  Games Center / Showcase / Re: Lionheart Remake on: 2011-06-04 15:44:33
I saw this and thought you meant Lionheart: Legacy of the Crusader.

Guess not. Smiley
9  Games Center / Archived Projects / Re: Calfstronaut and the Computer Bug Infection Beta Test on: 2011-06-04 15:43:19
It does seem to store the save file in the folder the installer assigns as the working directory (which happens to be directory it's installed to).  At least the file is winding up in some weird place, but it seems weird that it doesn't get stored in the user directory.  It should have been that way since Windows XP.

If it weren't for the installer assigning the working directory, it could think the working directory is anywhere a shortcut to the program happens to be.  Or at least that's what I remember from my own usage of the working directory (in Java - no, I wasn't putting the save game files in the working directory in the games I make with Java).
10  Games Center / Archived Projects / Calfstronaut and the Computer Bug Infection Beta Test on: 2011-06-03 18:07:54
http://www.orbitalcows.com/cbi.php

I've uploaded the beta test of Calfstronaut and the Computer Bug Infection to my website.

The artist I usually work with made this game himself using Gamemaker, and I'm setting up the beta test for him.

This is a casual game where you click on computer viruses to clear them off of your mainframe.  There's various power ups to use and malicious code sequences that you can't click on.

There's screenshots and a preview video at the url.  It provides a link for giving feedback.  Anyone who sends in feedback is eligible to receive a free copy of the finished game.

The game gets installed to the C:\Games\[our directory]\ directory instead of the C:\Program Files\[our directory]\ directory because he can't figure out how to put the save file in the user directory with Gamemaker.  So it just gets saved to the directory the game is in, which could be a problem if the program doesn't have write access to the C:\Program Files\ directory (which depends on the Windows settings for the user playing it).  If anyone has an idea about how to fix this, I'll pass it on to him.

Maybe I shouldn't post a Gamemaker game to a Java game forum, but I went ahead and posted it to the forum I actually have an account for.
11  Game Development / Performance Tuning / Re: Static Code Analyzers on: 2011-05-23 03:47:20
Find Bugs appears to be working out ok.  It isn't going to change anything drastically, but I'm rearranging some of my code.  It's relatively easy to locate problems with all these tools unless they find a superabundance of warnings about nothing.  Fortunately, you can turn most of that stuff off.

I don't think I want to go so far as to switch to a different IDE to get better static code analyzers.  It looks like I can use the IntelliJ IDEA for free because I'm making an open source game, but I don't want to encounter problems if I suddenly decide to use the same engine to make a shareware game.  I could just buy the IDE, but I don't want it badly enough.
12  Discussions / General Discussions / Re: Advice for Game Designers on: 2011-05-23 03:42:40
What kind of information are you looking for?

It sounds like you're looking for a design document that compares and contrasts different development choices.  I have no design document, though I probably should have one.  I might be willing to try to bang one out at some point.

Right now I'm interested in game-play mechanics.  E.g., how the animation loop, game loop, turns, etc. are done.  I would be interested in seeing a demo and then that might trigger more specific questions.  It's Angelband right?
Yes.  Angelband's seriously a demo where you can walk and open a door, so I don't know what you could learn from it at this point.  There MUST be better sources of information.  I think I will create another thread and try to post some links that my be useful to some people.

I think my map editor's nifty, but that's just my opinion.

However, I do plan to post the source code at some point in the near future.  I'm cleaning it up now but will probably implement dialogue before actually uploading it.  It shouldn't take long if I can actually find time to work on it.

One problem with the code is going to be that it includes my own widget system.  It even includes a couple packages of utility classes that essentially duplicate functionality java.util and other packages provided by Oracle.  So my code is sort of like a whole library of crap that happens to contain some files that are relevant to the actual game.
13  Game Development / Performance Tuning / Re: Static Code Analyzers on: 2011-05-18 18:28:11
I'm installing Find Bugs and will try it out tomorrow or Friday.  Even if it just catches a couple of things I want to change, it's worth trying out.

Thanks!
14  Discussions / General Discussions / Re: Advice for Game Designers on: 2011-05-18 18:21:42
I've always wanted to have some basic tutorials about how I did this on my website, but I never have time to do it.  I did have a very basic tutorial at one point, but I took it down to make a better version.  And then I never did.
hmm another tutorial, I want it Smiley

and I like only using library due to my low skill Cheesy
I really want to upload some kind of tutorial at some point, but I don't know when I'll ever have time.  I can't even find time to code my own game.

Maybe I could find some way to upload an article with one minor piece of information every so often.  I might eventually wind up with something resembling a real tutorial.

Maybe you could buy Developing Games in Java or Killer Game Programming in Java.  These books were both useful to me, though they're getting a little old now.
15  Game Development / Performance Tuning / Static Code Analyzers on: 2011-05-17 21:34:30
I'm trying to use static code analyzers to streamline my code and make it more readable.  The code's supposed to be open source, and I want it to actually be useable.

This isn't about performance so much as usability, but I wasn't sure where else to put this.

I've been getting my static code analyzers in the form of eclipse plug-ins.

First, I tried Unnecessary Code Detector (http://www.ucdetector.org/).  This worked pretty well.  I shut off all the warnings about changing visibility because most of them seemed unimportant, but I found the plug-in useful for removing unused code.  It also helped me find a few class stubs that I had created with the intention of implementing specific features.  I now have these specific features listed on my todo list so that I can implement them.

It also has the ability to check for dependency cycles (where class A calls class B and class B also calls class A).  Limiting dependencies is desireable, though I didn't do much with this.  It simply wasn't worth the time sorting out the mess.  Some of the cycles are perfectly acceptable for various reasons.

Second, I tried PMD (http://pmd.sourceforge.net/).  This found a ridiculous number of problems, most of which seem to be about obscure code style issues that seem somewhat arbitrary to me.  I am changing some of my code to match their naming conventions and such, but many of the warnings appear to be unimportant.

Does anyone have any advice about any other static code analyzer plug-ins to use or any comments about their experiences with static code analysis?
16  Discussions / General Discussions / Re: Advice for Game Designers on: 2011-05-17 17:46:09
Right now, I'm making a Rogue-like, so the proper thing to do would be to start with an existing Rogue-like engine and modify.  However, I'm going to still finish my own engine for this game.  I've implemented essentially every feature of a Rogue-like at one time or another (with the notable exception of random map generation).  I do have the technical know-how to generate a Rogue-like - I can outdo games from 30 years ago.

Cool, do you have any more information?  I'm working on a Rogue-like as well so I'm curious to find out more about what you have done and what your approaches to various aspects of the game are.
What kind of information are you looking for?

It sounds like you're looking for a design document that compares and contrasts different development choices.  I have no design document, though I probably should have one.  I might be willing to try to bang one out at some point.

I'm planning to include the source code for my game sometime soon.  Right now, I'm removing unused code and trying to eliminate some dependencies.  My code is unnecessarily complex because I've implemented my own custom widget system that's more image-centric than Swing and my own utility classes.  My utility classes are essentially a subset of those already present included with Java.  I programmed them largely for recreation after seeing a topic here about Java not having a Bag class.
17  Discussions / General Discussions / Re: Advice for Game Designers on: 2011-05-17 17:37:07
How much of: http://www.orbitalcows.com/ is yours?
It's only Angelband (a basically unplayable demo at this point), Nanotron, Lucky's Puzzle Carnival, and an old RPG called Rabbits (which is hiding at http://www.orbitalcows.com/cowgod/ because it doesn't have quality artwork).    For Nanotron and Lucky's Puzzle Carnival, I split the profits with Eduardo, who did the artwork.  There was also someone who did the music.  I did all the programming myself.

There's also a couple of Gamemaker games that Eduardo made without my help.  The rest of the games are games I'm selling as an affiliate through BMT Micro or freeware games the creators allow me to distribute on my website.

I have programmed other games, but they were more-or-less garbage.  They were, however, stepping stones up to Nanotron and Lucky's Puzzle Carnival.  I also made 3 "rpgs" which lead up to what I'm making now.  (Rpg #1 was never finished because I didn't know what I was doing back then.  Rpg #2 had a complete though low quality engine, but never really had content.  Rpg #3 was a complete though fairly simple RPG.)  Angelband is the next logical step in my rpg-chain.  It's totally awesome except that the only thing you can do at this point is open a frigging door, but, trust me, the code I wrote for it is awesome.

Selling games as an affiliate can be a valuable source of income, though my website is too obscure to really make money from it

My current plan is to make a Rogue-like to give away as a free open source game.  If I ever actually complete the Rogue-like, that might bring some people to my site.  Then I plan to upgrade the Rogue-like to an actual RPG with a plot and improve it based upon the feedback from the Rogue-like.

The game should be much farther along than it actually is.  I haven't been working on it enough, and alot of the work I've been doing is stuff that doesn't directly contribute to what the player does in the game.   I just wrote a utility program for assembling images of body parts into one-frame character images, but that doesn't make the game immediately better.

I think we talked about this long ago, and I think you should ignore my previous advice.  I looked at your games and I think you should do the following instead:

1. Use J2AS or use GWT for HTML5 or Flash output
2. Push your games on Flash websites with adverts
I think your previous advice would be good for transitioning to 3d games, which I have no idea how to make.  I've never been sufficiently motivated to take that step though.

Nanotron and Lucky's Puzzle Carnival would most likely receive better sales on phones or ipads or some such thing than on the pc.  And they would probably be played more as free games on Flash websites, though I doubt the advertisement income would be significant.  It would still be better than the relative pittance of sales I have now.

However, I don't know if I want to invest the time to learn how to port the games to other platforms.  I have to expend a significant amount of effort to learn how to port the game and then port the game.  I recall an instance where Eduardo wanted me to port Nanotron to a handheld console from South Korea.  I bought an external hard drive so that I could install Linux and try out their toolkit.  I couldn't get my network card to work with Linux and gave up on it.  I'm glad that I did because that handheld console is basically dead.

I would have had to buy the console just to test the game on it, and I'm not sure it's really worth it.  It's the same with porting it to a phone or something.

I did port the games to Mac OS X at one point, but no one bought it.  I stopped supported the Mac version and threw away the Mac I bought just to port the games.

I bookmarked a tutorial about GWT (which seems to be a little better organized than J2AS), but I've got a bad feeling that porting games over would be rather difficult.  It seems more likely that I could develop games in Java specifically to be converted with GWT and the convert them.  But then why not just make the games in HTML 5 in the first place?

At various times, I've considered making a game in Flash, and Eduardo seems to think that Gamemaker is wonderful for some reason.  If I'm going to invest time into something new, I want it to be something that can produce better games, which Flash and Gamemaker can't.  They may be faster, but I think the main problem with my games is quality, not platform.

You have lots of assets being wasted that would make you plenty.  I didn't realize you had done so much.  Great work BTW.

I also think that if you wanted to share then I could port them to my AllBinary Platform for J2ME and Android, but I have not finished my Adobe Air or HTML5 output yet.
I might be willing to do something like this with you.  If you could port Nanotron and Lucky's Puzzle Carnival to other platforms with little or no effort from me, that might be worthwhile.  I could probably convince Eduardo that we could share the profits from such an endeavor.  However, I'm not sure there would actually be profits from this.  Where would you distribute J2ME or Android games?

In the interest of full disclosure, Nanotron has only had several dozen sales (I don't know the exact number off the top of my head), and Lucky's Puzzle Carnival has had 0.

If you're really interesting in porting those 2 games in order to get a handful of sales, email me at cowgod14@yahoo.com.  I'll have to confer with Eduardo, but we might be able to work something out.  It would have to be some kind of royalty agreement though because I lack confidence that moving the games to phones and such would solve their problems.

You might have been talking about the other games on the site anyways, but I have no control over those.

@fletchergames
did you build all games of OC without any engine? I mean, from scratch?
Only the games I actually made.  But, yes, I built them from the scratch.  My first couple of games that I made years ago used an engine, but then I taught myself to make my own.

I've always wanted to have some basic tutorials about how I did this on my website, but I never have time to do it.  I did have a very basic tutorial at one point, but I took it down to make a better version.  And then I never did.

The sad story is that I never have enough time.  Last year was especially bad, but this year is looking a little bit better.
18  Discussions / General Discussions / Re: Advice for Game Designers on: 2011-05-15 14:39:08
fletchergames,

If you have a hard time making games then you should just start with a high level tool.  Go with Unity, UDK, or Crysis SDK (when it becomes semi free) and run with that.  Those tools will give you much of the correct philosophy required to make good games and give you a nearly free 10 year head start on people like me, cas, and others that built their own tools.
That sounds like excellent advice.  I've been resisting using 3rd party tools for a long time, but I think that's the only realistic choice I have for creating games that use 21st century technology.

Right now, I'm making a Rogue-like, so the proper thing to do would be to start with an existing Rogue-like engine and modify.  However, I'm going to still finish my own engine for this game.  I've implemented essentially every feature of a Rogue-like at one time or another (with the notable exception of random map generation).  I do have the technical know-how to generate a Rogue-like - I can outdo games from 30 years ago.

The main issue I have for this particular game is that I have to actually work on it.  There's been long periods where I haven't touched it.  In the time periods where I did work on it, I spent alot of time fiddling around with graphical user interface elements and making a map editor.  Adding actual features to the game should go much more quickly.

In some sense, this is a waste of time.  The end result isn't going to be a game people will buy, but I'm content to make a Rogue-like just as a hobby.
19  Discussions / General Discussions / Re: Advice for Game Designers on: 2011-05-14 14:26:50
About the actual topic...

I don't have computer science degree, though I do have a minor in computer science.  I didn't learn enough information to justify the vast amount of money I spent, but I acknowledge that I could have learned significantly more if I had been a better student.  However, very little of the course material was relevant to game programming.

There were high-level courses in computer graphics and networking that would have been useful, but I didn't have the requirements to take those classes.

After college, I've been trying for years to make games.  And everything I've made has been garbage.  It's gradually becoming better garbage, but I'm not on any path to ever being good.

So I didn't really benefit that much either from college or from trying to develop games at home.  There's more to becoming a game developer than just completing a few classes or making a better version of Pong at home.  I don't know what the path to being a real game developer is, but I have a feeling that I'm not on it.

I don't know if this really counts as advice or not.
20  Discussions / General Discussions / Re: Game development books on: 2011-04-26 16:03:25
Killer Game Programming in Java is similar to Developing Games in Java.  I'd suggest buying both.
21  Game Development / Newbie & Debugging Questions / Re: Is java a good language to make 8-bit games? on: 2011-04-09 03:17:10
I was curious because I really want to make some 8-bit games and I want to know if java can do that just as good or better than others such as c++. A great example of a good 8-bit game I want to make is http://wootfu.com/beacon/.
Forgive my ignorance, but what exactly do you mean by an "8-bit game"?  Is that just a game that's similar to those that were available in the era of 8-bit computers?

Or maybe you're programming for a phone or something that only has 8-bit registers?

It's not any of my business, but I'm curious.
22  Discussions / Business and Project Management Discussions / Re: How much would it cost? on: 2011-04-09 03:14:23
I don't think Facebook supports Java anymore.  I think you have to use Html or Flash for Facebook apps.

I don't know if that really applies to what you're doing, but I saw you mentioned Facebook.
23  Discussions / General Discussions / Re: Best general game programing books on: 2011-04-09 03:09:09
The standard suggestions are:

Killer Game Programming in Java
Developing Games in Java

If I can remember the names right.  It's been a while.

KGPiJ is available as a Kindle ebook if that means anything to you.

I wouldn't try using a book for a different language unless it were about a specific topic.  In C, you would have to deal with OpenGL or some such thing.  In Java, you can but don't have to.  I would suggest not trying to learn about optional information like OpenGL untill you have some solid Java experience.
24  Discussions / Business and Project Management Discussions / Re: How much would it cost? on: 2011-03-22 14:01:03
Well, what you need is website hosting that supports servlets.  You get hosting + servlets for about $10/month from Lunar Pages ($4.95 hosting, $4.95 servlets) unless they've changed their prices.  There may be other cheaper services.
25  Game Development / Newbie & Debugging Questions / Re: Game Loop question: Which way is better? on: 2011-03-07 13:43:41
In all fairness, I did screw around with the Killer Game loop slightly.  It's supposed to have an update phase that always uses a constant time period, but I made mine use a variable time period.  I was losing time when the timer was too granular because it would still sleep or yield or whatever.
26  Game Development / Newbie & Debugging Questions / Re: Game Loop question: Which way is better? on: 2011-03-04 21:21:36
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
protected final void runSafely() {
   //verify that the loop will continue
   shouldContinueLoop = true;
   
   //This variable is used for computing the length of an update phase.
   long lastUpdatePhase = Time.currentTimeMillis();

   while(shouldContinueLoop) {
      //if the application isn't active, sleep for half a second
      if(!isApplicationActive()) {
         try {
            Thread.sleep(500);
         } catch(InterruptedException exception) {}
           
         continue;
      } //end if the frame isn't active
     
      //figure out the start of the current phase
      long currentCycle = Time.currentTimeMillis();
      long updatePhaseLength = currentCycle - lastUpdatePhase;
      if(updatePhaseLength > maximumUpdateLength)
         updatePhaseLength = maximumUpdateLength;
     
      //update the current model
      doUpdatePhase(updatePhaseLength);
      lastUpdatePhase = currentCycle;
   
      //render the game
      render();
     
      //yield to other threads
      Thread.yield();
   } //end while forever
} //end runSafely


I was just talking about this at http://www.java-gaming.org/topics/simple-game-loop/23831/msg/198753/view.html#msg198753.  I added the Thread.yield because of what they said, though it doesn't seem to change anything.  My current code doesn't have any of the sleeping and oversleeping stuff from Killer Game Programming in Java.
27  Game Development / Newbie & Debugging Questions / Re: Game Loop question: Which way is better? on: 2011-03-04 04:07:26
Andrew Davison covers this in his book "killer game programming", You can download the source he has for various timers here http://fivedots.coe.psu.ac.th/~ad/jg/ch1/index.html
I had some weird problems using the game loop code from that book, though I admit that I did make a couple of small changes to it.  The problems were only a significant issue on older computers, so it took me years to figure out what caused it.  I deleted the portion of my game loop that was from Killer Game Programming in Java, and my code suddenly started working.
28  Game Development / Shared Code / Re: Simple Game Loop on: 2011-03-03 17:15:01
I didn't notice the replies to this thread before.

I added a Thread.yield() with no apparent difference.  I don't think I want to mess with it any more than that since it actually works now.  I might tamper with it for future games, but this is a game that I released quite two years ago.

Maybe now that it doesn't have these performance issues on certain computers, someone will actually buy it.

It was never that much of an issue on newer computers, but it did mess up the timer.  I had received reports of the game being unplayable on really old computers, but I used to think it was because of the giant background images.  Removing the background images did increase performance, but that wasn't the real issue.  Sadly, it's difficult to pinpoint these things because I don't have any QA staff or even a bunch of old computers to test the game.
29  Game Development / Shared Code / Simple Game Loop on: 2011-02-24 00:22:09
I was making a video of gameplay for a game I made previously when I noticed that the level timer was horribly slow.  For a 23-minute video, it said that it took me 6-minutes to play the level!  First, I looked at the code for outputting the time.  That was fine.  Then I traced the method calls that set the time all the way back to the main loop.

I've had various problems with the game running sluggishly since before the game was released.  On newer computers, it wasn't much of a problem, but it was horrible on older computers.  It was odd because the game didn't seem like it should use much in the way of system resources.  I've "fixed" this many times without the problem really being fixed.  I decided to take a long hard look at my game loop.

Here was my old code:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
protected final void runSafely() {
   //verify that the loop will continue
   shouldContinueLoop = true;
   
   //This variable is used to only skip yielding a certain number of times in a row.
   byte numDelays = 0;
   
   //This variable stores how much time the loop overslept by in the last cycle.
   //Negative values probably won't occur because Thread.sleep shouldn't undersleep.
   long overSleepTime = 0L;
   
   //This variable is used for computing the length of an update phase.
   long lastUpdatePhase = Time.currentTimeMillis();

   while(shouldContinueLoop) {
      //if the application isn't active, sleep for half a second
      if(!isApplicationActive()) {
         try {
            Thread.sleep(500);
         } catch(InterruptedException exception) {}
           
         continue;
      } //end if the frame isn't active
     
      //figure out the start of the current phase
      long currentCycle = Time.currentTimeMillis();
      long updatePhaseLength = currentCycle - lastUpdatePhase;
      if(updatePhaseLength > period)
         updatePhaseLength = period;
     
      //update the current model
      doUpdatePhase(updatePhaseLength);
      lastUpdatePhase = Time.currentTimeMillis();
   
      //render the game
      render();
   
      //figure out how long the cycle took
      long timeAfterCycle = Time.currentTimeMillis();
      long cycleLength = timeAfterCycle - currentCycle;
      long sleepTime = period - cycleLength - overSleepTime;
     
      //if some time is left in this cycle
      if(sleepTime > 0) {
         //sleep
         try {
            Thread.sleep(sleepTime);
         } catch(InterruptedException exception) {}
           
         overSleepTime = Time.currentTimeMillis() - timeAfterCycle - sleepTime;
      } //end if some time is left in this cycle
      //else no time is left in this cycle
      else {
         overSleepTime = 0L;

         //don't sleep, but yield if absolutely necessary
         numDelays++;
         if(numDelays >= maximumDelaysPerYield) {
            //yield to let other threads execute
            Thread.yield();
            numDelays = 0;
         } //end if there have been too many delays
      } //end else no time is left in this cycle
   } //end while forever
} //end runSafely


The code was heavily based upon the game loop code in Killer Game Programming in Java, though it wasn't quite identical.  The point of most of the code was to allow other processes to run at the same time as the game rather than hogging all the system's resources.  I deleted most of that code.

Suddenly, the sluggishness problems were less, though the bug with the time wasn't fixed.  It increased the "period" constant from 40 to 250 because it is effectively the maximum length of the update phase in milliseconds.  The problem was solved.

I also changed one other line of code
1  
lastUpdatePhase = Time.currentTimeMillis();
to
1  
lastUpdatePhase = currentCycle;
.  This didn't change anything for me, but I figure I was losing the time that update phase took, which wouldn't show up on the timer.  Since my computer is way more powerful than what the program needs, the update phase just happened to be almost instantaneous.

This is now my game loop for a game I'm updating:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
protected final void runSafely() {
   //verify that the loop will continue
   shouldContinueLoop = true;
   
   //This variable is used for computing the length of an update phase.
   long lastUpdatePhase = Time.currentTimeMillis();

   while(shouldContinueLoop) {
      //if the application isn't active, sleep for half a second
      if(!isApplicationActive()) {
         try {
            Thread.sleep(500);
         } catch(InterruptedException exception) {}
           
         continue;
      } //end if the frame isn't active
     
      //figure out the start of the current phase
      long currentCycle = Time.currentTimeMillis();
      long updatePhaseLength = currentCycle - lastUpdatePhase;
      if(updatePhaseLength > maximumUpdateLength)
         updatePhaseLength = maximumUpdateLength;
     
      //update the current model
      doUpdatePhase(updatePhaseLength);
      lastUpdatePhase = currentCycle;
   
      //render the game
      render();
   } //end while forever
} //end runSafely


I won't go so far as to say that the code from Killer Game Programming in Java was wrong because I didn't copy it exactly.  I'm just saying that you have to be careful what you do with your main loop code.  My program has always been somewhat sluggish because of the main loop code, and I didn't notice the timer but until I made a gameplay video.

The problem is probably caused by how the rest of my code worked.  In KGPiJ, the update phase seems like it does a specific amount of updating in each phase.  My own code sends the number of milliseconds elapsed to the update method, which updates different amounts based upon how much time has passed.  This caused me to change parts of KGPiJ's game loop, which is probably how things got screwed up.

I have some concerns that my program might run at 100% CPU usage now, but that doesn't seem to actually happen for some reason.  In any case, I would rather use 100% of the CPU than have the game run slowly with an incorrect timer.
30  Java Game APIs & Engines / Java 2D / Re: 2D-sprites and screen resolution on: 2011-02-20 04:45:53
If you're using mouse controls, your mouse coordinates will no longer match the coordinates of objects on the screen after you stretch the graphics.  You'll have to take that into account.
Pages: [1] 2 3 ... 19
 
Riven (388 views)
2019-09-04 15:33:17

hadezbladez (5280 views)
2018-11-16 13:46:03

hadezbladez (2204 views)
2018-11-16 13:41:33

hadezbladez (5544 views)
2018-11-16 13:35:35

hadezbladez (1149 views)
2018-11-16 13:32:03

EgonOlsen (4583 views)
2018-06-10 19:43:48

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

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

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

nelsongames (4707 views)
2018-04-24 18:15:36
A NON-ideal modular configuration for Eclipse with JavaFX
by philfrei
2019-12-19 19:35:12

Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08
java-gaming.org 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‑gaming.org
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!