@@ -71,7 +71,7 @@ def __init__(
71
71
screen_width = 800 ,
72
72
screen_height = 600 ,
73
73
background_color = "black" ,
74
- title = "Simple Game Library by Jonathan " ,
74
+ title = "Simple Game Library" ,
75
75
splash_time = 3 ):
76
76
77
77
# Setup using Turtle module methods
@@ -171,7 +171,7 @@ def tick(self):
171
171
self .update_screen ()
172
172
173
173
def click (self , x , y ):
174
- print ("The window was clicked at ({},{})" . format ( x , y ) )
174
+ print (f "The window was clicked at ({ x } ,{ y } )" )
175
175
176
176
def show_splash (self , seconds ):
177
177
# Show splash screen
@@ -192,7 +192,7 @@ def show_splash(self, seconds):
192
192
turtle .bgpic ("" )
193
193
194
194
except :
195
- Game .logs .append ("Warning: {} missing from disk." . format ( self . SPLASHFILE ) )
195
+ Game .logs .append (f "Warning: { self . SPLASHFILE } missing from disk." )
196
196
197
197
# Change state to running
198
198
self .state = "running"
@@ -208,7 +208,7 @@ def save_data(self, key, value):
208
208
data = pickle .load (open (self .DATAFILE , "rb" ))
209
209
except :
210
210
data = {}
211
- Game .logs .append ("Warning: Creating new {} file on disk." . format ( self . DATAFILE ) )
211
+ Game .logs .append (f "Warning: Creating new { self . DATAFILE } file on disk." )
212
212
213
213
data [key ] = value
214
214
@@ -221,7 +221,7 @@ def load_data(self, key):
221
221
data = pickle .load (open (self .DATAFILE , "rb" ))
222
222
except :
223
223
data = {}
224
- Game .logs .append ("Warning: {} missing from disk." . format ( self . DATAFILE ) )
224
+ Game .logs .append (f "Warning: { self . DATAFILE } missing from disk." )
225
225
226
226
if key in data :
227
227
return data [key ]
@@ -289,7 +289,7 @@ def clear_terminal_screen(self):
289
289
def print_game_info (self ):
290
290
print (self .title )
291
291
print ("" )
292
- print ("Window Dimensions: {}x{}" . format ( self .SCREEN_WIDTH , self . SCREEN_HEIGHT ) )
292
+ print (f "Window Dimensions: { self . SCREEN_WIDTH } x{ self .SCREEN_HEIGHT } " )
293
293
print ("" )
294
294
295
295
# Calcuate number of active sprites
@@ -298,12 +298,12 @@ def print_game_info(self):
298
298
if sprite .state :
299
299
active_sprites += 1
300
300
301
- print ("Number of Sprites (Active / Total): {} / {}" . format ( active_sprites , len (Game .sprites )) )
301
+ print (f "Number of Sprites (Active / Total): { active_sprites } / { len (Game .sprites )} " )
302
302
303
- print ("Number of Labels: {}" . format ( len (Game .labels )) )
304
- print ("Number of Buttons: {}" . format ( len (Game .buttons )) )
303
+ print (f "Number of Labels: { len (Game .labels )} " )
304
+ print (f "Number of Buttons: { len (Game .buttons )} " )
305
305
print ("" )
306
- print ("Frames Per Second (Target): {}" . format ( self .fps ) )
306
+ print (f "Frames Per Second (Target): { self .fps } " )
307
307
print ("" )
308
308
self .print_error_logs ()
309
309
@@ -334,7 +334,7 @@ def set_background(self, image):
334
334
if image .endswith (".gif" ):
335
335
turtle .bgpic (image )
336
336
else :
337
- Game .logs .append ("Warning: Background image {} must be a gif." . format ( image ) )
337
+ Game .logs .append (f "Warning: Background image { image } must be a GIF." )
338
338
339
339
def set_fps (self , fps ):
340
340
self .fps = fps
@@ -363,7 +363,7 @@ def __init__(self,
363
363
try :
364
364
turtle .register_shape (shape )
365
365
except :
366
- Game .logs .append ("Warning: {} file missing from disk." . format ( shape ) )
366
+ Game .logs .append (f "Warning: { shape } file missing from disk." )
367
367
368
368
# Set placeholder shape
369
369
shape = "square"
@@ -417,7 +417,7 @@ def set_image(self, image, width, height):
417
417
try :
418
418
turtle .register_shape (image )
419
419
except :
420
- Game .logs .append ("Warning: {} file missing from disk." . format ( image ) )
420
+ Game .logs .append (f "Warning: { image } file missing from disk." )
421
421
422
422
# Set placeholder shape
423
423
image = "square"
@@ -436,7 +436,7 @@ def set_bounding_box(self, width, height):
436
436
self .height = height
437
437
438
438
def click (self , x , y ):
439
- print ("The sprite was clicked at ({},{})" . format ( x , y ) )
439
+ print (f "The sprite was clicked at ({ x } ,{ y } )" )
440
440
441
441
def rotate_left (self , degrees ):
442
442
self .lt (degrees )
@@ -453,7 +453,7 @@ def go_backward(self, distance):
453
453
454
454
#Label Class
455
455
class Label (turtle .Turtle ):
456
- def __init__ (self ,text ,color ,x = 0 ,y = 0 ,font_name = "Arial " ,font_size = 12 ,font_type = "normal" ,align = "left" ):
456
+ def __init__ (self ,text ,color ,x = 0 ,y = 0 ,font_name = "commodore 64 pixelized " ,font_size = 12 ,font_type = "normal" ,align = "left" ):
457
457
turtle .Turtle .__init__ (self )
458
458
self .hideturtle ()
459
459
self .penup ()
@@ -509,7 +509,7 @@ def __init__(self,
509
509
try :
510
510
turtle .register_shape (shape )
511
511
except :
512
- Game .logs .append ("Warning: {} file missing from disk." . format ( shape ) )
512
+ Game .logs .append (f "Warning: { shape } file missing from disk." )
513
513
514
514
# Set placeholder shape
515
515
shape = "square"
@@ -530,7 +530,7 @@ def set_image(self, image):
530
530
try :
531
531
turtle .register_shape (shape )
532
532
except :
533
- Game .logs .append ("Warning: {} file missing from disk." . format ( shape ) )
533
+ Game .logs .append (f "Warning: { shape } file missing from disk." )
534
534
535
535
# Set placeholder shape
536
536
shape = "square"
@@ -542,4 +542,4 @@ def set_image(self, image):
542
542
self .onclick (self .click )
543
543
544
544
def click (self , x , y ):
545
- print ("The button was clicked at ({},{})" . format ( x , y ) )
545
+ print (f "The button was clicked at ({ x } ,{ y } )" )
0 commit comments