Development #57
					 2 changed files with 64 additions and 5 deletions
				
			
		
							
								
								
									
										8
									
								
								main.py
									
										
									
									
									
								
							
							
						
						
									
										8
									
								
								main.py
									
										
									
									
									
								
							|  | @ -2,6 +2,7 @@ import pygame | ||||||
| import sys | import sys | ||||||
| import json | import json | ||||||
| import time | import time | ||||||
|  | import random | ||||||
| from classes import * | from classes import * | ||||||
| from viecher import * | from viecher import * | ||||||
| fps = 60 | fps = 60 | ||||||
|  | @ -27,9 +28,8 @@ def quitGame(): | ||||||
|     quit() |     quit() | ||||||
| 
 | 
 | ||||||
| def play(screen, clock, running, background, isblack, WIDTH, HEIGHT): | def play(screen, clock, running, background, isblack, WIDTH, HEIGHT): | ||||||
|     main = [MainCharacter('Herbert', 100, 'reddy.png', 500, 500, 20, 5, 1, 1, 50)] |     main = [MainCharacter('Herbert', 100, 'oldman.png', 500, 500, 20, 5, 1, 1, 50)] | ||||||
|     mobs=[] |     mobs=[Skeleton(i, 50, 'reddy.png', random.randint(20,1000), random.randint(20,700), 125, 1, 1, 1, 200) for i in range(0,random.randint(2,8))] | ||||||
|     mobs.append(Skeleton('s1', 50, 'reddy.png', 250, 250, 125, 1, 1, 1, 200)) |  | ||||||
|     others = [] |     others = [] | ||||||
|     objects = [main, mobs, others] |     objects = [main, mobs, others] | ||||||
| 
 | 
 | ||||||
|  | @ -48,7 +48,7 @@ def play(screen, clock, running, background, isblack, WIDTH, HEIGHT): | ||||||
| """  | """  | ||||||
|         for thing in objects[0]: |         for thing in objects[0]: | ||||||
|             if thing.update(pygame.key.get_pressed()) ==False: |             if thing.update(pygame.key.get_pressed()) ==False: | ||||||
|                 quitGame() |                 menu(screen, clock, running, background, isblack, WIDTH, HEIGHT) | ||||||
|             thing.draw(screen) |             thing.draw(screen) | ||||||
|          |          | ||||||
|         for mob in objects[1]: |         for mob in objects[1]: | ||||||
|  |  | ||||||
							
								
								
									
										61
									
								
								viecher.py
									
										
									
									
									
								
							
							
						
						
									
										61
									
								
								viecher.py
									
										
									
									
									
								
							|  | @ -2,6 +2,40 @@ import pygame as pg | ||||||
| vec = pg.math.Vector2 | vec = pg.math.Vector2 | ||||||
| fps = 60 | fps = 60 | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|  | pg.font.init() | ||||||
|  | fonts = { | ||||||
|  |     'medieval': 'medieval.ttf', | ||||||
|  |     'minecraft': 'Minecraft Evenings.otf', | ||||||
|  |     '3dpixel': '3D-Pixel.ttf', | ||||||
|  |     '8bit': '8bitlim.ttf', | ||||||
|  |     '8bito': '8blimro.ttf', | ||||||
|  |     'arcade': 'ARCADECLASSIC.ttf', | ||||||
|  |     'modern_game': 'astron boy video.otf', | ||||||
|  |     'modern': 'astron boy.otf', | ||||||
|  |     'wonder': 'Beyond Wonderland.ttf', | ||||||
|  |     'curved': 'Digitag.ttf', | ||||||
|  |     'simple': 'DisposableDroidBB.ttf', | ||||||
|  |     'rounded': 'dpcomic.ttf', | ||||||
|  |     'playfull': 'Endalian Script.ttf', | ||||||
|  |     'blocky': 'FREAKSOFNATURE.ttf', | ||||||
|  |     'catchy': 'Future TimeSplitters.otf', | ||||||
|  |     'simple_wide': 'Halo3.ttf', | ||||||
|  |     'simple_fat': 'INVASION2000.ttf', | ||||||
|  |     'very_gamy': 'ka1.ttf', | ||||||
|  |     'simple_round': 'Karma Suture.otf', | ||||||
|  |     'mono': 'manaspc.ttf', | ||||||
|  |     'damaged': 'Merchant Copy.ttf', | ||||||
|  |     'big_natural': 'MorialCitadel.TTF', | ||||||
|  |     'spacy': 'nasalization-rg.otf', | ||||||
|  |     'sci-fi': 'neuropol.otf', | ||||||
|  |     'hollow_big_edge': 'papercut.ttf', | ||||||
|  |     'space_shuttle': 'pdark.ttf', | ||||||
|  |     'thin': 'PixelFJVerdana12pt.ttf', | ||||||
|  |     'random': 'Seattle Avenue.ttf', | ||||||
|  |     'pixel': 'yoster.ttf' | ||||||
|  | } | ||||||
|  | 
 | ||||||
