www.jpct.net

jPCT - a 3d engine for Java => Projects => Topic started by: fireside on October 01, 2008, 04:23:15 am

Title: strategy game
Post by: fireside on October 01, 2008, 04:23:15 am
My next project, which is basically in the concept phase, will involve turn based strategy but be single player.  I was inspired by RoBombs to do something involving pathfinding and AI.  I plan to start fairly simple with just a fight test, but as usual, I think more in terms of characters because I'm a modeler.  Anyway, this is a character I plan to put in the game.
(http://img229.imageshack.us/img229/9264/dragongamebl5.th.jpg) (http://img229.imageshack.us/my.php?image=dragongamebl5.jpg)(http://img229.imageshack.us/images/thpix.gif) (http://g.imageshack.us/thpix.php)

It's just taken from inside of Blender so far.
Title: Re: strategy game
Post by: fireside on November 19, 2008, 09:57:38 pm
Finally got started on this project.  I'm not the greatest programmer, so things are going a little slow.  So far I can click and put a cube on the closest square of a 30X30 grid and then move around another cube which will show possible moves.
(http://img84.imageshack.us/img84/279/screen1ud6.th.jpg) (http://img84.imageshack.us/my.php?image=screen1ud6.jpg)(http://img84.imageshack.us/images/thpix.gif) (http://g.imageshack.us/thpix.php)

The next thing is to set up an imaginary map using a two dimensional array that has character position and blocked squares because of walls or something and implement astar pathfinding.  I'm not sure if strategy is the right name for this game but it won't really be role playing either since there won't be character choices, etc, but it will eventually act somewhat more like a role playing game with a story without as much inventory management or camping and whatnot.  I plan on wandering around in first person and then jumping to a high altitude 3rd person when there is a fight.
Title: Re: strategy game
Post by: EgonOlsen on November 19, 2008, 11:08:21 pm
Sounds like Heroes of Might and Magic with a first person view or something. I remember the old AD&D games that did the same: First person (very basic of course) when moving around and a turn based view from above (or isometric) when there was a fight.

Edit: My own RPG for the Amiga did exactly the same thing... ;)
Title: Re: strategy game
Post by: fireside on November 19, 2008, 11:24:45 pm
Yeah, where I saw it was from the game Betrayal at Krondor.  It's so old that the first person view is more like a slide show and then they do turn based fighting from a somewhat overhead.  The game is still a lot of fun, though, except for the slide show effect.
Title: Re: strategy game
Post by: fireside on November 30, 2008, 06:26:12 pm
This is the latest screen shot from my project.
(http://img513.imageshack.us/img513/6794/screen1wj9.th.jpg) (http://img513.imageshack.us/my.php?image=screen1wj9.jpg)

I've been using a still of the dragon as a test model.  Right now I can move the mouse around and the marker will follow it in a closest to grid motion and then when I click the dragon will turn and move to it.  I've written an astar path finding algorithm from a tutorial on the internet but haven't installed it in the game yet.  The dragon looks pretty small but I think it will be alright with animations.  The trees are experiments with billboarding that seem to work pretty good.  I'm considering using a map for main movement and then doing closeups for fights and towns to save file space.
Title: Re: strategy game
Post by: fireside on December 05, 2008, 06:00:40 am
(http://img386.imageshack.us/img386/9564/screen1qh5.th.jpg) (http://img386.imageshack.us/my.php?image=screen1qh5.jpg)

I've finally gotten the applet working properly.  I have idle and fly animations for the dragon.  It seems to run fairly well with this number of trees but I'll have to see what happens when more characters are in the scene.  Next is getting my astar algorithm in the game.  I also tried a different world texture.  The grass seemed too redundant.
Title: Re: strategy game
Post by: fireside on December 11, 2008, 06:02:47 pm
I think I have the path finding implemented now.  I'll have to do some testing but it seems to work.  I plan to put up a small demo when I'm sure it's OK.
Title: Re: strategy game
Post by: fireside on December 13, 2008, 04:59:20 am
A demo of path finding can be found here:
http://fireside7games.com/labz/strat_test1.html
Title: Re: strategy game
Post by: paulscode on December 13, 2008, 01:19:55 pm
Cool.  What heuristic are you using in your pathfinding code?
Title: Re: strategy game
Post by: fireside on December 13, 2008, 02:43:32 pm
I'm using the Manhattan thing from this tutorial I found. I think it's the simplest one.  I hope that's what you mean.  Otherwise I'm just using zero right now for the other thing.
Title: Re: strategy game
Post by: EgonOlsen on December 13, 2008, 03:52:37 pm
Nice. However, i got this once right after clicking somewhere into the applet:

Code: [Select]
Exception in thread "Thread-11" java.lang.NullPointerException
at org.me.hello.WebPlayer.move(WebPlayer.java:391)
at org.me.hello.WebPlayer.run(WebPlayer.java:143)
at java.lang.Thread.run(Unknown Source)
Title: Re: strategy game
Post by: fireside on December 13, 2008, 04:34:42 pm
Yeah, it's still a little buggy.  ;D
Title: Re: strategy game
Post by: paulscode on December 13, 2008, 08:20:05 pm
The manhattan distance heuristic is what I am using in my pathfinding code too.  Basically that's adding the difference in x to the difference in y to estimate distance to the target - less precise than using a pythagorean distance heuristic, but much faster in most cases.
Title: Re: strategy game
Post by: fireside on December 13, 2008, 08:44:25 pm
Yeah, I think speed is the most important.  It probably doesn't matter much for this game because it will be turn based, but real time games where the npc's are constantly making decisions like Robomb, I think you would need the fastest thing you could get. It should come in handy for lots of games.   
Title: Re: strategy game
Post by: EgonOlsen on December 14, 2008, 12:24:18 pm
...but real time games where the npc's are constantly making decisions like Robomb, I think you would need the fastest thing you could get. It should come in handy for lots of games.   
It shouldn't be too slow, but whether you are doing a sqrt or not usually doesn't matter. Even less in Robombs, where the bots are running on their own client instance, i.e. they are running in their own thread. On current multi core cpus, i have at least 75% of one cpu available for AI, which, if used properly, could lead to much smarter bots than i have today...
Title: Re: strategy game
Post by: paulscode on December 14, 2008, 02:15:02 pm
That's a good point.  Computers have gotten a tad faster than they were back when when I wrote pathfinding code for my games on the 486 (25MHz) ;D  Still I would think it could become a concern for really huge maps with lots of NPCs, although I have no solid numbers to back that comment up, lol.
Title: Re: strategy game
Post by: fireside on December 14, 2008, 09:03:07 pm
Yes, those were the days.  That was my first real computer, I guess.  Before that, I had a Radio Shack Color Computer.  I didn't even consider path finding back then, though.  I was lucky if I could keep from messing up Windows. 

My next thing to think about on this project is particles.  I did a search and it sounds like it's something that I need to write myself but I found some of Egon's code so I'm looking at it.
Title: Re: strategy game
Post by: paulscode on December 15, 2008, 12:11:29 am
Before that, I had a Radio Shack Color Computer.
Hah!  I learned to program on the Color Computer.

Come to think of it, I made my first game on a Color Computer (it was a text-based math problem game).
Title: Re: strategy game
Post by: fireside on December 16, 2008, 03:25:24 am
I remember typing a lot and that's about it.  I think I did actually write a few programs, but I copied a lot of them out of a magazine and then ran the game for a few minutes and turned it off.  I did get to be a good typist anyway.  ;D

I got the particle system in the game for the dragon fire.  I plan to use software render so I cut down the count quite a bit.  The next thing to do is work out a menu system at the bottom of the screen.

(http://img386.imageshack.us/img386/3301/drfiremx5.th.jpg) (http://img386.imageshack.us/my.php?image=drfiremx5.jpg)
Title: Re: strategy game
Post by: fireside on December 18, 2008, 02:32:49 am
(http://img88.imageshack.us/img88/9898/screen1ab2.th.jpg) (http://img88.imageshack.us/my.php?image=screen1ab2.jpg)

This is the menu system I decided to at least start out with.  I'll probably have the attack button cascade up to more buttons for choices.  The game will be fairly simple so there won't be an elaborate inventory system. 
I finally figured out how to change fonts with the buffer.  It must have something to do with instancing.  If I used:
buffer.getGraphics.setFont()
buffer.getGraphics.drawString();

 it doesn't work, but if I use:

Graphics n = buffer.getGraphics();
n.setFont();
n.drawString();

it works.
Title: Re: strategy game
Post by: EgonOlsen on December 18, 2008, 08:40:17 am
If I used:
buffer.getGraphics.setFont()
buffer.getGraphics.drawString();

 it doesn't work, but if I use:

Graphics n = buffer.getGraphics();
n.setFont();
n.drawString();

it works.
That makes no sense to me...both are equivalent.... ???
Title: Re: strategy game
Post by: paulscode on December 18, 2008, 01:17:43 pm
If I used:
buffer.getGraphics.setFont()
buffer.getGraphics.drawString();

 it doesn't work, but if I use:

Graphics n = buffer.getGraphics();
n.setFont();
n.drawString();

it works.

I noticed the same thing in one of my projects a while back.
Title: Re: strategy game
Post by: fireside on December 18, 2008, 05:08:44 pm
It must have something to do with the font not being permanent when it's changed, so when you get a new instance the font is lost and goes back to a default.  If the graphics were a static it shouldn't do that.  But then, I'm not the best java programmer, so that's just a wild guess.
Title: Re: strategy game
Post by: EgonOlsen on December 18, 2008, 11:50:31 pm
Ok, but the context should be static. The graphics context that the buffer returns is the one from the BufferedImage which backups the frame buffer. And that doesn't change as long as you don't dispose the frame buffer... ???
Title: Re: strategy game
Post by: fireside on December 19, 2008, 12:00:51 am
That is strange then.  At least it works this way. ;D 
Title: Re: strategy game
Post by: paulscode on December 19, 2008, 01:37:27 am
I did a test, and noticed the same thing happens for the BufferedImage.getGraphics() method.

This prints the message in the correct font and color:
Code: [Select]
        BufferedImage imageBuffer = new BufferedImage( 640, 480, BufferedImage.TYPE_4BYTE_ABGR );
        Graphics g = imageBuffer.getGraphics();
        g.setFont( new Font( "Courier", Font.BOLD, 16 ) );
        g.setColor( Color.RED );
        g.drawString( "TESTING", 100, 100 );

This on the other hand just prints the message in the default font and color:
Code: [Select]
        BufferedImage imageBuffer = new BufferedImage( 640, 480, BufferedImage.TYPE_4BYTE_ABGR );
        imageBuffer.getGraphics().setFont( new Font( "Courier", Font.BOLD, 16 ) );
        imageBuffer.getGraphics().setColor( Color.RED );
        imageBuffer.getGraphics().drawString( "TESTING", 100, 100 );

That would explain why it happens in the frame buffer's getGraphics() method, since it is backed by a BufferedImage.
Title: Re: strategy game
Post by: EgonOlsen on December 19, 2008, 09:17:56 am
Maybe getGraphics() creates a new instance every time?
Title: Re: strategy game
Post by: paulscode on December 19, 2008, 01:26:46 pm
Seems like it.

Nice job on the game, BTW.  I need to get back to working on my game at some point.  I'm easily side-tracked ;D
Title: Re: strategy game
Post by: fireside on December 19, 2008, 02:51:42 pm
Quote
Nice job on the game, BTW.

Thanks. 
Title: Re: strategy game
Post by: fireside on December 28, 2008, 09:00:00 am
I posted an update.  The two buttons move and attack work.  The cursor must be close to the dragon for the attack, then click after clicking the attack button.
http://fireside7games.com/labz/strat_test1.html
Title: Re: strategy game
Post by: fireside on December 31, 2008, 10:49:44 pm
I started working on my second character and changed the trees.
(http://img187.imageshack.us/img187/6491/screen1vh5.th.jpg) (http://img187.imageshack.us/my.php?image=screen1vh5.jpg)
Title: Re: strategy game
Post by: fireside on January 06, 2009, 06:07:33 am
Small update.  There are two players now and an icon tells which is which.
http://fireside7games.com/labz/strat_test1.html
Title: Re: strategy game
Post by: EgonOlsen on January 07, 2009, 08:28:48 pm
How can i move the dragon? I'm always playing as the wizard... ???
Title: Re: strategy game
Post by: fireside on January 08, 2009, 05:31:13 pm
If you hit the attack button, the player will change after the attack is complete.  Attacks are shorter range so you need to put the cursor closer to the character before you can see the cube that shows where it will turn towards.
Title: Re: strategy game
Post by: fireside on January 15, 2009, 05:23:49 am
I've been reorganizing my code, which I think is a little more extensible now, so nothing to show.  My next goal is to have two attack choices for each character.
Title: Re: strategy game
Post by: EgonOlsen on January 15, 2009, 08:08:18 pm
If you hit the attack button, the player will change after the attack is complete.  Attacks are shorter range so you need to put the cursor closer to the character before you can see the cube that shows where it will turn towards.
I see...have you considered to make move/attack context based, i.e. if i click on the terrain it's always move and if i click on a character other than myself (and i'm close enough), it will always attack? It feels a bit clumsy to be forced to click on "move" first to start moving. There's no need for this extra click IMHO...if it's my turn, i should be able to move right ahead.
Title: Re: strategy game
Post by: fireside on January 15, 2009, 10:09:51 pm
Hmm.  I think your right.  I should probably remove the "move" button and have it as the default.  If there is a cancel for the attack, it wouldn't matter.  For now, I'll leave the attack button.  There will be multiple long range attacks so that needs to be there, I think.  It's going to expand into choices when I get that far.
Title: Re: strategy game
Post by: fireside on January 15, 2009, 11:05:09 pm
On thinking further, I might leave it for a bit.  One thing I was going to possibly do was have a one or the other situation.  It's not set up that way now, but if you could both move and attack, that would take away some of the strategy involved.  I was thinking of possibly having the move cost one turn, but it needs experimentation.  I've played some games like that I think.  Like, if I could move the mage away to cast a spell, and cast the spell, then it wouldn't do any good to have a rule that says she can't cast a spell when there is a character next to her.
Title: Re: strategy game
Post by: fireside on January 17, 2009, 08:05:57 pm
The program reads a an attack list now and provides a button for each attack.
(http://img523.imageshack.us/img523/6951/screen1ij1.th.jpg) (http://img523.imageshack.us/my.php?image=screen1ij1.jpg)

I don't have the input worked out yet.
Title: Re: strategy game
Post by: fireside on February 03, 2009, 12:44:05 am
I've uploaded a new app that has attack choices.  The animations are very preliminary and there isn't a spell animation for the mage yet.
Title: Re: strategy game
Post by: fireside on March 05, 2009, 11:09:57 pm
Small update.  The characters make a place on the map so they can't walk through each other anymore and the first enemy is up but doesn't do anything except idle.
http://fireside7games.com/labz/strat_test1.html
Title: Re: strategy game
Post by: fireside on March 26, 2009, 09:10:03 pm
I changed the attack to object picking. 
Title: Re: strategy game
Post by: EgonOlsen on March 26, 2009, 09:22:58 pm
It's getting somewhere... ;D Do you mind if i put it on the projects page?

And is it actually possible to kill that beholder thing? I hit it and fired at it, but it seemed to be unaffected!?

Edit: Can i zoom somehow?
Title: Re: strategy game
Post by: fireside on March 26, 2009, 11:11:21 pm
It's still has a long ways to go, but it would probably be all right on the projects page.  It doesn't show damage to the monster yet.  I'll probably get working on that next, or right after I get the monster to seek out a target.  There's no zoom, yet. Thanks for checking it out.
Title: Re: strategy game
Post by: fireside on April 13, 2009, 08:41:00 pm
Small update.  The monster is targeting the girl for now, however hiding the girl behind a tree will cause the monster to skip a turn.  Also, placing the dragon next to the monster will cause it to not seek out the girl.  These will hopefully be strategy elements in the fights since the girl will be the most vulnerable as the mage of the small party.

http://fireside7games.com/labz/strat_test1.html
Title: Re: strategy game
Post by: fireside on May 05, 2009, 04:54:31 am
http://fireside7games.com/labz/strat_test1.html

I thought I'd do an update.  There are two monsters now that move in on the victims and attack.  There are also attack stats.  The monsters die when their health goes to zero, but the players don't yet.  The attack buttons work a little bit more in that the lettering is white if the attack is possible, however, there is no limiting the wrong attacks yet.  The lettering can get  overwritten during attacks.  I'll probably do a health bar instead of using a lower number for the health as I'm doing now.  It's also a little less buggy as I rewrote some of the code.
Title: Re: strategy game
Post by: fireside on October 07, 2010, 05:15:17 pm
Hi, everyone.  I've been thinking about picking up this project again.  I do this kind of thing. ;D.  Anyway, does anyone have any suggestions for what could be done to make it more interesting?  I would like to keep it turn based as I may experiment with a simple multiplayer system eventually. 
Title: Re: strategy game
Post by: EgonOlsen on October 08, 2010, 08:49:47 pm
Controls should be more accessible like i said some years ago... ;D IMHO, all you need is the defend button. The rest (movement and attack) can be executed based on the context. If i click on the ground, the character moves, if i click on an enemy, i can choose which attack to execute, if i click on a friendly character, i can heal or something. Maybe no button is needed at all. Defend can be an option, if you click on the current character for example.

And sound would be cool.
Title: Re: strategy game
Post by: fireside on October 09, 2010, 05:13:17 am
Yeah, you're right.  It does seem awkward looking at it now.  I think maybe a button for defend, since some kind of confirmation would be needed otherwise, and it would leave the possibility of an equip button also.  The only options necessary would be for the mage during a long range attack.  I think having distance limitations for movement would also add to strategy elements in the fights.  Things in the area that have different effects on different types of characters would also add interest and strategy.  Thanks for the suggestion.  Was it years ago?  Time flies.
Title: Re: strategy game
Post by: fireside on October 12, 2010, 08:36:48 pm
(http://www.freeimagehosting.net/uploads/4886bbf470.jpg)

Some graphical changes.  I'm going to call the game Dragon Mage.  Just started looking at the code.  It needs some rework and of course the movement changes.
Title: Re: strategy game
Post by: fireside on October 17, 2010, 06:04:32 pm
(http://www.freeimagehosting.net/uploads/18d601a7bc.jpg)

Added a tree and a turn marker.  I'm currently working on rescaling the grid. My idea right now is to eliminate the move button and have choices pop up from the attack button when an enemy is clicked on.  A health bar would be kind of nice, but I think it would have to be a billboard and that might get a little complicated.