Skip to content Skip to sidebar Skip to footer

Opinion On Gui For A Battleship Game In Python

I am making a battleship game for a project. While I have completed the logic and the game works with text input. I was hoping make a (very basic) GUI while still use the methods c

Solution 1:

This is a fairly trivial thing to do in Tkinter. A battleship game shows an array of coordinates which you can display as a grid of checkbuttons.

Solution 2:

You could check Kivy, it's working in top of OpenGL, provide severals basics widgets (label, button, slider, textinput, layouts, ...), and you can create your own / display graphics etc. Works as a python framework, almost all platforms.

You can also check the recent game contest to see what you can do with it :)

Solution 3:

Solution 4:

I suggest you use pyqt/pyside for this task. This lets you access the powerful Qt framework which has great documentation. If you design a game that does not need fast graphics you can simply use QGraphicsView/QGraphicsScene and related classes to display icons/numbers/whatever. Of course you can use OpenGL with Python and Qt as well.

Solution 5:

You can render text on pygame, just use:

class pygame.font.Font

#createa new Fontobjectfroma file
pygame.font.Font(filename, size): return Font
pygame.font.Font(object, size): return Font

method Font.render

#method of Font() to draw texton a new Surface
Font.render(text, antialias, color, background=None): return Surface

Simple example how to use text on pygame:

from pygame import font as pgfont, sprite as pgspr
import pygame as pg

    classFontSprite(pgspr.DirtySprite):
        def__init__(self, text, x, y):
            '''self.image = surface'''
            pgspr.DirtySprite.__init__(self)
            self.text = text
            self.color = [0,0,0]
            self.image = self.get_image()
            self.rect = pg.Rect((x, y), self.image.get_size())

        defget_image(self):
            self.dirty = 1return pgfont.Font('fonts\\BRLNSR.TTF', self.size).render(self.text,
                                                                      True,
                                                                      self.color)

Post a Comment for "Opinion On Gui For A Battleship Game In Python"