Advertisement
Guest User

Untitled

a guest
Sep 27th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.61 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import pygame
  4. from pygame.locals import *
  5.  
  6. import pygcurse
  7.  
  8. #GAME MODES
  9. game_modes = ['tiro',
  10.                 'rookie',
  11.                 'amateur',
  12.                 'professional',
  13.                 'maestro',
  14.                 'Grand Master']
  15. game_modes = enumerate(game_modes)
  16.  
  17. #Title of Game.
  18. TITLE = "Knights Templar: Resurgence"
  19.  
  20. #Game Screen Size
  21. SIZE = 1920, 1080
  22. #Speed of Characters
  23. SPEED = 2
  24. RUN = SPEED * 3
  25.  
  26.  
  27. #Origin of cartesian
  28. ORIGIN = 0, 0
  29. #Tile Size
  30. TILE = 64
  31. TEAL = pygame.Color(0, 255, 255)
  32. WHITE = pygame.Color(255, 255, 255)
  33.  
  34. def init():
  35.     #Make a screen object
  36.  
  37.     pygame.init()
  38.     screen = pygame.display.set_mode((1920, 1080))
  39.     templar = TemplarSystem(screen)
  40.  
  41.  
  42.  
  43.  
  44. class Screen(object):
  45.     def __init__(self, size=(1920, 1080), ):
  46.         try:pygame.display.init()
  47.         except pygame.error as e:
  48.             print "This message came back as an error: ", (e.message)
  49.  
  50.         self.screen = pygame.display.set_mode(SIZE)
  51.  
  52. class TileSystem(object):
  53.     """
  54.    This is the tile system. Tiles will be 64, 64 and will,
  55.    if toggled, display over the screen.
  56.  
  57.  
  58.  
  59.    """
  60.     tile_representation = pygame.Surface((TILE, TILE))
  61.     tile_representation_color = TEAL
  62.     mos_hover_boolean = False
  63.  
  64.     def __init__(self, screen):
  65.         self.tile = []
  66.         self.screen = screen
  67.         column = self.column = SIZE[0] / TILE
  68.         row = self.row = SIZE[1] / TILE
  69.         self.amount_of_tiles = column * row
  70.         self.make_tiles()
  71.         self.arrange_tile()
  72.         self.raw_tile = TileSystem.tile_representation
  73.         self.tile_representation_color = TileSystem.tile_representation_color
  74.  
  75.     def make_tiles(self, ):
  76.         self.tile_rect = pygame.Rect(ORIGIN, [TILE for x in xrange(2)])
  77.         for i in range(self.amount_of_tiles):
  78.             self.tile.append(pygame.Rect(ORIGIN, [TILE for x in xrange(2)]))
  79.  
  80.     def draw_to_screen(self, ):
  81.         self.column_list = [x*TILE for x in range((SIZE[0])/TILE)]
  82.         self.row_list = [x*TILE for x in range((SIZE[1]+64)/TILE)]
  83.         hover_counter = 0
  84.         #column means the amount of 64 by 1080 columns
  85.         #row means the amount of 1920 by 64 rows
  86.         #The next two lines mean it blits by vertically down first...
  87.         for row in range(self.row_list.__len__()):
  88.             for column in range(self.column_list.__len__()):
  89.                 if TileSystem.mos_hover_boolean:
  90.                     if (self.column_list[column], self.row_list[row]) == self.marked_tile.topleft:
  91.                         new_surface = pygame.Surface((TILE, TILE), 0)
  92.                         new_surface.fill(TEAL)
  93.                         self.screen.blit(new_surface, (self.column_list[column], self.row_list[row]))
  94.                         hover_counter += 1
  95.                         del self.marked_tile
  96.                         TileSystem.mos_hover_boolean = False
  97.                         continue
  98.                 self.raw_tile.fill(WHITE)
  99.                 self.screen.blit(self.raw_tile,(self.column_list[column], self.row_list[row]))
  100.                 hover_counter += 1
  101.  
  102.     def arrange_tiles(self, ):
  103.         max_row = self.row
  104.         max_column = self.column
  105.         i_again = 0
  106.         for i in range(self.amount_of_tiles):
  107.             if i < max_column:
  108.                 if i < max_row:
  109.                     if i == max_row - 1:
  110.                         max_y = i * TILE
  111.                     self.tile[i].topleft = (TILE*i, TILE*i)
  112.                     continue
  113.                 self.tile[i].topleft = (TILE*i, max_y)
  114.  
  115.     def arrange_tile(self, ):
  116.         i = 0
  117.         print self.amount_of_tiles,
  118.         print self.column,
  119.         print self.row,
  120.         for row in range(self.column):
  121.             for column in range(self.row):
  122.                 self.tile[i].topleft = (64*row, 64*column)
  123.                 i += 1
  124.         #for i in range(self.amount_of_tiles):
  125.             #print self.tile[i],
  126.  
  127.  
  128.     def mos_hover_tile(self, mos_pos):
  129.         for i in range(self.amount_of_tiles):
  130.             if self.tile[i].collidepoint(mos_pos):
  131.                 self.marked_tile = pygame.Rect(self.tile[i])
  132.                 self.marked_tile_again = i
  133.                 TileSystem.mos_hover_boolean = True
  134.  
  135.  
  136. class Unit(pygame.sprite.Sprite):
  137.     def __init__(self, color, size, ai=None ):
  138.         pygame.sprite.Sprite.__init__(self)
  139.  
  140.         self.image = pygame.Surface(size)
  141.         self.image.fill(color)
  142.  
  143.         self.rect = self.image.get_rect()
  144.  
  145. class Enemy(Unit):
  146.     def __init__(self, ):
  147.         pass
  148.  
  149.  
  150. class NPC(Unit):
  151.     pass
  152.  
  153.  
  154. class Friendly(Unit):
  155.     pass
  156.  
  157. class UnitSystem(object):
  158.     pass
  159.  
  160. class AssetSystem(object):
  161.     pass
  162.  
  163. class TemplarSystem(object):
  164.     Units = UnitSystem()
  165.     Assets = AssetSystem()
  166.     def __init__(self,screen, enemies=None, npcs=None, friendlies=None):
  167.         self.screen = screen
  168.         self.tile_system = TileSystem(self.screen)
  169.         self.gameloop()
  170.  
  171.     def cleanup(self, ):
  172.         del self
  173.         pygame.quit()
  174.     def gameloop(self,):
  175.         ActiveLoop = True
  176.         while ActiveLoop:
  177.             self.screen.fill(WHITE)
  178.             self.tile_system.mos_hover_tile(pygame.mouse.get_pos())
  179.             for event in pygame.event.get():
  180.                 if event.type == QUIT or (event.type == KEYUP and event.key \
  181.                         == K_q):
  182.                     ActiveLoop = False
  183.             self.tile_system.draw_to_screen()
  184.             pygame.display.update()
  185.         self.cleanup()
  186.  
  187. class ArtificialIntelligence(object):
  188.     def __init__(self, ):
  189.         pass
  190.     pass
  191.  
  192. if __name__ == '__main__':
  193.     init()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement