Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys, os, time, random, pygame, math, socket
- from pygame.locals import *
- from load_image import load_image
- pygame.init()
- # This is to replace the gmk "all" and also to update everything.
- global globalGameObjectList
- globalGameObjectList = []
- # All drawing should be done on the globalSurface object
- global globalWindow, globalScreen
- globalWindow = pygame.display.set_mode((1280, 1024))
- globalSurface = pygame.display.get_surface()
- global globalXview, globalYview, globalWview, globalHview
- globalXview, globalYview = 0, 0
- globalWview = 800
- globalHview = 600
- class GameObject(pygame.sprite.Sprite):
- def __init__(self, xpos, ypos):
- pygame.sprite.Sprite.__init__(self)
- self.x = xpos
- self.y = ypos
- self.hspeed = 0
- self.vspeed = 0
- self.sprite = 0
- globalGameObjectList.append(self)
- def BeginStep(self):
- pass
- def Step(self):
- pass
- def EndStep(self):
- self.x += self.hspeed
- self.y += self.vspeed
- def Draw(self):
- globalSurface.blit(self.sprite, (self.rect.topleft[0]-globalXview, self.rect.topleft[1]-globalYview))
- class MapObject(GameObject):
- def __init__(self):
- GameObject.__init__(self, 0, 0)
- self.sprite, self.rect = load_image('Sprites/Maps/MapTesting2.png')
- class Character(GameObject):
- def __init__(self):
- GameObject.__init__(self, 200, 200)
- self.sprite, self.rect = load_image('Sprites/Characters/Scout/Red/ScoutRedS_fr1.png')
- self.rect.center = (self.x, self.y)
- def Step(self):
- self.y += 2
- self.rect.center = (self.x, self.y)
- gameMap = MapObject()
- global globalMyself
- globalMyself = Character()
- while True:
- print globalXview
- for a in range(len(globalGameObjectList)):
- globalGameObjectList[a].BeginStep()
- for a in range(len(globalGameObjectList)):
- globalGameObjectList[a].Step()
- for a in range(len(globalGameObjectList)):
- globalGameObjectList[a].EndStep()
- globalXview = globalMyself.x-globalWview/2
- globalYview = globalMyself.y-globalHview/2
- globalSurface.fill((255, 255, 255))
- for a in range(len(globalGameObjectList)):
- globalGameObjectList[a].Draw()
- pygame.display.flip()
Add Comment
Please, Sign In to add comment