Author Topic: strategy game  (Read 38078 times)

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: strategy game
« Reply #15 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.

Offline fireside

  • double
  • *****
  • Posts: 607
    • View Profile
Re: strategy game
« Reply #16 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.
« Last Edit: December 14, 2008, 09:54:47 pm by fireside »
click here->Fireside 7 Games<-

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: strategy game
« Reply #17 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).

Offline fireside

  • double
  • *****
  • Posts: 607
    • View Profile
Re: strategy game
« Reply #18 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.

click here->Fireside 7 Games<-

Offline fireside

  • double
  • *****
  • Posts: 607
    • View Profile
Re: strategy game
« Reply #19 on: December 18, 2008, 02:32:49 am »


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.
« Last Edit: December 18, 2008, 02:39:13 am by fireside »
click here->Fireside 7 Games<-

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: strategy game
« Reply #20 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.... ???

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: strategy game
« Reply #21 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.

Offline fireside

  • double
  • *****
  • Posts: 607
    • View Profile
Re: strategy game
« Reply #22 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.
« Last Edit: December 18, 2008, 05:13:08 pm by fireside »
click here->Fireside 7 Games<-

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: strategy game
« Reply #23 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... ???

Offline fireside

  • double
  • *****
  • Posts: 607
    • View Profile
Re: strategy game
« Reply #24 on: December 19, 2008, 12:00:51 am »
That is strange then.  At least it works this way. ;D 
click here->Fireside 7 Games<-

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: strategy game
« Reply #25 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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: strategy game
« Reply #26 on: December 19, 2008, 09:17:56 am »
Maybe getGraphics() creates a new instance every time?

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: strategy game
« Reply #27 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

Offline fireside

  • double
  • *****
  • Posts: 607
    • View Profile
Re: strategy game
« Reply #28 on: December 19, 2008, 02:51:42 pm »
Quote
Nice job on the game, BTW.

Thanks. 
click here->Fireside 7 Games<-

Offline fireside

  • double
  • *****
  • Posts: 607
    • View Profile
Re: strategy game
« Reply #29 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
click here->Fireside 7 Games<-