Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (767)
Games in Android Showcase (230)
games submitted by our members
Games in WIP (854)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Fire-Power clone, how to start?  (Read 5881 times)
0 Members and 1 Guest are viewing this topic.
Offline max_power

Junior Newbie




Java games rock!


« Posted 2003-05-14 11:45:31 »

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.
Offline Backmask

Junior Devvie




586: The average IQ needed to understand a PC


« Reply #1 - Posted 2003-05-14 12:10:04 »

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.


Offline max_power

Junior Newbie




Java games rock!


« Reply #2 - Posted 2003-05-14 12:20:13 »

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.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Backmask

Junior Devvie




586: The average IQ needed to understand a PC


« Reply #3 - Posted 2003-05-14 12:22:57 »

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.

Offline Backmask

Junior Devvie




586: The average IQ needed to understand a PC


« Reply #4 - Posted 2003-05-14 12:29:08 »

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

Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #5 - Posted 2003-05-14 12:31:01 »

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:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
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! Smiley 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.

Java Game Console Project
Last Journal Entry: 12/17/04
Offline max_power

Junior Newbie




Java games rock!


« Reply #6 - Posted 2003-05-14 12:50:20 »

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...
Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #7 - Posted 2003-05-14 13:06:14 »

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

Java Game Console Project
Last Journal Entry: 12/17/04
Offline max_power

Junior Newbie




Java games rock!


« Reply #8 - Posted 2003-05-14 13:18:20 »

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

Ok, I will do that. Thanks  Cheesy
Offline zparticle

Senior Devvie




Thick As A Brick


« Reply #9 - Posted 2003-05-14 15:20:05 »

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

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline DarkwingGT

Senior Newbie




Java games rock!


« Reply #10 - Posted 2003-05-14 17:21:21 »

jbanes, the digital GAGE pimp  Grin.  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)
Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #11 - Posted 2003-05-14 17:57:47 »

Flattery will get you nowhere.  Wink

Java Game Console Project
Last Journal Entry: 12/17/04
Online Abuse

JGO Ninja


Medals: 70


falling into the abyss of reality


« Reply #12 - Posted 2003-05-14 21:01:53 »

Quote
Flattery will get you nowhere.  Wink

How about insults ? Cheesy

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

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #13 - Posted 2003-05-14 22:22:24 »

> How about insults ?

Everybody's a smartass these days.  Roll Eyes  Cheesy

Java Game Console Project
Last Journal Entry: 12/17/04
Offline DarkwingGT

Senior Newbie




Java games rock!


« Reply #14 - Posted 2003-05-15 19:33:32 »

Cheesy

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".  Grin

Offline max_power

Junior Newbie




Java games rock!


« Reply #15 - Posted 2003-05-25 15:49:07 »

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...
Pages: [1]
  ignore  |  Print  
 
 

 
EgonOlsen (1303 views)
2018-06-10 19:43:48

EgonOlsen (1161 views)
2018-06-10 19:43:44

EgonOlsen (900 views)
2018-06-10 19:43:20

DesertCoockie (1301 views)
2018-05-13 18:23:11

nelsongames (1106 views)
2018-04-24 18:15:36

nelsongames (1337 views)
2018-04-24 18:14:32

ivj94 (2079 views)
2018-03-24 14:47:39

ivj94 (1231 views)
2018-03-24 14:46:31

ivj94 (2212 views)
2018-03-24 14:43:53

Solater (798 views)
2018-03-17 05:04:08
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!