forked from Frankie-q22/Fighting-For-Honor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FightingForHonor.py
95 lines (73 loc) · 2.52 KB
/
FightingForHonor.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import pygame
from fighter import Fighter
pygame.init()
#creates Game Window
Screen_Width = 1000
Screen_Height = 600
Screen = pygame.display.set_mode((Screen_Width,Screen_Height))
pygame.display.set_caption("Fighting For Honor")
#Set Framerate
clock = pygame.time.Clock()
FPS = 60
#Define colors
Red = (255,0,0)
Yellow = (255,255,0)
White = (255,255,255)
#define the fighter sizes/sprites
RoninSizeWidth = 200
RoninSizeHeight = 200
RoninScale = 3.8
RoninOffset = [90,75.5]
RoninData = [RoninSizeWidth,RoninSizeHeight,RoninScale,RoninOffset]
SamuraiSizeHeight = 200
SamuraiSizeWidth = 160
SamuraiScale = 4
SamuraiOffset = [89,72]
SamuraiData = [RoninSizeWidth,SamuraiSizeHeight,SamuraiScale,SamuraiOffset]
#load BackGround Image
background = pygame.image.load("Fighting-For-Honor/GateJapan.jpg").convert_alpha()
#load Spritesheets
Roninsheet = pygame.image.load("Fighting-For-Honor/FullRonin.png").convert_alpha()
Samuraisheet = pygame.image.load("Fighting-For-Honor/FullSamurai.png").convert_alpha()
#steps in each animation
RoninAnimation = [4,8,2,2,4,4,3,7]
SamuraiAnimation =[8,8,2,2,6,6,4,6]
#Function that displays background
def display_Bg():
scaledBG = pygame.transform.scale(background,(Screen_Width, Screen_Height))
Screen.blit(scaledBG,(0,0))
#Function for drawing the health bars
# bottom bar is character's health in yellow. length of color has to be set to character's health value in order for character to take damage
def Health_Bar(Health, x, y):
pygame.draw.rect (Screen, White, (x-2,y-2,404,35))
pygame.draw.rect (Screen, Red, (x,y, 400,30))
pygame.draw.rect (Screen, Yellow, (x,y, Health,30))
#Creates both Characters
Ronin = Fighter(1,200,360,False,RoninData,Roninsheet,RoninAnimation)
Samurai = Fighter(2,700,360,True,SamuraiData,Samuraisheet,SamuraiAnimation)
#gameloop
run = True
while run:
clock.tick(FPS)
#Display Background
display_Bg()
#Show Health Bars
Health_Bar(Ronin.Health, 20,20)
Health_Bar(Samurai.Health, 580,20)
#Move the fighters
Ronin.Move(Screen_Width, Screen_Height,Screen, Samurai)
Samurai.Move(Screen_Width, Screen_Height,Screen, Ronin)
#updates the sprites for each character
Ronin.update()
Samurai.update()
#Draw Fighters
Ronin.Draw(Screen)
Samurai.Draw(Screen)
#event handler
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
#Updates display for background
pygame.display.update()
#exit pygame
pygame.quit()