strategy game

Started by fireside, October 01, 2008, 04:23:15 AM

Previous topic - Next topic

paulscode

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.

fireside

#16
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.
click here->Fireside 7 Games<-

paulscode

Quote from: fireside on December 14, 2008, 09:03:07 PM
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).

fireside

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<-

fireside

#19


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.
click here->Fireside 7 Games<-

EgonOlsen

Quote from: fireside on December 18, 2008, 02:32:49 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.... ???

paulscode

Quote from: fireside on December 18, 2008, 02:32:49 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.

I noticed the same thing in one of my projects a while back.

fireside

#22
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.
click here->Fireside 7 Games<-

EgonOlsen

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... ???

fireside

That is strange then.  At least it works this way. ;D 
click here->Fireside 7 Games<-

paulscode

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:
        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:
        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.

EgonOlsen

Maybe getGraphics() creates a new instance every time?

paulscode

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

fireside

QuoteNice job on the game, BTW.

Thanks. 
click here->Fireside 7 Games<-

fireside

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<-