Ejemplo n.º 1
0
 def moreEnemys(self):
     x = random.randint(0, 31)
     y = random.randint(0, 17)
     while self.board[x][y] != -1:
         x = random.randint(0, 31)
         y = random.randint(0, 17)
     enemy = Enemy((x, y), self.EnemyImage, "")
     self.enemys.append(enemy)
     self.EnemySpr.append(
         EnemySprites(self.EnemySprites, enemy.return_image(),
                      (enemy.coords[0] * 40, enemy.coords[1] * 40)))
     self.board[x][y] = 2
Ejemplo n.º 2
0
 def restart(self):
     self.showMesegesInLog(self.screen, "Вы умерли.", pygame.Color("red"))
     self.board = [[-1] * self.height for _ in range(self.width)]
     self.enemys = []
     self.backSprites = pygame.sprite.Group()
     self.playerSprites = pygame.sprite.Group()
     self.EnemySprites = pygame.sprite.Group()
     self.attack_dir = ""
     self.player = Player((random.randint(0, 31), random.randint(0, 17)),
                          self.playerImage, "")
     self.board[self.player.return_coords()[0]][self.player.return_coords()
                                                [1]] = 1
     self.EnemySpr = []
     self.EAU = False
     self.EAD = False
     self.EAR = False
     self.EAL = False
     for i in range(5):
         x = random.randint(0, 31)
         y = random.randint(0, 17)
         while self.board[x][y] != -1:
             x = random.randint(0, 31)
             y = random.randint(0, 17)
         enemy = Enemy((x, y), self.EnemyImage, "")
         self.enemys.append(enemy)
         self.EnemySpr.append(
             EnemySprites(self.EnemySprites, enemy.return_image(),
                          (enemy.coords[0] * 40, enemy.coords[1] * 40)))
         self.board[x][y] = 2
     self.playerSpr = PlayerSprites(
         self.playerSprites, self.player.return_image(),
         (self.player.coords[0] * 40, self.player.coords[1] * 40))
     for row in range(self.height):
         for col in range(self.width):
             rect = pygame.Rect(self.left + self.cell_size * col,
                                self.top + self.cell_size * row,
                                self.cell_size, self.cell_size)
             BackImage(self.backSprites, self.backImage, rect)
Ejemplo n.º 3
0
from tkinter import *
import time
from Tower import Tower
from CandyCoordinates import Coordinates
from Enemys import Enemy  #http://stackoverflow.com/questions/13215215/python-tkinter-animation
start_time = time.time()
grid = []
entitygrid = []
level = 1
window = Tk()
canvas = Canvas(window, bg="#e1ff89", height=950, width=950)
canvas.create_oval(11, 11, 41, 41, fill="yellow")
for _ in range(2 ^ level):
    entitygrid.append(Enemy("Circle", 1, 25, Coordinates(0, 0)))
for row in range(20):
    for col in range(20):
        grid.append(canvas.create_rectangle(row * 50, col * 50, 3, 3))


def moveLeft(object):
    canvas.after(100, moveLeft)
    canvas.move(object, -1, 0)


def moveRight(object):
    canvas.after(100, moveRight)
    canvas.move(object, 1, 0)


def moveForward(object):
    canvas.after(100, moveForward)
Ejemplo n.º 4
0


#img4= pygame.image.load(r'C:\Users\morom\Downloads\zalivka.')
#connect = sqlite3.connect('enemys.db')
#cursor = connect.cursor()
#cursor.execute('CREATE TABLE enemys(size INT,rev INT)')
#cursor.execute('INSERT INTO enemys VALUES(85,0)')
#cursor.execute('INSERT INTO enemys VALUES(85,1)')
#cursor.execute('''SELECT * FROM enemys''')
#data_from_db = cursor.fetchall()
#print(*data_from_db, sep='\n')
#print(data_from_db[0][0])


Black_E=Enemy(W, img , 20, 85, 0)
Red_E=Enemy(W,img1,10,85,1)
Pl=Player(500,H-100,95,img2)
print(H-Red_E.size)


def hit(Enemy,Player):
    if Player.y+Player.size>H-Enemy.size and Player.x+Player.size>Enemy.x and Player.x<Enemy.x+Enemy.size:
        sc.blit(img3,(W/2-435,100 ))
        music = pygame.mixer.music.load('C:/Users/morom/Documents/Mike/First_Game/orrr.mp3')
        pygame.mixer.music.play(-1, 0.0)
        r=pygame.time.get_ticks()
        font = pygame.font.Font(None, 50)
        strin="Ваше время: " + str(r/1000)+ ' секунды'
        text = font.render(strin,True,[0,0,0])
        sc.blit(text, [450,H-85])
Ejemplo n.º 5
0
img2 = pygame.image.load(r'C:\Users\morom\Documents\Mike\First_Game\dedd.jpg')
img3 = pygame.image.load(
    r'C:\Users\morom\Documents\Mike\First_Game\game_over.png')

#img4= pygame.image.load(r'C:\Users\morom\Downloads\zalivka.')
connect = sqlite3.connect('enemys.db')
cursor = connect.cursor()
#cursor.execute('CREATE TABLE enemys(size INT,rev INT)')
cursor.execute('INSERT INTO enemys VALUES(85,0)')
cursor.execute('INSERT INTO enemys VALUES(85,1)')
cursor.execute('''SELECT * FROM enemys''')
data_from_db = cursor.fetchall()
#print(*data_from_db, sep='\n')
#print(data_from_db[0][0])

Black_E = Enemy(W, img, 20, data_from_db[0][0], data_from_db[0][1])
Red_E = Enemy(W, img1, 10, data_from_db[1][0], data_from_db[1][1])
Pl = Player(500, H - 100, 95, img2)
print(H - Red_E.size)


def hit(Enemy, Player):
    if Player.y + Player.size > H - Enemy.size and Player.x + Player.size > Enemy.x and Player.x < Enemy.x + Enemy.size:
        sc.blit(img3, (W / 2 - 435, 100))
        music = pygame.mixer.music.load(
            'C:/Users/morom/Documents/Mike/First_Game/orrr.mp3')
        pygame.mixer.music.play(-1, 0.0)
        r = pygame.time.get_ticks()
        font = pygame.font.Font(None, 50)
        strin = "Ваш счет: " + str(r / 1000) + ' секунды'
        text = font.render(strin, True, [0, 0, 0])
Ejemplo n.º 6
0
from Enemys import Enemy
from Tower import Tower
enemy = Enemy(15, 15, 15)
tower = Tower("f", 100, 5)
print(tower.shoot(enemy))
tower.upgrade()
towers = []
enemys = []
for i in range(10):
    towers.append(Tower(i, 15 * i, 1 * (i)))
    enemys.append(Enemy(i, 5, 20))
print(enemys)
print(towers)
Ejemplo n.º 7
0
 def __init__(self, width, height, enemyCount, backImage, playerImage,
              enemyImage, screen):
     super().__init__(width, height)
     self.screen = screen
     self.itemsOnTheMap = dict()
     self.codes = {
         30: 'head',
         31: 'body',
         32: 'arms',
         33: 'foot',
         34: 'weapon',
         35: 'shild'
     }
     self.attack_coords = (0, 0)
     self.backImage = load_image(backImage, -1)
     self.playerImage = load_image(playerImage, -1)
     self.backSprites = pygame.sprite.Group()
     self.playerSprites = pygame.sprite.Group()
     self.EnemySprites = pygame.sprite.Group()
     self.dora = 1
     self.EnemyImage = load_image(enemyImage)
     self.headImage = load_image("head.png")
     self.bodyImage = load_image("body.png")
     self.armsImage = load_image("arms.png")
     self.footImage = load_image("foot.png")
     self.weaponImage = load_image("weapon.png")
     self.shildImage = load_image("shild.png")
     self.enemys = []
     self.pause = False
     self.attack_dir = ""
     self.player = Player((random.randint(0, 31), random.randint(0, 17)),
                          self.playerImage, "")
     self.con = sqlite3.connect('database/database.db')
     self.cur = self.con.cursor()
     self.player_coords = list(
         self.cur.execute(
             "SELECT position FROM players WHERE login = '******'".format(
                 log=names.player_login)))[0][0].split()
     self.player = Player(
         (int(self.player_coords[0]), int(self.player_coords[1])),
         self.playerImage, "")
     names.player_coords = (int(self.player_coords[0]),
                            int(self.player_coords[1]))
     self.board[self.player.return_coords()[0]][self.player.return_coords()
                                                [1]] = 1
     self.EnemySpr = []
     self.eqip = [
         self.player.head, self.player.body, self.player.arms,
         self.player.foot, self.player.weapon, self.player.shild
     ]
     self.hasInventory = False
     self.hasLog = False
     self.EAU = False
     self.EAD = False
     self.EAR = False
     self.EAL = False
     self.items = [
         i[0]
         for i in self.cur.execute('SELECT name FROM items').fetchall()
     ]
     self.itemOnBoard = 0
     self.logMeseges = []
     for i in range(enemyCount):
         x = random.randint(0, 31)
         y = random.randint(0, 17)
         while self.board[x][y] != -1:
             x = random.randint(0, 31)
             y = random.randint(0, 17)
         enemy = Enemy((x, y), self.EnemyImage, "")
         self.enemys.append(enemy)
         self.EnemySpr.append(
             EnemySprites(self.EnemySprites, enemy.return_image(),
                          (enemy.coords[0] * 40, enemy.coords[1] * 40)))
         self.board[x][y] = 2
     self.playerSpr = PlayerSprites(
         self.playerSprites, self.player.return_image(),
         (self.player.coords[0] * 40, self.player.coords[1] * 40))
     self.blade_left = load_image("blade_left.png", -1)
     self.blade_right = load_image("blade_right.png", -1)
     self.blade_down = load_image("blade_down.png", -1)
     self.blade_up = load_image("blade_up.png", -1)
     for row in range(self.height):
         for col in range(self.width):
             rect = pygame.Rect(self.left + self.cell_size * col,
                                self.top + self.cell_size * row,
                                self.cell_size, self.cell_size)
             BackImage(self.backSprites, self.backImage, rect)