Rename license, readme, todo files
[orange-guys-quest.git] / orange.py
blobe71acf81a0b88418c2f2b23fa08fd19707c5ce39
1 #! /usr/bin/env python
3 # Orange Guy's Quest mainfile
5 #Contains code from pymike's public domain collision and camera tutorials
6 #Pymike's website: http://pymike.pynguins.com/
7 #This code has been heavily modified and is unrecognizable unless you look
8 #closely.
10 # Copyright (c) 2011-2020 Philip Pavlick
12 # <swashdev@pm.me> wrote this file. Feel free to do whatever you want
13 # with it so long as you don't hold me liable for any damages; there is no
14 # warranty. In exchange, if you ever find yourself thinking "I can't do
15 # this," or "I'll never be that good," I want you to stop, take a deep breath,
16 # and say "Yes I can." Then prove you can. Don't prove it to me; don't prove
17 # it to your friends and family; don't prove it to your boss; prove it to
18 # yourself. This software is already free; now free yourself.
19 # - Philip Pavlick
21 # For more information about the rationale behind this licensing, see
22 # https://www.pavlick.net/fyl/
24 #import os
25 import sys
26 import random
27 import pygame
28 from pygame.locals import *
30 print "Welcome to Orange Guy's Quest, version 1.3, by Philip Pavlick."
32 ##########################
33 # Configuration options: #
34 ##########################
36 # Set LEVELPATH to the file where you have your levels saved. By default,
37 # this is ./orange-levels. Don't set it to ./extraLevels.txt because those
38 # levels are awful.
39 # Can be set with -l <file> or --level <file> in the command line
40 LEVELPATH = "orange-levels"
42 # Much like LEVELPATH, determines the path for the introductory levels.
43 # Can be accessed with --help, -?, or --intro, but should not be modified.
44 INTROLEVELS = "help.txt"
46 # WINDOWS changes whether \ or / are used for directory trees. You shouldn't
47 # need to change this unless your system is only able to use \. Most versions
48 # of windows will run just fine with only /.
49 WINDOWS = False
51 # Set USERECTS to True to force the old-school Atari2600-style blocky
52 # graphics or False to use the Retro pixel graphics. Any other value will
53 # give a prompt.
54 # Can be set to False with -r or -s, or True with -a or -b, in the command line
55 USERECTS = False
57 # Set these to the pixel values you want the game to use for the screen. Note
58 # that the game was originally programmed for a 640x480 window, and it looks
59 # just fine in that resolution.
60 # Can be set with -W in the command line, or individually with -x or -w for
61 # WIN_X and -y or -h for WIN_Y
62 WIN_X = 640
63 WIN_Y = 480
65 # Set BIGPLAYER to True to restore the player's original large hitbox. This is
66 # not recommended, but I thought people might get a chuckle out of this.
67 # Can be set with -B in the command line
68 BIGPLAYER = False
70 # Set this to True if you want annoying debug messages in your console.
71 # Can be set with -D in the command line
72 DEBUG = False
74 ##########################
75 # Pre-code configuration #
76 ##########################
78 getting_help = False
80 vars = sys.argv
81 vars.pop(0)
82 while len( vars ) > 0:
83 global USERECTS,LEVELPATH,BIGPLAYER,DEBUG
84 opt = vars.pop(0)
85 if opt == "-r":
86 USERECTS = False
87 elif opt == "-b" or opt == '-a':
88 USERECTS = True
89 elif opt == "-B":
90 BIGPLAYER = True
91 elif opt == "-D":
92 DEBUG = True
93 elif opt == "-W":
94 WIN_X = int(vars.pop(0))
95 WIN_Y = int(vars.pop(0))
96 elif opt == "-x" or opt == "-w":
97 WIN_X = int(vars.pop(0))
98 elif opt == "-y" or opt == "-h":
99 WIN_Y = int(vars.pop(0))
100 elif opt == "-l" or opt == "--levels":
101 if len(vars) > 0:
102 LEVELPATH = vars.pop(0)
103 else:
104 raise SystemExit, "Not enough parameters for --levels: Must specify a file."
105 elif opt in ["-?", "--help", "--levels"]:
106 LEVELPATH = INTROLEVELS
107 getting_help = True
109 d = '/'
110 if WINDOWS == True:
111 d = '\\'
113 while USERECTS not in [True,False]:
114 print "Use [R]etro or [A]ncient graphics? [R/A]"
115 USERECTS=raw_input("[\'\b").upper()
116 if USERECTS=="R":
117 USERECTS=False
118 elif USERECTS=="A":
119 USERECTS=True
121 # Initialise pygame
122 #os.environ["SDL_VIDEO_CENTERED"] = "1"
123 pygame.init()
125 # Set up the display
126 pygame.display.set_caption("Orange Guy's Quest!!")
127 screen = pygame.display.set_mode((WIN_X, WIN_Y))
128 if DEBUG:
129 print "Create: PyGame screen"
131 #pygame.display.toggle_fullscreen()
133 ##################################
134 # Pre-code variable declarations #
135 ##################################
137 clock = pygame.time.Clock()
138 walls = [] # List to hold the walls
140 jumpDY=0
142 timeBuffer=0
144 tele_rect=pygame.Rect(0,0,16,16)
146 end_rect=None
147 won = False
149 lvlMessage=""
151 # Important: See ``fonts/readme-proggy.txt'' for the Proggy license
152 font = pygame.font.Font("fonts" + d + "ProggySquareSZ.ttf", 24)
153 text = None
154 textpos = None
155 message_delay = 0
157 # Sprite declarations:
158 import orange_images
160 ######################
161 # Class declarations #
162 ######################
164 # Class for the orange dude
165 class Player(object):
166 jump=False
167 dJump=False
168 dead = False
169 sprite=None
170 ID="Player"
171 color=(255,128,0)
172 def __init__(self):
173 global BIGPLAYER
174 if not BIGPLAYER:
175 self.rect = pygame.Rect(32, 32, 8, 16)
176 else:
177 self.rect = pygame.Rect(32, 32, 16, 16)
178 if not USERECTS:
179 self.sprite = orange_images.get_sprite( "player", d, DEBUG )
181 def move(self, dx, dy):
182 if not self.dead:
183 # Move each axis separately. Note that this checks for collisions both times.
184 if dx != 0:
185 self.move_single_axis(dx, 0)
186 if dy != 0:
187 self.move_single_axis(0, dy)
189 def move_single_axis(self, dx, dy):
191 # Move the rect
192 self.rect.x += dx
193 self.rect.y += dy
195 # If you collide with a wall, move out based on velocity
196 for wall in walls:
197 if self.rect.colliderect(wall.rect):
198 if wall.ID not in ["Enemy","spike","Key","Portal","Destination"]:
199 if dx > 0: # Moving right; Hit the left side of the wall
200 self.rect.right = wall.rect.left
201 if dx < 0: # Moving left; Hit the right side of the wall
202 self.rect.left = wall.rect.right
203 if dy > 0: # Moving down; Hit the top side of the wall
204 self.rect.bottom = wall.rect.top
205 self.jump=False#Edited by me to simulate landing
206 self.dJump=False
207 global jumpDY
208 jumpDY=0
209 #if wall.ID=="Mover":
210 # self.rect.x+=wall.direction
211 if dy < 0: # Moving up; Hit the bottom side of the wall
212 self.rect.top = wall.rect.bottom
213 global jumpDY
214 jumpDY=0
215 elif wall.ID in ["Enemy","spike"]:
216 if DEBUG:
217 print "Event: Player killed by "+wall.ID
218 global text, textpos
219 text = font.render("You are dead. Press BACKSPACE to restart.", 1, (255, 128, 0))
220 textpos = text.get_rect(centerx=screen.get_width()/2)
221 self.dead = True
222 elif wall.ID=="Key":
223 for object in walls:
224 if object.ID=="Door":
225 if object.Color==wall.Color:
226 object.Open()
227 elif wall.ID == "Portal":
228 if DEBUG:
229 print "Event: Player touched a portal"
230 for object in walls:
231 if object.ID=="Destination":
232 self.rect = object.rect
233 if DEBUG:
234 print "Zzzap! Sent player to", self.rect.x, self.rect.y
236 # Nice class to hold a wall rect
237 class Wall(object):
238 sprite=None
239 ID="Wall"
240 color=(255,255,255)
241 def __init__(self, pos):
242 global walls
243 walls.append(self)
244 self.rect = pygame.Rect(pos[0], pos[1], 16, 16)
246 class Mover(Wall):
247 ID="Mover"
248 direction=-1
249 difference=0
250 maxDiff=5
253 def __init__(self,coord,direction):
254 self.h=direction[0]
255 self.v=direction[1]
256 super(Mover,self).__init__(coord)
257 def update(self):
258 if self.direction==1:
259 if self.difference<self.maxDiff*16:
260 self.rect.x+=self.h
261 self.rect.y+=self.v
262 self.difference+=1
263 else:
264 self.direction=-1
265 else:
266 if self.difference>-(self.maxDiff*16):
267 self.rect.x-=self.h
268 self.rect.y-=self.v
269 self.difference-=1
270 else:
271 self.direction=1
273 dx = self.h * self.direction
274 dy = self.v * self.direction
276 # If you collide with a wall, move out based on velocity
277 for wall in walls:
278 if wall.ID=="Door" and self.rect.colliderect(wall.rect):
279 if dx > 0: # Moving right; Hit the left side of the wall
280 self.rect.right = wall.rect.left
281 self.direction *= -1
282 if dx < 0: # Moving left; Hit the right side of the wall
283 self.rect.left = wall.rect.right
284 self.direction *= -1
285 if dy > 0: # Moving down; Hit the top of the wall
286 self.rect.bottom = wall.rect.top
287 self.direction *= -1
288 if dy < 0:
289 self.rect.top = wall.rect.bottom
290 self.direction *= -1
291 #if wall.ID=="Player" and self.rect.colliderect(wall.rect):
292 #wall.move(self.direction,1)
294 class Door(Wall):
295 close=True
296 openx=1#1 for right, -1 for left, 0 for none
297 openy=1#1 for down, -1 for up, 0 for none
298 sprite=None
299 ID="Door"
300 Color="blue"
301 def Open(self):
302 if self.close:
303 self.rect.x+=(16*self.openx)
304 self.rect.y+=(16*self.openy)
305 self.close=False
306 if DEBUG:
307 print "Event: Open door"
308 def __init__(self, pos,openx,openy,color="green"):
309 if color.lower()=="red":
310 self.color=(255,255,255)
311 self.Color="red"
312 self.sprite = "HIDDEN"
313 else:
314 self.Color="green"
315 self.color=(0,0,255)
316 if not USERECTS:
317 self.sprite = orange_images.get_sprite( "door", d, DEBUG )
318 self.rect=pygame.Rect(pos[0],pos[1],16,16)
319 self.openx=openx
320 self.openy=openy
322 class Key(Wall):
323 ID="Key"
324 Color="blue"
325 sprite=None
326 def __init__(self,pos,color="green"):
327 self.Color=color
328 if color=="red":
329 if not USERECTS:
330 self.sprite = orange_images.get_sprite( "key2", d, DEBUG )
331 self.color=(255,255,0)
332 self.Color="red"
333 else:
334 if not USERECTS:
335 self.sprite = orange_images.get_sprite( "key", d, DEBUG )
336 self.Color="green"
337 self.color=(0,255,0)
338 super(Key,self).__init__(pos)
340 class Portal(Wall):
341 ID="Portal"
342 color = (0, 0, 255)
344 class Destination(Wall):
345 ID="Destination"
346 def __init__(self, pos):
347 global walls
348 walls.append(self)
349 if BIGPLAYER:
350 self.rect = pygame.Rect(pos[0], pos[1], 16, 16)
351 else:
352 self.rect = pygame.Rect(pos[0], pos[1], 8, 16)
354 class Enemy(Mover):
355 difference=0
356 maxDiff=5
357 direction=1
358 ID="Enemy"
359 species="giantRat"
360 sprite=None
363 color=(255,0,255)
364 def __init__(self,x,y,size1,size2,direction,maximum=5,type="random"):
365 self.rect=pygame.Rect(x,y,size1,size2)
366 if direction not in [-1,1]:
367 self.direction=random.choice([-1,1])
368 else:
369 self.direction=direction
370 if maximum<0:
371 maximum=random.randrange(6)
372 else:
373 self.maxDiff=maximum
374 if type == "bat":
375 self.v = 1
376 self.h = 0
377 else:
378 self.v = 0
379 self.h = 1
380 if not USERECTS:
381 if type == "random":
382 self.sprite = orange_images.get_sprite( \
383 random.choice( ["rat","bat"] ), d, DEBUG )
384 else:
385 self.sprite = orange_images.get_sprite( type.lower(), d, DEBUG )
387 class Spike(Enemy):
388 ID="spike"
390 # Holds the level layout in a list of strings.
391 class Level(object):
392 level = []
393 Message=""
394 def create(self):
395 global walls,player,end_rect,lvlExit,end_rect_offset,tele_rect,camera
396 if DEBUG:
397 print "Work: Building level"
398 # Parse the level string above. W = wall, E = exit
399 x = y = 0
400 self.Message = ""
401 get_message = False
402 for row in self.level:
403 for col in row:
404 if get_message:
405 if col == '\"':
406 if DEBUG:
407 print "Work: Message collection stopped... final \
408 message:\n\"" + self.Message + "\""
409 get_message = False
410 else:
411 self.Message += col
412 continue
413 if col == ";":
414 if DEBUG:
415 print "Comment found--ignoring following text"
416 break
417 if col == "W":
418 Wall((x, y))
419 if col=="-":
420 Mover((x,y),(1,0))
421 if col=="|":
422 Mover((x,y),(0,1))
423 if col == "E":
424 end_rect = pygame.Rect(x, y, 16, 16)
425 if not USERECTS:
426 lvlExit = orange_images.get_sprite( "exit", d, DEBUG )
427 end_rect_offset = 0
428 if DEBUG:
429 print "Event: Place ending object at", x, y
430 if col=="A":
431 end_rect = pygame.Rect(x + 4, y, 8, 16)
432 if not USERECTS:
433 lvlExit = orange_images.get_sprite( "end", d, DEBUG )
434 end_rect_offset = -4
435 if DEBUG:
436 print "Event: Place ending object at", x, y
437 if col=="K":
438 key=Key((x,y))
439 if col=="R":
440 key=Key((x,y),color="red")
441 if col in ["8","*"]:
442 if col=="8":
443 Color="green"
444 else:
445 Color="red"
446 door=Door((x,y),0,-1,color=Color)
447 walls.append(door)
448 if col in ["2","@"]:
449 if col=="2":
450 Color="green"
451 else:
452 Color="red"
453 door=Door((x,y),0,1,color=Color)
454 walls.append(door)
455 if col in ["4","$"]:
456 if col=="4":
457 Color="green"
458 else:
459 Color="red"
460 door=Door((x,y),-1,0,color=Color)
461 walls.append(door)
462 if col in ["6","^"]:
463 if col=="6":
464 Color="green"
465 else:
466 Color="red"
467 door=Door((x,y),1,0,color=Color)
468 walls.append(door)
469 if col in ["7","&"]:
470 if col=="7":
471 Color="green"
472 else:
473 Color="red"
474 door=Door((x,y),-1,-1,color=Color)
475 walls.append(door)
476 if col in ["9","("]:
477 if col=="9":
478 Color="green"
479 else:
480 Color="red"
481 door=Door((x,y),1,-1,color=Color)
482 walls.append(door)
483 if col in ["1","!"]:
484 if col=="1":
485 Color="green"
486 else:
487 Color="red"
488 door=Door((x,y),-1,1,color=Color)
489 walls.append(door)
490 if col in ["3","#"]:
491 if col=="3":
492 Color="green"
493 else:
494 Color="red"
495 door=Door((x,y),1,1,color=Color)
496 walls.append(door)
497 if col=="T":
498 Portal( (x, y) )
499 if col=="t":
500 Destination( (x, y) )
501 if col=="P":
502 player.rect.x=x
503 player.rect.y=y
504 if DEBUG:
505 print "Event: Place player object at", x, y
506 if col=="M":
507 mine_rect=Enemy(x,y,16,16,2,type="rat")
508 walls.append(mine_rect)
509 if col=="k":
510 mine_rect=Enemy(x,y,16,16,2,type="ratking")
511 mine_rect.species = "ratking"
512 walls.append(mine_rect)
513 if col=="B":
514 mine_rect=Enemy(x,y,16,16,2,type="bat")
515 walls.append(mine_rect)
516 if col=="S":
517 spike=Spike(x,y,16,16,2,type="spike")
518 walls.append(spike)
519 if col=="D":
520 tele_rect=pygame.Rect(x,y,16,16)
521 if col == '\"':
522 if DEBUG:
523 print "Work: Message found in level; collecting..."
524 get_message = True
525 if not get_message:
526 x += 16
527 if not get_message:
528 y += 16
529 x = 0
531 if len( self.Message ) > 0:
532 global text, textpos, message_delay, font
533 text = font.render(self.Message, 1, (255, 128, 0))
534 textpos = text.get_rect(centerx=screen.get_width()/2)
535 if len( self.Message ) > 10:
536 message_delay = 500 + (10 * (len( self.Message ) - 10))
537 else:
538 message_delay = 500
539 else:
540 global text
541 text = None
543 def __init__(self,lObjects,Message=""):
544 global Levels
545 self.level=lObjects
546 if DEBUG:
547 print "Create: Level object"
548 self.Message=Message
550 # Returns a new rect for drawing by the camera's offset.
551 def translate(rect):
552 return pygame.Rect(rect.x - camera.x, rect.y - camera.y,
553 rect.w, rect.h)
555 #########################################
556 # Final initializations before mainloop #
557 #########################################
559 import orange_levels
561 levelIndex=0
562 levels = orange_levels.get_levels( LEVELPATH, DEBUG )
563 Levels=[]
565 if DEBUG:
566 print "Work: Passing level strings into level list"
567 for level_string in levels:
568 Levels.append( Level( level_string ) )
570 if len( Levels ) <= 0:
571 raise SystemExit, "Did not find any valid levels in ." + d + LEVELPATH + \
572 "\nCheck ." + d + "doc" + d + "levels.txt for help"
574 player = Player() # Create the player
576 # This is the camera, simply a rect.
577 camera = pygame.Rect(0, 0, screen.get_width(), screen.get_height())
578 if DEBUG:
579 print "Create: camera"
581 lvlExit=None
582 end_rect_offset = 0
583 player_rect_offset = -4
584 if BIGPLAYER:
585 player_rect_offset = 0
587 # Build the first level from data
588 Levels[0].create()
590 #############
591 # main loop #
592 #############
594 running=True
595 quitMsg = "Thanks for playing!"
597 while running:
598 global jumpDY,text,message_delay
600 clock.tick(60)
602 for e in pygame.event.get():
603 if e.type == pygame.QUIT or (e.type == pygame.KEYDOWN and e.key == pygame.K_ESCAPE):
604 running = False
605 elif e.type == pygame.KEYDOWN and e.key == pygame.K_BACKSPACE:
606 if DEBUG:
607 print "Event: Level reset"
608 delete=True
609 while delete:
610 try:
611 walls.remove(walls[0])
612 except:
613 delete=False
614 Levels[levelIndex].create()
615 jumpDY=0
616 player.jump=False
617 player.dJump=False
618 player.dead = False
620 # Move the player if an arrow key is pressed
621 key = pygame.key.get_pressed()
622 if key[pygame.K_LEFT]:
623 player.move(-2, 0)
624 if key[pygame.K_RIGHT]:
625 player.move(2, 0)
626 if not player.dJump:#Edited to simulate jumping
627 if key[pygame.K_UP]:
628 if not player.jump:
629 player.jump=True#Edited to simulate jumping
630 jumpDY=-2.1
631 timeBuffer=16
632 elif timeBuffer==0:
633 player.dJump=True
634 jumpDY=-2.1
635 player.move(0, jumpDY)
636 jumpDY+=0.1
638 camera.x=player.rect.x-int(screen.get_width()/2)
639 camera.y=player.rect.y-int(screen.get_height()/2)
641 # Just added this to make it slightly fun ;)
642 if player.rect.colliderect(end_rect) or player.rect.colliderect(tele_rect):
643 levelIndex+=1
644 delete=True
645 while delete:
646 try:
647 walls.remove(walls[0])
648 except:
649 delete=False
650 jumpDY=0
651 player.jump=False
652 player.dJump=False
653 if DEBUG:
654 print "Event: Level win"
655 if levelIndex < len( Levels ):
656 Levels[levelIndex].create()
657 else:
658 # A special message if you've gotten the sword (the sword doesn't
659 # exist yet in the game, so this just displays when you win)
660 running = False
661 if not getting_help:
662 won = True
664 # Draw the scene
665 screen.fill((0, 0, 0))
666 for wall in walls:
668 # Translate the object's rect to the camera's offset for drawing
669 if wall.rect.right >= camera.left \
670 and wall.rect.left <= camera.right \
671 and wall.rect.bottom >= camera.top \
672 and wall.rect.top <= camera.bottom:
673 draw=True
674 else:
675 draw=False
676 wall.rect = translate(wall.rect)
677 if wall.ID in ["Enemy","Mover"]:
678 wall.update()
679 if wall.ID != "Destination":
680 if USERECTS==True or wall.ID == "Portal":
681 pygame.draw.rect(screen,wall.color,wall.rect)
682 if wall.ID == "Portal":
683 pygame.draw.rect( screen, (0, 0, 0), \
684 pygame.Rect( wall.rect.x + 4, wall.rect.y + 4, \
685 wall.rect.w - 8, wall.rect.h - 8 ) )
686 if wall.ID == "Enemy":
687 if wall.species == "ratking":
688 pygame.draw.rect( screen, (255, 255, 0), \
689 pygame.Rect( wall.rect.x + 4, wall.rect.y - 4, 8, 4 ) )
691 else:
692 if wall.ID in ["Door","Key","spike","Enemy"] and draw:
693 if wall.sprite!="HIDDEN":
694 if wall.ID == "Enemy" and wall.species == "ratking":
695 screen.blit(wall.sprite,(wall.rect.x,wall.rect.y - 1))
696 else:
697 screen.blit(wall.sprite,(wall.rect.x,wall.rect.y))
698 else:
699 pygame.draw.rect(screen,(255,255,255),wall.rect)
700 elif draw and wall.ID in ["Wall","Mover"]:
701 pygame.draw.rect(screen, (255, 255, 255), wall.rect)
703 player.rect=translate(player.rect)
704 tele_rect=translate(tele_rect)
705 end_rect=translate(end_rect)
707 pygame.draw.rect(screen,(255,255,255),tele_rect)
708 if USERECTS==False:
709 screen.blit(lvlExit,(end_rect.x + end_rect_offset,end_rect.y))
710 if not player.dead:
711 screen.blit(player.sprite, \
712 (player.rect.x + player_rect_offset,player.rect.y))
713 else:
714 screen.blit(orange_images.get_sprite( "dead", d, DEBUG ), \
715 (player.rect.x + player_rect_offset,player.rect.y))
716 else:
717 pygame.draw.rect(screen,(255,0,0),end_rect)
718 if not player.dead:
719 pygame.draw.rect(screen,(255,128,0),player.rect)
720 else:
721 pygame.draw.rect(screen,(255,128,0), \
722 pygame.Rect(player.rect.x, player.rect.y+8, 16, 8))
724 if player.dead:
725 # We are guaranteed by the player's `update' function that `text' here
726 # has been set, as has `textpos'
727 screen.blit( text, textpos )
728 elif text != None and message_delay > 0:
729 screen.blit(text,textpos)
730 message_delay -= 1
732 pygame.display.flip()
735 if timeBuffer>0:
736 timeBuffer-=1
738 if won:
740 screen.fill((0, 0, 0))
742 text = font.render( "Congratulations!", 1, (255, 128, 0) )
743 textpos = text.get_rect( centerx = screen.get_width() / 2 )
744 textpos.y = 16
746 screen.blit( text, textpos )
748 text = font.render( "You've recovered the legendary sword", 1, (255, 128, 0) )
749 textpos = text.get_rect( centerx = screen.get_width() / 2 )
750 textpos.y = 32
752 screen.blit( text, textpos )
754 text = font.render( "of the Dragon King!", 1, (255, 128, 0) )
755 textpos = text.get_rect( centerx = screen.get_width() / 2 )
756 textpos.y = 48
758 screen.blit( text, textpos )
760 text = font.render( "You've reached the end of the game.", 1, (255, 128, 0) )
761 textpos = text.get_rect( centerx = screen.get_width() / 2 )
762 textpos.y = 80
764 screen.blit( text, textpos )
766 text = font.render( "Press ESCAPE to finish.", 1, (255, 128, 0) )
767 textpos = text.get_rect( centerx = screen.get_width() / 2 )
768 textpos.y = 96
770 screen.blit( text, textpos )
772 text = font.render( "Original game by Philip Pavlick", 1, (255, 128, 0) )
773 textpos = text.get_rect( centerx = screen.get_width() / 2 )
774 textpos.y = 216
776 screen.blit( text, textpos )
778 text = font.render( "Special thanks to my family and friends", 1, (255, 128, 0) )
779 textpos = text.get_rect( centerx = screen.get_width() / 2 )
780 textpos.y = 232
782 screen.blit( text, textpos )
784 text = font.render( "who got a kick out of this dumb computer game", 1, (255, 128, 0) )
785 textpos = text.get_rect( centerx = screen.get_width() / 2 )
786 textpos.y = 248
788 screen.blit( text, textpos )
790 text = font.render( "I wrote ages ago", 1, (255, 128, 0) )
791 textpos = text.get_rect( centerx = screen.get_width() / 2 )
792 textpos.y = 264
794 screen.blit( text, textpos )
796 text = font.render( "(seriously, this source code is terrible!)", 1, (255, 128, 0) )
797 textpos = text.get_rect( centerx = screen.get_width() / 2 )
798 textpos.y = 280
800 screen.blit( text, textpos )
802 text = font.render( "For more and better games,", 1, (255, 128, 0) )
803 textpos = text.get_rect( centerx = screen.get_width() / 2 )
804 textpos.y = 312
806 screen.blit( text, textpos )
808 text = font.render( "check back at my website at", 1, (255, 128, 0) )
809 textpos = text.get_rect( centerx = screen.get_width() / 2 )
810 textpos.y = 328
812 screen.blit( text, textpos )
814 text = font.render( "www.pavlick.net", 1, (255, 128, 0) )
815 textpos = text.get_rect( centerx = screen.get_width() / 2 )
816 textpos.y = 344
818 screen.blit( text, textpos )
820 text = font.render( "or", 1, (255, 128, 0) )
821 textpos = text.get_rect( centerx = screen.get_width() / 2 )
822 textpos.y = 360
824 screen.blit( text, textpos )
826 text = font.render( "swashdev.github.io", 1, (255, 128, 0) )
827 textpos = text.get_rect( centerx = screen.get_width() / 2 )
828 textpos.y = 376
830 screen.blit( text, textpos )
832 text = font.render( "Thank you so much for playing!", 1, (255, 128, 0) )
833 textpos = text.get_rect( centerx = screen.get_width() / 2 )
834 textpos.y = 408
836 screen.blit( text, textpos )
838 if USERECTS:
840 if BIGPLAYER:
841 pygame.draw.rect( screen, player.color, \
842 pygame.Rect( screen.get_width() / 2, 144, \
843 16, 16 ) )
844 else:
845 pygame.draw.rect( screen, player.color, \
846 pygame.Rect( screen.get_width() / 2, 144, \
847 8, 16 ) )
849 pygame.draw.rect( screen, (255, 0, 0), \
850 pygame.Rect( (screen.get_width() / 2) - 6, 134, \
851 8, 16 ) )
853 else:
855 screen.blit( orange_images.get_sprite( "won" ), \
856 pygame.Rect( (screen.get_width() / 2) - 6, 134, \
857 15, 32 ) )
859 pygame.display.flip()
861 running = True
863 while running:
865 for e in pygame.event.get():
866 if e.type == pygame.QUIT or (e.type == pygame.KEYDOWN and e.key == pygame.K_ESCAPE):
867 running = False
869 print quitMsg