Esempio n. 1
0
def start(x):
    if score1.text == 11:
        game.pause = True
        game.Label("Green is winner!", (130, 250), game.GREEN, size=72)
    elif score2.text == 11:
        game.pause = True
        game.Label("Red is winner!", (170, 250), game.RED, size=72)
    else:
        ball.position = (385, 285)
        ball.speed = (x * 3, 0)
Esempio n. 2
0
def end(name, color):
    game.sound("audio/launch.ogg")
    game.pause = True
    game.Label(name + " is winner!", (140, 180), color, size=72, tag="temp")
    re = game.Label(" Restart ", (240, 300),
                    game.WHITE,
                    back=color,
                    size=72,
                    radius=.3,
                    tag="temp")
    re.click = restart
Esempio n. 3
0
def playerCollision(item):
	if item.tag == "bomb":
		item.pause = True
		item.color = game.GRAY
		health.text -= item.size[0]
		if health.text <= 0:
			health.text = 0
			game.pause=True
			game.Box((200, 200), (415, 210), color=game.WHITE, alpha=.5, tag="temp")
			game.Label("GAME OVER", (220, 200), color=game.WATER, size=64, tag="temp")
			r = game.Label(" Restart ", (270, 300), color=game.WHITE, back=game.WATER, size=64, radius=0.4, tag="temp")
			r.click = Restart
