From: Harishankar Date: Sat, 1 Oct 2011 17:03:21 +0000 (+0530) Subject: Completed scrolling in tile picker for level editor X-Git-Url: https://harishankar.org/repos/?a=commitdiff_plain;h=e233a6fc3203883436813db4a7a76242d77b6483;p=butaba-adventures.git Completed scrolling in tile picker for level editor Bit the bullet (phew!) and completed the logic for scrolling through a tileset that is larger than the 480*480 view. This logic is quite tricky so I documented it in readable English --- diff --git a/level.py b/level.py index 8224332..4ba77a9 100644 --- a/level.py +++ b/level.py @@ -14,34 +14,6 @@ import object KEY_CHEST1 = 1000 KEY_ROOM1 = 1001 -# start level background data -LEVEL_1 = [ - [ (0, 0, 0), (1, 0, 0), (0, 5, 1), (0, 6, 1), (1, 0, 0), (0, 0, 0), (1, 0, 0), (1, 0, 0), (0, 0, 0), (1, 0, 0) ], - [ (0, 0, 0), (0, 0, 0), (1, 5, 1), (1, 6, 1), (0, 0, 0), (3, 8, 1), (0, 7, 1), (0, 7, 1), (0, 7, 1), (0, 7, 1) ], - [ (0, 0, 0), (0, 0, 0), (0, 0, 0), (2, 0, 1), (1, 0, 0), (0, 8, 1), (3,10, 0), (3,10, 0), (3,10, 0), (3,10, 0) ], - [ (2, 0, 1), (2, 0, 1), (2, 0, 1), (2, 0, 1), (0, 0, 0), (1, 9, 1), (3,10, 0), (3,10, 0), (3,10, 0), (3,10, 0) ], - [ (4, 5, 0), (4, 5, 0), (4, 5, 0), (4, 5, 0), (4, 5, 0), (3,10, 0), (3,10, 0), (3,10, 0), (3,10, 0), (3,10, 0) ], - [ (5, 5, 0), (5, 5, 0), (5, 5, 0), (5, 5, 0), (5, 5, 0), (3,10, 0), (3,10, 0), (3,10, 0), (3,10, 0), (3,10, 0) ], - [ (2, 0, 1), (2, 0, 1), (2, 0, 1), (2, 0, 1), (1, 0, 0), (0, 9, 1), (3,10, 0), (3,10, 0), (3,10, 0), (3,10, 0) ], - [ (0, 0, 0), (0, 0, 0), (0, 0, 0), (2, 0, 1), (1, 0, 0), (1,11, 1), (3,10, 0), (3,10, 0), (3,10, 0), (3,10, 0) ], - [ (0, 0, 0), (0, 0, 0), (0, 5, 1), (0, 6, 1), (0, 0, 0), (0,10, 1), (0, 7, 1), (0, 7, 1), (1,10, 1), (0, 7, 1) ], - [ (1, 0, 0), (0, 0, 0), (1, 5, 1), (1, 6, 1), (1, 0, 0), (0, 0, 0), (0, 0, 0), (1, 0, 0), (0, 0, 0), (1, 0, 0) ] -] - -# level to the east of start level background data -LEVEL_1E = [ - [ (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (1, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0) ], - [ (0, 7, 1), (0, 7, 1), (0, 7, 1), (0, 7, 1), (0, 7, 1), (0, 7, 1), (3, 9, 1), (0, 0, 0), (0, 0, 0), (2, 0, 1) ], - [ (3,10, 0), (3,10, 0), (3,10, 0), (3,10, 0), (3,10, 0), (3,10, 0), (0, 8, 1), (0, 0, 0), (0, 0, 0), (0, 0, 0) ], - [ (0, 9, 1), (3,10, 0), (3,10, 0), (3,10, 0), (3,10, 0), (3,10, 0), (0, 8, 1), (0, 0, 0), (3, 6, 0), (3, 5, 0) ], - [ (0, 8, 1), (3,10, 0), (6, 2, 1), (6, 3, 1), (3,10, 0), (3,10, 0), (0, 8, 1), (0, 0, 0), (3, 5, 0), (3, 6, 0) ], - [ (0, 8, 1), (3,10, 0), (7, 2, 0), (7, 3, 0), (3,10, 0), (3,10, 0), (0, 8, 1), (0, 0, 0), (3, 6, 0), (3, 5, 0) ], - [ (0, 8, 1), (3,10, 0), (3,10, 0), (3,10, 0), (3,10, 0), (3,10, 0), (0, 8, 1), (0, 0, 0), (3, 5, 0), (3, 6, 0) ], - [ (0, 8, 1), (3,10, 0), (3,10, 0), (3,10, 0), (3,10, 0), (3,10, 0), (0, 8, 1), (0, 0, 0), (0, 0, 0), (0, 0, 0) ], - [ (3, 7, 1), (0 ,7, 1), (0, 7, 1), (0, 7, 1), (0, 7, 1), (1,10, 1), (0,11, 1), (0, 0, 0), (0, 0, 0), (2, 0, 1) ], - [ (0, 0, 0), (0, 0, 0), (1, 0, 0), (3, 4, 0), (0, 0, 0), (0, 0, 0), (1, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0) ] -] - # Class to represent levels class Level: def __init__ (self, bgdata, levelleft=None, levelright=None, leveltop = None, levelbottom = None, objects=[]): diff --git a/leveleditor.py b/leveleditor.py index 5b98c09..1fe96e1 100755 --- a/leveleditor.py +++ b/leveleditor.py @@ -25,7 +25,7 @@ def draw_level (screen, leveldata, tileset): j += 1 i += 1 -def display_menu (screen): +def display_menu (screen, tileset, tilerow, tilecol): utility.put_text (screen, 490, 10, 10, (255,255,0), "p to pick tile") utility.put_text (screen, 490, 50, 10, (255,255,0), "w to wall (solid)") utility.put_text (screen, 490, 90, 10, (255,255,0), " to place") @@ -33,6 +33,10 @@ def display_menu (screen): utility.put_text (screen, 490, 170, 10, (255,255,0), "s to Save level") utility.put_text (screen, 490, 210, 10, (255,255,0), "q to Quit editor") + # currently selected tile + utility.put_text (screen, 490, 250, 10, (255,255,255), "Tile selected") + screen.blit (tileset, (490, 290), (tilecol*48, tilerow*48, 48, 48)) + # draw the tile cursor def draw_cursor (screen, currow, curcol): pygame.draw.rect (screen, (255,255,255), (curcol*48, currow*48, 48, 48), 1) @@ -51,13 +55,57 @@ def put_tile (leveldata, row, col, tilerow, tilecol): def pick_tile (screen, tileset): selrow, selcol = 0, 0 + # total number of rows and columns totalrows = tileset.get_height () / 48 totalcols = tileset.get_width () / 48 + # implement scrolling by 480x480 + # first get the number of pages to span across. If the width is + # exactly fitting in the page use totalwidth/480 else totalwidth/480+1 + # (integer divison) + if tileset.get_width () % 480 == 0: + totalpages_cols = tileset.get_width () / 480 + else: + totalpages_cols = tileset.get_width () / 480 + 1 + + if tileset.get_height () % 480 == 0: + totalpages_rows = tileset.get_height () / 480 + else: + totalpages_rows = tileset.get_height () / 480 + 1 + + # set the current page + curpage_cols = 0 + curpage_rows = 0 + + # cursor row and column + cursor_row = 0 + cursor_col = 0 + + # the code for scrolling through the tileset is quite complicated here are the steps + # first we determine the total number of pages (number of row pages and col pages + # then when scrolling we check for two things: + # first horizontal scrolling: + # logic goes like this + # left arrow key movement: + # is the cursor col < 0 ? if so, is it the first page? if so, then set the + # cursor col to the last col of the last page. This unfortunately is not so easy + # because it need not be 10. So we determine the last col as follows: + # total width of the tileset image modulo 480 = this gives us a multiple of 48 + # since we are using 48x48 tiles and the tileset file size is a multiple of 48. + # then we divide that value by 48 which gives us a number between 0 and 9. + # this is the last col. If it is not the first page, we simply set the cursor + # column to 9 and reduce the page by 1. + # right arrow movement: + # simply if it is the last col and last page we simply reset the + # page to 0 and the cursor col to 0. Otherwise page is incremented by 1 + # and col is still set to 0. simple logic + + # vertical scrolling using the same logic + while 1: screen.fill (pygame.Color (0, 0, 0)) - screen.blit (tileset, (0, 0)) - draw_cursor (screen, selrow, selcol) + screen.blit (tileset, (0, 0), (curpage_cols * 480, curpage_rows * 480, 480, 480)) + draw_cursor (screen, cursor_row, cursor_col) pygame.display.update () for event in pygame.event.get (): if event.type == pygame.KEYDOWN: @@ -66,22 +114,83 @@ def pick_tile (screen, tileset): elif event.key == pygame.K_SPACE or event.key == pygame.K_RETURN: return selrow, selcol elif event.key == pygame.K_UP: + # reduce the selected row by 1 selrow -= 1 if selrow < 0: selrow = totalrows - 1 + + # reduce the cursor row by 1 + cursor_row -= 1 + # if cursor row is < 0 + if cursor_row < 0: + # reduce the page by 1 + curpage_rows -= 1 + if curpage_rows < 0: + curpage_rows = totalpages_rows - 1 + if tileset.get_height () % 480 > 0 : + # cursor row should be the last row - this is + cursor_row = (tileset.get_height () % 480) / 48 - 1 + else: + cursor_row = 9 + else: + cursor_row = 9 + elif event.key == pygame.K_DOWN: + # increase the selected row by 1 selrow += 1 if selrow >= totalrows: selrow = 0 + + # increase the cursor row by 1 + cursor_row += 1 + # if cursor row is > 9 + if ((tileset.get_height () % 480 > 0 and curpage_rows >= totalpages_rows - 1 and cursor_row >= (tileset.get_height () % 480) / 48) + or cursor_row >= 10): + # increase the page by 1 + curpage_rows += 1 + # if the pages rows is >= totalpages_rows + if curpage_rows >= totalpages_rows: + curpage_rows = 0 + cursor_row = 0 + else: + cursor_row = 0 + elif event.key == pygame.K_LEFT: + # decrease the selected col by 1 selcol -= 1 if selcol < 0: selcol = totalcols - 1 + + # decrease the cursor col by 1 + cursor_col -= 1 + # if cursor col < 0 + if cursor_col < 0: + curpage_cols -= 1 + if curpage_cols < 0: + curpage_cols = totalpages_cols - 1 + if tileset.get_width () % 480 > 0: + cursor_col = (tileset.get_width () % 480) / 48 - 1 + else: + cursor_col = 9 + else: + cursor_col = 9 elif event.key == pygame.K_RIGHT: selcol += 1 if selcol >= totalcols: selcol = 0 + # increase the cursor col by 1 + cursor_col += 1 + # if cursor col > 9 + if ((tileset.get_width () % 480 > 0 and curpage_cols >= totalpages_cols - 1 and cursor_col >= (tileset.get_width () % 480) / 48) + or cursor_col >= 10): + curpage_cols += 1 + if curpage_cols >= totalpages_cols: + curpage_cols = 0 + cursor_col = 0 + else: + cursor_col = 0 + # the actual level editor def level_editor (fname): @@ -98,7 +207,7 @@ def level_editor (fname): while 1: screen.fill (pygame.Color (0, 0, 0)) - display_menu (screen) + display_menu (screen, tileset, tilerow, tilecol) draw_level (screen, leveldata, tileset) draw_cursor (screen, currow, curcol) pygame.display.update () diff --git a/levels/level1.dat b/levels/level1.dat new file mode 100644 index 0000000..a8101c8 --- /dev/null +++ b/levels/level1.dat @@ -0,0 +1,412 @@ +(lp1 +(lp2 +(lp3 +I0 +aI0 +aI0 +aa(lp4 +I0 +aI0 +aI0 +aa(lp5 +I0 +aI5 +aI01 +aa(lp6 +I0 +aI6 +aI01 +aa(lp7 +I0 +aI0 +aI0 +aa(lp8 +I0 +aI0 +aI0 +aa(lp9 +I0 +aI0 +aI0 +aa(lp10 +I1 +aI0 +aI0 +aa(lp11 +I0 +aI0 +aI0 +aa(lp12 +I0 +aI0 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+aaa. \ No newline at end of file diff --git a/levels/level1e.dat b/levels/level1e.dat new file mode 100644 index 0000000..022af7f --- /dev/null +++ b/levels/level1e.dat @@ -0,0 +1,412 @@ +(lp1 +(lp2 +(lp3 +I0 +aI0 +aI0 +aa(lp4 +I0 +aI0 +aI0 +aa(lp5 +I0 +aI0 +aI0 +aa(lp6 +I1 +aI0 +aI0 +aa(lp7 +I0 +aI0 +aI0 +aa(lp8 +I0 +aI0 +aI0 +aa(lp9 +I0 +aI0 +aI0 +aa(lp10 +I0 +aI0 +aI0 +aa(lp11 +I1 +aI0 +aI0 +aa(lp12 +I0 +aI0 +aI0 +aaa(lp13 +(lp14 +I0 +aI7 +aI01 +aa(lp15 +I0 +aI7 +aI01 +aa(lp16 +I1 +aI10 +aI01 +aa(lp17 +I0 +aI7 +aI01 +aa(lp18 +I0 +aI7 +aI01 +aa(lp19 +I0 +aI7 +aI01 +aa(lp20 +I0 +aI7 +aI01 +aa(lp21 +I3 +aI9 +aI01 +aa(lp22 +I0 +aI0 +aI0 +aa(lp23 +I0 +aI0 +aI0 +aaa(lp24 +(lp25 +I3 +aI10 +aI0 +aa(lp26 +I3 +aI10 +aI0 +aa(lp27 +I3 +aI10 +aI0 +aa(lp28 +I3 +aI10 +aI0 +aa(lp29 +I3 +aI10 +aI0 +aa(lp30 +I3 +aI10 +aI0 +aa(lp31 +I3 +aI10 +aI0 +aa(lp32 +I0 +aI8 +aI01 +aa(lp33 +I2 +aI0 +aI01 +aa(lp34 +I3 +aI5 +aI0 +aaa(lp35 +(lp36 +I0 +aI9 +aI01 +aa(lp37 +I3 +aI10 +aI0 +aa(lp38 +I3 +aI10 +aI0 +aa(lp39 +I3 +aI10 +aI0 +aa(lp40 +I3 +aI10 +aI0 +aa(lp41 +I3 +aI10 +aI0 +aa(lp42 +I3 +aI10 +aI0 +aa(lp43 +I0 +aI8 +aI01 +aa(lp44 +I2 +aI0 +aI01 +aa(lp45 +I3 +aI6 +aI0 +aaa(lp46 +(lp47 +I0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+aI01 +aa(lp97 +I0 +aI7 +aI01 +aa(lp98 +I0 +aI11 +aI01 +aa(lp99 +I0 +aI0 +aI0 +aa(lp100 +I0 +aI0 +aI0 +aaa(lp101 +(lp102 +I0 +aI0 +aI0 +aa(lp103 +I0 +aI0 +aI0 +aa(lp104 +I0 +aI0 +aI0 +aa(lp105 +I3 +aI4 +aI0 +aa(lp106 +I0 +aI0 +aI0 +aa(lp107 +I0 +aI0 +aI0 +aa(lp108 +I0 +aI0 +aI0 +aa(lp109 +I0 +aI0 +aI0 +aa(lp110 +I0 +aI0 +aI0 +aa(lp111 +I0 +aI0 +aI0 +aaa. \ No newline at end of file diff --git a/levels/level1w.dat b/levels/level1w.dat new file mode 100644 index 0000000..38187ec --- /dev/null +++ b/levels/level1w.dat @@ -0,0 +1,412 @@ +(lp1 +(lp2 +(lp3 +I2 +aI0 +aI01 +aa(lp4 +I4 +aI6 +aI0 +aa(lp5 +I5 +aI7 +aI0 +aa(lp6 +I1 +aI1 +aI0 +aa(lp7 +I1 +aI2 +aI0 +aa(lp8 +I1 +aI3 +aI0 +aa(lp9 +I1 +aI3 +aI0 +aa(lp10 +I1 +aI4 +aI0 +aa(lp11 +I2 +aI10 +aI01 +aa(lp12 +I0 +aI0 +aI0 +aaa(lp13 +(lp14 +I2 +aI0 +aI01 +aa(lp15 +I5 +aI6 +aI0 +aa(lp16 +I5 +aI7 +aI0 +aa(lp17 +I1 +aI1 +aI0 +aa(lp18 +I1 +aI3 +aI0 +aa(lp19 +I1 +aI3 +aI0 +aa(lp20 +I1 +aI3 +aI0 +aa(lp21 +I1 +aI4 +aI0 +aa(lp22 +I2 +aI10 +aI01 +aa(lp23 +I0 +aI0 +aI0 +aaa(lp24 +(lp25 +I2 +aI0 +aI01 +aa(lp26 +I5 +aI6 +aI0 +aa(lp27 +I5 +aI7 +aI0 +aa(lp28 +I1 +aI1 +aI0 +aa(lp29 +I1 +aI3 +aI0 +aa(lp30 +I1 +aI3 +aI0 +aa(lp31 +I1 +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+aI6 +aI0 +aa(lp82 +I5 +aI7 +aI0 +aa(lp83 +I2 +aI0 +aI01 +aa(lp84 +I0 +aI0 +aI0 +aa(lp85 +I2 +aI0 +aI01 +aa(lp86 +I0 +aI0 +aI0 +aa(lp87 +I0 +aI0 +aI0 +aa(lp88 +I2 +aI10 +aI01 +aa(lp89 +I0 +aI0 +aI0 +aaa(lp90 +(lp91 +I2 +aI0 +aI01 +aa(lp92 +I5 +aI6 +aI0 +aa(lp93 +I5 +aI7 +aI0 +aa(lp94 +I0 +aI0 +aI0 +aa(lp95 +I3 +aI4 +aI0 +aa(lp96 +I0 +aI0 +aI0 +aa(lp97 +I0 +aI0 +aI0 +aa(lp98 +I2 +aI0 +aI01 +aa(lp99 +I2 +aI10 +aI01 +aa(lp100 +I0 +aI0 +aI0 +aaa(lp101 +(lp102 +I2 +aI0 +aI01 +aa(lp103 +I4 +aI6 +aI0 +aa(lp104 +I5 +aI7 +aI0 +aa(lp105 +I0 +aI0 +aI0 +aa(lp106 +I2 +aI0 +aI01 +aa(lp107 +I0 +aI0 +aI0 +aa(lp108 +I0 +aI0 +aI0 +aa(lp109 +I0 +aI0 +aI0 +aa(lp110 +I2 +aI10 +aI01 +aa(lp111 +I0 +aI0 +aI0 +aaa. \ No newline at end of file diff --git a/maingame.py b/maingame.py index bde655d..75702b8 100644 --- a/maingame.py +++ b/maingame.py @@ -2,6 +2,7 @@ import pygame import sys import random import os.path +import cPickle import level import butaba @@ -65,18 +66,23 @@ class MainGame: # set up the levels and their interactions def setup_levels (self): - self.level1 = level.Level (level.LEVEL_1) - self.level1e = level.Level (level.LEVEL_1E, - objects = [ gameobjects.Key (4, 3, "a chest key", self.img_key2, level.KEY_CHEST1), - gameobjects.Key (4, 3, "a room key", self.img_key, level.KEY_ROOM1), - gameobjects.HealthPotion (4, 2, self.img_redpotion), + self.level1 = level.Level (cPickle.load (file ("levels/level1.dat"))) + self.level1w = level.Level (cPickle.load (file ("levels/level1w.dat"))) + self.level1e = level.Level (cPickle.load (file ("levels/level1e.dat")), + objects = [ gameobjects.Key (5, 3, "a chest key", self.img_key2, level.KEY_CHEST1), + gameobjects.Key (5, 3, "a room key", self.img_key, level.KEY_ROOM1), + gameobjects.HealthPotion (5, 2, self.img_redpotion), gameobjects.Chest (2, 5, "chest", self.img_chest, level.KEY_CHEST1, True), - gameobjects.GoldCoins (5, 2, self.img_goldcoins, 50) + gameobjects.GoldCoins (6, 2, self.img_goldcoins, 50) ] ) self.level1.levelright = self.level1e + self.level1.levelleft = self.level1w + self.level1e.levelleft = self.level1 + self.level1w.levelright = self.level1 + def main_loop (self): # main game loop while 1: