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 (844)
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 / Shared Code / text class - centered shadowed text with multiple colors and fonts per line on: 2015-08-31 15:36:36
Here's a class I made for adding text in my games with shadowing to improve visibility and different fonts and colors for highlighting.  Does multiple lines of left/right/centered text with multiple fonts and colors.

Example usage:

Font p30 = new Font(Font.SERIF, Font.PLAIN, 30),  
     b20 = new Font(Font.SERIF, Font.BOLD, 20),
     i25 = new Font(Font.SERIF, Font.ITALIC, 25);

// drawing to Graphics object g
Text.draw(g, p30, Color.white, Text.NOSHADOW,
         Text.LEFT, Text.xy(20, 40), "left", 30, "aligned", 30, "text",
         Text.RIGHT, Text.xy(580, 40), "right", 30, "aligned", 30, "text",
         Text.CENTER, Text.xy(300, 40), "center", 30, "aligned", 30, "text",
         40, Text.shadow(, 1, 2), "centered shadowed text",
         30,, "with multiple ", i25,, "colors",
   , " and ", Color.cyan, b20, "fonts per line.");


The text class:

public class Text{
  static int x0 = 0, y = 0, xOffSet = 0, yOffSet = 0, alignment = 0;
  static Color shadowColor = null;
  // for use as parameters in draw method
  public static Position xy(int x, int y){
    return new Position(x, y);
  public static Shadow shadow(Color c, int x, int y){
    return new Shadow(c, x, y);
  public static final Shadow NOSHADOW = new Shadow(null, 0, 0);
  public static final Alignment LEFT = new Alignment(0),  
                                CENTER = new Alignment(1),
                                RIGHT = new Alignment(2);
  // args: String, Color, Integer(new line spacing), Font,
  //       Position( xy(x, y) ), Shadow( shadow(c, x, y) or NOSHADOW ),
  //       or Alignment( LEFT, CENTER or RIGHT )
  public static void draw(Graphics g, Object...args){
    int i = 0;
    while (i < args.length){
      int w = 0, j = i;
      // get number of arguments in current line
      if (alignment == 0){
        while ((j < args.length) &&
               ((args[j] instanceof String) || (args[j] instanceof Color) ||
                (args[j] instanceof Font) || (args[j] instanceof Shadow)))
        // if center or right alignment calc line width
        Font f = g.getFont();
        while ((j < args.length) &&
               ((args[j] instanceof String) || (args[j] instanceof Color) ||
                (args[j] instanceof Font) || (args[j] instanceof Shadow))){
          if (args[j] instanceof String)
            w+= g.getFontMetrics().stringWidth((String)args[j]);
          else if (args[j] instanceof Font)
      // arguments starting a new line
      if (j == i){
        if (args[j] instanceof Integer){
          y+= (Integer)args[j];
        }else if (args[j] instanceof Position){
          x0 = ((Position)args[j]).x;
          y = ((Position)args[j]).y;
        }else if (args[j] instanceof Alignment){
          alignment = ((Alignment)args[j]).alignment;
      // draw line of text
        int x = (alignment==1) ? x0 - w/2 : (alignment==2) ? x0 - w : x0;
        for (int k = i; k < j; k++){
          if (args[k] instanceof String){
            if (shadowColor == null){
              g.drawString((String)args[k], x, y);
              Color c = g.getColor();
              g.drawString((String)args[k], x+xOffSet, y+yOffSet);
              g.drawString((String)args[k], x, y);
            x+= g.getFontMetrics().stringWidth((String)args[k]);
          }else if (args[k] instanceof Color){
          }else if (args[k] instanceof Font){
          }else if (args[k] instanceof Shadow){
            shadowColor = ((Shadow)args[k]).color;
            xOffSet = ((Shadow)args[k]).xOffset;
            yOffSet = ((Shadow)args[k]).yOffset;
        i = j;
  public static class Shadow{
    Shadow(Color c, int x, int y){ color = c; xOffset = x; yOffset = y; }
    Color color;
    int xOffset, yOffset;
  public static class Alignment{
    Alignment(int a){ alignment = a; }
    int alignment;  // 0 = left, 1 = center, 2 = right
  public static class Position{
    Position(int X, int Y){ x = X; y = Y; }
    int x, y;
2  Games Center / Showcase / Re: Regrowth [move to showcase board] on: 2014-02-10 17:20:54
Please move to the showcase board.
3  Games Center / Showcase / Re: Regrowth [Update Jan 22, 2014] on: 2014-01-23 00:15:55
Jan. 22, 2014 updates

  - lots of new and improved sound effects
  - more music
  - music is streamed with a fade effect for transitions
  - improved sunset background and night background with twinkling stars
  - the day slowly transitions to night during gameplay
  - added fireflies which follow you around at night to provide light
  - sound and music volume settings
  - can now move with arrow keys in addition to WASD keys
4  Games Center / Showcase / Re: Regrowth [Update Dec. 22, 2013] on: 2013-12-23 01:51:14
Updates for Dec. 22, 2013

  - upon exiting, progress is autosaved to Regrowth.sav
  - game settings are saved to Regrowth.ini
  - for better compatibility, starts up in windowed mode and added a
    borderless windowed fullscreen display mode
  - main menu order changed to continue/save&exit/new game
  - more descriptive in game tutorial
  - vines grow faster
  - can remove plants while still growing
  - removing plants causes them to shrink instead of fade out
  - variable cloud movement speeds and transparency
  - minor fixes to game map tiles and layout alterations
  - several other minor improvements

For the next update I plan to focus mainly on improving the audio.
5  Games Center / Showcase / Re: Zombie Hordes on: 2013-11-22 02:02:38
Pretty solid start. Add some buildings to run around and you have the makings of something pretty fun.

Flaming zombies is always good.

I'm probably not going to add any more to this game, but sometime I might make a sequel with more survival elements such as searching buildings for ammo and equipment.  Got two other games I'm working on at the moment so it'll be awhile.
6  Games Center / Showcase / Re: Zombie Hordes on: 2013-11-22 01:56:54
Great start indeed.
It's working fine and it's addictive too !  Grin

Is there a way to redefine controls ?


Sorry but there's no way to redefine controls.
7  Games Center / Showcase / Re: Regrowth on: 2013-11-18 15:15:56
I played it for about 15 minutes and stopped when I got stuck.

I feel like the pause menu should have "Continue" at the top, rather than below "New Game".
There are a few graphical glitches, but other than that the game runs perfectly fine.

- Jev

Yeah I think that might be better.

Here is a playthrough by BlueByte on youtube.
8  Games Center / Showcase / Re: Regrowth on: 2013-11-17 22:34:16
I just played the game through the end. Very nice!

My only suggestion for the ending, have one more sound cue, a single chord perhaps that resolves or otherwise gives a nice ending, instead of letting the loop music continue forever. Have it come in after the end of a complete loop cycle.

Possible ending: Asus4 chord, then add low E, then drop to low A and resolve the sus4 to a maj 3rd.

That sounds like a good idea.  I'll put it on the list for my next update. 
9  Games Center / Showcase / Re: Regrowth on: 2013-11-16 17:21:59
I think the term you're looking for is "Borderless Fullscreen" (Although true fullscreen is borderless as well, this is just how it's referred to)
You can just add an option to use borderless fullscreen or regular fullscreen in your options menu.

Yeah, sounds like the best solution.  I'll have something like:

Display mode:  Windowed / Fullscreen Exclusive / Borderless Fullscreen
10  Games Center / Showcase / Re: Regrowth on: 2013-11-16 17:19:25
It works but the dock and menubar comes over it.

Maybe it's just a problem with Java2D because OpenGL works on my system well. Anyway, thanks for trying.

Oh well.  At least it works windowed.  I agree it must be a Java problem.  Thanks for letting me know.
11  Games Center / Showcase / Re: Regrowth on: 2013-11-15 16:34:49

Sorry, but there is no change over versions.

Here's a version using an undecorated maximized window as a fake fullscreen.  

(link removed)

It looks just like fullscreen to me from a static display and the transition in and out of fullscreen is much smoother.  Unfortunately, when moving its not so smooth.   If only Java had a vertical sync function!! (without using native code)

If you turn on show fps it also should display 'mac' to the right of it.  Considering just using the fake fullscreen if a mac is detected although i'd hate to set it for all macs if only a few are affected.  Maybe I'll allow it to be set in the options.

Let me know if this fixes the fps and keyboard problems.
12  Games Center / Showcase / Re: Regrowth on: 2013-11-15 04:29:38

I think this is an issue in with the Java. Here's a question that might help you to solve this. It says to set frame to invisible and then make it visible again after entering fullscreen mode.

Heres a version setting the frame invisible after calling setFullScreenMode()

(link removed)

like this:


Hope it works.
13  Games Center / Showcase / Re: Regrowth on: 2013-11-14 17:23:41

No, a desktop. Intel Dual Core CPU @ 3.6GHz, 4 GB DDR3 Ram, nVidia GeForce 210 1GB graphics card, Mac OS X 10.8.5

Fullscreen exclusive mode uses double buffering, but memory shouldn't be a problem at all.  If you maximize the window does it have a large performance hit too?   Whats the fps with the bilinear filtering option turned on?

 I should probably switch back to starting up in windowed mode by default.  It seems less likely to have problems.
14  Games Center / Showcase / Re: Regrowth on: 2013-11-14 01:45:57
[EDIT: It occurs to me some system info might be helpful. I am running Windows XP, Java 7. Also, was wondering about the OP name: J(ava) Gard(e)ner...and its relationship to the game!]

Ha you have found me out!  I am the Java Gardener!

I tried running the game two ways and had a problem with seed throwing each time.

When I ran the game after clicking the jar (I do have a Windows system), throwing the seed (left mouse click) always threw for a long distance to the left. Right click did the same and did cause the mushrooms to fade.

When I ran via the .exe, the same thing happened except the throws were much closer to the tree (shorter distance). (Second try via .exe, the left throw was again a long distance and only to the left, regardless of which way I was facing.)

I wish I knew what could be causing that problem.   Could you check if the bullets go where the mouse pointer is in my game Zombie Hordes?  Click on my name in the GameJolt download page to find it.

I think the sounds and music are reasonably good, but maybe a bit more tweaking is in order. I found the slow piano music a bit morose for this game. I think it is a very pretty piece of music, well written and solid as a composition, just not exactly hitting the right tone for the game. I can see wanting something peaceful, but maybe this can be achieved without what for me evokes melancholy.

Yeah I was originally intending, and time permitting will, make the story that you have returned from a long journey to find your forest home burned down and you have to restore it.  Also, that would be just the intro music.  More energetic music would play when you encounter enemies.

Likewise the seed throwing seems like a near miss. And the "ungrow" maybe could be different from the "grow"? But I don't know what I'd use instead.

The sprite is slightly different, but it needs revising.  Also needs a different sound.

You might rerecord your music sample, if you decide to keep this same cue. There are at least 3 audible clicks in it, two near the beginning and one close to the end that almost sound like lp record pops.

Hey there is!  Gotta admit I didn't notice that.

I like the menu system a lot and the way the game kicks off seems very promising and clear. It looks like a really neat concept for a game and I look forward to being able to grow my way past the first two-level obstacle. Congratulations on all you have achieved here!

Thanks for the feedback!  Hopefully someday you will make it past that obstacle!

15  Games Center / Showcase / Regrowth on: 2013-11-13 21:48:26
Returning home from a long journey, you must make your way up a mountainside.  Overcome obstacles along the way by growing climbable mushrooms, vines and roots with magical seeds.


Regrowth is fairly short at roughly 10 to 20 minutes to complete, although I am considering making a greatly expanded remake/sequel sometime.

Read Regrowth.txt in the download for more info

a full playthrough:

<a href=";hl=en_US&amp;start=" target="_blank">;hl=en_US&amp;start=</a>

16  Games Center / WIP games, tools & toy projects / Re: The Chasm [Update Oct. 3, 2013] on: 2013-10-04 00:21:51
I guess I'm not cool then Sad

Jgardner: Sounds like its going good! I like the art concept and I would love to see this finished so keep it up!

Thanks!  and... come on!  Start putting dates on your topics!  Then you can be kool too!  Grin
17  Games Center / WIP games, tools & toy projects / Update Oct. 3, 2013 changes on: 2013-10-03 22:32:27
Oct. 3, 2013 Update:
  - Flattened tiles to better simulate a viewpoint looking down at
    roughly 45 degrees(tile size increased from 32x32 to 48x32).

  - Most tiles were touched up for the increased tile size.
  - Lighting, movement, and ambient sound altered for the new tile dimensions.
  - Some combat mob images and grid sizes were altered to work with the new
    tile dimensions.

  - Switched resolution to widescreen(960x540). Looks best in fullscreen at
    1920x1080 with no bilinear filtering.

I still have some perspective correcting changes to do for the next update.
18  Games Center / WIP games, tools & toy projects / Re: The Chasm on: 2013-09-23 01:46:50
honestly I had no problem with the tiles, they are what made me play it for so damn long really.

but I get whats being said, surely all you need is what Robin said, like in the first picture you'd just keep the flat big and be able to go under in (for the bit facing upwards)

I see what you mean about the part facing upwards.

I've been trying different tiles sizes and I'm leaning toward 32x24.  It corresponds roughly to a 45 degree angle so horizontal and vertical should be flattened the same amount which makes it a lot easier.  Plus the change isn't too drastic, but an improvement.
19  Games Center / WIP games, tools & toy projects / Re: The Chasm on: 2013-09-22 18:11:46
Yeah, currently you look topdown at the tiles, and at the side / top of chars, this gives some odd effects.
Just make the tiles instead of 32x32 something like 32x16, so the tiles or more squeezed tougether for the (looking from the side) effect.
If you want to do this easly for your game, you could just give textcoords 0, 0, 1, 2 instead of 0, 0, 1, 1 (the corners needs some hacking though)

Thanks for the comments! Looks like I'll be making this the main focus for my next update.  I'm considering 32x16, 32x24 or 48x32.  I'd say I'm leaning to 32x16 (30 degree angle view from horizontal) right now since most of my mobs and vertical objects will look reasonable as they are(basically a sideview).  The main concern is how to handle this in combat.  Also considering switching from 960x640 to 960x540 so its a nice x2 scale to 1920x1080 fullscreen and since there will now be more tiles shown vertically in the screen.
20  Games Center / WIP games, tools & toy projects / Re: The Chasm on: 2013-09-21 18:13:58

Ah I see.  I bet that would look nicer.
21  Games Center / WIP games, tools & toy projects / Re: The Chasm on: 2013-09-21 18:05:09
dat ass, i mean art,

that was really good, combat could do with some variety, perhaps bonus if you get attacked from behind and ability to choose direction

sometimes when i positioned myself behind a chest the spiders all bunched and I could just kill them with range attacks

Combat is pretty basic so far.  I'm planning on adding lots and lots of variety.   Definitely hitting from behind should give a major bonus.  Also I hope to add special attacks which require stamina and magic.  Monsters will have effects too such as an immobilizing web attack for the spiders.

Combat pathfinding is pretty basic right now too.  I plan on using A* or something similar eventually.
22  Games Center / WIP games, tools & toy projects / Re: The Chasm on: 2013-09-21 17:56:11
Nice art, however you should consider making your terrain tiles more flat, so it matches the 45 degrees rotation effect of the entitys.

Thanks for the feedback.  I'll keep it in mind when I eventually go back and reevaluate all my tiles.  Do you mean to flatten out the tiles for terrain horizontal to the ground to make them more distinguishable from entities and barriers such as cliff wall tiles?
23  Games Center / WIP games, tools & toy projects / Re: The Chasm on: 2013-09-21 17:53:18
Wow really interesting art style and lighting! I love how your tiles sort of blend together at the edges, it looks very nice.

Thanks!  That's nice to hear.
24  Games Center / WIP games, tools & toy projects / The Chasm [Update Oct. 3, 2013] on: 2013-09-21 00:53:52
The Chasm is an RPG with a huge area to explore and turn-based strategic combat.


See post below for update notes.

After taking a tumble over a waterfall you find yourself alone and trapped at
the bottom of a chasm with nothing but the tattered clothes on your back.

In development, but fully playable with roughly 1 to 2 hours of gameplay so far.  
The Chasm is a role-playing game in which you explore a huge area gathering
together a group of followers along the way.  Encounter NPC's and a large
variety of creatures to combat.  Engage in turn-based strategic combat with
multiple factions.

25  Games Center / Showcase / Re: Zombie Hordes on: 2013-09-11 22:35:18
Im getting the creator is a Zombicide board game fan Smiley

Afraid I've never played it.   Looks like fun though.
26  Games Center / Showcase / Re: Zombie Hordes on: 2013-09-11 22:31:37
Hey, this looks pretty neat. Graphics are for sure a +1. Is it made from you?

Thanks!  Everything is made by me, except for the music and most of the sound effects.
27  Games Center / Showcase / Zombie Hordes on: 2013-09-11 16:15:37
Can you survive against the relentless onslaught of the zombie hordes? Each new wave brings more and tougher hordes of zombies.


Random weapons(12 guns + 2 grenades) and other items drop with more powerful weapons becoming available in later waves.  The flame thrower and other fire base weapons can ignite zombies causing damage over time and in turn ignite other zombies nearby.

random item drops / wave first available
Pistol / Default (not dropped)
Medkit / 1
Molotov Cocktail / 1
Incendiary Ammo / 1
Flare Gun / 1
.44 Magnum / 1
Sawed-Off Shotgun / 2
SMG / 4
Flame Thrower / 5
Riot Shotgun / 6
Assault Rifle / 8
Fire Grenade / 9
Combat Shotgun / 10
Railgun / 12
Minigun / 14
Plasma Gun / 16

a short gameplay video

<a href=";hl=en_US&amp;start=" target="_blank">;hl=en_US&amp;start=</a>

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

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

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

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

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

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

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

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

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

Solater (159 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!