| class Objects(): | class Objects(): | ||||||
|     def __init__(self, name, ms, sprite, x, y) -> None: |     def __init__(self, name, ms, sprite, x, y) -> None: | ||||||
|         self.name = name |         self.name = name | ||||||
|  | @ -45,6 +79,7 @@ class MainCharacter(Fighter): | ||||||
|         self.attack_spell = weapon |         self.attack_spell = weapon | ||||||
|         self.shield_spell = shield |         self.shield_spell = shield | ||||||
|         self.talking = False |         self.talking = False | ||||||
|  |         self.level = Level(1000, 38, level, 150, 40, f'will to live: {level}%', 'simple', 20) | ||||||
|         self.health = Hearts(health, sprite=['fullheart.png','fullheart.png','fullheart.png','fullheart.png','fullheart.png'], x=900, y= 50) |         self.health = Hearts(health, sprite=['fullheart.png','fullheart.png','fullheart.png','fullheart.png','fullheart.png'], x=900, y= 50) | ||||||
|      |      | ||||||
|     def draw(self, screen): |     def draw(self, screen): | ||||||
|  | @ -53,6 +88,7 @@ class MainCharacter(Fighter): | ||||||
|         self.rect.x, self.rect.y = self.x, self.y |         self.rect.x, self.rect.y = self.x, self.y | ||||||
|         screen.blit(self.sprite, self.rect) |         screen.blit(self.sprite, self.rect) | ||||||
|         self.health.draw(screen) |         self.health.draw(screen) | ||||||
|  |         self.level.draw(screen) | ||||||
| 
 | 
 | ||||||
|     def hurt(self,damage): |     def hurt(self,damage): | ||||||
|         self.health.hurt(damage) |         self.health.hurt(damage) | ||||||
|  | @ -126,6 +162,29 @@ class Hearts(): | ||||||
|             with open(f'art/images/{parts}') as i: |             with open(f'art/images/{parts}') as i: | ||||||
|                 self.sprite.append(pg.image.load(i)) |                 self.sprite.append(pg.image.load(i)) | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|  | class Level(): | ||||||
|  |     def __init__(self, x, y, level, width, height, text, font, font_size) -> None: | ||||||
|  |         self.x = x | ||||||
|  |         self.y = y | ||||||
|  |         self.level = level | ||||||
|  |         self.width = width | ||||||
|  |         self.height = height | ||||||
|  |         self.font = pg.font.Font(f'fonts/{fonts[font]}', font_size) | ||||||
|  |         self.hidden = False | ||||||
|  |         with open('art/images/label.png', 'r') as tb: | ||||||
|  |             self.box = pg.image.load(tb) | ||||||
|  |             self.box = pg.transform.scale(self.box, (width, height)) | ||||||
|  |         self.labelRect = pg.Rect(self.x, self.y, self.width, self.height) | ||||||
|  |         self.labelSurf = self.font.render(text, True, '#1E90FF') | ||||||
|  | 
 | ||||||
|  |     def draw(self, screen): | ||||||
|  |         self.box.blit(self.labelSurf, [ | ||||||
|  |             self.labelRect.width/2 - self.labelSurf.get_rect().width/2, | ||||||
|  |             self.labelRect.height/2 - self.labelSurf.get_rect().height/2 | ||||||
|  |         ]) | ||||||
|  |         screen.blit(self.box, self.labelRect) | ||||||
|  |          | ||||||
| class Mobs(Fighter): | class Mobs(Fighter): | ||||||
|     def __init__(self, name, ms, sprite, x, y, health, damage, level, asp, atr, drops) -> None: |     def __init__(self, name, ms, sprite, x, y, health, damage, level, asp, atr, drops) -> None: | ||||||
|         super().__init__(name, ms, sprite, x, y, health, damage, level, asp, atr) |         super().__init__(name, ms, sprite, x, y, health, damage, level, asp, atr) | ||||||
|  | @ -165,7 +224,7 @@ class Weapons(Objects): | ||||||
| class Arrow(Weapons): | class Arrow(Weapons): | ||||||
|     def __init__(self, name, ms, x, y, moveto, damage, sprite="arrow.png") -> None: |     def __init__(self, name, ms, x, y, moveto, damage, sprite="arrow.png") -> None: | ||||||
|         super().__init__(name, ms, sprite, x, y, moveto, damage) |         super().__init__(name, ms, sprite, x, y, moveto, damage) | ||||||
|         pos = vec(x,y) |         pos = vec(1,0) | ||||||
|         angle = pos.angle_to(moveto) |         angle = pos.angle_to(moveto) | ||||||
|         with open(f'art/images/{sprite}') as i: |         with open(f'art/images/{sprite}') as i: | ||||||
|             self.sprite = pg.transform.rotate(pg.image.load(i), angle) |             self.sprite = pg.transform.rotate(pg.image.load(i), angle) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue