Tags » PyGame

TypeError: method missing required positional argument

This is a simplified version of the script I’m working on, in order to be posted here.

import pyglet as py
import pygame as pg
import os, time

pg.init()

class g:

    wMainDisplay = 1024
    hMainDiplay = 576
    textTitle = "Pokémon Life and Death: ESPLORATORI DEL PROPRIO DESTINO"
    flag = pg.DOUBLEBUF | pg.HWSURFACE | pg.NOFRAME
    fpsDefault = 60
    black = (0, 0, 0)
    loopIntro = False
    loopWarn = True

    def __init__(self):
        os.environ["SDL_VIDEO_CENTERED"] = "1"
        self.display = pg.display.set_mode((self.wMainDisplay, self.hMainDiplay), self.flag)
        self.display.set_alpha(None)
        pg.display.set_caption(self.textTitle)
        self.alphaSurface = pg.Surface((self.wMainDisplay, self.hMainDiplay))
        self.alphaSurface.set_alpha(0)
        self.clock = pg.time.Clock()
        pg.key.set_repeat(500, 100)
        pg.mouse.set_visible(False)
        py.options['audio'] = ("openal", "pulse", "directsound", "silent")
        self.all_sprites = pg.sprite.Group()

    def warnings(self):
        alph = 0
        img_in = True
        img_out = False
        warnCount = 0
        color = self.black
        self.warningGroups = pg.sprite.Group()
        _Warning(self, 1)
        time.sleep(2)

        while self.loopWarn:
            self.clock.tick(self.fpsDefault)
            self.display.fill(color)

            if img_in and img_out is False:
                alph += 1
                if alph >= 255:
                    warnCount += 1
                    img_in = False
                    time.sleep(0.01)
            if img_out and img_in is False:
                alph -= 5
                if alph <= 0:
                    warnCount += 1
                    img_out = False
                    time.sleep(0.01)

            if warnCount == 1:
                _Warning.sound(1)
                warnCount += 1
                time.sleep(0.01)
            elif warnCount == 2:
                if _Warning.updateAudio() is False:
                    warnCount += 1
                    time.sleep(0.01)
            elif warnCount == 3:
                img_out = True
            elif warnCount == 4:
                _Warning(2)
                img_in = True
            elif warnCount == 5:
                _Warning.sound(2)
                warnCount += 1
                time.sleep(0.01)
            elif warnCount == 6:
                if _Warning.updateAudio() is False:
                    warnCount += 1
                    time.sleep(0.01)
            elif warnCount == 7:
                self.loopWarn = False
                self.loopIntro = True
            else:
                pass

            self.alphaSurface.set_alpha(alph)
            self.warningGroups.draw(self.alphaSurface)
            self.display.blit(self.alphaSurface, (0, 0))
            pg.display.flip()

class _Warning(pg.sprite.Sprite):

    def __init__(self, game, objectI):
        self.groups = game.warningGroups
        pg.sprite.Sprite.__init__(self, self.groups)
        self.game = game
        self.player = py.media.Player()

        self.warningImage_1 = pg.image.load("wra.png")
        self.warningImage_2 = pg.image.load("wrb.png")
        self.warningSound_1 = py.media.load("wra.mp3")
        self.warningSound_2 = py.media.load("wra.mp3")

        if objectI == 1:
            self.image = self.warningImage_1
        elif objectI == 2:
            self.image = self.warningImage_2
        self.image = pg.transform.scale(self.image, (self.game.wMainDisplay, self.game.hMainDiplay))

        self.rect = self.image.get_rect()
        self.rect.x = 0
        self.rect.y = 0

    def sound(self, objectS):
        if objectS == 1:
            self.player.queue(self.warningSound_1)
        elif objectS == 2:
            self.player.queue(self.warningSound_2)
        self.player.play()
        py.app.run()

    def updateAudio(self):
        check = self.player.playing()
        return check

g = g()
g.warnings()
… 156 more words
Python

Battles - Game inspired by Clash Of Clans

In the last 2 weeks of December 2017, I challenged myself to code a game similar to the popular mobile video game, Clash Of Clans. And by 30th of December 2017 I completed this game and am here to share it with you guys! 568 more words

Coding Is Fun!!

Simple Python Game: BoxBox 🎮

Simple Python Game: BoxBox

I made a game named “BoxBox” , if you ask me the reason for naming it “BoxBox”, i dont know; it just suddenly occurred to me. 530 more words

Python

Explorers - Using Genetic Algorithm

In computer science and operations research, a genetic algorithm is a metaheuristic inspired by process of natural selection that belongs to the larger class of evolutionary algorithms. 338 more words

Coding Is Fun!!

Creating & Animating Graphics

Quick Python Summary: Chapters 17-20 introduces advanced graphics using the pygame module. Whilst the last chapter of the book will combine all the concepts learnt in… 172 more words

Coding

CP11, chp 7 quiz on lists

Please take the following quiz on Chp7 which is on lists. If you need more practice, take the practice quiz first on the pygame website: 6 more words

CP11

Day 6 - Resuming after hiatus

So! I had to move, get a 2nd job, dove deep into my web development education, and also got my personal website up, but as of today I am resuming this project. 243 more words

Gamedev