Fire-Power clone, how to start?

Hi!

First off all i have to excuse me for my English, i’m not very good at it…

Does anybody remember Fire-Power, this funny game on Amiga? A few days ago i saw it again and got the idea to do a remake. This is my first try to program a (Java-) game, i just wrote Pong for practice, so i’m not sure, which is the best way to design this game.

It is an action game, you look at the map from top and rare driving a tank. Target is to capture the enemy’s flag. You have to enter his base and destroy his cannons. You can play alone or against a friend in split-screen-mode. This are the basics.

So important points each cycle are:

  • react on input (no problem, i think)
  • eventually scroll the map (if the map depends on 10x10px graphics, how can a view only a part from point 5,5?)
  • test if the tank touches a wall/tree/etc.
  • test if a missle from the tank touches something
  • is the tank in the range of an cannon?
  • calculate the orientation of the cannons
  • calculate the new positions of missles

My problem is, that i don’t know, how to carry it out. Shall i make a thread for each missle? Shall i calculate everything in a fixed order and update the screen after that? Could this lead to performance problems?

I hope you understand my problems and i gave you enough informations.

Hi

Try to divide the game in small steps and finish each step before you continue with the next.

Some example.

  1. Get the scrolling tiled background on place. There are much source code on this on these forum. Search for GAGE for example.
  2. Add sprites/actors/(or whatever you like to call the tanks) to the battlefield. Add the control and the rotation of the tanks
  3. Make the tank move and the map scrolls with it.
  4. Make the tanks fire missiles
  5. Implement a collision detection

You main game loop should look something like this.

do{
//tick updates all tanks, missiles etc. That is moves it in the direction it’s velocity is positiv
tick();

//render draws everything to screen
render();

//sleep alittle
Thread.sleep(30);

} while (!endgame)

And when you have any trouble about one specfic part in the game please feel free to ask again.

Thanks, seems to be a good suggestion.
In the Pong-game I used a similar main-loop, but at Thread.sleep(x) it only ran good with x=1.

Though you don’t mean, that i need to use thread, do you?

edit: I don’t think, that GAGE is good for me, because i want to do most by myself.

More threads = more trouble… in general… with all syncronization problems that can occure.

A game without network can easy only use one thread. So start with that and see how it goes.

You could check this link

http://umeweb.com/backmask/j2dgamedev/

It is a small 2D game lib I wrote ages ago. The version that is one that pages is old and broken. I have a newer at home but I think that package can serve as example code atleast.

Read through the document. It describes the concept on a scene (basicly a level in a game) that contains a number of layers (background, sprite, textlayers etc) and a layer may contain a number of actors(sprites). And each actor can have a number of handlers, like path (for moving), outofbounds for checking if the actor is outside the screen. The lib also contains a simple collision check.

If you find it useful and have question mail me

Just to add, you may find GAGE to be the perfect solution for what you’re trying to do. It already has classes to handle sprites, collision detection, parallax scrolling, etc. The one major piece of code missing that I haven’t had time to test well enough to release, is a CollisionMap. The idea is that walls will always take up a set block of pixles (i.e. 16x16 pixels). This means that you can look at the game map as a grid of 16x16 pixels and test if you collide with a filled grid square. To convert from pixels to grid blocks is as simple as throwing away the extra coords. For example:

gridx = playerx/16;
gridy = playery/16;

A more thorough explaination was give on this board:

http://www.scottshaver2000.com/forum/viewtopic.php?t=47

Here’s the source:


package com.dnsalias.java.gage.collision;

/**
 * Used for collision detection on maps.
 */

public class CollisionMap
{
    private int[] grid;
    
    private int cellwidth;
    private int cellheight;
    private int cellsx;
    private int cellsy;

    /**
     * Sets up a collision map "cellsx" wide by "cellsy" tall with each grid cell
     * "cellwidth"x"cellheight" in size.  
     */
    public CollisionMap(int cellsx, int cellsy, int cellwidth, int cellheight)
    {
        this.cellsx = cellsx;
        this.cellsy = cellsy;
        this.cellwidth = cellwidth;
        this.cellheight = cellheight;
        
        grid = new int[cellsx*cellsy];
    }

    /**
     * Returns the value for the grid cell at the specified pixel location. 
     */
    public int getCollision(int x, int y)
    {
        return grid[(y/cellheight)*cellsx+(x/cellwidth)];
    }
    

    /**
     * Returns true if there is a collision at the specified pixel coordinates.
     */
    public boolean isCollision(int x, int y)
    {
        return (getCollision(x, y) != 0);
    }
    
    /**
     * Copies in the values for the collision grid. Non-zero is considered a collision.
     */
    public void copyGrid(int[] grid)
    {
        System.arraycopy(grid, 0, this.grid, 0, Math.min(grid.length, this.grid.length));
    }
    
    /**
     * Returns the value for the specified grid cell.
     */
    public int getValue(int cellx, int celly)
    {
        return grid[celly*cellsy+cellx];
    }
    
    /**
     * Sets the value for the specified grid cell.
     */
    public void setValue(int cellx, int celly, int value)
    {
        grid[celly*cellsy+cellx] = value;
    }
}

Good luck on your gaming experience! :slight_smile: Oh, and if you do something with GAGE, drop me a line. I’d love to know where it gets used and if people find it useful.

Yeah, many answers in such a short time, great!

It seems, that GAGE does excactly what i need, but i want to do most work by myself. It could be, that i have the one or other look at the named classes, but i won’t use them direct, sorry. This game shall be something like an experiment, if and how something like this is possible. So the development can be very slow, too…

It could be, that i have the one or other look at the named
classes, but i won’t use them direct, sorry.

No problem. :slight_smile: Learning is always good. GAGE is simply meant to take care of some of the repetitive code that always takes a long time to hash out. If you’d like, feel free to use it as example code for whatever you’re doing. The collision detection is a piece that I’m especially proud of. I’ve found that it can be very difficult to develop efficient collision code, but I think I’ve managed it. So when you’re sitting there pulling your hair out because your collision detection has become 90% of your code, go take a look at GAGE. :wink:

[quote]So when you’re sitting there pulling your hair out because your collision detection has become 90% of your code, go take a look at GAGE. :wink:
[/quote]
Ok, I will do that. Thanks :smiley:

Can’t wait to see this one get done, I loved fire-power on my A4000.

jbanes, the digital GAGE pimp ;D. It is a really good API so if you want a quick start I suggest it.

(Although I’d expect no less from the author)

Flattery will get you nowhere. :wink:

[quote]Flattery will get you nowhere. :wink:
[/quote]
How about insults ? :smiley:

http://www.java-gaming.org/cgi-bin/JGOForums/YaBB.cgi?board=2D;action=display;num=1052940511

How about insults ?

Everybody’s a smartass these days. ::slight_smile: :smiley:

:smiley:

I think you misinterpreted.

(Although I’d expect no less from the author) should read “Although I’d expect the author to pimp his own stuff”. ;D

Hi!

This weekend I had a bit time to go on. I’ve made a few pictures for the street, not much, but enough to start with the scrolling.

I found another homepage about a FirePower Clone: http://www.nongnu.org/feuerkraft/welcome.html
That looks much better as that what I’m working on, but it seems, that it has fallen asleep…