Advertisement
Guest User

MapTest.py

a guest
Aug 8th, 2013
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 62.13 KB | None | 0 0
  1. #!/usr/bin/env python2.7
  2. # Last Hazard on the Moon (A 2D Online Myltiplayer Platformer Shooter for Android --- yeah, it's that cool)
  3. # By Mark Beiline ohmnivore.elementfx.com
  4. # Created with PyGame
  5.  
  6. from pygame.locals import *
  7. import legume
  8. import pygame._view
  9. import pygame, os, sys # copy
  10. import random
  11. import math
  12. import cPickle as pickle
  13. import euclid     #from https://code.google.com/p/pyeuclid/
  14. import traceback
  15. import threading
  16. import pyganim
  17. import spritesheet
  18. import pygsheet
  19. import pymunk
  20. from pymunk.vec2d import Vec2d
  21. from pymunk.pygame_util import draw_space, from_pygame, to_pygame
  22. from pymunk import Vec2d
  23. import zlib, base64
  24. from configobj import ConfigObj
  25. #import PyIgnition
  26. #import enet
  27. #parentdir = os.path.dirname(os.path.abspath(__file__))
  28. #sys.path.insert(0,parentdir)
  29.  
  30. #import jpath
  31.  
  32. import os
  33. #import sys
  34.  
  35. #import module_locator
  36. #mypath = module_locator.module_path()
  37.  
  38. def we_are_frozen():
  39.     """Returns whether we are frozen via py2exe.
  40.    This will affect how we find out where we are located."""
  41.  
  42.     return hasattr(sys, "frozen")
  43.  
  44.  
  45. def module_path():
  46.     """ This will get us the program's directory,
  47.    even if we are frozen using py2exe"""
  48.  
  49.     if we_are_frozen():
  50.         return os.path.dirname(unicode(sys.executable, sys.getfilesystemencoding( )))
  51.  
  52.     return os.path.dirname(unicode(__file__, sys.getfilesystemencoding( )))
  53.  
  54. #if hasattr(sys,"frozen") and sys.frozen in ("windows_exe", "console_exe"):
  55. #    mypath=jpath.path(os.path.abspath(sys.executable)).dirname()
  56.  
  57. mypath = module_path()
  58.  
  59. config = ConfigObj(os.path.join(mypath,'ClientSettings.cfg'))
  60.  
  61. global FPSCLOCK, DISPLAYSURF, IMAGESDICT, BRUSH, PLAYERIMAGES, running, mx, my, dtime, dtime_ms, drag, n
  62. global moving, n2, colour, rotationCounter, scalingCounter, nameSize, ghostinit, leftReleased, rightReleased
  63. global moving2, aReleased, dReleased, ghostinit2, isOn2, impo1, impo2, n10, lololol, n5, n6, n8, m
  64. global tempx, tempy, tempx2, tempy2, xrect, yrect, xrect2, yrect2, RocketList, rocketdist, sx, sy, reloaded, CloudList
  65. global mapx, mapy, lolx, loly, n
  66. global reloadclock, wind, dfps, noLeft, noRight, lol
  67. global running, mesg, oldmesg, otherplayers, BotsList, otherbot, xdistance, playerbuffer, ArrowStatus, oldmesgpos, sendtimer, sentmsg
  68. mapstring = ''
  69. my_map = None
  70. sentmsg = False
  71. sendtimer = 0
  72. oldmesgpos = 0
  73. ArrowStatus = ['0', '0', '0', '0', '0', '0', '0', '0']
  74. xdistance = 1000
  75. playerbuffer = 'lol'
  76. BotsList = []
  77. lol = 20
  78. noLeft = False
  79. noRight = False
  80. reloadclock = 0
  81. #gravity = 0.04
  82. lololol = 0
  83. #inAir = False
  84. RocketList = []
  85. reloaded = True
  86. #mypath = os.path.normpath(os.path.dirname(os.path.abspath(sys.argv[0])))
  87. CloudList = []
  88. wind = 2
  89. running = True
  90. mesg = ''
  91. otherplayers = []
  92. ExploAnimList = []
  93. groups = 1
  94.  
  95.  
  96. FPS = 50  # frames per second to update the screen
  97. WINWIDTH = 800  # width of the program's window, in pixels
  98. WINHEIGHT = 600  # height in pixels
  99.  
  100. #Colors
  101. white = 255,255,255
  102. red = 151, 51, 51
  103. green = 112, 145, 28
  104. yellow = 222, 200, 29
  105. blue = 51, 102, 153
  106. black = 0, 0, 0
  107.  
  108. pygame.init()
  109. pygame.font.init()
  110. FPSCLOCK = pygame.time.Clock()
  111. leftReleased = True
  112. rightReleased = True
  113. aReleased = True
  114. dReleased = True
  115. #isOn1 = False
  116. isOn2 = False
  117. impo1 = 0
  118. impo2 = 0
  119. n10 = 0
  120. n6 = 0
  121. RocketList = []
  122. n = 0
  123.  
  124. # Setting of the system icon
  125. icon=pygame.image.load(os.path.join(mypath, 'Images', 'ICO.ico'))
  126. #icon=pygame.image.load('ICO.ico')
  127. pygame.display.set_icon(icon)
  128.  
  129. # Setting of the caption and global font
  130. pygame.display.set_caption('Last Hazard on the Moon')
  131. BRUSH = pygame.font.Font(os.path.join(mypath, 'Fonts', 'ElectricCity.TTF'), 18)
  132.  
  133. # Surface object that is drawn to the actual computer screen
  134. DISPLAYSURF = pygame.display.set_mode((WINWIDTH, WINHEIGHT))
  135.  
  136.  
  137. Crosshairs = pyganim.PygAnimation(pygsheet.spritesheet(os.path.join(mypath, 'Images', 'Crosshairs3.png')).load_strip((0,0,100,100), 8, colorkey = (204, 204, 204), time = 0.05))
  138. Crosshairs.play()
  139.  
  140. Health = pyganim.PygAnimation(pygsheet.spritesheet(os.path.join(mypath, 'Images', 'HoloHealthSprite2.png')).load_strip((0,0,32,32), 7, colorkey = (0, 0, 0), time = 0.07))
  141. Health.play()
  142.  
  143. Shield = pyganim.PygAnimation(pygsheet.spritesheet(os.path.join(mypath, 'Images', 'HoloBatterySprite.png')).load_strip((0,0,32,32), 7, colorkey = (0, 0, 0), time = 0.07))
  144. Shield.play()
  145.  
  146. Speed = pyganim.PygAnimation(pygsheet.spritesheet(os.path.join(mypath, 'Images', 'HoloSpeedSprite.png')).load_strip((0,0,32,32), 7, colorkey = (0, 0, 0), time = 0.07))
  147. Speed.play()
  148.  
  149. ScientistRight = pyganim.PygAnimation(pygsheet.spritesheet(os.path.join(mypath, 'Images', 'scientistright.png')).load_strip((0,0,37,45), 11, colorkey = (14, 24, 45), time = 0.05))
  150. ScientistRight.play()
  151. ScientistRightRev = ScientistRight.getCopy()
  152. ScientistRightRev.reverse()
  153. ScientistRightRev.play()
  154. ScientistRightImmo = pygame.image.load(os.path.join(mypath, 'Images', 'scientistrightimmo.png')).convert_alpha()
  155.  
  156. ScientistLeft = pyganim.PygAnimation(pygsheet.spritesheet(os.path.join(mypath, 'Images', 'scientistleft.png')).load_strip((0,0,37,45), 11, colorkey = (14, 24, 45), time = 0.05))
  157. ScientistLeft.reverse()
  158. ScientistLeft.play()
  159. ScientistLeftRev = ScientistLeft.getCopy()
  160. ScientistLeftRev.reverse()
  161. ScientistLeftRev.play()
  162. ScientistLeftImmo = pygame.image.load(os.path.join(mypath, 'Images', 'scientistleftimmo.png')).convert_alpha()
  163.  
  164. ScientistGreen = {
  165.               'Right' : ScientistRight,
  166.               'RightRev' : ScientistRightRev,
  167.               'RightImmo' : ScientistRightImmo,
  168.               'Left' : ScientistLeft,
  169.               'LeftRev' : ScientistLeftRev,
  170.               'LeftImmo' : ScientistLeftImmo,
  171. }
  172.  
  173. ScientistRightBlue = pyganim.PygAnimation(pygsheet.spritesheet(os.path.join(mypath, 'Images', 'scientistrightblue.png')).load_strip((0,0,37,45), 11, colorkey = (14, 24, 45), time = 0.05))
  174. ScientistRightBlue.play()
  175. ScientistRightRevBlue = ScientistRightBlue.getCopy()
  176. ScientistRightRevBlue.reverse()
  177. ScientistRightRevBlue.play()
  178. ScientistRightImmoBlue = pygame.image.load(os.path.join(mypath, 'Images', 'scientistrightimmoblue.png')).convert_alpha()
  179.  
  180. ScientistLeftBlue = pyganim.PygAnimation(pygsheet.spritesheet(os.path.join(mypath, 'Images', 'scientistleftblue.png')).load_strip((0,0,37,45), 11, colorkey = (14, 24, 45), time = 0.05))
  181. ScientistLeftBlue.reverse()
  182. ScientistLeftBlue.play()
  183. ScientistLeftRevBlue = ScientistLeftBlue.getCopy()
  184. ScientistLeftRevBlue.reverse()
  185. ScientistLeftRevBlue.play()
  186. ScientistLeftImmoBlue = pygame.image.load(os.path.join(mypath, 'Images', 'scientistleftimmoblue.png')).convert_alpha()
  187.  
  188. ScientistBlue = {
  189.               'Right' : ScientistRightBlue,
  190.               'RightRev' : ScientistRightRevBlue,
  191.               'RightImmo' : ScientistRightImmoBlue,
  192.               'Left' : ScientistLeftBlue,
  193.               'LeftRev' : ScientistLeftRevBlue,
  194.               'LeftImmo' : ScientistLeftImmoBlue,
  195. }
  196.  
  197. ScientistRightRed = pyganim.PygAnimation(pygsheet.spritesheet(os.path.join(mypath, 'Images', 'scientistrightred.png')).load_strip((0,0,37,45), 11, colorkey = (14, 24, 45), time = 0.05))
  198. ScientistRightRed.play()
  199. ScientistRightRevRed = ScientistRightRed.getCopy()
  200. ScientistRightRevRed.reverse()
  201. ScientistRightRevRed.play()
  202. ScientistRightImmoRed = pygame.image.load(os.path.join(mypath, 'Images', 'scientistrightimmored.png')).convert_alpha()
  203.  
  204. ScientistLeftRed = pyganim.PygAnimation(pygsheet.spritesheet(os.path.join(mypath, 'Images', 'scientistleftred.png')).load_strip((0,0,37,45), 11, colorkey = (14, 24, 45), time = 0.05))
  205. ScientistLeftRed.reverse()
  206. ScientistLeftRed.play()
  207. ScientistLeftRevRed = ScientistLeftRed.getCopy()
  208. ScientistLeftRevRed.reverse()
  209. ScientistLeftRevRed.play()
  210. ScientistLeftImmoRed = pygame.image.load(os.path.join(mypath, 'Images', 'scientistleftimmored.png')).convert_alpha()
  211.  
  212. ScientistRed = {
  213.               'Right' : ScientistRightRed,
  214.               'RightRev' : ScientistRightRevRed,
  215.               'RightImmo' : ScientistRightImmoRed,
  216.               'Left' : ScientistLeftRed,
  217.               'LeftRev' : ScientistLeftRevRed,
  218.               'LeftImmo' : ScientistLeftImmoRed,
  219. }
  220.  
  221. ScientistRightYellow = pyganim.PygAnimation(pygsheet.spritesheet(os.path.join(mypath, 'Images', 'scientistrightyellow.png')).load_strip((0,0,37,45), 11, colorkey = (14, 24, 45), time = 0.05))
  222. ScientistRightYellow.play()
  223. ScientistRightRevYellow = ScientistRightYellow.getCopy()
  224. ScientistRightRevYellow.reverse()
  225. ScientistRightRevYellow.play()
  226. ScientistRightImmoYellow = pygame.image.load(os.path.join(mypath, 'Images', 'scientistrightimmoyellow.png')).convert_alpha()
  227.  
  228. ScientistLeftYellow = pyganim.PygAnimation(pygsheet.spritesheet(os.path.join(mypath, 'Images', 'scientistleftyellow.png')).load_strip((0,0,37,45), 11, colorkey = (14, 24, 45), time = 0.05))
  229. ScientistLeftYellow.reverse()
  230. ScientistLeftBlue.play()
  231. ScientistLeftRevYellow = ScientistLeftYellow.getCopy()
  232. ScientistLeftRevYellow.reverse()
  233. ScientistLeftRevYellow.play()
  234. ScientistLeftImmoYellow = pygame.image.load(os.path.join(mypath, 'Images', 'scientistleftimmoyellow.png')).convert_alpha()
  235.  
  236. ScientistYellow = {
  237.               'Right' : ScientistRightYellow,
  238.               'RightRev' : ScientistRightRevYellow,
  239.               'RightImmo' : ScientistRightImmoYellow,
  240.               'Left' : ScientistLeftYellow,
  241.               'LeftRev' : ScientistLeftRevYellow,
  242.               'LeftImmo' : ScientistLeftImmoYellow,
  243. }
  244.  
  245. PLAYERANIMS = [ScientistGreen, ScientistBlue, ScientistRed, ScientistYellow]
  246.  
  247. Gun = pygame.image.load(os.path.join(mypath, 'Images', 'gunsquare.png')).convert_alpha()
  248. GunReverse = pygame.transform.flip(Gun, True, False)
  249.  
  250. BlueBullet = pyganim.PygAnimation(pygsheet.spritesheetalpha(os.path.join(mypath, 'Effects', 'Bullet', 'BlueBulletTransparent5.png')).load_strip((0,0,37,37), 8, colorkey = (255,255,255), time = 0.04))
  251. BlueBullet.set_colorkey(black)
  252. BlueBullet.play()
  253.  
  254. GreenBullet = pyganim.PygAnimation(pygsheet.spritesheetalpha(os.path.join(mypath, 'Effects', 'Bullet', 'GreenBulletTransparent5.png')).load_strip((0,0,37,37), 8, colorkey = (255,255,255), time = 0.04))
  255. GreenBullet.set_colorkey(black)
  256. GreenBullet.play()
  257.  
  258. RedBullet = pyganim.PygAnimation(pygsheet.spritesheetalpha(os.path.join(mypath, 'Effects', 'Bullet', 'RedBulletTransparent5.png')).load_strip((0,0,37,37), 8, colorkey = (255,255,255), time = 0.04))
  259. RedBullet.set_colorkey(black)
  260. RedBullet.play()
  261.  
  262. YellowBullet = pyganim.PygAnimation(pygsheet.spritesheetalpha(os.path.join(mypath, 'Effects', 'Bullet', 'YellowBulletTransparent5.png')).load_strip((0,0,37,37), 8, colorkey = (255,255,255), time = 0.04))
  263. YellowBullet.set_colorkey(black)
  264. YellowBullet.play()
  265.  
  266. GreenExplo = pyganim.PygAnimation(pygsheet.spritesheet(os.path.join(mypath, 'Images', 'ExploGreenBlack.png')).load_strip((0,0,256,256), 20, colorkey = (0,0,0), time = 0.03))
  267. GreenExplo.set_colorkey(black)
  268.  
  269. BlueExplo = pyganim.PygAnimation(pygsheet.spritesheet(os.path.join(mypath, 'Images', 'ExploBlueBlack.png')).load_strip((0,0,256,256), 20, colorkey = (0,0,0), time = 0.03))
  270. BlueExplo.set_colorkey(black)
  271.  
  272. RedExplo = pyganim.PygAnimation(pygsheet.spritesheet(os.path.join(mypath, 'Images', 'ExploRedBlack.png')).load_strip((0,0,256,256), 20, colorkey = (0,0,0), time = 0.03))
  273. RedExplo.set_colorkey(black)
  274.  
  275. YellowExplo = pyganim.PygAnimation(pygsheet.spritesheet(os.path.join(mypath, 'Images', 'ExploYellowBlack.png')).load_strip((0,0,256,256), 20, colorkey = (0,0,0), time = 0.03))
  276. YellowExplo.set_colorkey(black)
  277.  
  278. RectBlocks = spritesheet.spritesheet(os.path.join(mypath, 'Images', 'RectBlocks.png')).load_strip((0,0,171,22), 16, colorkey = (51, 51, 51))
  279. SquareBlocks = spritesheet.spritesheet(os.path.join(mypath, 'Images', 'SquareBlocks.png')).load_strip((0,0,168,171), 16, colorkey = (51, 51, 51))
  280.  
  281. ArmorAnimRight = pyganim.PygAnimation(pygsheet.spritesheet(os.path.join(mypath, 'Images', 'armoranimright.png')).load_strip((0,0,37,45), 11, colorkey = (14, 24, 45), time = 0.05))
  282. ArmorAnimRight.play()
  283.  
  284. ArmorAnimLeft = pyganim.PygAnimation(pygsheet.spritesheet(os.path.join(mypath, 'Images', 'armoranimleft.png')).load_strip((0,0,37,45), 11, colorkey = (14, 24, 45), time = 0.05))
  285. ArmorAnimLeft.reverse()
  286. ArmorAnimLeft.play()
  287. ArmorAnimLeft.fastForward(0.15)
  288.  
  289. SpeedAnimRight = pyganim.PygAnimation(pygsheet.spritesheet(os.path.join(mypath, 'Images', 'speedright.png')).load_strip((0,0,37,45), 11, colorkey = (14, 24, 45), time = 0.05))
  290. SpeedAnimRight.play()
  291. #SpeedAnimRight.nextFrame(jump=6)
  292.  
  293. SpeedAnimLeft = pyganim.PygAnimation(pygsheet.spritesheet(os.path.join(mypath, 'Images', 'speedleft.png')).load_strip((0,0,37,45), 11, colorkey = (14, 24, 45), time = 0.05))
  294. SpeedAnimLeft.reverse()
  295. SpeedAnimLeft.play()
  296. #SpeedAnimLeft.nextFrame(jump=6)
  297.  
  298. Heartbeat = pyganim.PygAnimation(pygsheet.spritesheetalpha(os.path.join(mypath, 'Effects', 'Heart-beat', 'HeartBeatLoopTransparent.png')).load_strip((0,0,256,256), 8, colorkey = (14, 24, 45), time = 0.05))
  299. #Heartbeat.convert_alpha()
  300. Heartbeat.play()
  301.  
  302. Cloak = pyganim.PygAnimation(pygsheet.spritesheetalpha(os.path.join(mypath, 'Effects', 'Cloak', 'CloakTransparent.png')).load_strip((0,0,128,128), 8, colorkey = (14, 24, 45), time = 0.05))
  303. #Heartbeat.convert_alpha()
  304. Cloak.play()
  305. #Cloak.loop = False
  306.  
  307. Cloak2 = pyganim.PygAnimation(pygsheet.spritesheetalpha(os.path.join(mypath, 'Effects', 'Cloak', 'CloakTransparent.png')).load_strip((0,0,128,128), 8, colorkey = (14, 24, 45), time = 0.05))
  308. #Heartbeat.convert_alpha()
  309. Cloak2.play()
  310. #Heartbeat.convert_alpha()
  311. #Cloak2.play()
  312. Cloak2.loop = False
  313.  
  314. DeathExplo = pyganim.PygAnimation(pygsheet.spritesheetalpha(os.path.join(mypath, 'Effects', 'Death', 'DeathTransparent.png')).load_strip((0,0,256,256), 8, colorkey = (14, 24, 45), time = 0.05))
  315. #Heartbeat.convert_alpha()
  316. DeathExplo.play()
  317.  
  318. Heal = pyganim.PygAnimation(pygsheet.spritesheetalpha(os.path.join(mypath, 'Effects', 'Heal', 'HealLoopTransparent.png')).load_strip((0,0,256,256), 8, colorkey = (14, 24, 45), time = 0.05))
  319. #Heartbeat.convert_alpha()
  320. Heal.play()
  321.  
  322. Circle = pyganim.PygAnimation(pygsheet.spritesheetalpha(os.path.join(mypath, 'Effects', 'Loading', 'CircleTransparent.png')).load_strip((0,0,256,256), 8, colorkey = (14, 24, 45), time = 0.05))
  323. #Heartbeat.convert_alpha()
  324. Circle.play()
  325.  
  326. Powerup = pyganim.PygAnimation(pygsheet.spritesheetalpha(os.path.join(mypath, 'Effects', 'Powerup', 'PowerupTransparent.png')).load_strip((0,0,256,256), 8, colorkey = (14, 24, 45), time = 0.05))
  327. #Heartbeat.convert_alpha()
  328. Powerup.play()
  329.  
  330. ShieldAbility = pyganim.PygAnimation(pygsheet.spritesheetalpha(os.path.join(mypath, 'Effects', 'Shield', 'Shield2.png')).load_strip((0,0,80,80), 8, colorkey = (14, 24, 45), time = 0.05))
  331. #Heartbeat.convert_alpha()
  332. ShieldAbility.play()
  333.  
  334. ShieldStart = pyganim.PygAnimation(pygsheet.spritesheetalpha(os.path.join(mypath, 'Effects', 'Shield', 'ShieldStartTransparent.png')).load_strip((0,0,128,128), 8, colorkey = (14, 24, 45), time = 0.05))
  335. #Heartbeat.convert_alpha()
  336. #ShieldStart.play()
  337.  
  338. Timezone = pyganim.PygAnimation(pygsheet.spritesheetalpha(os.path.join(mypath, 'Effects', 'Timezone', 'TimezoneLoopTransparent.png')).load_strip((0,0,256,256), 8, colorkey = (14, 24, 45), time = 0.05))
  339. #Heartbeat.convert_alpha()
  340. Timezone.play()
  341.  
  342. ABILITYDICT = {
  343.                 'Heartbeat' : Heartbeat,
  344.                 'Cloak' : Cloak2,
  345.                 'Heal' : Heal,
  346.                 'Shield' : ShieldAbility,
  347.                 'Timezone' : Timezone
  348. }
  349.  
  350. BULLETS = [GreenBullet, BlueBullet, RedBullet, YellowBullet]
  351. EXPLOS = [GreenExplo, BlueExplo, RedExplo, YellowExplo]
  352. #PLAYERANIMS = {
  353. #              'ScientistRight'
  354. #}
  355.  
  356. # A global dict value that will contain all the Pygame
  357. # Surface objects returned by pygame.image.load().
  358. IMAGESDICT = {#'Player' : pygame.image.load('GreenSquare.png'),
  359.               'ArmorRight' : pygame.image.load(os.path.join(mypath, 'Images', 'armorright.png')).convert(),
  360.               'ArmorLeft' : pygame.image.load(os.path.join(mypath, 'Images', 'armorleft.png')).convert(),
  361.               'SpeedRight' : pygame.image.load(os.path.join(mypath, 'Images', 'speedrightimmo.png')).convert(),
  362.               'SpeedLeft' : pygame.image.load(os.path.join(mypath, 'Images', 'speedleftimmo.png')).convert(),
  363.               'PackRight' : pygame.image.load(os.path.join(mypath, 'Images', 'PackRight.png')).convert_alpha(),
  364.               'PackLeft' : pygame.image.load(os.path.join(mypath, 'Images', 'PackLeft.png')).convert_alpha(),
  365.               'MovingDanger' : pygame.image.load(os.path.join(mypath, 'Images', 'dangermoving.png')).convert(),
  366.               'Playerr' : pygame.transform.scale(pygame.image.load(os.path.join(mypath, 'Images', 'GreenSquare2.png')).convert_alpha(),(42,42)),
  367.               #'WHOCARES' : os.path.join("Blast2D\Images\BlueSquare.png"),
  368.               'Playerblue' : pygame.transform.scale(pygame.image.load(os.path.join(mypath, 'Images', 'BlueSquare2.png')).convert_alpha(),(42,42)),
  369.               'Playerred' : pygame.transform.scale(pygame.image.load(os.path.join(mypath, 'Images', 'RedSquare2.png')).convert_alpha(),(42,42)),
  370.               'Playeryellow' : pygame.transform.scale(pygame.image.load(os.path.join(mypath, 'Images', 'YellowSquare2.png')).convert_alpha(),(42,42)),
  371.               'Crosshair' : pygame.image.load(os.path.join(mypath, 'Images', 'Cross.png')).convert(),
  372.               'CrosshairC' : pygame.image.load(os.path.join(mypath, 'Images', 'Cross.png')).convert(), # CrosshairC is a duplicate for easier scaling and rotation
  373.               'Background' : pygame.image.load(os.path.join(mypath, 'Backgrounds', config['Video']['background'])).convert(),
  374.               'PlatformGreen' : pygame.image.load(os.path.join(mypath, 'Images', 'GreenPlatform.png')).convert(),
  375.               'PlatformBlue' : pygame.image.load(os.path.join(mypath, 'Images', 'BluePlatform.png')).convert(),
  376.               'PlatformRed' : pygame.image.load(os.path.join(mypath, 'Images', 'RedPlatform.png')).convert(),
  377.               'PlatformYellow' : pygame.image.load(os.path.join(mypath, 'Images', 'YellowPlatform.png')).convert(),
  378.               'PlatformMoving' : pygame.image.load(os.path.join(mypath, 'Images', 'Danger.png')).convert(),
  379.               'Floor' : pygame.image.load(os.path.join(mypath, 'Images', 'Block.png')).convert_alpha(),
  380.               'RocketGreen' : pygame.image.load(os.path.join(mypath, 'Images', 'RocketGreen.png')).convert_alpha(),
  381.               'RocketBlue' : pygame.image.load(os.path.join(mypath, 'Images', 'RocketBlue.png')).convert_alpha(),
  382.               'RocketRed' : pygame.image.load(os.path.join(mypath, 'Images', 'RocketRed.png')).convert_alpha(),
  383.               'RocketYellow' : pygame.image.load(os.path.join(mypath, 'Images', 'RocketYellow.png')).convert_alpha(),
  384.               'Cloud1' : pygame.image.load(os.path.join(mypath, 'Images', 'Cloud1.png')).convert_alpha(),
  385.               'Cloud2' : pygame.image.load(os.path.join(mypath, 'Images', 'Cloud2.png')).convert_alpha(),
  386.               'Cloud3' : pygame.image.load(os.path.join(mypath, 'Images', 'Cloud3.png')).convert_alpha(),
  387.               'Shield' : pygame.image.load(os.path.join(mypath, 'Images', 'Shield.png')).convert_alpha(),
  388.               'Speed' : pygame.image.load(os.path.join(mypath, 'Images', 'Speed.png')).convert_alpha(),
  389.               'Health' : pygame.image.load(os.path.join(mypath, 'Images', 'holohealthtrans.png')).convert_alpha(),
  390.               'Bubble' : pygame.image.load(os.path.join(mypath, 'Images', 'Bubble.png')).convert_alpha(),
  391.               'Chili' : pygame.transform.scale(pygame.image.load(os.path.join(mypath, 'Images', 'Chili.png')).convert_alpha(), (42, 42))}
  392.  
  393. bckgroundwidth = IMAGESDICT['Background'].get_width()
  394. #pygame.image.save(IMAGESDICT['MovingDanger'], 'movingdanger.png')
  395.  
  396. IMAGESDICT['MovingDanger'].set_colorkey((51,51,51))
  397. IMAGESDICT['ArmorRight'].set_colorkey((14, 24, 45))
  398. IMAGESDICT['ArmorLeft'].set_colorkey((14, 24, 45))
  399. IMAGESDICT['SpeedRight'].set_colorkey((14, 24, 45))
  400. IMAGESDICT['SpeedLeft'].set_colorkey((14, 24, 45))
  401.  
  402. #IMAGESDICT['Health'].set_colorkey((255,255,255))
  403. #IMAGESDICT['Health'].set_alpha(160, pygame.RLEACCEL)
  404.  
  405. #IMAGESDICT['MovingDanger'].set_colorkey((51,51,51))
  406. # PLAYERIMAGES is a list of all possible characters the player can be.
  407. PLAYERIMAGES = [IMAGESDICT['Playerr'], IMAGESDICT['Playerblue'],
  408.                 IMAGESDICT['Playerred'], IMAGESDICT['Playeryellow']]
  409.  
  410. # COLORS is a list of all possible colors.
  411. COLORS = [green, blue,
  412.                 red, yellow]
  413.  
  414. #ROCKETS is a list of possible platforms
  415. ROCKETS = [IMAGESDICT['RocketGreen'], IMAGESDICT['RocketBlue'],
  416.                 IMAGESDICT['RocketRed'], IMAGESDICT['RocketYellow']]
  417.  
  418. #PlATFORMS is a list of possible platforms
  419. PLATFORMS = [IMAGESDICT['PlatformGreen'], IMAGESDICT['PlatformBlue'],
  420.                 IMAGESDICT['PlatformRed'], IMAGESDICT['PlatformYellow'],
  421.                 IMAGESDICT['Floor']]
  422.  
  423. #Clouds is a list of possible clouds
  424. CLOUDS = [IMAGESDICT['Cloud1'], IMAGESDICT['Cloud2'],
  425.                 IMAGESDICT['Cloud3']]
  426.  
  427. ##Particle effects (PyIgnition)
  428. #fire = PyIgnition.ParticleEffect(DISPLAYSURF, (0, 0), (800, 600))
  429. ##gravity = fire.CreateDirectedGravity(strength = 0.07, direction = [0, -1])
  430. ##wind = fire.CreateDirectedGravity(strength = 0.05, direction = [1, 0])
  431. #source = fire.CreateSource((300, 500), initspeed = 2.0, initdirection = 0.0, initspeedrandrange = 1.0, initdirectionrandrange = 0.5, particlesperframe = 10, particlelife = 100, drawtype = PyIgnition.DRAWTYPE_CIRCLE, colour = (255, 200, 100), radius = 3.0)
  432. #source.CreateParticleKeyframe(10, colour = (200, 50, 20), radius = 4.0)
  433. #source.CreateParticleKeyframe(30, colour = (150, 0, 0), radius = 6.0)
  434. #source.CreateParticleKeyframe(60, colour = (50, 20, 20), radius = 20.0)
  435. #source.CreateParticleKeyframe(80, colour = (0, 0, 0), radius = 50.0)
  436. #fire.SaveToFile("Fire.ppe")
  437.  
  438.  
  439.  
  440. # Loading the music
  441. pygame.mixer.music.load(os.path.join(mypath, 'Tracks', random.choice(os.listdir(os.path.join(mypath, 'Tracks')))))
  442. pygame.mixer.music.play()
  443.  
  444. SONGFINISHED = USEREVENT+25
  445. #songfinishedevent = pygame.event.Event(SONGFINISHED)
  446.  
  447. pygame.mixer.music.set_endevent(SONGFINISHED)
  448.  
  449. MusicVolume = int(config['Audio']['music'])
  450. #if MusicVolume == 0:
  451. #    MusicVolume = 1
  452. EffectsVolume = int(config['Audio']['effects'])
  453. #if EffectsVolume == 0:
  454. #    EffectsVolume = 1
  455.  
  456. pygame.mixer.music.set_volume(0.7 * MusicVolume/100)
  457.  
  458. # Loading the sounds
  459. SOUNDSDICT = {'Jump' : pygame.mixer.Sound(os.path.join(mypath, 'Sounds', 'Jump2.ogg')),
  460.               'Dead' : pygame.mixer.Sound(os.path.join(mypath, 'Sounds', 'Dead.ogg')),
  461.               'Boom' : pygame.mixer.Sound(os.path.join(mypath, 'Sounds', 'Boom.ogg')),
  462.               'Hit' : pygame.mixer.Sound(os.path.join(mypath, 'Sounds', 'Hit.ogg')),
  463.               'Kill' : pygame.mixer.Sound(os.path.join(mypath, 'Sounds', 'Kill.ogg')),
  464.               'Explosion' : pygame.mixer.Sound(os.path.join(mypath, 'Sounds', 'Explosion.ogg')),
  465.               'Powa' : pygame.mixer.Sound(os.path.join(mypath, 'Sounds', 'Powa.ogg')),}
  466.  
  467. # Setting sounds' volumes
  468. SOUNDSDICT['Jump'].set_volume(0.3 * EffectsVolume/100)
  469. SOUNDSDICT['Boom'].set_volume(0.3 * EffectsVolume/100)
  470. SOUNDSDICT['Dead'].set_volume(0.6 * EffectsVolume/100)
  471. SOUNDSDICT['Powa'].set_volume(0.6 * EffectsVolume/100)
  472. SOUNDSDICT['Explosion'].set_volume(1 * EffectsVolume/100)
  473.  
  474. # The variable that keeps the main loop running
  475. running = True
  476.  
  477. # A variable to determine if the user is moving the player
  478. moving = False
  479.  
  480. # Set key repeat to repeatable
  481. pygame.key.set_repeat(1, 8)
  482.  
  483. # Counters for rotation and scaling
  484. rotationCounter = 0
  485. scalingCounter = 0
  486.  
  487. # Hide the cursor
  488. pygame.mouse.set_visible(0)
  489.  
  490. SENDTIMER = USEREVENT + 7
  491. sendtimerevent = pygame.event.Event(SENDTIMER)
  492. pygame.event.post(sendtimerevent)
  493. pygame.time.set_timer(USEREVENT + 7, 100)
  494.  
  495. RELOADUSER = USEREVENT+3
  496. reloadevent = pygame.event.Event(RELOADUSER)
  497. pygame.event.post(reloadevent)
  498.  
  499. #CLOUDTIMER = USEREVENT+4
  500. #cloudtimerevent = pygame.event.Event(CLOUDTIMER)
  501. #pygame.event.post(cloudtimerevent)
  502. #pygame.time.set_timer(USEREVENT+4, 5000 * 3/wind)
  503.  
  504. WINDRESET = USEREVENT+5
  505. windresetevent = pygame.event.Event(WINDRESET)
  506. pygame.event.post(windresetevent)
  507. pygame.time.set_timer(USEREVENT+5, 30000)
  508.  
  509. SHIELDRESET = USEREVENT+6
  510. shieldresetevent = pygame.event.Event(SHIELDRESET)
  511.  
  512. # Set events for left and right key presses
  513. LEFTGHOST = USEREVENT+2
  514. ghostleft = pygame.event.Event(LEFTGHOST)
  515. pygame.event.post(ghostleft)
  516.  
  517. RIGHTGHOST = USEREVENT+1
  518. ghostright = pygame.event.Event(RIGHTGHOST)
  519. pygame.event.post(ghostright)
  520.  
  521. ghostinit = 0
  522.  
  523. space = pymunk.Space()  
  524. space.gravity = (0.0, -700.0)
  525. space.collision_slop = 0.0001
  526. space.collision_bias = pow(1.0-0.1, 120.0)
  527. #space.add_collision_handler()
  528.  
  529. def textHollow(font, message, fontcolor):
  530.     notcolor = [c^0xFF for c in fontcolor]
  531.     base = font.render(message, 0, fontcolor, notcolor)
  532.     size = base.get_width() + 2, base.get_height() + 2
  533.     img = pygame.Surface(size, 16)
  534.     img.fill(notcolor)
  535.     base.set_colorkey(0)
  536.     img.blit(base, (0, 0))
  537.     img.blit(base, (2, 0))
  538.     img.blit(base, (0, 2))
  539.     img.blit(base, (2, 2))
  540.     base.set_colorkey(0)
  541.     base.set_palette_at(1, notcolor)
  542.     img.blit(base, (1, 1))
  543.     img.set_colorkey(notcolor)
  544.     return img
  545.  
  546. def textOutline(font, message, fontcolor, outlinecolor):
  547.     base = font.render(message, 0, fontcolor)
  548.     outline = textHollow(font, message, outlinecolor)
  549.     img = pygame.Surface(outline.get_size(), 16)
  550.     img.blit(base, (1, 1))
  551.     img.blit(outline, (0, 0))
  552.     img.set_colorkey(0)
  553.     return img
  554.  
  555. # The Platform class represents
  556. #class Platform:
  557. #    
  558. #    def __init__(self, position_x, position_y, colour = random.randint(0, 3), char = '#'):
  559. #        self.position_x = position_x
  560. #        self.position_y = position_y
  561. #        self.colour = colour
  562. #        self.char = char
  563. #        self.block = 1
  564. #        #self.block = random.choice(RectBlocks)
  565.  
  566. class Platform:
  567.     def __init__(self, position_x, position_y, variety, mode):
  568.         self.position_x = position_x
  569.         self.position_y = position_y
  570.         self.type = variety
  571.         self.mode = mode
  572.         self.bound = None
  573.         self.image = None
  574.         self.body = None
  575.         self.shape = None
  576.  
  577.  
  578. # The map class is for reading and displaying a map
  579. class Map:
  580.     def __init__(self, mapname, maptext):
  581.         global space
  582.  
  583.         self.mapname = str(mapname)
  584.         self.lowest_y = 0
  585.  
  586.         self.powerups = []
  587.         self.platforms = []
  588.         self.spawns = []
  589.         self.movingplatforms = []
  590.         self.PowerTimes = []
  591.         self.spawnlist = []
  592.         self.spawnlist = []
  593.         self.poweruplist = []
  594.         self.MapNameText = ''
  595.         for x in maptext:
  596.             if self.lowest_y < x[1]:
  597.                 self.lowest_y = x[1] + 300
  598.             platform = Platform(x[0], x[1], x[2], x[3])
  599.             platform.mode = x[3]
  600.             if x[2] == 0:
  601.                 platform.image = random.choice(RectBlocks)
  602.                 platform.bound = Rect(x[0], x[1], 168, 22)
  603.                 platform.body = pymunk.Body()
  604.                 platform.body.position = from_pygame(Vec2d(platform.position_x, platform.position_y), DISPLAYSURF)
  605.                 xp, yp = platform.bound.topleft
  606.                 width = platform.bound.width
  607.                 height = platform.bound.height
  608.                 platform.shape = pymunk.Poly(space.static_body, [from_pygame(Vec2d(xp,yp), DISPLAYSURF), from_pygame(Vec2d(xp+width,yp), DISPLAYSURF), from_pygame(Vec2d(xp+width,yp+height), DISPLAYSURF), from_pygame(Vec2d(xp,yp+height), DISPLAYSURF)])
  609.                 platform.shape.friction = 2.4
  610.                 space.add(platform.shape)
  611.                 self.platforms.append(platform)
  612.                
  613.             if x[2] == 1:
  614.                 platform.image = random.choice(SquareBlocks)
  615.                 platform.bound = Rect(x[0], x[1], 168, 168)
  616.                 platform.body = pymunk.Body()
  617.                 platform.body.position = from_pygame(Vec2d(platform.position_x, platform.position_y), DISPLAYSURF)
  618.                 xp, yp = platform.bound.topleft
  619.                 width = platform.bound.width
  620.                 height = platform.bound.height
  621.                 platform.shape = pymunk.Poly(space.static_body, [from_pygame(Vec2d(xp,yp), DISPLAYSURF), from_pygame(Vec2d(xp+width,yp), DISPLAYSURF), from_pygame(Vec2d(xp+width,yp+height), DISPLAYSURF), from_pygame(Vec2d(xp,yp+height), DISPLAYSURF)])
  622.                 platform.shape.friction = 2.4
  623.                 space.add(platform.shape)
  624.                 self.platforms.append(platform)
  625.             if x[2] == 2:
  626.                 platform.image = IMAGESDICT['MovingDanger']
  627.                 platform.initposx = platform.position_x
  628.                 platform.initposy = platform.position_y
  629.                 platform.lx = x[4]
  630.                 platform.ly = x[5]
  631.                 platform.sx = x[6]
  632.                 platform.sy = x[7]
  633.                 platform.ox = x[8]
  634.                 platform.oy = x[9]
  635.                 platform.xxx = 0
  636.                 platform.yyy = 0
  637.                 platform.bound = Rect(x[0], x[1], 168, 22)
  638.                 platform.body = pymunk.Body(pymunk.inf,pymunk.inf)
  639.                 platform.body.position = from_pygame(Vec2d(platform.position_x, platform.position_y), DISPLAYSURF)
  640.                 xp, yp = platform.bound.topleft
  641.                 width = platform.bound.width
  642.                 height = platform.bound.height
  643.                 platform.shape = pymunk.Poly(platform.body, [from_pygame(Vec2d(xp,yp), DISPLAYSURF), from_pygame(Vec2d(xp+width,yp), DISPLAYSURF), from_pygame(Vec2d(xp+width,yp+height), DISPLAYSURF), from_pygame(Vec2d(xp,yp+height), DISPLAYSURF)])
  644.                 platform.shape.friction = 2.4
  645.                 space.add(platform.shape)
  646.                 self.platforms.append(platform)
  647.                 self.movingplatforms.append(platform)
  648.                 #platform.body.apply_impulse(Vec2d(0, platform.yyy / 500))
  649.                 #platform.body.apply_force(Vec2d(0.0, 700.0))
  650.             if x[2] == 3:
  651.                 platform.bound = Rect(x[0], x[1], 168, 168)
  652.                 platform.body = pymunk.Body()
  653.                 platform.body.position = from_pygame(Vec2d(platform.position_x, platform.position_y), DISPLAYSURF)
  654.                 self.spawns.append(platform)
  655.                 self.spawnlist.append(platform.shape)
  656.             if x[2] == 4:
  657.                 platform.bound = Rect(x[0], x[1], 168, 168)
  658.                 platform.body = pymunk.Body()
  659.                 platform.body.position = from_pygame(Vec2d(platform.position_x, platform.position_y), DISPLAYSURF)
  660.                 xp, yp = platform.bound.topleft
  661.                 width = platform.bound.width
  662.                 height = platform.bound.height
  663.                 platform.shape = pymunk.Poly(space.static_body, [from_pygame(Vec2d(xp,yp), DISPLAYSURF), from_pygame(Vec2d(xp+width,yp), DISPLAYSURF), from_pygame(Vec2d(xp+width,yp+height), DISPLAYSURF), from_pygame(Vec2d(xp,yp+height), DISPLAYSURF)])
  664.                 platform.shape.friction = 0.0
  665.                 platform.shape.sensor = True
  666.                 space.add(platform.shape)
  667.                 if x[3] == 0:
  668.                     platform.image = IMAGESDICT['Health']
  669.                 if x[3] == 1:
  670.                     platform.image = IMAGESDICT['Speed']
  671.                 if x[3] == 2:
  672.                     #print 'Shield'
  673.                     platform.image = IMAGESDICT['Shield']
  674.                 self.powerups.append(platform)
  675.                 self.poweruplist.append(platform.shape)
  676.  
  677.                
  678.  
  679.     def DrawFromText(self):
  680.         pass
  681.        
  682. # The player class: represents the controllable character on screen
  683. class Playerz:
  684.    
  685.     def __init__(self, position, colour, name , health , velocity): # Constructor
  686.         #self.PlayerInfo = open(os.path.join(mypath, 'TXT Files', 'PlayerInfo.txt'), 'r')
  687.         global space, groups
  688.         #INFO = self.PlayerInfo.readlines()
  689.         self.AIrect = Rect(0,0,700, 500)
  690.         #self.newstr = INFO[0].replace("\n", "")
  691.         if name == 'init':
  692.             self.id = 1
  693.             self.name = config['Player']['name']
  694.             self.colour = int(config['Player']['color'])
  695.             self.reloadspeed = int(config['Player']['g_reload'])
  696.             self.weaponvelocity = int(config['Player']['g_speed'])
  697.             self.damage = int(config['Player']['g_dmg'])
  698.             self.cacheddamage = 700 + self.damage * 25
  699.             self.cachedvelocity = 15 + self.weaponvelocity
  700.             self.cachedreloadspeed = 1500 - self.reloadspeed * 50
  701.  
  702.             self.armor = int(config['Player']['p_armor'])
  703.             self.speed = int(config['Player']['p_speed'])
  704.             self.energy = int(config['Player']['p_energy'])
  705.             self.ability = config['Player']['ability'].capitalize()
  706.             self.cachedarmor = self.armor * 0.02
  707.             self.cachedspeed = 1 + self.speed * 0.1
  708.             self.cachedenergy = 0.1 + self.energy * 0.1
  709.  
  710.             if self.armor > 5:
  711.                 self.displayarmor = True
  712.             else:
  713.                 self.displayarmor = False
  714.             if self.speed > 5:
  715.                 self.displayshoes = True
  716.             else:
  717.                 self.displayshoes = False
  718.             if self.energy > 5:
  719.                 self.displaypack = True
  720.             else:
  721.                 self.displaypack = False
  722.         else:
  723.             self.colour = colour
  724.             self.reloadspeed = random.randint(0, 15)
  725.             self.weaponvelocity = random.randint(0, 15 - self.reloadspeed)
  726.             self.damage = random.randint(0, 15 - self.reloadspeed - self.weaponvelocity)
  727.             self.cacheddamage = 700 + self.damage * 25
  728.             self.cachedvelocity = 15 + self.weaponvelocity
  729.             self.cachedreloadspeed = 1500 - self.reloadspeed * 50
  730.  
  731.             self.armor = random.randint(0, 15)
  732.             self.speed = random.randint(0, 15 - self.armor)
  733.             self.energy = random.randint(0, 15 - self.armor - self.speed)
  734.             self.cachedarmor = 1 + self.armor * 0.02
  735.             self.cachedspeed = 1 + self.speed * 0.1
  736.             self.cachedenergy = 0.1 + self.energy * 0.1
  737.  
  738.             if self.armor > 5:
  739.                 self.displayarmor = True
  740.             else:
  741.                 self.displayarmor = False
  742.             if self.speed > 5:
  743.                 self.displayshoes = True
  744.             else:
  745.                 self.displayshoes = False
  746.             if self.energy > 5:
  747.                 self.displaypack = True
  748.             else:
  749.                 self.displaypack = False
  750.  
  751.         self.shoot = False
  752.         self.abilitystatus = False
  753.         self.a = 1
  754.         self.position = position
  755.         #self.colour = int(INFO[1])
  756.         self.health = health
  757.         self.velocity = velocity
  758.         self.rect = pygame.Rect(379 -2, 279 -2, 46, 46)
  759.         self.armor = 1
  760.         self.shielded = False
  761.         self.speedup = 1
  762.         self.speeded = False
  763.         self.inAir = False
  764.         self.gravity = 0.04
  765.         self.isOn1 = False
  766.         self.hitbox = Rect(self.position.x, self.position.y, 42, 42)
  767.         self.body = pymunk.Body(1, pymunk.inf)
  768.         self.body.position = from_pygame(self.position, DISPLAYSURF)
  769.         self.shape = pymunk.Poly(self.body, [(0,40), (40,40), (40,0), (0,0)])
  770.         self.shape.friction = 0.1
  771.         self.shape.elasticity = 0.0
  772.         self.shape.group = groups
  773.         groups += 1
  774.         #self.shape.group = 1
  775.         space.add(self.body, self.shape)
  776.         self.timer = 0
  777.         self.cachedname = 0
  778.         if name != 'Bot':
  779.             if int(self.colour) == 0:
  780.                 #self.cachedname = BRUSH.render(INFO[0].replace("\n", ""), True, (153,204,0))
  781.                 self.cachedname = textOutline(BRUSH, self.name, (153,204,0),(0,0,2))
  782.             if int(self.colour) == 1:
  783.                 #self.cachedname = BRUSH.render(INFO[0].replace("\n", ""), True, (94,165,199))
  784.                 self.cachedname = textOutline(BRUSH, self.name, (94,165,199),(0,0,2))
  785.             if int(self.colour) == 2:
  786.                 #self.cachedname = BRUSH.render(INFO[0].replace("\n", ""), True, (191,59,42))
  787.                 self.cachedname = textOutline(BRUSH, self.name, (191,59,42),(0,0,2))
  788.             if int(self.colour) == 3:
  789.                 #self.cachedname = BRUSH.render(INFO[0].replace("\n", ""), True, (255,255,0))
  790.                 self.cachedname = textOutline(BRUSH, self.name, (255,255,0),(0,0,2))
  791.  
  792.     def checkIfValid(self):
  793.         if self.reloadspeed + self.weaponvelocity + self.damage > 15:
  794.             self.reloadspeed, self.weaponvelocity, self.damage = 0
  795.         if self.armor + self.speed + self.energy > 15:
  796.             self.armor, self.speed, self.energy = 0
  797.  
  798.     def display(self):
  799.         global dtime_ms
  800.         rx = int(379)
  801.         ry = int(279)
  802.         #DISPLAYSURF.blit(PLAYERIMAGES[self.colour], (rx,ry))
  803.         pygame.draw.rect(DISPLAYSURF, black, Rect((rx - 21,ry - 12 - 15),(78, 8)))
  804.         pygame.draw.rect(DISPLAYSURF, red, Rect((rx - 18,ry - 9 - 15),(78, 6)))
  805.         if self.health > 100:
  806.             self.health = 100
  807.         pygame.draw.rect(DISPLAYSURF, green, Rect((rx - 18,ry - 9 - 15),(78*(self.health/100), 6)))
  808.         nameSize = BRUSH.size(self.name)
  809.         DISPLAYSURF.blit(self.cachedname, (rx + ((42 - nameSize[0])/2), ry - 33 - 20))
  810.         #DISPLAYSURF.blit(BRUSH.render(str(FPSCLOCK.get_fps()), True, (255,255,255)), (5, 5))
  811.         DISPLAYSURF.blit(textOutline(BRUSH, str(FPSCLOCK.get_fps()), (255,255,255),(0,0,2)), (5, 5))
  812.         #nameSize = BRUSH.size(self.name)
  813.        
  814.         pygame.draw.rect(DISPLAYSURF, black, Rect((rx - 21,ry - 12),(78, 8)))
  815.         global reloadclock
  816.         if self.timer > self.cachedreloadspeed - 1:
  817.             self.timer = self.cachedreloadspeed
  818.         float(self.timer)
  819.         self.timer += dtime_ms
  820.         timerbuffer = self.timer
  821.         if timerbuffer > self.cachedreloadspeed:
  822.             timerbuffer = self.cachedreloadspeed
  823.         pygame.draw.rect(DISPLAYSURF, yellow, Rect((rx - 18,ry - 9),(78*(float(timerbuffer/float(self.cachedreloadspeed))), 6)))
  824.        
  825.     def displayBot(self):
  826.         self.hitbox.topleft = (self.position.x + 379, self.position.y + 279)
  827.         rx = self.position.x
  828.         ry = self.position.y
  829.         #+ euclid.Vector2(379, 279)
  830.         DISPLAYSURF.blit(PLAYERIMAGES[self.colour], (rx - my_player.position.x + 379,ry - my_player.position.y + 279))
  831.         pygame.draw.rect(DISPLAYSURF, black, Rect((rx - 21 - my_player.position.x + 379,ry - 12 - 15 - my_player.position.y + 279),(78, 8)))
  832.         pygame.draw.rect(DISPLAYSURF, red, Rect((rx - 18 - my_player.position.x + 379,ry - 9 - 15 - my_player.position.y + 279),(78, 6)))
  833.         pygame.draw.rect(DISPLAYSURF, green, Rect((rx - 18 - my_player.position.x + 379,ry - 9 - 15 - my_player.position.y + 279),(78*(self.health/100), 6)))
  834.         nameSize = BRUSH.size(self.name)
  835.         DISPLAYSURF.blit(self.cachedname, (rx + ((42 - nameSize[0])/2) - my_player.position.x + 379, ry - 33 - 20 - my_player.position.y + 279))
  836.         #DISPLAYSURF.blit(BRUSH.render(str(FPSCLOCK.get_fps()), True, (255,255,255)), (5, 5))
  837.         nameSize = BRUSH.size(self.name)
  838.        
  839.         pygame.draw.rect(DISPLAYSURF, black, Rect((rx - 21 - my_player.position.x + 379,ry - 12 - my_player.position.y + 279),(78, 8)))
  840.         global reloadclock
  841.         if reloadclock > self.cachedreloadspeed - 1:
  842.             reloadclock = self.cachedreloadspeed
  843.         float(reloadclock)
  844.         pygame.draw.rect(DISPLAYSURF, yellow, Rect((rx - 18 - my_player.position.x + 379,ry - 9 - my_player.position.y + 279),(78*(float(self.timer/float(self.cachedreloadspeed))), 6)))
  845.        
  846.     def move(self):
  847.         #print self.body.position
  848.         if self.body.velocity.y > 700:
  849.             self.body.velocity.y = 700
  850.         if self.body.velocity.x > 600:
  851.             self.body.velocity.x = 600
  852.         if self.body.velocity.x < -600:
  853.             self.body.velocity.x = -600
  854.         if self.body.position.y < -my_map.lowest_y+600 - 700:
  855.             self.DieNow()
  856.             self.inAir = False
  857.         self.body.velocity.x *= 0.95
  858.  
  859.     def DieNow(self):
  860.         SOUNDSDICT['Dead'].play()
  861.         self.health = 100
  862.         spawnpoint = my_map.spawns[random.randint(0, len(my_map.spawns)-1)]
  863.         self.body.position = from_pygame(Vec2d(spawnpoint.position_x+65, spawnpoint.position_y+65), DISPLAYSURF)
  864.         self.body.velocity = (0,0)
  865.         self.armor -= 0.04
  866.         self.shielded = False
  867.         self.speeded = False
  868.  
  869. # The rocket class: represents the projectiles
  870. class Rocket:
  871.     def __init__(self, parent, a, mx, start_pos):
  872.         self.ExploBlueCopy = 0
  873.         mass = 1
  874.         radius = 18
  875.         inertia = pymunk.moment_for_circle(mass, 0, radius)
  876.         self.body = pymunk.Body(mass, inertia)
  877.         self.body.position = start_pos + (5,18)
  878.         self.oldpos = self.body.position
  879.         self.shape = pymunk.Circle(self.body, 9)
  880.         self.shape.group = parent.shape.group
  881.         space.add(self.body, self.shape)
  882.         self.parent = parent
  883.         self.a = a
  884.         self.mx = mx
  885.         if mx >= 400:
  886.             self.angle = math.atan(self.a)
  887.             print self.angle
  888.             self.body.lol = Vec2d(parent.cachedvelocity, 0)
  889.             self.body.apply_impulse((self.body.lol.rotated(self.angle)*20)+(parent.body.velocity/2))
  890.         if mx < 400:
  891.             self.angle = math.atan(self.a)
  892.             print self.angle
  893.             self.body.lol = Vec2d(-parent.cachedvelocity, 0)
  894.             self.body.apply_impulse((self.body.lol.rotated(self.angle)*20)+(parent.body.velocity/2))
  895.         #self.shape.group = 1
  896.         self.shape.sensor = True
  897.         #self.body.angle_degrees = self.angle
  898.         RocketList.append(self)
  899.  
  900.     def DisplayRocket(self):
  901.         self.body.apply_force(self.body.mass*space.gravity*-1)
  902.         if -100 < self.body.position.x - my_player.body.position.x + 379< 900 and -100 < self.body.position.y - my_player.body.position.y + 321< 700:
  903.             BULLETS[self.parent.colour].blit(DISPLAYSURF, to_pygame((self.body.position.x-my_player.body.position.x+379, self.body.position.y-my_player.body.position.y+300), DISPLAYSURF))
  904.         #self.trail = pymunk.Segment(self.body, self.oldpos, self.body.position, 16)
  905.         #self.trail.sensor = True
  906.         #pygame.draw.line(DISPLAYSURF, (255,255,255), to_pygame(self.oldpos, DISPLAYSURF), to_pygame(self.body.position, DISPLAYSURF), 6)
  907.         #self.oldpos = self.body.position
  908.         #if len(space.shape_query(self.shape)) > 1:
  909.         #print space.segment_query_first(self.oldpos, self.body.position)
  910.         #print self.body.position - self.oldpos
  911.         if space.segment_query_first(self.oldpos, self.body.position) != None or len(space.shape_query(self.shape)) > 0:
  912.             for i in space.shape_query(self.shape):
  913.                 if i in my_map.spawnlist:
  914.                     print 'spawn ignored'
  915.                 elif i in my_map.poweruplist:
  916.                     print 'pwup ignored'
  917.                 elif i not in my_map.spawnlist and i not in my_map.poweruplist:
  918.                     #print space.shape_query(self.shape)
  919.                     #print space.segment_query_first(self.oldpos, self.body.position)
  920.                     self.ExploBlueCopy = EXPLOS[self.parent.colour].getCopy()
  921.                     self.ExploBlueCopy.play()
  922.                     self.ExploBlueCopy.loop = False
  923.                     #if -100 < self.position.x - my_player.position.x < 900 and -100 < self.position.y - my_player.position.y < 700:
  924.                     ExploAnimList.append((self.ExploBlueCopy,(to_pygame(self.body.position, DISPLAYSURF))))
  925.                     SOUNDSDICT['Explosion'].play()
  926.                     #RocketList.remove(self)
  927.                     diff = my_player.body.position - self.body.position + Vec2d(5,15)
  928.                     length = diff.length
  929.                     direc = diff.normalized()
  930.                     #direc *= 10.0/length*3000
  931.                     lol = 700 - length*14 * my_player.damage/15
  932.                     if lol < 0:
  933.                         lol = 0
  934.                     direc *= lol
  935.                     #if direc.y > 700:
  936.                         #direc.y = 700
  937.                     my_player.body.apply_impulse(direc)
  938.                     if self in RocketList:
  939.                         RocketList.remove(self)
  940.         self.oldpos = self.body.position.int_tuple
  941.  
  942. def rot_center(image, angle):
  943.     """rotate an image while keeping its center and size"""
  944.     orig_rect = image.get_rect()
  945.     rot_image = pygame.transform.rotate(image, angle)
  946.     rot_rect = orig_rect.copy()
  947.     rot_rect.center = rot_image.get_rect().center
  948.     rot_image = rot_image.subsurface(rot_rect).copy()
  949.     return rot_image
  950.  
  951.     # or return tuple: (Surface, Rect)
  952.         # return rot_image, rot_image.get_rect()
  953.  
  954. def rot_center_uneven(image, rect, angle):
  955.         """rotate an image while keeping its center"""
  956.         rot_image = pygame.transform.rotate(image, angle)
  957.         rot_rect = rot_image.get_rect(center=rect.center)
  958.         return rot_image
  959.  
  960. def AnimateCursor():
  961.     global rotationCounter, scalingCounter, value
  962.     IMAGESDICT['Crosshair'] = rot_center(pygame.image.load(os.path.join(mypath, 'Images', 'Cross.png')), rotationCounter)
  963.     IMAGESDICT['Crosshair'] = pygame.transform.scale(IMAGESDICT['Crosshair'], (64-int(scalingCounter), 64-int(scalingCounter)))
  964.     DISPLAYSURF.blit(IMAGESDICT['Crosshair'], (mx-((64-int(scalingCounter))/2),my-((64-int(scalingCounter))/2)))
  965.     IMAGESDICT['Crosshair'] = IMAGESDICT['CrosshairC']
  966.     rotationCounter -= 3
  967.     if scalingCounter > 15:
  968.         value = -0.6
  969.     if scalingCounter < 1:
  970.         value = 0.6
  971.     scalingCounter += value
  972.  
  973. my_player = Playerz(euclid.Vector2(700,-300), 1, 'init', 100, euclid.Vector2(0,0))
  974.  
  975.  
  976. while my_map == None:
  977.     pygame.time.wait(1)
  978.     print 'Waiting for map'
  979.     my_map = Map(config['Map']['map'], pickle.load(open(os.path.join(mypath, 'Maps', config['Map']['map']), 'r')))
  980.     my_map.MapNameText = textOutline(BRUSH, os.path.splitext(os.path.basename(os.path.join(mypath, 'Maps', config['Map']['map'])))[0], (white),(0,0,2))
  981.  
  982. sentmsg = True
  983.  
  984. while running:  # main game loop
  985.     moving = False
  986.     mx,my = pygame.mouse.get_pos()
  987.     if my == None:
  988.         my = 301
  989.     if mx == None:
  990.         mx = 401
  991.     if my == 300:
  992.         my = 301
  993.     if mx == 400:
  994.         mx = 401
  995.        
  996.     my_player.a = float((300 - my)) / float((mx - 400))
  997.  
  998.     if leftReleased == False:
  999.         pygame.event.post(ghostleft)
  1000.         leftReleased = True
  1001.  
  1002.     if rightReleased == False:
  1003.         pygame.event.post(ghostright)
  1004.         rightReleased = True
  1005.  
  1006.     for event in pygame.event.get():
  1007.          if event.type == SONGFINISHED:
  1008.               pygame.mixer.music.load(os.path.join(mypath, 'Tracks', random.choice(os.listdir(os.path.join(mypath, 'Tracks')))))
  1009.               pygame.mixer.music.play()
  1010.               pygame.mixer.music.set_endevent(SONGFINISHED)
  1011.               pygame.mixer.music.set_volume(0.7 * MusicVolume/100)
  1012.          if event.type == USEREVENT+3:
  1013.              reloaded = True
  1014.  
  1015.          if event.type == MOUSEBUTTONDOWN and event.button == 1 and my_player.timer > my_player.cachedreloadspeed:
  1016.              my_player.shoot = True
  1017.              SOUNDSDICT['Boom'].play()
  1018.              my_player.timer = 0
  1019.              rocket = Rocket(my_player, my_player.a, mx, my_player.body.position)
  1020.              reloaded = False
  1021.  
  1022.          if event.type == MOUSEBUTTONDOWN and event.button == 3:
  1023.              my_player.abilitystatus = not my_player.abilitystatus
  1024.              if my_player.abilitystatus == True:
  1025.                  Cloak2.play()
  1026.                  Cloak2.prevFrame(Cloak2.elapsed % Cloak2.rate)
  1027.  
  1028.          if event.type == pygame.QUIT:
  1029.             sentmsg = True
  1030.             running = False
  1031.  
  1032.          if event.type == KEYDOWN and event.key == K_ESCAPE:
  1033.             sentmsg = True
  1034.             running = False
  1035.  
  1036.          if event == ghostright:
  1037.             ArrowStatus[1] = '1'
  1038.             sentmsg = True
  1039.             my_player.body.velocity += (Vec2d(my_player.cachedspeed*30,0))
  1040.             if ghostinit == 1:
  1041.                 rightReleased = False
  1042.  
  1043.          if event == ghostleft:
  1044.              ArrowStatus[0] = '1'
  1045.              sentmsg = True
  1046.              my_player.body.apply_impulse(Vec2d(-my_player.cachedspeed*30,0))
  1047.              if ghostinit == 1:
  1048.                  leftReleased = False
  1049.  
  1050.          if event.type == KEYDOWN and event.key == K_a and noLeft == False:
  1051.              if leftReleased == True:
  1052.                  if my_player.speeded == False:
  1053.                      my_player.body.apply_impulse(Vec2d(-my_player.cachedspeed*30,0))
  1054.                      ArrowStatus[0] = '1'
  1055.                      sentmsg = True
  1056.                  else:
  1057.                      my_player.body.velocity += (-my_player.cachedspeed*30-5,0)
  1058.              leftReleased = False
  1059.              
  1060.          if event.type == KEYUP and event.key == K_a:
  1061.              ArrowStatus[0] = '0'
  1062.              sentmsg = True
  1063.              leftReleased = True
  1064.  
  1065.          if event.type == KEYDOWN and event.key == K_d and noRight == False:
  1066.              if rightReleased == True:
  1067.                  if my_player.speeded == False:
  1068.                      ArrowStatus[1] = '1'
  1069.                      sentmsg = True
  1070.                      my_player.body.velocity += (my_player.cachedspeed*30,0)
  1071.                  else:
  1072.                      my_player.body.velocity += (my_player.cachedspeed*30+5,0)
  1073.              rightReleased = False
  1074.  
  1075.          if event.type == KEYUP and event.key == K_d:
  1076.              ArrowStatus[1] = '0'
  1077.              sentmsg = True
  1078.              rightReleased = True
  1079.  
  1080.          if event.type == KEYDOWN and event.key == K_w and 0 <= my_player.body.velocity.y <= 0.01: #and my_player.inAir == False:
  1081.              pygame.key.set_repeat()
  1082.              my_player.body.velocity += (0,600)
  1083.              ArrowStatus[2] = '1'
  1084.              sentmsg = True
  1085.              pygame.key.set_repeat(2, 8)
  1086.              SOUNDSDICT['Jump'].play()
  1087.  
  1088.     reloadclock += FPSCLOCK.get_time()
  1089.  
  1090.     dtime_ms = FPSCLOCK.tick(50)
  1091.     dtime = dtime_ms/1000
  1092.     dfps = 50/(FPSCLOCK.get_fps() + 0.001)
  1093.     if dfps > 2:
  1094.         dfps = 2
  1095.  
  1096.     m = 0
  1097.     while m <= 800 // bckgroundwidth + 1:
  1098.         DISPLAYSURF.blit(IMAGESDICT['Background'], ((m)*bckgroundwidth - (my_player.body.position.x/3)%bckgroundwidth,0))
  1099.         m += 1
  1100.  
  1101.  
  1102.  
  1103.     my_player.move() # Update the player's position and velocity
  1104.     #
  1105.     #for clientplayer in otherplayers:
  1106.     #    DISPLAYSURF.blit(PLAYERIMAGES[clientplayer.colour], (clientplayer.position - my_player.position + euclid.Vector2(379, 279)))
  1107.  
  1108.     for s in my_map.powerups:
  1109.         if s.mode == 2:
  1110.             sx, sy = s.position_x + 51, s.position_y + 51
  1111.             if -300 < sx - my_player.body.position.x < 900 and -100 < sy - my_player.body.position.y < 700:
  1112.                 Shield.blit(DISPLAYSURF, (sx - my_player.body.position.x, sy - my_player.body.position.y))
  1113.             shieldcoll = pygame.Rect(sx - my_player.body.position.x - 16, sy - my_player.body.position.y - 16, 32, 32)
  1114.             if shieldcoll.colliderect(my_player.rect) and my_player.shielded == False:
  1115.                 SOUNDSDICT['Powa'].play()
  1116.                 my_map.Shields.remove(s)
  1117.                 pygame.time.set_timer(USEREVENT+6, 60000)
  1118.                 my_map.PowerTimes.append((int(pygame.time.get_ticks()) + 60000, 'D'))
  1119.                 my_player.cachedarmor += 0.4
  1120.                 my_player.shielded = True
  1121.         elif s.mode == 1:
  1122.             sx, sy = s.position_x + 51, s.position_y + 51
  1123.             if -300 < sx - my_player.body.position.x < 900 and -100 < sy - my_player.body.position.y < 700:
  1124.                 Speed.blit(DISPLAYSURF, (sx - my_player.body.position.x, sy - my_player.body.position.y))
  1125.             #DISPLAYSURF.blit(IMAGESDICT['Speed'], (sx - my_player.position.x, sy - my_player.position.y))
  1126.             speedcoll = pygame.Rect(sx - my_player.body.position.x - 16, sy - my_player.body.position.y - 16, 32, 32)
  1127.             if speedcoll.colliderect(my_player.rect) and my_player.speeded == False:
  1128.                 SOUNDSDICT['Powa'].play()
  1129.                 my_map.Speeds.remove(s)
  1130.                 pygame.time.set_timer(USEREVENT+7, 60000)
  1131.                 my_map.PowerTimes.append((int(pygame.time.get_ticks()) + 60000, 'S'))
  1132.                 my_player.speedup = 2
  1133.                 my_player.speeded = True
  1134.            
  1135.         elif s.mode == 0:
  1136.             sx, sy = s.position_x + 51, s.position_y + 51
  1137.             px, py = to_pygame(my_player.body.position, DISPLAYSURF)
  1138.             #DISPLAYSURF.blit(IMAGESDICT['Health'], (sx - my_player.position.x, sy - my_player.position.y))
  1139.             #if -300 < sx - my_player.body.position.x < 900 and -100 < sy - my_player.body.position.y < 700:
  1140.             Health.blit(DISPLAYSURF, (sx - px + 400, sy - py + 351))
  1141.             #s.image.blit(DISPLAYSURF, (sx - px + 400, sy - py + 351))
  1142.             #healthcoll = pygame.Rect(sx - my_player.body.position.x - 16, sy - my_player.body.position.y - 16, 32, 32)
  1143.             #if healthcoll.colliderect(my_player.rect) and my_player.health != 100:
  1144.             #    SOUNDSDICT['Powa'].play()
  1145.             #    my_map.Healths.remove(s)
  1146.             #    my_map.PowerTimes.append((int(pygame.time.get_ticks()) + 60000, 'H'))
  1147.             #    pygame.time.set_timer(21, 60000)
  1148.             #    if my_player.health <= 75:
  1149.             #        my_player.health += 25
  1150.             #    else:
  1151.             #        my_player.health = 100
  1152.                
  1153.     for x in my_map.PowerTimes:
  1154.         time, power = x
  1155.         if time < int(pygame.time.get_ticks()):
  1156.             if power == 'D':
  1157.                 my_map.Shields.append(my_map.DeletedPowerD[0])
  1158.                 my_player.cachedarmor -= 0.4
  1159.                 my_player.shielded = False
  1160.                 my_map.PowerTimes.remove(x)
  1161.             if power == 'S':
  1162.                 my_map.Speeds.append(my_map.DeletedPowerS[0])
  1163.                 my_player.speedup = 1
  1164.                 my_player.speeded = False
  1165.                 my_map.PowerTimes.remove(x)
  1166.             if power == 'H':
  1167.                 my_map.Healths.append(my_map.DeletedPowerH[0])
  1168.                 my_map.PowerTimes.remove(x)
  1169.                
  1170.  
  1171.     if my_player.abilitystatus == True:
  1172.         halfheight = ABILITYDICT[my_player.ability].getRect().height/2
  1173.         if my_player.ability != 'Cloak':
  1174.             ABILITYDICT[my_player.ability].blit(DISPLAYSURF, (379 - halfheight + 21, 279 - halfheight + 21))
  1175.         else:
  1176.             ABILITYDICT[my_player.ability].blit(DISPLAYSURF, (379 - halfheight + 21, 279 - halfheight + 21))
  1177.         #halfheight = Cloak2.getRect().height/2
  1178.         #Cloak2.blit(DISPLAYSURF, (379 - halfheight + 21, 279 - halfheight + 21))
  1179.         #
  1180.         ##x,y = coord
  1181.         #Explo, coord = anim
  1182.         #x, y = coord
  1183.         ##Explo.play
  1184.         #Explo.blit(DISPLAYSURF, (x - my_player.position.x - 110, y - my_player.position.y - 125))
  1185.         #if Explo.isFinished() == True:
  1186.         #      ExploAnimList.remove(anim)
  1187.  
  1188.     for platform in my_map.platforms:
  1189.         plx, ply = to_pygame(platform.body.position, DISPLAYSURF)
  1190.         lolx, loly = to_pygame(my_player.body.position, DISPLAYSURF)
  1191.         if -300 < platform.position_x - (lolx) + 379 < 900 and -100 < platform.position_y - loly + 321 < 700:
  1192.             if platform.type == 1:
  1193.                 DISPLAYSURF.blit(platform.image, (plx - (lolx) + 379, ply - loly + 318))
  1194.             else:
  1195.                 DISPLAYSURF.blit(platform.image, (plx - (lolx) + 379, ply - loly + 321))
  1196.  
  1197.     for platform in my_map.movingplatforms:
  1198.         #px = platform.lx * math.sin(platform.sx * platform.xxx + platform.ox)
  1199.         #py = platform.ly * math.sin(platform.sy * platform.yyy + platform.oy)
  1200.         #platform.body.velocity = Vec2d(px, -py)
  1201.         #platform.body.apply_force(platform.body.mass*space.gravity*-1)
  1202.         oldpos = platform.body.position
  1203.         platform.body.position.x += platform.lx * math.sin(platform.sx * platform.xxx + platform.ox) #* dfps
  1204.         platform.body.position.y -= platform.ly * math.sin(platform.sy * platform.yyy + platform.oy)
  1205.         platform.body.velocity = platform.body.position - oldpos
  1206.         #py = platform.ly * math.sin(platform.sy * platform.yyy + platform.oy)
  1207.         #platform.body.position.y += platform.yyy / 1000
  1208.         #platform.body.velocity = Vec2d(0, platform.yyy / 1000)
  1209.         #platform.body.position.x += 0
  1210.         #platform.body.apply_impulse(Vec2d(0, platform.yyy / 1000))
  1211.         #platform.body.apply_impulse(Vec2d(platform.lx * math.sin(platform.sx * platform.xxx + platform.ox), - platform.ly * math.sin(platform.sy * platform.yyy + platform.oy)))
  1212.         #platform.body.apply_impulse = Vec2d(platform.lx * math.sin(platform.sx * platform.xxx + platform.ox), platform.ly * math.sin(platform.sy * platform.yyy + platform.oy))
  1213.         platform.yyy += 1
  1214.         platform.xxx += 1
  1215.        
  1216.         #platform.body.apply_impulse(platform.body.mass*space.gravity*-1)
  1217.         #space.reindex_static()
  1218.  
  1219.     #pygame.draw.rect(DISPLAYSURF, black, Rect(0 - lolx,0 - loly - 500,my_map.max_limit_x, my_map.max_limit_y + 773 + 50), 5)
  1220.  
  1221.     ##PyIgnition particle effects
  1222.     #source.SetPos(pygame.mouse.get_pos())
  1223.     #if source.curframe % 50 == 0:
  1224.     #    source.ConsolidateKeyframes()
  1225.     #fire.Update()
  1226.     #fire.Redraw()
  1227.  
  1228.     my_player.display() # Display the player
  1229.    
  1230.    
  1231.     if mx <= 400 and ArrowStatus[0] == '1' and ArrowStatus[1] == '0' and my_player.body.velocity.y <= 0.1:
  1232.         #ScientistLeft.blit(DISPLAYSURF, (379,279))
  1233.         #ScientistLeftRev.blit(DISPLAYSURF, (379,279))
  1234.         if my_player.displaypack == True:
  1235.             DISPLAYSURF.blit(IMAGESDICT['PackLeft'], (395,272))
  1236.         PLAYERANIMS[my_player.colour]['Left'].blit(DISPLAYSURF, (379,279))
  1237.         #if my_player.displayshoes == True:
  1238.         #    SpeedAnimLeft.blit(DISPLAYSURF, (381,279))
  1239.         #if my_player.displayshoes == True:
  1240.         #    ArmorAnimLeft.blit(DISPLAYSURF, (383,279))
  1241.        
  1242.     if mx > 400 and ArrowStatus[1] == '1' and ArrowStatus[0] == '0' and my_player.body.velocity.y <= 0.1:
  1243.         #ScientistRight.blit(DISPLAYSURF, (379,279))
  1244.         if my_player.displaypack == True:
  1245.             DISPLAYSURF.blit(IMAGESDICT['PackRight'], (373,272))
  1246.         PLAYERANIMS[my_player.colour]['Right'].blit(DISPLAYSURF, (379,279))
  1247.         #if my_player.displayarmor == True:
  1248.         #    ArmorAnimRight.blit(DISPLAYSURF, (379,279))
  1249.        
  1250.     if mx <= 400 and ArrowStatus[0] == '0' and ArrowStatus[1] == '1' and my_player.body.velocity.y <= 0.1:
  1251.         #ScientistLeft.reverse()
  1252.         #ScientistLeftRev.blit(DISPLAYSURF, (379,279))
  1253.         if my_player.displaypack == True:
  1254.             DISPLAYSURF.blit(IMAGESDICT['PackLeft'], (395,272))
  1255.         PLAYERANIMS[my_player.colour]['LeftRev'].blit(DISPLAYSURF, (379,279))
  1256.         #if my_player.displayarmor == True:
  1257.         #    ArmorAnimLeft.blit(DISPLAYSURF, (383,279))
  1258.        
  1259.     if mx > 400 and ArrowStatus[1] == '0' and ArrowStatus[0] == '1' and my_player.body.velocity.y <= 0.1:
  1260.         #ScientistRight.reverse()
  1261.         #ScientistRightRev.blit(DISPLAYSURF, (379,279))
  1262.         if my_player.displaypack == True:
  1263.             DISPLAYSURF.blit(IMAGESDICT['PackRight'], (373,272))
  1264.         PLAYERANIMS[my_player.colour]['RightRev'].blit(DISPLAYSURF, (379,279))
  1265.         #if my_player.displayarmor == True:
  1266.         #    ArmorAnimRight.blit(DISPLAYSURF, (379,279))
  1267.        
  1268.     if (my_player.body.velocity.y >= 1 and my_player.body.velocity!=0) or (ArrowStatus[0] == '0' and ArrowStatus[1] == '0') or (ArrowStatus[0] == '1' and ArrowStatus[1] == '1'):
  1269.         if mx <= 400:
  1270.               if my_player.displaypack == True:
  1271.                   DISPLAYSURF.blit(IMAGESDICT['PackLeft'], (395,272))
  1272.               DISPLAYSURF.blit(PLAYERANIMS[my_player.colour]['LeftImmo'], (379,279))
  1273.               #if my_player.displayarmor == True:
  1274.               #    DISPLAYSURF.blit(IMAGESDICT['ArmorLeft'], (385,279))
  1275.               #if my_player.displayshoes == True:
  1276.                   #DISPLAYSURF.blit(IMAGESDICT['SpeedLeft'], (381,308))
  1277.               #PLAYERANIMS[my_player.colour]['LeftImmo'].blit(DISPLAYSURF, (379,279))
  1278.               #ScientistLeft.blitFrameNum(0, DISPLAYSURF, (379,279))
  1279.         if mx > 400:
  1280.               if my_player.displaypack == True:
  1281.                   DISPLAYSURF.blit(IMAGESDICT['PackRight'], (373,272))
  1282.               DISPLAYSURF.blit(PLAYERANIMS[my_player.colour]['RightImmo'], (379,279))
  1283.               #if my_player.displayarmor == True:
  1284.               #    DISPLAYSURF.blit(IMAGESDICT['ArmorRight'], (382,279))
  1285.               #if my_player.displayshoes == True:
  1286.                   #DISPLAYSURF.blit(IMAGESDICT['SpeedRight'], (379,308))
  1287.               #PLAYERANIMS[my_player.colour]['RightImmo'].blit(DISPLAYSURF, (379,279))
  1288.               #ScientistRight.blitFrameNum(10, DISPLAYSURF, (379,279))
  1289.  
  1290.     if mx <= 400:
  1291.         #DISPLAYSURF.blit(ScientistLeftImmo, (379,279))
  1292.         #ScientistLeft.blitFrameNum(0, DISPLAYSURF, (379,279))
  1293.         Gun2 = rot_center(GunReverse, math.degrees(math.atan(float((300 - my)) / float((mx - 400)))))
  1294.         if my_player.displayarmor == True:
  1295.             DISPLAYSURF.blit(IMAGESDICT['ArmorLeft'], (385,279))
  1296.         DISPLAYSURF.blit(Gun2, (379,285))
  1297.  
  1298.     if mx > 400:
  1299.         Gun2 = rot_center(Gun, math.degrees(math.atan(float((300 - my)) / float((mx - 400)))))
  1300.         if my_player.displayarmor == True:
  1301.             DISPLAYSURF.blit(IMAGESDICT['ArmorRight'], (382,279))
  1302.         #Gun2 = pygame.transform.rotate(Gun, math.degrees(math.atan(float((300 - my)) / float((mx - 400)))))
  1303.         DISPLAYSURF.blit(Gun2, (379,285))
  1304.         #ScientistRight.blitFrameNum(10, DISPLAYSURF, (379,279))
  1305.  
  1306.     for anim in ExploAnimList:
  1307.         #x,y = coord
  1308.         Explo, coord = anim
  1309.         x, y = coord
  1310.         Explo.loop = False
  1311.         #Explo.play
  1312.         Explo.blit(DISPLAYSURF, (Vec2d(x,y) - to_pygame(my_player.body.position, DISPLAYSURF) - Vec2d(125, 125) + Vec2d(400, 300)))
  1313.         if Explo.isFinished() == True:
  1314.               ExploAnimList.remove(anim)
  1315.  
  1316.     for rocket in RocketList:
  1317.         rocket.DisplayRocket()
  1318.  
  1319.     Crosshairs.blit(DISPLAYSURF, (mx -50, my - 50))
  1320.     rocket = 0
  1321.     ghostinit = 1
  1322.     #for rocket in RocketList:
  1323.     #    rocket.UpdateAll(my_player)
  1324.                
  1325.     if my_player.health < 1:
  1326.         my_player.DieNow()
  1327.  
  1328.     my_player.shoot = False
  1329.     space.step(1/50.0)
  1330.     #draw_space(DISPLAYSURF, space)
  1331.     for rocket in RocketList:
  1332.         rocket.body.reset_forces()
  1333.     #for platform in my_map.movingplatforms:
  1334.     #    platform.body.reset_forces()
  1335.     DISPLAYSURF.blit(my_map.MapNameText, (200, 5))
  1336.     pygame.display.update() # Display all to the screen (yay!)
  1337.     #draw_space(DISPLAYSURF, space)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement