def __init__(self, x, y, kek): self.FON = (int(write_ini_file().get("Game zone", "color1")), int(write_ini_file().get("Game zone", "color2")), int(write_ini_file().get("Game zone", "color3"))) sprite.Sprite.__init__(self) super(Robot, self).__init__(x, y, kek) self.save = [x, y] self.image = image.load('F:/Project/image/bot/bot_grave.png') boltAnim = [] for anim in ANIMATION_RIGHT: boltAnim.append((anim, ANIMATION_DELAY)) self.boltAnimRight = PygAnimation(boltAnim) self.boltAnimRight.play() boltAnim = [] for anim in ANIMATION_LEFT: boltAnim.append((anim, ANIMATION_DELAY)) self.boltAnimLeft = PygAnimation(boltAnim) self.boltAnimLeft.play() self.boltAnimDeath = PygAnimation(ANIMATION_DEATH) self.boltAnimDeath.play()
def start(): pygame.init() pygame.display.set_caption("GAME") screen = pygame.display.set_mode([WIDTH_WINDOW, HEIGHT_WINDOW]) bg = pygame.image.load("F:/Project/image/others/image001.png") screen.blit(bg, (0, 0)) flag = int(write_ini_file().get("Others", "start_game")) while 1: Game.FON = FON if main(screen, bg) == 0: Game.main(flag) if main(screen, bg) == 1: flag = show_skin_menu(screen, bg, flag) if main(screen, bg) == -1: break pygame.quit()
from abc import ABC, abstractmethod from pygame import Rect, Surface from old.Ini import write_ini_file BLOCK_SIZE = int(write_ini_file().get("Others", "block size")) class APatron(ABC): DEFAULT_DAMAGE = 2 def __init__(self, x, y): self.x = x self.y = y @abstractmethod def drawing(self, win: Surface): pass # draw.ellipse(win, self.color, (self.x, self.y)) # draw.ellipse(win, self.color, (self.x, self.y,2,3)) # # draw.circle(win, self.color, (self.x, self.y), self.radius) # self.x += self.vel @abstractmethod def damage(self): pass def collide(self, blocks): for block in blocks: if Rect(block.x, block.y, BLOCK_SIZE,
import configparser import pygame from pygame import * from old import Game from old.Ini import write_ini_file import os ICON_DIR = os.path.dirname(__file__) WIDTH_WINDOW = 1100 HEIGHT_WINDOW = 640 WHITE = (255, 255, 255) RED = (255, 0, 0) FON = (int(write_ini_file().get("Game zone", "color1")), int(write_ini_file().get("Game zone", "color2")), int(write_ini_file().get("Game zone", "color3"))) def show_skin_menu(screen, bg, flag): mousex = mousey = mousexC = mouseyC = 0 screen.blit(bg, (0, 0)) pygame.font.init() config = configparser.ConfigParser() config.read("%s/settings.ini" % ICON_DIR) p1 = transform.scale(image.load("%s/image/others/platform.png" % ICON_DIR), (20, 20)) p2 = transform.scale(
from pygame import draw, Rect, Surface from guns.ASnarad import APatron from old.Ini import write_ini_file SPEED = int(write_ini_file().get("Others", "speed of bullet")) RADIUS = int(write_ini_file().get("Others", "radius bullet")) BLOCK_SIZE = int(write_ini_file().get("Others", "block size")) class Patron2(APatron): DEFAULT_SPEED = 10 DEFAULT_DAMAGE = 3 def __init__(self, x, y, color, facing): super().__init__(x, y) self.radius = RADIUS self.color = color self.facing = facing self.vel = self.DEFAULT_SPEED * facing def drawing(self, win: Surface): draw.circle(win, self.color, (self.x, self.y), self.radius) self.x += self.vel def damage(self): return self.DEFAULT_DAMAGE class Patron3(APatron): DEFAULT_SPEED = 15
from pygame import * from old.Block import Medicines, Monster from old.Ini import write_ini_file from old.Pyganim import PygAnimation from guns.bullets.Snarad import Patron3, Patron2 from old.Start import FON import os RIGHT_MOVE = int(write_ini_file().get("Players", "speed")) LEFT_MOVE = -RIGHT_MOVE JUMP = int(write_ini_file().get("Players", "Jump")) GRAVITY = float(write_ini_file().get("Others", "gravity")) ANIMATION_DELAY = 0.1 ICON_DIR = os.path.dirname(__file__) ANIMATION_RIGHT = [ 'F:/Project/image/player/r1.png', 'F:/Project/image/player/r2.png', 'F:/Project/image/player/r3.png', 'F:/Project/image/player/r4.png', 'F:/Project/image/player/r5.png' ] ANIMATION_LEFT = [ 'F:/Project/image/player/l1.png ', 'F:/Project/image/player/l2.png', 'F:/Project/image/player/l3.png', 'F:/Project/image/player/l4.png', 'F:/Project/image/player/l5.png' ] ANIMATION_JUMP_LEFT = [('F:/Project/image/player/jl.png', 0.1)] ANIMATION_JUMP_RIGHT = [('F:/Project/image/player/jr.png', 0.1)] ANIMATION_JUMP = [('F:/Project/image/player/j.png', 0.1)] ANIMATION_STAY = [('F:/Project/image/player/0.png', 0.1)]
import os import random from pygame import sprite, image, Surface, Rect from old.Ini import write_ini_file from old.Pyganim import PygAnimation ICON_DIR = os.path.dirname(__file__) WIDTH_WINDOW = int(write_ini_file().get("Game zone", "width window")) HEIGHT_WINDOW = int(write_ini_file().get("Game zone", "height window")) BLOCK_SIZE = int(write_ini_file().get("Others", "block size")) ANIMATION_MONSTER = ['F:/Project/image/others/MONSTR1.png', 'F:/Project/image/others/MONSTR2.png'] class Block(sprite.Sprite): """Create blocks for the game. 'location' is the place where the images of the block are stored """ def __init__(self, location): sprite.Sprite.__init__(self) self.image = Surface((BLOCK_SIZE, BLOCK_SIZE)) self.image = image.load(location) self.rect = self.image.get_rect() @property def x(self): return self.rect.x @property def y(self): return self.rect.y