Esempio n. 1
0
def init(sp1, sp2, ai):
    global SPRITE1, SPRITE2, has_ai
    has_ai = ai
    kbd.ai = has_ai
    SPRITE1 = sp1
    SPRITE2 = sp2
    Master.masterframe.setDrawHandler(draw)
    Mouse.screen = "game"
    #Master.masterframe.set_canvas_background('rgba(0, 200, 200, 0.3)')

    Master.masterframe.setKeydownHandler(kbd)
    Master.masterframe.setKeyupHandler(kbd)
    Master.music.pause()
    Master.music.play("fight")

    player1Sprite = Sprite(sprites[SPRITE1], 2, 14, (100, 300), 4, "idle",
                           "left")
    player2Sprite = Sprite(sprites[SPRITE2], 2, 14, (400, 300), 4, "idle",
                           "right")
    player1.setSprite(player1Sprite, SPRITE1)
    player2.setSprite(player2Sprite, SPRITE2)
    #display main menu
    #
    round.reset()
    round.start()
Esempio n. 2
0
def drawSpriteSheet(canvas):
    canvas.draw_polygon([[125, 105], [125, 420], [375, 420], [375, 105]], 1,
                        'Grey', 'Grey')
    canvas.draw_text("Select Sprite", (200, 50), 20, "White")
    player1.update()
    player2.update()
    selection.draw(canvas)
    if Mouse.spriteSel1:
        cursor1.selected = True
        if not Mouse.spriteSel2:
            cursor1.position = Mouse.spriteSelection
    if Mouse.spriteSel2:
        Mouse.spriteSel1 = False
        cursor2.selected = True
        cursor2.position = Mouse.spriteSelection
        Mouse.spriteSel2 = False
    if cursor1.getSelected():
        selectedSprite1.changeState("on")
        selectedSprite1.nextSprite()
    else:
        selectedSprite1.changeState("off")
        selectedSprite1.nextSprite()
    if cursor2.getSelected():
        selectedSprite2.changeState("on")
        selectedSprite2.nextSprite()
    else:
        selectedSprite2.changeState("off")
        selectedSprite2.nextSprite()
    cursor1.draw(canvas)
    cursor2.draw(canvas)
    Sprite(previewSprites[cursor1.previewSelection()], 2, 14, (50, 250), 8,
           "idle", "right").updateStatic(canvas)
    Sprite(previewSprites[cursor2.previewSelection()], 2, 14, (450, 250), 8,
           "idle", "left").updateStatic(canvas)
    selectedSprite1.draw(canvas)
    selectedSprite2.draw(canvas)

    if ready():
        Master.gameLoop(finalnames[cursor1.previewSelection()],
                        finalnames[cursor2.previewSelection()], False)
Esempio n. 3
0
cursor2.addPos([125, 255], [125, 420], [250, 420], [250, 255], 1)
cursor2.addPos([250, 255], [250, 420], [375, 420], [375, 255], 1)

player1 = Navigation(cursor1, kbd, 0)
player2 = Navigation(cursor2, kbd, 1)

selection = StaticSprite("https://i.ibb.co/wCnM7pP/fullscaled.png", [250, 255],
                         1)
previewSprites = [
    "https://i.ibb.co/M7Ff2wx/redsheet.png",
    "https://i.ibb.co/2hv9qcq/bluesheet.png",
    "https://i.ibb.co/K2616MG/greensheet.png",
    "https://i.ibb.co/CbMDdVC/yellowsheet.png"
]

selectedSprite1 = Sprite("https://i.ibb.co/p0QcQJg/lights.png", 1, 2,
                         [100, 100], 2, "on", "left")
selectedSprite2 = Sprite("https://i.ibb.co/p0QcQJg/lights.png", 1, 2,
                         [400, 100], 2, "off", "left")

finalnames = ["Red", "Blue", "Green", "Yellow"]


def ready():
    if cursor1.getSelected() and cursor2.getSelected():

        cursor1.deselect()
        cursor2.deselect()
        return True
    else:
        return False
Esempio n. 4
0
from Fighter.Rounds import Rounds
from Fighter.Mouse import Mouse

CANVAS_WIDTH = 500
CANVAS_HEIGHT = 500
has_ai = False
sprites = {
    "Red": "https://i.ibb.co/M7Ff2wx/redsheet.png",
    "Blue": "https://i.ibb.co/2hv9qcq/bluesheet.png",
    "Green": "https://i.ibb.co/K2616MG/greensheet.png",
    "Yellow": "https://i.ibb.co/CbMDdVC/yellowsheet.png",
    "Base": "https://i.ibb.co/6m5sd2h/fullsheet.png"
}
SPRITE1 = "Red"
SPRITE2 = "Blue"
player1Sprite = Sprite(sprites[SPRITE1], 2, 14, (100, 300), 4, "idle", "left")
player2Sprite = Sprite(sprites[SPRITE2], 2, 14, (400, 300), 4, "idle",
                       "right")  ##Get Sprite sheets
player1 = Character(player1Sprite, Vector(100, 300), 1, 'right')
player2 = Character(player2Sprite, Vector(400, 300), 2, 'left')
round = Rounds(player1, player2)


