예제 #1
0
def game_click(point):
    global tag
    tag += 1
    point = game.sum2d(point, (-5, -5))
    c = game.Ellipse(point, (10, 10),
                     game.WHITE,
                     thick=2,
                     detailed=True,
                     tag=tag)
    c.click = blob_click
    c.collision = blob_collision
예제 #2
0
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
예제 #3
0
파일: alpha.py 프로젝트: safineh/HelliGame
import helligame as game

fade = False
ball = game.Ellipse((400, 10), (20, 20), speed=(0, 25), color=(255, 0, 0))
wall = game.Box((0, 550), (800, 10), color=(0, 0, 255))
alphaBox = game.Box((0, 0), (800, 600), color=(0, 0, 0), alpha=0)


def ball_collision(item):
    global fade
    if item == wall:
        ball.position = (400, 530)
        game.pause = True
        fade = True


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)


ball.collision = ball_collision
game.frame = game_frame
game.mainloop()
예제 #4
0

def ball_collision(item):
    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:
예제 #5
0
		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)

def onFrame():
	if game.pause:
		return
	score.text += 1 / game.fps

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

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

game.frame = onFrame
game.mainloop()
예제 #6
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()
예제 #7
0
    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
btnX = game.Label(" X ", (750, 10), back=game.RED, radius=1)
btnX.click = game.back

# level 1
bomb = game.Ellipse((25, 275), (50, 50), color=game.BLACK, tag="bomb")

# mainloop
game.mainloop("level game", game.SKY, 800, 600, room=[btn1, btn2, btnQ])
예제 #8
0
import helligame as game
game.Ellipse((50, 50), (700, 500), game.WHITE)  # Ellipse: دایره یا بیضی
game.Box((200, 150), (400, 100), game.GREEN)
game.Box((200, 250), (400, 100), game.GRAY,
         thick=1)  # thick: ضخامت، جعبه توخالی می‌شود
game.Box((200, 350), (400, 100), game.RED,
         radius=.2)  # radius: درصد گردی لبه. بین 0 تا 1

game.mainloop("Salam", game.YELLOW)  # عنوان صفحه و رنگ زمینه