开发者

algorithm for a capture game

开发者 https://www.devze.com 2023-04-11 03:09 出处:网络
There was this old game (J2ME) but I cannot find it now in google. The name was \"Capture\".(Accoring to the commen开发者_StackOverflowts it\'s more like \"Jezzball\")

There was this old game (J2ME) but I cannot find it now in google. The name was "Capture".(Accoring to the commen开发者_StackOverflowts 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,

algorithm for a capture game

Can anyone suggest an algorithm?

(I hope the ideas is clear)


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号