first commit
@@ -0,0 +1,161 @@
|
|||||||
|
import pygame, random
|
||||||
|
pygame.init()
|
||||||
|
win_width, win_height = 1280, 720
|
||||||
|
win = pygame.display.set_mode((win_width, win_height))
|
||||||
|
pygame.display.set_caption("Best Gaem Evur!")
|
||||||
|
font = pygame.font.SysFont('', 200)
|
||||||
|
clock = pygame.time.Clock()
|
||||||
|
|
||||||
|
# Images
|
||||||
|
pic_arrow = [
|
||||||
|
pygame.image.load("img/arrowU.png"),
|
||||||
|
pygame.image.load("img/arrowD.png")]
|
||||||
|
|
||||||
|
pic_heart = [
|
||||||
|
pygame.image.load("img/heartE.png"),
|
||||||
|
pygame.image.load("img/heartF.png")]
|
||||||
|
|
||||||
|
pic_hp = pygame.image.load("img/hp.png")
|
||||||
|
|
||||||
|
pic_num = [
|
||||||
|
pygame.image.load("img/num0.png"),
|
||||||
|
pygame.image.load("img/num1.png"),
|
||||||
|
pygame.image.load("img/num2.png"),
|
||||||
|
pygame.image.load("img/num3.png"),
|
||||||
|
pygame.image.load("img/num4.png"),
|
||||||
|
pygame.image.load("img/num5.png"),
|
||||||
|
pygame.image.load("img/num6.png"),
|
||||||
|
pygame.image.load("img/num7.png"),
|
||||||
|
pygame.image.load("img/num8.png"),
|
||||||
|
pygame.image.load("img/num9.png"),
|
||||||
|
pygame.image.load("img/numA.png"),
|
||||||
|
pygame.image.load("img/numB.png"),
|
||||||
|
pygame.image.load("img/numC.png"),
|
||||||
|
pygame.image.load("img/numD.png")]
|
||||||
|
|
||||||
|
# Variables
|
||||||
|
arrow = [0, 0]
|
||||||
|
|
||||||
|
cards = [ # [playable, value]
|
||||||
|
[True, 0],
|
||||||
|
[True, 0],
|
||||||
|
[True, 0],
|
||||||
|
[True, 0],
|
||||||
|
[True, 0],
|
||||||
|
[True, 0],
|
||||||
|
[True, 0],
|
||||||
|
[True, 0],
|
||||||
|
[True, 0],
|
||||||
|
[True, 0],
|
||||||
|
[True, 0],
|
||||||
|
[True, 0],
|
||||||
|
[True, 0],
|
||||||
|
[True, 0],
|
||||||
|
[True, 0],
|
||||||
|
[True, 0],
|
||||||
|
[True, 0],
|
||||||
|
[True, 0]]
|
||||||
|
|
||||||
|
end_card = [True, True]
|
||||||
|
|
||||||
|
hp = [2, 2]
|
||||||
|
|
||||||
|
score = [0, 0]
|
||||||
|
|
||||||
|
def draw_arrow():
|
||||||
|
win.blit(pic_arrow[1], (arrow[0], 425))
|
||||||
|
|
||||||
|
def draw_cards():
|
||||||
|
for i in range(9):
|
||||||
|
win.blit(pic_num[11], (i*128, 64))
|
||||||
|
if cards[i][0] == True:
|
||||||
|
win.blit(pic_num[cards[i][1]], (i*128, 525))
|
||||||
|
else:
|
||||||
|
win.blit(pic_num[11], (i*128, 525))
|
||||||
|
if end_card[0] == True:
|
||||||
|
win.blit(pic_num[12], (1152,525))
|
||||||
|
else:
|
||||||
|
win.blit(pic_num[13], (1152,525))
|
||||||
|
win.blit(pic_num[13], (1152,64))
|
||||||
|
|
||||||
|
def draw_hp():
|
||||||
|
win.blit(pic_hp, (0,0))
|
||||||
|
win.blit(pic_hp, (0,650))
|
||||||
|
if hp[0] == 0:
|
||||||
|
win.blit(pic_heart[0], (64, 650))
|
||||||
|
win.blit(pic_heart[0], (128, 650))
|
||||||
|
elif hp[0] == 1:
|
||||||
|
win.blit(pic_heart[1], (64, 650))
|
||||||
|
win.blit(pic_heart[0], (128, 650))
|
||||||
|
else:
|
||||||
|
win.blit(pic_heart[1], (64, 650))
|
||||||
|
win.blit(pic_heart[1], (128, 650))
|
||||||
|
|
||||||
|
if hp[1] == 0:
|
||||||
|
win.blit(pic_heart[0], (64, 0))
|
||||||
|
win.blit(pic_heart[0], (128, 0))
|
||||||
|
elif hp[1] == 1:
|
||||||
|
win.blit(pic_heart[1], (64, 0))
|
||||||
|
win.blit(pic_heart[0], (128, 0))
|
||||||
|
else:
|
||||||
|
win.blit(pic_heart[1], (64, 0))
|
||||||
|
win.blit(pic_heart[1], (128, 0))
|
||||||
|
|
||||||
|
def draw_score():
|
||||||
|
global score
|
||||||
|
my_score = font.render(str(score[0]), 1, (0,0,0))
|
||||||
|
enemy_score = font.render(str(score[1]), 1, (0,0,0))
|
||||||
|
win.blit(my_score, (int(640 - my_score.get_rect().width/2), 361))
|
||||||
|
win.blit(enemy_score, (int(640 - enemy_score.get_rect().width/2), 221))
|
||||||
|
|
||||||
|
def generate_cards():
|
||||||
|
global cards
|
||||||
|
my_cards = [0,1,2,3,4,5,6,7,8,9]
|
||||||
|
enemy_cards = [0,1,2,3,4,5,6,7,8,9]
|
||||||
|
random.shuffle(my_cards)
|
||||||
|
random.shuffle(enemy_cards)
|
||||||
|
for i in range(9):
|
||||||
|
cards[i][1] = my_cards[i]
|
||||||
|
cards[i+9][1] = enemy_cards[i]
|
||||||
|
|
||||||
|
generate_cards()
|
||||||
|
|
||||||
|
run = True
|
||||||
|
while run:
|
||||||
|
for event in pygame.event.get():
|
||||||
|
if event.type == pygame.QUIT:
|
||||||
|
run = False
|
||||||
|
|
||||||
|
if event.type == pygame.KEYDOWN:
|
||||||
|
if event.key == pygame.K_q:
|
||||||
|
run = False
|
||||||
|
|
||||||
|
if event.key == pygame.K_LEFT or event.key == pygame.K_a:
|
||||||
|
if arrow[0] >= 128:
|
||||||
|
arrow[0] -= 128
|
||||||
|
else:
|
||||||
|
arrow[0] = 1152
|
||||||
|
|
||||||
|
if event.key == pygame.K_RIGHT or event.key == pygame.K_d:
|
||||||
|
if arrow[0] <= 1024:
|
||||||
|
arrow[0] += 128
|
||||||
|
else:
|
||||||
|
arrow[0] = 0
|
||||||
|
|
||||||
|
if event.key == pygame.K_RETURN or event.key == pygame.K_SPACE:
|
||||||
|
if arrow[0] != 1152 and end_card[0] == True:
|
||||||
|
if cards[int(arrow[0]/128)][0] != False:
|
||||||
|
cards[int(arrow[0]/128)][0] = False
|
||||||
|
score[0] += cards[int(arrow[0]/128)][1]
|
||||||
|
else:
|
||||||
|
end_card[0] = False
|
||||||
|
|
||||||
|
win.fill((255,255,255))
|
||||||
|
draw_arrow()
|
||||||
|
draw_cards()
|
||||||
|
draw_hp()
|
||||||
|
draw_score()
|
||||||
|
pygame.display.update()
|
||||||
|
clock.tick(30)
|
||||||
|
|
||||||
|
pygame.quit()
|
||||||
|
After Width: | Height: | Size: 266 B |
|
After Width: | Height: | Size: 335 B |
|
After Width: | Height: | Size: 986 B |
|
After Width: | Height: | Size: 701 B |
|
After Width: | Height: | Size: 517 B |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 2.1 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 2.7 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 2.7 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 3.0 KiB |