From b5a81fc0c7b3d61854486fbaf2ce4f70d479a3df Mon Sep 17 00:00:00 2001 From: fblundun Date: Sat, 9 Nov 2013 01:17:14 +0000 Subject: [PATCH] second commit --- space-files/button.png | Bin 0 -> 251 bytes space-files/button_B.png | Bin 0 -> 251 bytes space-files/button_G.png | Bin 0 -> 253 bytes space-files/button_M.png | Bin 0 -> 253 bytes space-files/closed.png | Bin 0 -> 237 bytes space-files/closed_B.png | Bin 0 -> 280 bytes space-files/closed_G.png | Bin 0 -> 284 bytes space-files/closed_M.png | Bin 0 -> 283 bytes space-files/cloud.png | Bin 0 -> 595 bytes space-files/evil_eye.png | Bin 0 -> 312 bytes space-files/exit.png | Bin 0 -> 180 bytes space-files/flyer.png | Bin 0 -> 325 bytes space-files/open.png | Bin 0 -> 164 bytes space-files/platformer7.py | 767 ++++++++++++++++++++++++++++++++++ space-files/pushed_button.png | Bin 0 -> 335 bytes space-files/pygame1.py | 48 +++ space-files/shadow.png | Bin 0 -> 190 bytes space-files/shadow_B.png | Bin 0 -> 190 bytes space-files/shadow_G.png | Bin 0 -> 192 bytes space-files/shadow_M.png | Bin 0 -> 192 bytes space-files/spinner.png | Bin 0 -> 326 bytes space-files/static.png | Bin 0 -> 247 bytes space-files/static_2.png | Bin 0 -> 247 bytes space-files/walker.png | Bin 0 -> 347 bytes space-files/wood.png | Bin 0 -> 824 bytes 25 files changed, 815 insertions(+) create mode 100644 space-files/button.png create mode 100644 space-files/button_B.png create mode 100644 space-files/button_G.png create mode 100644 space-files/button_M.png create mode 100644 space-files/closed.png create mode 100644 space-files/closed_B.png create mode 100644 space-files/closed_G.png create mode 100644 space-files/closed_M.png create mode 100644 space-files/cloud.png create mode 100644 space-files/evil_eye.png create mode 100644 space-files/exit.png create mode 100644 space-files/flyer.png create mode 100644 space-files/open.png create mode 100644 space-files/platformer7.py create mode 100644 space-files/pushed_button.png create mode 100644 space-files/pygame1.py create mode 100644 space-files/shadow.png create mode 100644 space-files/shadow_B.png create mode 100644 space-files/shadow_G.png create mode 100644 space-files/shadow_M.png create mode 100644 space-files/spinner.png create mode 100644 space-files/static.png create mode 100644 space-files/static_2.png create mode 100644 space-files/walker.png create mode 100644 space-files/wood.png diff --git a/space-files/button.png b/space-files/button.png new file mode 100644 index 0000000000000000000000000000000000000000..988a9d3a7dccbe64a9ba1caf80dc2f78ad7826f8 GIT binary patch literal 251 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}c0*}aI1_r((Aj~*bn@<`jIKk7!F~q_@IVBNS%G}c0*}aI1_r((Aj~*bn@<`jIKk7!F~q_@IVBNS%G}c0*}aI1_r((Aj~*bn@<`jILXt+F~q_@IVBVm{!G; zn#iQ4;cIG;rSP=j6ToLf&7oIdg!AlET?y85}Sb4q9e0H*9u_y7O^ literal 0 HcmV?d00001 diff --git a/space-files/button_M.png b/space-files/button_M.png new file mode 100644 index 0000000000000000000000000000000000000000..d8ce23e727846a49cc8c1f1829bc973c4859b4ce GIT binary patch literal 253 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}c0*}aI1_r((Aj~*bn@<`jILXt+F~q_@IVB#g?QZ9plL=?%?kvp?75Zu?vi5TO;=R^eo(Q<$`|Dhn+(6W#Yt> zE_-NLa8ya&WN>P0WVm`*ApfH)-+?TJjh)ib0ta|)YJM1WBvoAaCg3B?Ewbv#!7Xdo t>ds(mS3G0j#c+nlO`*9f@x%cJ2KF6V5nJCm8v|X(;OXk;vd$@?2>?X%P=f#f literal 0 HcmV?d00001 diff --git a/space-files/closed.png b/space-files/closed.png new file mode 100644 index 0000000000000000000000000000000000000000..3561838c9411dd115e7fd7242a4c67afff461dd9 GIT binary patch literal 237 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1SFYWcSQjy#^NA%Cx&(BWL^R}Ea{HEjtmSN z`?>!lvI6;>1s;*b3=DjSL74G){)!Z!V3VhdV~Bs+PrUu@vHiU18j&Vh2a20_XYrh0u!(b?|IUD`FU?Z4W=xy=N_Ov=Q*B(?d!~2# zhja*qL@pB!Y|`@HR&lr_vG==?na{=3eyo>`RvRo>bvbth&s5(BI}h?-l~C<=NS%G}c0*}aI1_r)EAj~ML;ne^XTXu{8sFD zOTJ;++OQ7?1G;)oa>+g2HGk8@&FgM|kgc;X4c__gztmOE`-<{MNS%G}c0*}aI1_r)EAj~ML;ne^X-011z7-HeSb_yfcVFMoK%eKiE#J}#XzL;?T z#;Ub^U1{okPZp@KL{H2*@vY+R`%M#WZ`C_oT5)Io^>@c3KgTXEK3007^@cOY{CU+p z{}Ydi2FqqW=DBm*<(rGU;Z}9iRF2+7QoRbZ3X;|KU47|#HXuZ!=;~^3*Le$P8r>J! z$sBdOFFVEh4QFLWyq3|d8?OEPHMMn~bY}UB&gnf>kS}pFsmSnKncT)dKc)7WZCNS%G}c0*}aI1_r)EAj~ML;ne^X+~Dcr7-HeSb_yfkVFe!Mmv!6ix2(VYZ^QH4 zuh$eFs|u+2t#Z&XEK}ZS`|f;sPx#1ZP1_K>z@;j|==^1poj532;bRa{vGi!~g&e!~vBn4jTXf0q99YK~y+Tt(3`% zDnSrMqnu})5OL!N3HnLm{|Mp-iQvYCD2j@+cAx0JNwxIq^}CSfVC0FLkyRC$+3T~} za5$v)2WY< zJ4C%+&jF9e!>-q>olYmaTrR#rz~}SnO>+czFc^H#Vn9HNM8Y=+jMxBxbwo@&36fhB zfR#$cve~S|2u`Qd-dHP@N&!j(N?CqW04g}19ha=p3(8n^jXRTm00|;HfojaIk$Yz2$3IKW?OY50T#=70E&k@jfmjOtSvg^nMGX|E==N(8gL3FCPemGPe z5u2%7ypaA43anOFhx6Ni_>-E~lyfyRr++nx_B4E6Z0SJgdTr8JM+iti1`YAg- zbp*)K-(5-p$REe!(N?RKozLgs1h+I20@P+fiD9o4M!Vh44u?Z1IDl%kYK=z2n$4!w zYBgWyl7NzgSfIZG$K$aFkhxGOSf|smR;v|0XN$$cUpZg`5KAd0lZnp}{$Ky&1B>`- hdn$dt|DrF3*#}O`Hjd1;F`xhd002ovPDHLkV1kjE2wMOE literal 0 HcmV?d00001 diff --git a/space-files/evil_eye.png b/space-files/evil_eye.png new file mode 100644 index 0000000000000000000000000000000000000000..08c2f95e7b8ec7aa8ddfaebab7a33c7f9298bfb5 GIT binary patch literal 312 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}c0*}aI1_r((Aj~*bn@<`jc-GU!F~q`u>l8G`4PS0Cfhi7XFFRQ<2(vm6cB=Jb7p7GD_hkUw?ecfm_PQHJ&KUnJgH$t~1S0gex+)aL*heq2IT^`2Na%eNAjpYD?zS z51Za`{!bOFTJDtnr}}A;gKwqo?X5g(%Jyg$|2X1$`o@CLL#J0w3;%zkkT=k3ud7A` zxA>!`fMB-;B~}lfx-BdXe75A8oaMIN36@)v?nZLRZ;Gz-imhSR26~La)78&qol`;+ E06Us?fB*mh literal 0 HcmV?d00001 diff --git a/space-files/exit.png b/space-files/exit.png new file mode 100644 index 0000000000000000000000000000000000000000..7721419ec31db17d03f2e2bd8a78b9dd1410d87b GIT binary patch literal 180 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1SFYWcSQjy#^NA%Cx&(BWL^R}Ea{HEjtmSN z`?>!lvI6;>1s;*b3=DjSL74G){)!Z!pr@ycV~B-+@|y&KR0VMZ$IML(htlq*%LuSJ z7DT>cZ*iP>Hl)Z*l40S_KmWBknE9+Ek2a|26)H$r*!QzZbS8utcQ!P+96G?jAg&;s U+t@7W1vHew)78&qol`;+07QE*)c^nh literal 0 HcmV?d00001 diff --git a/space-files/flyer.png b/space-files/flyer.png new file mode 100644 index 0000000000000000000000000000000000000000..5fa50d1532a0cddd6f97fa0183fa9dfa4713f80a GIT binary patch literal 325 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}c0*}aI1_r)EAj~ML;ne^XyyfZQ7-Hc+cZwn3VFeynU;YaVi;w&4{U2%d zmFw*U?h7?X*7qIP<0Kaqc|+CrN-v|-`KDX#a?tVe5U7!h_NdU}5bSW} zv}O^UzV5*)>j`~}E@--IUT@3IFyH<>`^C9+iF^fXy-rs+6eO}8nbAG*>w}Vw)p^w! z;j=C;G&oq?z4c;SY`f3073SOdVjYuOO~STh?o{9A_4oqUB}v&HKA+uxEZ=l0dTu{# zX)eXszT?i%+WV(E9{dh8;5S{fI(w}I_oBq?+5Z09w==zV{Au||JLTl=6XM?vEl-|j S{^~x^mkge+elF{r5}E*nB7JiJ literal 0 HcmV?d00001 diff --git a/space-files/open.png b/space-files/open.png new file mode 100644 index 0000000000000000000000000000000000000000..80bc36e9f4c3e6a95309c09e2f9e9ee3d8b5ec62 GIT binary patch literal 164 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}c0*}aI1_r)EAj~ML;ne^XwDfdw46*P}{=?706L8?f369i>Y!iAC5}GcB zFo&26JaKQSUdh0=f4V#G5}6(;4@-$gw!R%q(;68WzAfdKtrv~H12lxe)78&qol`;+ E0MPI&Qvd(} literal 0 HcmV?d00001 diff --git a/space-files/platformer7.py b/space-files/platformer7.py new file mode 100644 index 0000000..2524eb6 --- /dev/null +++ b/space-files/platformer7.py @@ -0,0 +1,767 @@ +# Platformer 3 +import pygame, sys, random +from pygame.locals import * +BOARDHEIGHT = BOARDWIDTH = 20 +SQUAREHEIGHT = SQUAREWIDTH = 20 +WINDOWHEIGHT = BOARDHEIGHT * SQUAREHEIGHT +WINDOWWIDTH = BOARDWIDTH * SQUAREWIDTH +DISPLAYWIDTH = DISPLAYHEIGHT = (WINDOWWIDTH * 3)//2 +PLAYERHEIGHT = 15 +PLAYERWIDTH = 15 +PLAYERSPEED = 1 +SHADOWSPEED = 1 +ENEMYSPEED = 1 +TERMINALVEL = 4 +JUMPVEL = 5 +SOLIDTILES = ['1','P','b','g','m'] +#JUMPVEL = 15 +WEIGHT = 0.5 +BLACK = (0,0,0) +WHITE = (255,255,255) +GREEN = (0,255,0) +TEXTCOLOR = (200,200,200) +GREY = (200,100,100) +FPS = 20 + + +def terminate(): + pygame.quit() + sys.exit() +def waitForPlayerToPressKey(): + while True: + for event in pygame.event.get(): + if event.type == QUIT: + terminate() + if event.type == KEYDOWN: + if event.key == K_ESCAPE: + terminate() + return +def drawText(text, font, surface, x, y): + textobj = font.render(text, 1, TEXTCOLOR) + textrect = textobj.get_rect() + textrect.topleft = (x,y) + surface.blit(textobj,textrect) + +pygame.init() +main_clock = pygame.time.Clock() +#screen = pygame.display.set_mode((WINDOWWIDTH, WINDOWHEIGHT)) +window_surface = pygame.display.set_mode((DISPLAYWIDTH,DISPLAYHEIGHT)) +screen = pygame.Surface((WINDOWWIDTH, WINDOWHEIGHT)) +font = pygame.font.SysFont(None, 48) +#pygame.mixer.music.load('music.mid') (add music here) + +'''static_images = [] +for i in range(2*SQUAREWIDTH): + frame_surface = pygame.Surface((2*SQUAREWIDTH,2*SQUAREHEIGHT)) + pygame.draw.lines(frame_surface, (255,255,255), 0, ((i,0),(0,i))) + static_surface = pygame.Surface((SQUAREWIDTH, SQUAREHEIGHT)) + static_surface.blit(frame_surface, (0,0), (0,0,SQUAREWIDTH,SQUAREHEIGHT)) + static_images.append(static_surface) + +static_images = [] +for i in range(2*SQUAREWIDTH): + static_surface = pygame.Surface((SQUAREWIDTH, SQUAREHEIGHT)) + pygame.draw.lines(static_surface, (255,255,255), 0, ((i,0),(0,i))) + pygame.draw.lines(static_surface, (255,255,255), 0, ((SQUAREWIDTH-i,SQUAREWIDTH),(SQUAREWIDTH,SQUAREWIDTH-i))) + static_images.append(static_surface)''' +cloud_image = pygame.image.load('cloud.png') +wood_image = pygame.image.load('wood.png') +static_image = pygame.image.load('static.png') +static_image_2 = pygame.image.load('static_2.png') +spinner_image = pygame.image.load('spinner.png') +#spinner_image.set_masks((255, 65280, 16711680, 0)) +walker_image = pygame.image.load('walker.png') +flyer_image = pygame.image.load('evil_eye.png') +exit_image = pygame.image.load('exit.png') +button_image = pygame.image.load('button.png') +pushed_button_image = pygame.image.load('pushed_button.png') +closed_image = pygame.image.load('closed.png') +open_image = pygame.image.load('open.png') +button_image_B = pygame.image.load('button_B.png') #blue button +button_image_G = pygame.image.load('button_G.png') #green +button_image_M = pygame.image.load('button_M.png') #magenta +button_images = {'B': button_image_B, + 'G': button_image_G, + 'M': button_image_M} +closed_image_B = pygame.image.load('closed_B.png') +closed_image_G = pygame.image.load('closed_G.png') +closed_image_M = pygame.image.load('closed_M.png') +closed_images = {'b': closed_image_B, + 'g': closed_image_G, + 'm': closed_image_M} +"""open_image_B = pygame.image.load('closed_M.png') +open_image_G = pygame.image.load('closed_M.png') +open_image_M = pygame.image.load('closed_M.png') +open_images = {'B': open_image_B, + 'G': open_image_G, + 'M': open_image_M}""" +shadow_image_B = pygame.image.load('shadow_B.png') +shadow_image_G = pygame.image.load('shadow_G.png') +shadow_image_M = pygame.image.load('shadow_M.png') +shadow_images = {'C': shadow_image_B, + 'H': shadow_image_G, + 'N': shadow_image_M} + +images = [static_image,static_image_2,walker_image,spinner_image,flyer_image,cloud_image,wood_image,open_image,pushed_button_image] +for x in shadow_images: images.append(shadow_images[x]) +for x in closed_images: images.append(closed_images[x]) +for x in button_images: images.append(button_images[x]) +for image in images: + image.set_colorkey((0,0,0)) + a,b,c,d = image.get_masks() + + image.set_masks((a,b,c,0)) + image.convert_alpha() + + image.convert_alpha() + +'''button_image.set_colorkey(BLACK) +pushed_button_image.convert() +pushed_button_image.set_colorkey(BLACK) +pushed_button_image.convert() +button_image.convert() +button_image.set_colorkey(BLACK) +button_image.convert()''' +def letter_to_number(string): + if string in['B','b','C']: + return 0 + elif string in ['G','g','H']: + return 1 + elif string in ['M','m','N']: + return 2 +def copy(matrix): + copy = [] + for row in matrix: + copy.append(row) + return copy + +def toggle(x,y,level, entities): + #x,y are board positions + anvil = level + if level[y][x] not in ('1', 'P', 'C', 'D', '.') and check_if_empty(x,y,entities): + anvil[y][x] = '1' + elif level[y][x] == '1': + anvil[y][x] = ' ' + return anvil + +def check_if_empty(x,y,entities): + rectangle = pygame.Rect(x*SQUAREWIDTH, y*SQUAREHEIGHT, SQUAREWIDTH, SQUAREHEIGHT) + for e in entities: + if e.rect.colliderect(rectangle): + return False + return True +###title screen: +#drawText('Platformer 3', font, screen, 0,0) +#pygame.display.update() +#waitForPlayerToPressKey() + +class Entity(pygame.sprite.Sprite): + def __init__(self): + pygame.sprite.Sprite.__init__(self) + +class Platform(Entity): + def __init__(self,x,y,color): + Entity.__init__(self) + self.x = x + self.y = y + self.image = pygame.Surface((SQUAREHEIGHT, SQUAREWIDTH)) + self.image.fill(color) + self.rect = pygame.Rect(x,y,SQUAREWIDTH,SQUAREHEIGHT) + +class Button(Entity): + def __init__(self,x,y,hue): + Entity.__init__(self) + self.hue = hue + self.image = button_images[hue] + self.rect = pygame.Rect(x,y,SQUAREWIDTH, SQUAREHEIGHT) + +class Flyer(Entity): + + def __init__(self,x,y, facing = 'up'): + Entity.__init__(self) + self.x = x + self.y = y + self.facing = facing + self.xvel = self.yvel = 0 + self.image = flyer_image + self.rect = pygame.Rect(x,y,SQUAREWIDTH,SQUAREHEIGHT+1) + + def board_location_left(self): + xpos = self.rect.left//SQUAREWIDTH + ypos = self.rect.centery//SQUAREHEIGHT + return (xpos, ypos) + + def board_location_right(self): + xpos = (self.rect.right-1)//SQUAREWIDTH + ypos = self.rect.centery//SQUAREHEIGHT + return (xpos, ypos) + + def update(self, level): + if self.facing == 'down': self.yvel = ENEMYSPEED + else: self.yvel = -ENEMYSPEED + yvel = self.yvel + self.rect.top += yvel # used to move_ip + self.collide(0,yvel,level) + + def collide(self, xvel, yvel, level): + a,b = self.board_location_left() + for x in range(0,20): + for y in range(0,20): + if level[y][x] in SOLIDTILES: + rectangle = pygame.Rect(x*SQUAREWIDTH,y*SQUAREHEIGHT, SQUAREWIDTH,SQUAREHEIGHT) + + if self.rect.colliderect(rectangle): + if yvel > 0: + self.rect.bottom = rectangle.top + self.yvel = -self.yvel + self.facing = 'up' + elif yvel < 0: + self.rect.top = rectangle.bottom + self.yvel = -self.yvel + self.facing = 'down' + +class Enemy(Entity): + def __init__(self,x,y, facing = 'right'): + Entity.__init__(self) + self.x = x + self.y = y + self.facing = facing + self.xvel = self.yvel = 0 + self.image = spinner_image + self.rect = pygame.Rect(x,y,SQUAREWIDTH+1,SQUAREHEIGHT) + + def board_location_left(self): + xpos = self.rect.left//SQUAREWIDTH + ypos = self.rect.centery//SQUAREHEIGHT + return (xpos, ypos) + + def board_location_right(self): + xpos = (self.rect.right-1)//SQUAREWIDTH + ypos = self.rect.centery//SQUAREHEIGHT + return (xpos, ypos) + + def update(self, level): + if self.facing == 'right': self.xvel = ENEMYSPEED + else: self.xvel = -ENEMYSPEED + xvel = self.xvel + self.rect.left += xvel # used to move_ip + self.collide(xvel,0,level) + + def collide(self, xvel, yvel, level): + a,b = self.board_location_left() + for x in range(0,20): + for y in range(0,20): + if level[y][x] in SOLIDTILES: + rectangle = pygame.Rect(x*SQUAREWIDTH,y*SQUAREHEIGHT, SQUAREWIDTH,SQUAREHEIGHT) + + if self.rect.colliderect(rectangle): + if xvel > 0: + self.rect.right = rectangle.left + self.xvel = -self.xvel + self.facing = 'left' + elif xvel < 0: + self.rect.left = rectangle.right + self.xvel = -self.xvel + self.facing = 'right' + if yvel > 0: + self.rect.bottom = rectangle.top + self.grounded = True + self.yvel = 0 + + elif yvel < 0: + self.rect.top = rectangle.bottom + self.yvel = 0 + + + +class Player(Entity): + def __init__(self,x,y, dead): + Entity.__init__(self) + self.xvel = self.yvel = 0 + self.x = x + self.y = y + self.dead = dead + self.grounded = False + self.image = pygame.Surface((PLAYERWIDTH, PLAYERHEIGHT)) + self.image.fill((255,255,255)) + self.image.convert() + self.rect = pygame.Rect(x,y,PLAYERWIDTH,PLAYERHEIGHT) + self.facing = 'right' + + def board_location_left(self): + xpos = self.rect.left//SQUAREWIDTH + ypos = self.rect.centery//SQUAREHEIGHT + return (xpos, ypos) + + def board_location_right(self): + xpos = (self.rect.right-1)//SQUAREWIDTH + ypos = self.rect.centery//SQUAREHEIGHT + return (xpos, ypos) + + def update(self, up, left, right, level, enemies): + if up: + if self.grounded: self.yvel -= JUMPVEL + if left: + self.xvel = -PLAYERSPEED + if right: + self.xvel = PLAYERSPEED + if not self.grounded and self.yvel < TERMINALVEL: + self.yvel += WEIGHT + if not (left or right): + self.xvel = 0 + + self.rect.left += self.xvel + self.collide(self.xvel,0,level) + self.rect.top += self.yvel + self.grounded = False + self.collide(0,self.yvel,level) + + self.threats(enemies) + + def collide(self, xvel, yvel, level): + a,b = self.board_location_left() + for x in range(0,20): + for y in range(0,20): + if level[y][x] in SOLIDTILES: + rectangle = pygame.Rect(x*SQUAREWIDTH,y*SQUAREHEIGHT, SQUAREWIDTH,SQUAREHEIGHT) + + if self.rect.colliderect(rectangle): + if xvel > 0: + self.rect.right = rectangle.left + elif xvel < 0: + self.rect.left = rectangle.right + if yvel > 0: + self.rect.bottom = rectangle.top + self.grounded = True + self.yvel = 0 + + elif yvel < 0: + self.rect.top = rectangle.bottom + self.yvel = 0 + + def threats(self, enemies): + for e in enemies: + if self.rect.colliderect(e.rect): + self.dead = True + +class Walker(Entity): + def __init__(self,x,y,facing='right'): + Entity.__init__(self) + self.x = x + self.y = y + self.xvel = SHADOWSPEED + self.yvel = SHADOWSPEED + self.image = walker_image + self.image.convert() + self.rect = pygame.Rect(x,y,SQUAREWIDTH,SQUAREHEIGHT) + self.facing = facing + self.grounded = False + self.falling = True + + def board_location_left(self): + xpos = self.rect.left//SQUAREWIDTH + ypos = self.rect.centery//SQUAREHEIGHT + return (xpos, ypos) + + def update(self, level): + + xvel, yvel = self.xvel, self.yvel + if self.grounded: + if self.facing == 'right': self.xvel = SHADOWSPEED + else: self.xvel = -SHADOWSPEED + self.rect.move_ip(xvel,0) + self.collide(xvel,0,level) + else: + self.rect.move_ip(0, yvel) # FALLING + self.collide(0,yvel,level) + self.grounded = False + + if not self.falling: + self.rect.left += self.xvel + self.collide(self.xvel,0,level) + self.rect.top += self.yvel + self.grounded = False + self.collide(0,self.yvel,level) + + def collide(self, xvel, yvel, level): + a,b = self.board_location_left() + self.falling = True + for x in range(0,20): + for y in range(0,20): + if level[y][x] in SOLIDTILES: + rectangle = pygame.Rect(x*SQUAREWIDTH,y*SQUAREHEIGHT, SQUAREWIDTH,SQUAREHEIGHT) + + if self.rect.colliderect(rectangle): + if xvel > 0: + self.rect.right = rectangle.left + self.xvel = -self.xvel + self.facing = 'left' + elif xvel < 0: + self.rect.left = rectangle.right + self.xvel = -self.xvel + self.facing = 'right' + if yvel > 0: + self.rect.bottom = rectangle.top + self.grounded = True + #self.yvel = 0 + self.falling = False + + elif yvel < 0: + self.rect.top = rectangle.bottom + self.yvel = 0 + +class Shadow(Walker): + def __init__(self,x,y,hue,facing='right'): + Walker.__init__(self,x,y,facing) + self.hue = hue + self.image = shadow_images[hue] + + + + +maps = (( + + "PPPPPPPPPPPPPPPPPPPP", + "P b 31 EP P CP", + "P... PPPPPPP PPP1P", + "PPP PPPPPPPPP. 4 P", + "P P 3 P", + "P P PP P", + "P P 4 P", + "P 1P1 S P", + "PPP P3 1PPPPPPPPPPP", + "P P1P P", + "P PPP 2 P", + "P P P P PPPP P", + "PPPP P P P P", + "P B P P P P", + "PPP P P2 4 PP P", + "P PPP P P P", + "P P P PP P", + "P P PPPPPPP P", + "P P", + "PPPPPPPPPPPPPPPPPPPP", + ), + ( + "PPPPPPPPPPPPPPPPPPPP", + "P P PP", + "P P P", + "P P P", + "P P P", + "P P P", + "P P P", + "P P", + "P 2222222222222222 P", + "P222222222222222222P", + "P 2 P", + "P 2 P", + "P 2 P", + "P 2 P", + "P 2 P", + "P 2 P", + "P 2 P", + "P 2 P", + "PSBT 2 P", + "PPPPPPPPPPPPPPPPPPPP",), + ( + "PPPPPPPPPPPPPPPPPPPP", + "P P", + "P PPPPPPPPPPPPPPPP P", + "P P 1T 1 P P", + "P P 111 P P", + "P P P P", + "P P P P", + "P P P P", + "P P P P", + "P P P P", + "P P P P", + "P C B S P P", + "P PPPPPPPPPPPPPPPP P", + "P PP PPPPPPPPPPPP P", + "P P 211 P P", + "P P PPPP 2 P P", + "P P P", + "PPPPPPPPPPPPPPPPPP P", + "P P", + "PPPPPPPPPPPPPPPPPPPP", + ), + ( + "PPPPPPPPPPPPPPPPPPPP", + "P T PP", + "PPPPPPPPPPPPPPPPP1 P", + "P P PPPPP P P", + "P P P 2 P P", + "P P P 2 P P", + "P P P 2 P P", + "P P PPPPPPP C P", + "P P P 2PPP P", + "P PP P2 P P", + "P P PPPPPP PP", + "P P PP", + "P P B P P", + "P PP PPPPPPPPPPPP P", + "P P 211 P P P", + "P P PPPP P P P P P", + "PP 12 PP P", + "P PPPPPPPPPPPP P P", + "PS P P", + "PPPPPPPPPPPPPPPPPPPP", + ), + ( + "PPPPPPPPPPPPPPPPPPPP", + "P P C P", + "P P P", + "P P P", + "P P P", + "P P G P", + "P P P", + "P P g P", + "P P P", + "P 3 P P", + "P P P P", + "P 4 P m P", + "P P P", + "P111 11P P", + "P 4 4 P P", + "P P P", + "P111111P P", + "P P P", + "P S PMbN BP", + "PPPPPPPPPPPPPPPPPPPP", + ), + ( + "PPPPPPPPPPPPPPPPPPPP", + "PC PP H14 P", + "P11111111PPPP 4 P", + "P11 11 11PPP 2 P P", + "P11411411PP P..P", + "P11111111PP P ..P", + "P b P GP P", + "P PP P..P", + "P S B PP ..P", + "PPPPPPPPPPPPPPPPPPgP", + "PPPPPPPPPPPPPPPPPP P", + "P 31 ....2m P", + "P1P ....PP P", + "P P ....PP 1N 1 P", + "P PPPPPPPPP 2PPP P", + "P 3 1PP MP P", + "PPPPP1111PP PP P", + "PE 11PP P", + "PP 11PP 4P", + "PPPPPPPPPPPPPPPPPPPP",)) + + +def string_to_matrix(string): + matrix = [] + for i in string: + matrix.append(i) + return matrix + +def map_to_level(map): + level = [] + for string in map: + level.append(string_to_matrix(string)) + return level + +def make_level(mapp): + level = map_to_level(mapp) + x = y = 0 + entities = pygame.sprite.Group() + enemies = [] + buttons = [0,0,0] + gates = [0,0,0] + shadows = [0,0,0] + pushed = [1,1,1] + anvil = copy(level) + for row in anvil: + for col in row: + if col == 'S': + player = Player(x,y,False) + entities.add(player) + elif col == '2': + e = Enemy(x,y, 'left') + entities.add(e) + enemies.append(e) + elif col == '3': + w = Walker(x,y,'left') + entities.add(w) + enemies.append(w) + elif col =='4': + f = Flyer(x,y,'down') + entities.add(f) + enemies.append(f) + elif col in ['B','G','M']: + button = Button(x,y,col) + button.image = button_images[col] + entities.add(button) + buttons[letter_to_number(col)] = button + elif col in ['b','g','m']: + gate = (y//SQUAREWIDTH,x//SQUAREWIDTH) + gates[letter_to_number(col)] = gate + elif col in ['C','H','N']: + shadow = Shadow(x,y,col) + entities.add(shadow) + shadows[letter_to_number(col)] = shadow + pushed[letter_to_number(col)] = False + elif col == 'C': + gate = (y//SQUAREWIDTH,x//SQUAREWIDTH) + gates[letter_to_number(col)] = gate + x += SQUAREWIDTH + y += SQUAREHEIGHT + x = 0 + return [anvil, entities, enemies, buttons, gates, shadows, pushed, player] + + +def main(): + #pygame.mixer.music.play(-1) + while True: + # set up game + left = right = up = False + prelevel, entities, enemies, buttons, gates, shadows, pushed, player = make_level(maps[5]) + level = copy(prelevel) + cloud_mode = stilled = False + count = -0 + + while True: + main_clock.tick(FPS) + count+=1 + #play game + for e in pygame.event.get(): + + if e.type == KEYDOWN: + if e.key == ord('k'): + player.dead = True + if e.key == ord('p'): + waitForPlayerToPressKey() + if e.key == K_RIGHT: + player.facing = 'right' + elif e.key == K_LEFT: + player.facing = 'left' + elif e.key == K_DOWN: + stilled = True + left = right = False + + if e.type == KEYUP and e.key == K_DOWN: + stilled = False + + if e.type == QUIT: + terminate() + if not cloud_mode and not stilled: + if e.type == KEYDOWN: + if e.key == K_RIGHT: + right = True + left = False + elif e.key == K_LEFT: + right = False + left = True + elif e.key == K_UP: + up = True + elif e.key == K_SPACE: + cloud_mode = True + up = left = right = False + + if cloud_mode: + left = right = False + if e.type == KEYDOWN: + if player.facing == 'left': + xpos, ypos = player.board_location_left() + elif player.facing == 'right': + xpos, ypos = player.board_location_right() + + if e.key == K_UP: + if player.facing == 'right': + level = toggle(xpos + 1, ypos-1, level, entities) + elif player.facing == 'left': + level = toggle(xpos - 1, ypos-1, level, entities) + #level[ypos-1][xpos] = '1' + elif e.key == K_DOWN: + if player.facing == 'right': + level = toggle(xpos + 1, ypos+1, level, entities) + elif player.facing == 'left': + level = toggle(xpos - 1, ypos+1, level, entities) + + elif e.key == K_LEFT: + #cloud = Cloud((xpos-1)*SQUAREWIDTH , ypos*SQUAREHEIGHT, WHITE) + level = toggle(xpos-1, ypos, level, entities) + + #p = Cloud((xpos-1)*SQUAREWIDTH , ypos*SQUAREHEIGHT, WHITE) + #platforms.append(p) + #entities.add(p) + elif e.key == K_RIGHT: + xpos, ypos = player.board_location_right() + level = toggle(xpos+1, ypos, level, entities) + + elif e.type == KEYUP: + if e.key == K_SPACE: + cloud_mode = False + + if e.type == KEYUP: + if e.key == K_RIGHT: + right = False + elif e.key == K_LEFT: + left = False + elif e.key == K_UP: + up = False + elif e.key == K_ESCAPE: + terminate() + + + + screen.fill((10,10,10)) + + + + + x = y = 0 + for row in level: + for col in row: + if col == '1': + screen.blit(cloud_image, pygame.Rect(x,y,SQUAREWIDTH, SQUAREHEIGHT)) + elif col == 'P': + screen.blit(wood_image, pygame.Rect(x,y,SQUAREWIDTH,SQUAREHEIGHT)) + elif col == '.': + #if (x + y) % (2*SQUAREWIDTH)== 0: + #screen.blit(static_images[count%SQUAREWIDTH], pygame.Rect(x,y,SQUAREWIDTH, SQUAREHEIGHT)) + #else: screen.blit(static_images[(-count)%SQUAREWIDTH], pygame.Rect(x,y,SQUAREWIDTH, SQUAREHEIGHT)) + if count%10 < 5: screen.blit(static_image, pygame.Rect(x,y,SQUAREWIDTH, SQUAREHEIGHT)) + else: screen.blit(static_image_2, pygame.Rect(x,y,SQUAREWIDTH, SQUAREHEIGHT)) + elif col == 'E': + screen.blit(exit_image, pygame.Rect(x,y,SQUAREWIDTH,SQUAREHEIGHT)) + elif col in ['B','M','G']: + screen.blit(button_images[col], pygame.Rect(x,y,SQUAREWIDTH,SQUAREHEIGHT)) + elif col in ['b','g','m']: + screen.blit(closed_images[col], pygame.Rect(x,y,SQUAREWIDTH,SQUAREHEIGHT)) + elif col == 'D': + screen.blit(open_image, pygame.Rect(x,y,SQUAREWIDTH,SQUAREHEIGHT)) + x += SQUAREHEIGHT + y+= SQUAREWIDTH + x = 0 + + player.update(up, left, right, level, enemies) + + if True: + for e in enemies: + e.update(level) + + for i in range(len(shadows)): + if pushed[i] == False and count%2==1: + shadow = shadows[i] + shadow.update(level) + if shadow.rect.colliderect(buttons[i].rect): + shadow.remove(entities) + pushed[i] = True + level[gates[i][0]][gates[i][1]] = 'D' + buttons[i].image = pushed_button_image + + for entity in entities: + screen.blit(entity.image, entity.rect) + + pygame.transform.scale(screen, (DISPLAYWIDTH, DISPLAYHEIGHT), window_surface) + pygame.display.update() + if player.dead: + waitForPlayerToPressKey() + break + + +main() diff --git a/space-files/pushed_button.png b/space-files/pushed_button.png new file mode 100644 index 0000000000000000000000000000000000000000..9adb31b84456eb887ed17d8b0981fab5324d4f3e GIT binary patch literal 335 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}c0*}aI1_r((Aj~*bn@<`j_{7u2F~q`u?Ic^F76qQxL~Xv-y~j6v;kehL zTp_Txed$tF)$E2He^^|vn}1eQoRrUSxNN3+-tB8Tr;{86cCR~}|MQt~`+|U|>^qaq zr}Avby=|j3Er{#;)7~lG8yH&p#Fl7EFgi^>de}TMVN*p#Y>Ib58PQ6SG^|%5UTqo8O=8 dwr}02@4Smi&E&D!MWBBfJYD@<);T3K0RZ*8fz<#2 literal 0 HcmV?d00001 diff --git a/space-files/pygame1.py b/space-files/pygame1.py new file mode 100644 index 0000000..c3498d7 --- /dev/null +++ b/space-files/pygame1.py @@ -0,0 +1,48 @@ +import pygame, sys +from pygame.locals import * +# set up pygame +pygame.init() +# set up the window +windowSurface = pygame.display.set_mode((500, 400), 0, 32) +pygame.display.set_caption('Hello world!') +# set up the colors +BLACK = (0, 0, 0) +WHITE = (255, 255, 255) +RED = (255, 0, 0) +GREEN = (0, 255, 0) +BLUE = (0, 0, 255) +# set up fonts +basicFont = pygame.font.SysFont(None, 48) +# set up the text +text = basicFont.render('Hello world!', True, WHITE, BLUE) +textRect = text.get_rect() +textRect.centerx = windowSurface.get_rect().centerx +textRect.centery = windowSurface.get_rect().centery +# draw the white background onto the surface +windowSurface.fill(WHITE) +# draw a green polygon onto the surface +pygame.draw.polygon(windowSurface, GREEN, ((146, 0), (291, 106), (236, 277), (56, 277), (0, 106))) +# draw some blue lines onto the surface +pygame.draw.line(windowSurface, BLUE, (60, 60), (120, 60), 4) +pygame.draw.line(windowSurface, BLUE, (120, 60), (60, 120)) +pygame.draw.line(windowSurface, BLUE, (60, 120), (120, 120), 4) +# draw a blue circle onto the surface +pygame.draw.circle(windowSurface, BLUE, (300, 50), 20, 0) +# draw a red ellipse onto the surface +pygame.draw.ellipse(windowSurface, RED, (300, 250, 40, 80), 1) +# draw the text's background rectangle onto the surface +pygame.draw.rect(windowSurface, RED, (textRect.left - 20, textRect.top - 20, textRect.width + 40, textRect.height + 40)) +# get a pixel array of the surface +pixArray = pygame.PixelArray(windowSurface) +pixArray[480][380] = BLACK +del pixArray +# draw the text onto the surface +windowSurface.blit(text, textRect) +# draw the window onto the screen +pygame.display.update() +# run the game loop +while True: + for event in pygame.event.get(): + if event.type == QUIT: + pygame.quit() + sys.exit() diff --git a/space-files/shadow.png b/space-files/shadow.png new file mode 100644 index 0000000000000000000000000000000000000000..3c47f7989cf37946d05457fe4c7a8a86df48ed4b GIT binary patch literal 190 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}c0*}aI1_r((Aj~*bn@<`j80_id7-Hd{oRX06ga1efvroXRtcF)?NmZ2> zxiy+S1k@Q*9S%JBZnUa#NtHOug)cm&`oW9}JSysc5*R$+cknuU9pYzOkk)g+Acf^u ft-NS%G}c0*}aI1_r((Aj~*bn@<`j80_id7-Hd{oRX06ga1efvroXRtcF)?NmZ2> zxiy+S1k@Q*9S%JBZnUa#NtHOug)cm&`oW9}JSysc5*R$+cknuU9pYzOkk)g+Acf^u ft-NS%G}c0*}aI1_r((Aj~*bn@<`j80zWb7-Hd{oRX06ga1efvroXRtcF)?Nfni^ zjUzR>EgtB8l{nSZaPWPq2(#x`J&pyhC6nTou{B70`29G@u<71JskSLC@;nF5NHiv% i;P~=8L2sj^1Vc}fkoNmOr>+1kVDNPHb6Mw<&;$U9qC9Z` literal 0 HcmV?d00001 diff --git a/space-files/shadow_M.png b/space-files/shadow_M.png new file mode 100644 index 0000000000000000000000000000000000000000..b3fdc959de438befaa57fb463f97f6500ae87299 GIT binary patch literal 192 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}c0*}aI1_r((Aj~*bn@<`j80zWb7-Hd{oRX06ga1efvroXRtcF)?NfnhF zp9^VpTL|p7Wjoc>aPWPq2(#x`J&pyhC6nTou{B70`29G@u<71JskSLC@;nF5NHiv% i;P~=8L2sj^1jE#2g2KzhtsVj`VDNPHb6Mw<&;$TC@H!g+ literal 0 HcmV?d00001 diff --git a/space-files/spinner.png b/space-files/spinner.png new file mode 100644 index 0000000000000000000000000000000000000000..f8b663449e468c4224cf639f536eeca9aaf99cea GIT binary patch literal 326 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}c0*}aI1_r((Aj~*bn@<`jc-zy(F~q`u?G!`4Lk2vqljRy1HyR!~^7s59 z7G>#I2UxxKKMe27R%iU`8LC_mzwfSAWz|y6_dzHA)H|*&dvK_EfB*E&F$+SqIqkjW zyH5P8`n|5kB}0Cbj9mFn`+oJE?g_@3mEOBrJg#}UoB2nanXp+YaMg;unTq#g@}s46 znVsJ{{}tUaP4eI5OUsy*wrECXq_Zx{pVaqA_x0S4X;soU(!~_ZUu53hw#r&Z=$l8j zQ2pLRrZ?N2X{I^zucT-${lfP5W%Bo@ TPa9-_-emA}^>bP0l+XkK42XM? literal 0 HcmV?d00001 diff --git a/space-files/static.png b/space-files/static.png new file mode 100644 index 0000000000000000000000000000000000000000..dd15f96f4d259f177c1cb1f5c477b255a2b5a424 GIT binary patch literal 247 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1SFYWcSQjy#^NA%Cx&(BWL^R}Ea{HEjtmSN z`?>!lvI6;>1s;*b3=DjSL74G){)!Z!V2`JZV~B{rB3aKYUwhrmSoBl!nT4_ihBHs4PfvPhzj)VXm($9V zE%%glZeNs?oY9nhz(oC$!oz1`i&rNvvdd1KR*`q)aQZQZb1Q-jeBHh-$`GnPTEMwZ pJV+~kMajwk4VGUsUx+T!lvI6;>1s;*b3=DjSL74G){)!Z!V2`JZV~B#_`J~~W#QWP zyX=?DG&P^k$vGC1v$@6S_>!ZK1J^#{J0!9B zgjMNS%G}c0*}aI1_r((Aj~*bn@<`j_`%b~F~q`u?i6dGLk2u9vV9D?s-oZRxkJ68 zGU%m$??_$w okftkUdGp=jce1fJTfH;czCG}fzQS>B7trqvp00i_>zopr02HK%r2qf` literal 0 HcmV?d00001 diff --git a/space-files/wood.png b/space-files/wood.png new file mode 100644 index 0000000000000000000000000000000000000000..32729a1fbeed26e0c985ad03b6ffeaa3656cede4 GIT binary patch literal 824 zcmV-81IPS{P)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D0?kQ8K~y+Tom5+H z+b|H6D2XB^*|Hrwb^S@OG&@3A_+*ihPZ#+5bWan&}|7&o2moQ^aNt;%SeWOu=a+RmzuwZP(`~vJKV*0A<-&D{qu$@DQSTTe$a?2R;@2(SeH?D7#Dd`S6o!gQhKvw zDX`6PswggbT+bF;LOL2YhzO~&{Ukr8$T<)Oo6Poj_vD)48dy-)L{Y_f79mg)6k@)7901TfogQ$&A(eEaGX#1WyVUmr0sgc;}*uC-UlYy}G;yze8a<0{!wsN+7$WC@gA*cPm2l4^)Up z`TFhx&x!01y;!Z!SN8#JSyZbgDDn~UHChccA$V0q``r|=%6u&9$WnT=mH8LEwV7*{6#7G$9sMZbu%IkT$Z(~PkZ*#wVdYtp9 z3Yh?Gpe3UmZ%d|Oib@rNv} zRK~>#(U0&vGfDv