Esempio n. 4
0
def onCollisionPlayer(collider):
    global score, score_add
    if collider.tag == "bomb":
        game.sound("sfx/haaa.wav")
        game.pause = True
        game.Label("GAME OVER", position=(220, 200), color=game.ROSE, size=64)
        r = game.Label(" Restart ",
                       position=(280, 300),
                       color=game.LIME,
                       back=game.ROSE,
                       size=64,
                       radius=.5)
        r.click = onClickRestart
    '''elif collider.tag == "inc":
Esempio n. 5
0
def game_frame():
    global fade
    if fade:
        if alphaBox.color[3] >= 255 - 10:
            fade = False
            game.Label("FINISH !", (270, 250), color=(255, 255, 255), size=64)
        else:
            alphaBox.color = (0, 0, 0, alphaBox.color[3] + 10)
Esempio n. 6
0
def playerCollision(item):
	if item.tag == "bomb":
		item.pause = True
		item.color = game.GRAY
		health.text -= item.size[0]
		if health.text <= 0:
			health.text = 0
			game.pause=True
			game.Label("GAME OVER", (220, 200), color=game.WATER, size=64)
Esempio n. 7
0
def draw(color, text):
    global size, x, y, c, max_rows, col_width
    game.Box((x, y), (size, size), color)
    game.Label(text, (x + size + 8, y + 5), color, size=22)
    y += size
    c += 1
    if c >= max_rows:
        c = 0
        y = 0
        x += col_width
Esempio n. 8
0
def onStart():
    global score_add, score, player, counter

    player = game.Box(color=game.ORANGE,
                      size=(40, 40),
                      speed=(4, 4),
                      radius=.4,
                      tag="player")
    player.collision = onCollisionPlayer

    game.Image("images/coins.png", position=(10, 10))
    score = game.Label(0, position=(45, 0), color=game.LIGHT_CHOCOLATE)
    score.format = int

    for i in range(random.randint(2, 4)):
        addRandom("inc", game.INDEGO, None)
    for i in range(random.randint(2, 4)):
        addRandom("dec", game.GREEN, None)
    for i in range(random.randint(6, 8)):
        addRandom("bomb", game.RED, onClickBomb)

    game.sleep(3)
    game.sound("sfx/123start.wav")
Esempio n. 9
0
import helligame as game


def timer_done(owner, timer):
    owner.text += 1
    timer.restart()


lbl = game.Label(0, (10, 0))
lbl.addTimer(2, timer_done, True)

game.mainloop("timer test", game.SKY, 800, 560)
game.quit()
Esempio n. 10
0
import helligame as game


def keydown(key):
    if game.keyMap(" "):
        lbl.color = game.SILVER
        tmr.Pause()


def keyup(key):
    if key == game.keyMap(" "):
        lbl.color = game.WHITE
        tmr.Pause(False)


def timer_done():
    lbl.text += 1
    tmr.restart()


lbl = game.Label(0, (10, 0))
tmr = lbl.addTimer(2, timer_done)
game.Label("Hold SPACE to PAUSE timer", (350, 0))
game.keydown = keydown
game.keyup = keyup

game.mainloop("timer test", game.SKY, 800, 560)
game.quit()
Esempio n. 11
0
def keydown(key):
    if game.keyMap(" "):
        lbl.color = game.SILVER
        tmr.Pause()


def keyup(key):
    if key == game.keyMap(" "):
        lbl.color = game.WHITE
        tmr.Pause(False)


def frame():
    rem.text = int(tmr.remain * 10) / 10
    if tmr.done():
        lbl.text += 1
        tmr.restart()


lbl = game.Label(0, (10, 0))
rem = game.Label(0, (10, 40), color=game.CYAN)
game.Label("Hold SPACE to PAUSE timer", (350, 0))
tmr = game.Timer(2)
game.keydown = keydown
game.keyup = keyup
game.frame = frame

game.mainloop("timer test", game.SKY, 800, 560)
game.quit()
Esempio n. 12
0
import helligame as game

game.Image("images/stadium800.jpg")
game.Image("images/football.png", (384, 264))
game.Label(0, (10, 0), color=game.RED)
game.Label(0, (770, 0), color=game.BLUE)
game.Box((0, 180), (10, 200), color=game.RED, alpha=.2)
game.Box((790, 180), (10, 200), color=game.BLUE, alpha=.2)

game.mainloop("football", -1, 800, 560)
Esempio n. 13
0

def level1_click():
    player.position = (100, 275)
    player.speed = (10, 0)
    game.mainloop(room=[btnX, player, bomb])


def level2_click():
    player.position = (375, 25)
    player.speed = (10, 10)
    game.mainloop(room=[btnX, player])


# level select
btn1 = game.Label("  LEVEL 1 ", (170, 50), back=game.BLUE, size=100, radius=.5)
btn2 = game.Label("  LEVEL 2 ", (160, 225),
                  back=game.BLUE,
                  size=100,
                  radius=.5)
btnQ = game.Label("   QUIT   ", (170, 400),
                  back=game.BLUE,
                  size=100,
                  radius=.5)
btn1.click = level1_click
btn2.click = level2_click
btnQ.click = game.quit

# all levels
player = game.Ellipse(size=(50, 50), color=game.GREEN)
player.collision = collision
Esempio n. 14
0
    if item == rocket1:
        ball_return(1)
    elif item == rocket2:
        ball_return(-1)
    elif item == wall1:
        score2.text += 1
        start(1)
    elif item == wall2:
        score1.text += 1
        start(-1)


ball = game.Ellipse((400, 300), (30, 30), game.BLUE)
ball.collision = ball_collision

rocket1 = game.Box((20, 250), (30, 100), game.GREEN)
rocket1.moveBy("W_S", 15)
wall1 = game.Box((1, 0), (0, 600), game.GREEN)
score1 = game.Label(0, (80, 0), game.GREEN)

rocket2 = game.Box((750, 250), (30, 100), game.RED)
rocket2.moveBy(("Up", None, "Down"), 15)
wall2 = game.Box((799, 0), (0, 600), game.RED)
score2 = game.Label(0, (700, 0), game.RED)

if random.randint(1, 2) == 1:
    start(1)
else:
    start(-1)
game.mainloop()
Esempio n. 15
0
def randSpeed():
    v = random.random() * 3
    ball.speed = (game.randomSign(v + 5), game.randomSign(7 - v))
    ball.position = (384, 264)


def ball_bounce():
    game.sound("audio/hit1.ogg")


back = game.Image("images/stadium800.jpg")
ball = game.Image("images/football.png", (384, 264))
ball.moveBy("WASD", 10)
ball.collision = ball_collision
ball.bounce = ball_bounce
randSpeed()

rscore = game.Label(0, (10, 0), color=game.RED)
bscore = game.Label(0, (770, 0), color=game.BLUE)
bgoal = game.Box((0, 180), (10, 200), color=game.RED, alpha=.2)
rgoal = game.Box((790, 180), (10, 200), color=game.BLUE, alpha=.2)

room = [back, ball, rscore, bscore, bgoal, rgoal]
game.init("football", game.SKY, 800, 560)
while not game.done:
    game.events(room)
    game.update(room)
    game.draw(room)
game.quit()
Esempio n. 16
0
    if item == bomb:
        lbl.text = 5
        lbl.visible = True
        game.pause = True
        timer.restart()


def countdown(owner, timer):
    if owner.text > 0:
        owner.text -= 1
        timer.restart()
    else:
        owner.visible = False
        player.position = (375, 25)
        player.speed = (25, 0)
        player.visible = True
        bomb.position = (25, 25)
        bomb.visible = True
        game.pause = False


player = game.Ellipse(size=(50, 50), color=game.GREEN, visible=False)
bomb = game.Ellipse(size=(50, 50), color=game.RED, visible=False)
lbl = game.Label(5, (300, 70), alpha=.5, size=400)
timer = lbl.addTimer(.5, countdown, True)
player.collision = collision
game.pause = True

game.mainloop("countdown", game.SKY, 800, 560)
game.quit()
Esempio n. 17
0
#click
import helligame as game

def add_score(item):
	emtiaz.text += 1

emtiaz = game.Label(0, position=(35,20))
bomb = game.Box( position=(350,250) , size=(100,40) , color=game.BLUE, speed=(10, 0) )
bomb.click = add_score
game.mainloop()
Esempio n. 18
0
import helligame as game

i = 0


def click():
    global i
    i = (i + 1) % 2
    if i == 0:
        coin.load("images/coin1.png")
    else:
        coin.load("images/coins.png")


coin = game.Image("images/coin1.png", (385, 265))
game.Label("click on image", (290, 300))
coin.click = click
game.mainloop("sprite", game.SKY, 800, 560)
Esempio n. 19
0
	score.text += 1 / game.fps

def Restart(item):
	score.text = 0
	health.text = 20
	player.position = (260, 400)
	game.remove("temp")
	game.remove("bomb")
	game.pause=False

	for i in range(10):
		z = random.randint(5, 10)
		x = random.randint(100, 600)
		y = random.randint(0, 380)
		sx = random.random() - .5
		sy = random.random() * -5
		bomb = game.Ellipse( position=(x,y) , size=(z,z) , color=game.RED, speed=(sx, sy) , tag="bomb" )
		bomb.bound = False
		bomb.out = bombOut

player=game.Box( position=(260,400) , size=(100,40) , color=game.INDEGO )
player.moveBy(("Up", "Left", "Down", "Right"), 10)
health=game.Label(20, position=(10, 0))
score=game.Label(0, position=(720, 0))
score.format = int
player.collision = playerCollision
game.frame = onFrame

Restart(0)
game.mainloop()
Esempio n. 20
0

def playerCollision(item):
    if item.tag == "bomb":
        item.pause = True
        item.color = game.GRAY
        health.text -= item.size[0]
        if health.text <= 0:
            health.text = 0
            game.pause = True
            game.Label("GAME OVER", (220, 200), color=game.WATER, size=64)


player = game.Box(position=(260, 400), size=(100, 40), color=game.INDEGO)
player.moveBy(("Up", "Left", "Down", "Right"), 10)
health = game.Label(20, position=(10, 0))
player.collision = playerCollision

for i in range(10):
    z = random.randint(5, 10)
    x = random.randint(100, 600)
    y = random.randint(0, 380)
    sx = random.random() - .5
    sy = random.random() * -5
    bomb = game.Ellipse(position=(x, y),
                        size=(z, z),
                        color=game.RED,
                        speed=(sx, sy),
                        tag="bomb")
    bomb.bound = False
    bomb.out = bombOut
Esempio n. 21
0
    game.remove("bomb")
    game.pause = False

    for i in range(10):
        z = random.randint(5, 10)
        x = random.randint(100, 600)
        y = random.randint(0, 380)
        sx = random.random() - .5
        sy = random.random() * -5
        b = game.Ellipse(position=(x, y),
                         size=(z, z),
                         color=game.RED,
                         speed=(sx, sy),
                         tag="bomb")
        b.bound = False
        b.out = bombOut


player = game.Image("images/brick.png", position=(260, 400))
player.moveBy(("Up", "Left", "Down", "Right"), 10)
game.Image("images/life.png", position=(10, 10))
health = game.Label(20, position=(50, 0))
game.Image("images/star.png", position=(700, 10))
score = game.Label(0, position=(740, 0))
score.format = int
player.collision = playerCollision
game.frame = onFrame

Restart(0)
game.mainloop()
Esempio n. 22
0
def playerCollision(item):
    if item.tag == "bomb":
        game.pause = True
        game.Label("GAME OVER", (220, 200), color=game.WATER, size=64)