#when GameLoop is called by a class, init starts the frame
def init(sp1, sp2, ai):
    global SPRITE1, SPRITE2, has_ai
    has_ai = ai
    kbd.ai = has_ai
    SPRITE1 = sp1
    SPRITE2 = sp2
    Master.masterframe.setDrawHandler(draw)
Esempio n. 5
0
from Fighter import Master
from Fighter.Keyboard import MenuKeyboard
from Fighter.Mouse import Mouse
from Fighter.Ai import Ai
from Fighter.Sprite import Sprite

sprites = {
    "Red": "https://i.ibb.co/M7Ff2wx/redsheet.png",
    "Blue": "https://i.ibb.co/2hv9qcq/bluesheet.png",
    "Green": "https://i.ibb.co/K2616MG/greensheet.png",
    "Yellow": "https://i.ibb.co/CbMDdVC/yellowsheet.png",
    "Base": "https://i.ibb.co/6m5sd2h/fullsheet.png"
}

selected = False
redsprite = Sprite(sprites["Red"], 2, 14, (100, 235), 4, "idle", "left")
greensprite = Sprite(sprites["Green"], 2, 14, (200, 235), 4, "idle", "left")
bluesprite = Sprite(sprites["Blue"], 2, 14, (400, 235), 4, "idle", "left")
yellowsprite = Sprite(sprites["Yellow"], 2, 14, (300, 235), 4, "idle", "left")
kbd = MenuKeyboard()
pointer = 0
timer = 0


def init():
    global selected
    #Ai.leve1 = 0
    Master.masterframe.setDrawHandler(draw)
    Mouse.screen = "lvlSelect"
    Master.masterframe.setKeydownHandler(kbd)
    Master.masterframe.setKeyupHandler(kbd)
Esempio n. 6
0
 def set_sprite(self, colour):
     self.sprite = Sprite(sprites[colour], 2, 4, self.pos, 1, "fireball", self.direction)
Esempio n. 7
0
class Fireball:
    #initialises fireball with a player and a direction
    #if fireball is not being fired, it is stored off canvas (-100,-100)


    def __init__(self, player, direction):
        self.character = player
        self.stoppedPos = Vector(-100, -100) #off canvas
        self.pos = self.stoppedPos
        self.direction = direction
        #self.sprite = self.set_sprite() # gets correct sprite
        self.vel = Vector()
        self.sprite = self.set_sprite("Red")

    #sets velocity depending on direction
    def setvel(self, direction, x=0):
        if direction == 'left':
            vel = Vector(-x, self.vel.getY())
        else:
            vel = Vector(x, self.vel.getY())
        return vel

    #moves fireball
    def move(self):
        self.pos = self.pos + self.vel

    #fires a fireball from a position
    def shoot(self, starting, direction):
        self.pos = starting
        self.direction = direction
        self.vel = self.setvel(self.direction, 10)
        self.character.fireball_ready = False

    #stops fireball once a limit is reached
    def stop(self):
        self.pos = self.stoppedPos
        self.vel = Vector()
        self.character.fireball_ready = True

    #sets fireball sprite
    def set_sprite(self, colour):
        self.sprite = Sprite(sprites[colour], 2, 4, self.pos, 1, "fireball", self.direction)

    def setFacing(self, facing):
        self.direction = facing
        self.sprite.setFacing(self.direction)
        self.sprite.updateDirection()


    #draws the sprite on the canvas
    def draw(self, canvas):
        self.sprite.update(canvas, self.pos.getP())

    #looping method
    def update(self, canvas, enemy):
        self.draw(canvas)
        self.move()

        #bounds for stopping fireball
        if enemy.check_hit(self.pos):
            enemy.hit(15)
            self.stop()
        if self.off_screen():
            self.stop()

    #boundary for screen
    def off_screen(self):
        return self.pos.x < 0 or self.pos.x > 500
Esempio n. 8
0
from Fighter import Master
from Fighter.Keyboard import MenuKeyboard
from Fighter.Mouse import Mouse
from Fighter.Ai import Ai
from Fighter.Sprite import Sprite

sprites = {
    "Red": "https://i.ibb.co/M7Ff2wx/redsheet.png",
    "Blue": "https://i.ibb.co/2hv9qcq/bluesheet.png",
    "Green": "https://i.ibb.co/K2616MG/greensheet.png",
    "Yellow": "https://i.ibb.co/CbMDdVC/yellowsheet.png",
    "Base": "https://i.ibb.co/6m5sd2h/fullsheet.png"
}

selected = False
aisprite = Sprite(sprites["Base"], 2, 14, (350, 225), 4, "idle", "left")
redsprite = Sprite(sprites["Red"], 2, 14, (135, 253), 2, "idle", "right")
greensprite = Sprite(sprites["Green"], 2, 14, (135, 199), 2, "idle", "right")
bluesprite = Sprite(sprites["Blue"], 2, 14, (165, 253), 2, "idle", "left")
yellowsprite = Sprite(sprites["Yellow"], 2, 14, (165, 199), 2, "idle", "left")
kbd = MenuKeyboard()
pointer = 0
timer = 0


def init():
    global selected
    #Ai.leve1 = 0
    Master.masterframe.setDrawHandler(draw)
    Mouse.screen = "MultOrNo"
    Master.masterframe.setKeydownHandler(kbd)