4

There was this old game (J2ME) but I cannot find it now in google. The name was "Capture".(Accoring to the comments it's more like "Jezzball")
I tried to implement this game but I cannot come up with a good algorithm and data structues.
The ideas of the game is,
enter image description here
Can anyone suggest an algorithm?
(I hope the ideas is clear)

Dinushan
  • 2,067
  • 6
  • 30
  • 47

2 Answers2

3

By algorithm, I guess you mean the design of the program. You would end up using several algorithms in the final game.

You would design this the same way you'd tackle any piece of software (there's nothing special about it being a game). First, you'd start with a specification, which you have. Then, you'd break it down into logical units:

  • the board
  • the player
  • the enemies

and then you'd consider how they interact. For example, when the player moves, the board is updated. When an enemy moves, it checks the board to see if it has collided with the player. And so on.

As for the structure of the game, every game I've worked on does this:

set up the world

while (playing)
{
   draw the world
   update the world
}

In your case, the world would be the board, the player and the enemies (it would also include the UI). There is a hierarchy here, the player and the enemies belong to the board, so you get:

create_board

while (playing)
{
   draw_board
   update_board
}

and draw_board is:

draw_background
draw_player
draw_enemies

and update_board:

update_player
update_enemies

The update_ and draw_ functions can be further broken down. This is know as top down design.

Designing the whole game for you would require a huge answer, and it would take away from you the fun of figuring these out for yourself. Hopefully this will get you started.

Skizz
  • 69,698
  • 10
  • 71
  • 108
  • thank you ."and it would take away from you the fun of figuring these out for yourself." I'll try some more. I guess a data representation of the 'board' would be a starting point. – Dinushan Oct 04 '11 at 10:50
  • 1
    @D-Shan: That would be a good place to start. You could also look into [unit testing](http://en.wikipedia.org/wiki/Unit_testing) and add test cases to the board code. – Skizz Oct 04 '11 at 11:45
0

At last I found a similar game+sourcecode.allegro.cc/depot/Jezzball/
Not to "copy" the code but have a start/idea as I struck there for months.
and this answer also is a good start.

Community
  • 1
  • 1
Dinushan
  • 2,067
  • 6
  • 30
  • 47