def __init__(self, i, stateobj): self.stateobj = stateobj self.count = int(i * 1.5) self.wave = 1 self.health_max = 100 self.health = self.health_max #Stats self.game_zombies_killed = 0 self.game_legs_shot_off = 0 self.game_headshots = 0 self.game_shotsfired = 0 self.game_time = datetime.datetime.now().replace(microsecond=0) self.game_hitcount = 0 self.paused = False self.game_over = False self.font = pygame.font.init() self.font = pygame.font.Font("resources/fonts/Lato-Regular.ttf", fnt_size) self.txt_remaining = self.font.render("Wave remaining: " + str(self.count), True, fnt_color) self.txt_wave = self.font.render("Wave number: " + str(self.wave), True, fnt_color) self.txt_health = self.font.render("Health: ", True, fnt_color) self.stand = Stand() self.enemies = [pygame.sprite.Group(), pygame.sprite.Group(), pygame.sprite.Group()] self.stand = pygame.sprite.GroupSingle(self.stand) self.stains = pygame.sprite.Group()
def listStands(self): conn = sqlite3.connect(self.nomBD) curseur = conn.cursor() sql1 = "SELECT * FROM STAND" curseur.execute(sql1) l = curseur.fetchall() stands = [] for i in range(0, len(l)): s = Stand(l[i][0], l[i][1], l[i][2]) stands.append(s) curseur.close() conn.close() return stands
global continue_reading print "\nCtrl+C captured, ending program." continue_reading = False GPIO.cleanup() sys.exit() # Hook the SIGINT signal.signal(signal.SIGINT, end_read) # Create an object of the class MFRC522 reader = SimpleMFRC522() stand = [] for i in range(8): s = Stand(i) stand.append(s) stand[0].name = 'Core' stand[1].name = 'Subhansiri' stand[2].name = 'Siang' stand[3].name = 'K.V. gate' stand[4].name = 'Faculty gate' stand[5].name = 'Biotech Park' stand[6].name = 'Guest House' stand[7].name = 'Quarters' current_standId = 0 # Welcome message print "Welcome to E-Rickshaw Services" print "Press Ctrl-C to stop.\n"
class Level: def __init__(self, i, stateobj): self.stateobj = stateobj self.count = int(i * 1.5) self.wave = 1 self.health_max = 100 self.health = self.health_max #Stats self.game_zombies_killed = 0 self.game_legs_shot_off = 0 self.game_headshots = 0 self.game_shotsfired = 0 self.game_time = datetime.datetime.now().replace(microsecond=0) self.game_hitcount = 0 self.paused = False self.game_over = False self.font = pygame.font.init() self.font = pygame.font.Font("resources/fonts/Lato-Regular.ttf", fnt_size) self.txt_remaining = self.font.render("Wave remaining: " + str(self.count), True, fnt_color) self.txt_wave = self.font.render("Wave number: " + str(self.wave), True, fnt_color) self.txt_health = self.font.render("Health: ", True, fnt_color) self.stand = Stand() self.enemies = [pygame.sprite.Group(), pygame.sprite.Group(), pygame.sprite.Group()] self.stand = pygame.sprite.GroupSingle(self.stand) self.stains = pygame.sprite.Group() def update(self): if not self.paused: self.update_enemies() self.stains.update() random = randint(0, 30) if self.count > 0 and random == 1: self.count -= 1 self.txt_remaining = self.font.render("Wave remaining: " + str(self.count), True, fnt_color) rand = randint(0, 2) val = rand * 130 + 500 zombie = Zombie(val, rand, self, 2*self.wave) self.enemies[rand].add(zombie) if self.count == 0 and self.no_enemies_left(): self.wave += 1 self.count = 10 * self.wave # TODO betere curve voor zombiespawn self.txt_remaining = self.font.render("Wave remaining: " + str(self.count), True, fnt_color) self.txt_wave = self.font.render("Wave number: " + str(self.wave), True, fnt_color) else: pass #TODO pause menu??? def getRemaining(self): return int(self.count) def draw(self, screen): self.stand.draw(screen) self.draw_enemies(screen) screen.blit(self.txt_remaining, txt_remaining_pos) screen.blit(self.txt_wave, txt_wave_pos) screen.blit(self.txt_health, txt_health_pos) self.draw_healthbar(screen) self.stains.draw(screen) if self.game_over: self.popup.draw(screen) def shoot(self, x, y): if not self.paused: self.game_shotsfired += 1 for i in [self.enemies[2], self.enemies[1], self.enemies[0]]: for enemy in i: case = enemy.hit(x, y) if not case == HitType.miss: if HitType.headshot == case: self.game_headshots += 1 self.game_zombies_killed += 1 pass elif HitType.chest == case: self.game_zombies_killed += 1 pass elif HitType.legshot == case: self.game_legs_shot_off += 1 pass if Settings.bloodspawn: self.stains.add(BloodStain(self)) self.game_hitcount += 1 return else: self.popup.click(x, y) def delete_enemy(self, enemy): self.enemies[enemy.getLayer()].remove(enemy) def update_enemies(self): self.enemies[0].update() self.enemies[1].update() self.enemies[2].update() def draw_enemies(self, screen): self.enemies[0].draw(screen) self.enemies[1].draw(screen) self.enemies[2].draw(screen) def no_enemies_left(self): return len(self.enemies[0]) == 0 and len(self.enemies[1]) == 0 and len(self.enemies[2]) == 0 def deletestain(self, stain): self.stains.remove(stain) def draw_end_round_stats(self): pass def draw_healthbar(self, screen): pygame.draw.line(screen, (0, 0, 0), [1600, 30], [1900, 30], 45) if self.health > 0: pygame.draw.line(screen, (0, 255, 0), [1600, 30], [1600 + (1900-1600)*self.health/self.health_max, 30], 45) def decrease_health(self, value): if self.health - value <= 0: self.health = 0 self.paused = True self.game_over = True self.popup = Popup(PopupType.gameover, self, self.stateobj) self.addRowsToPopup(self.popup) else: self.health -= value def replay(self): self.health = self.health_max self.paused = False self.game_over = False self.count = 15 self.wave = 1 self.enemies = [pygame.sprite.Group(), pygame.sprite.Group(), pygame.sprite.Group()] self.stains = pygame.sprite.Group() self.resetStats() def resetStats(self): self.game_zombies_killed = 0 self.game_legs_shot_off = 0 self.game_headshots = 0 self.game_shotsfired = 0 self.game_hitcount = 0 self.game_time = datetime.datetime.now().replace(microsecond=0) def addRowsToPopup(self, popup): pref = SharedPreference() popup.addRow("Wave reached", self.wave, pref.loadHighscore("game_wave", -1)) popup.addRow("Zombies killed", self.game_zombies_killed, pref.loadHighscore("game_killed", -1)) popup.addRow("Legs shot off", self.game_legs_shot_off, pref.loadHighscore("game_legs", -1)) popup.addRow("Headshots", self.game_headshots, pref.loadHighscore("game_headshots", -1)) popup.addRow("Shots fired", self.game_headshots, pref.loadHighscore("game_shotsfired", -1)) timeplayed = datetime.datetime.now().replace(microsecond=0) - self.game_time popup.addRow("Time played", timeplayed, pref.loadHighscore("game_timeplayed", -1)) if self.game_shotsfired > 0: precision = round(self.game_hitcount/self.game_shotsfired*100, 2) else: precision = 0 popup.addRow("Accuracy", precision, pref.loadHighscore("game_precision", -1)) pref.writeHighscore("game_wave", self.wave) pref.writeHighscore("game_killed", self.game_zombies_killed) pref.writeHighscore("game_legs", self.game_legs_shot_off) pref.writeHighscore("game_headshots", self.game_headshots) pref.writeHighscore("game_shotsfired", self.game_shotsfired) pref.writeHighscore("game_timeplayed", timeplayed) pref.writeHighscore("game_precision", precision) pref.commit()
def creationstand(): s = Stand(len(list_stands), nom.get(), getint(prix.get())) list_stands.append(s) bd.addStand(s) ns_interf.destroy() Home()
from playsound import playsound import random from Stand import Stand, GoldExperience, TheWorld goldExperience = GoldExperience("Gold Experience", "C", "A", "C", "C", "A", 100) starPlatinum = Stand("Star Platinium", "A", "A", "C", "A", "C", 100) theWorld = TheWorld("The World", "A", "A", "C", "B", "B", 100) killerQueen = Stand("Killer Queen", "A", "B", "D", "B", "A", 100) goldExperience.Heal() goldExperience.Barrage("Mudaa") theWorld.ThrowKnife(goldExperience) goldExperience.Heal() stands = [goldExperience, starPlatinum, theWorld, killerQueen] choice = input("Welcome to a Fighting Text Game !!! CHOOSE A CHARACTER : ") Char = [ "Giorno Giovanna", "Jotaro Kujo", "Goku", "Dio Brando", "Vegeta", "Kira Yoshikage" ] randomEnemy = random.choice(Char) if choice in Char: print(f"you will fight {randomEnemy}")