woensdag 28 mei 2014

getWitdh() and getHeight() example.

I was using getSize().width and getSize().height. Now I discovered that you can just use getWidth() and getHeight() for getting the applet width and height. Below in the sourcecode I am using these commands.

package test001;
import java.awt.*;
import java.applet.*;

public class testing001 extends Applet implements Runnable {
 // Graphics for double buffering.
 Graphics      bufferGraphics;
 Image       offscreen;
 public void init() {
     offscreen = createImage(getWidth(),getHeight());
     bufferGraphics = offscreen.getGraphics();
     new Thread(this).start();


    public void run() {
        for(;;) { // animation loop never ends
         try {
             catch (InterruptedException e) {

    public void update(Graphics g){
     bufferGraphics.clearRect( 0 , 0 , getWidth() , getHeight() );
     bufferGraphics.setColor( Color.red );
     bufferGraphics.drawString( "getWidth() and getHeight()" , 10 , 10 );

     bufferGraphics.drawRect( 20 , 20 , getWidth()-40 , getHeight()-40 );


dinsdag 8 april 2014

Planning part of Civilization game code

One of the type of games that I want to  make is the civilization like game. For a long time now I am learning how to program a civilization clone. The last few weeks I have been programming the worker automation and artificial intelligence of it. I got to the point where I have code that creates a map with cities and worker units that improve the map with roads and irrigation. I am working my way towards creating a more completed and civilization alike version. I am getting better at it.

It has been months since I posted on this blog and I think that I need to keep adding code to it. I am currently in the process of repeatitly retyping what I have in my main language blitz basic. I get to about a thousand lines per version. I think I wil be able to create a java version of it. It wil have pathfinding and map generating in it. 

I have no idea when I wil do this but I am sure I wil do it. Keep a look out for it.

Here is a link to a video of a older version.