Grid-based Game

510 Views Asked by At

I am trying to make a graphical grid-based game. It is supposed to look somewhat like Conway's Game of Life, with a simplistic grid consisting of cells, which can be individually turned on and off either by the player or programmatically. There is not much more to the grid itself; the actual gameplay is controlled entirely by the backend.

I can use any programming language (preferably Python, Java, or C) to make the grid, but I have no idea about how to get started. I looked at some of the options I have:

  • Java's 2D graphics library
  • Using GTK or Qt in C/C++
  • Python and PyGTK or PyGObject
  • Python and PyGame

But the main issue is that I do not want anything too complicated or heavy, because this grid will only be used for two purposes:

  • to design shapes before gameplay
  • to display a small section of the grid during gameplay, only if anyone is interested (otherwise the game can go on rapidly without any human interference or display)

This grid would display a maximum area of around 300x300, scrollable but not resizable. If it is being used for designing, the player should be able to click on cells to change their status and at the end, save the shape (in some internal format) to a file. If it is showing a game in progress, it would have to be programmatically updated from 1 to 5 updates per second.

Here is a rough picture of what it should look like, with the yellow representing 'on' cells. This image is a screenshot of golly, and I don't know how golly does it because the code is above me. what it should look like

1

There are 1 best solutions below

1
On

simplest way would be to create s simple two dimentinal array with O and X like this:

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXX0XXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXX00XXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX0XXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX000XXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

and just print it on the console.

otherwise you need graphical library.

java has:

https://docs.oracle.com/javase/tutorial/2d/overview/index.html

phyton got: http://anh.cs.luc.edu/python/hands-on/3.1/handsonHtml/graphics.html

just create a "draw shape1 at location" and "drawshape2 at location" methods. and draw!