Exemple #1
0
import os
import random
import signal
from board import Board
from brick import Brick
from bomberman import Bomberman
from getchunix import GetchUnix
from enemy import Enemy
from bomb import Bomb
from alarmexception import AlarmException
EMB = Board(42, 84, 2, 4)         # creates object b od class Board
BNE = EMB.createboard()
BNE = EMB.buildrigidboard(BNE)        # Builds borders of board with walls
BNE = EMB.buildmiddlewalls(BNE)       # symmetric spaces of board with walls
B = Bomberman(2, 4, 3, 0)     # bom is our object bomberman
BNE = B.generatebomberman(BNE)
C = Brick(30, 2, 4, 42, 84)
BNE = C.generatebricks(BNE)         # Creates bricks(breakable) randomly on board
EMB.enemies = [0] * 6             # Creates list of enemies
G = GetchUnix()


def alarmhandler(signum, frame):
    """ this method controls time and char relation """
    signum = signum
    frame = frame
    raise AlarmException


def input_to(timeout=1):  # time after which enemies move automatically
    """ this method is to get input """
Exemple #2
0
# TEST1 is an object of Manage
TEST1 = Manage()

# the initial Welcome Print.
print("")
print("Welcome, to this rendition of Bomberman!")
print("")
print("Press 'Enter' to start playing.")
TAKENINPUT = input()

# This generates bricks on the board
TEST.generatebricks()
# This generates enemies on the board
TEST.generateenemies()
# This generates the bomberman
TEST.generatebomberman()

i = 0
while True:
    os.system("tput reset")
    TEST1.printhead()
    TEST.getprint()

    if i == 10:
        TEST.moveenemies()
        TEST.bombcounter()
        TEST1.timer()
        i = 0
    TEST.movebomberman()
    i = i + 1