diff --git a/game.py b/game.py index 5e7640f..641595a 100644 --- a/game.py +++ b/game.py @@ -1,4 +1,4 @@ -from PIL import Image +from PIL import Image, ImageDraw, ImageFont import logging import pygame import gameUtils @@ -49,7 +49,7 @@ class Game(gameUtils.Game): # an object or something, I don't know. Keep in mind you # have to load all of the font files for use later. with open(f'./fonts/fonts.json', 'r') as f: - j = json.loads(f.read()) + self.fontList = json.loads(f.read())#loads the fonts from the json (Why the fuck was the variable called 'j' before????) #for fontData in j: # self.fonts.update() @@ -87,7 +87,18 @@ class Game(gameUtils.Game): # Don't remove this. It does important things. :3 super().update() - self.surf.fill((0, 0, 0)) + self.Drawsurface = Image.new("RGB",(800,220),(255,255,255)) #creates a surface to draw the fonts on + self.textTest = ImageFont.truetype("./fonts/"+self.fontList[2]["file"],200) #loads the font + self.draw = ImageDraw.Draw(self.Drawsurface) #creates an object to let us draw to the surface + + self.draw.text((10,10),"Hello", font=self.textTest, fill=(0,0,0)) #actually draws the text + + self.pygameConvert = pygame.image.fromstring(self.Drawsurface.tobytes(), self.Drawsurface.size, self.Drawsurface.mode) #converts the pillow image to a pygame image + #no, there wasn't an easier way I could find to achieve this, stab me + + self.surf.fill((0, 0, 0)) #sets the background colour + self.surf.blit(gameUtils.centre(self.pygameConvert,self.size)) #draws the text to center of the screen + #TODO: actually scale the text, however, more work needs to be done on the actual function of the game first def close(self): """ diff --git a/launch.json b/launch.json new file mode 100644 index 0000000..4fef3e8 --- /dev/null +++ b/launch.json @@ -0,0 +1,17 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Python Debugger", + "type": "debugpy", + "request": "launch", + "python": "../PainJamLauncher/.venv/Scripts/python.exe", + "program": "../PainJamLauncher/__main__.py", + "args": ["captchaGame"], + "console": "integratedTerminal" + } + ] +} \ No newline at end of file