Skip to content
Browse files

WordSlider built using PyGame

  • Loading branch information...
0 parents commit 66ea7b0084552600b4a405fe0b2d2d985a3d756d @suttree committed Mar 20, 2011
Showing with 1,482 additions and 0 deletions.
  1. +609 −0 WordSlider.py
  2. BIN WordSlider_Setup.exe
  3. BIN fonts/nrkis.ttf
  4. BIN images/.DS_Store
  5. BIN images/Thumbs.db
  6. BIN images/background.png
  7. BIN images/favicon.ico
  8. BIN images/found/Thumbs.db
  9. BIN images/found/a.png
  10. BIN images/found/b.png
  11. BIN images/found/c.png
  12. BIN images/found/d.png
  13. BIN images/found/e.png
  14. BIN images/found/f.png
  15. BIN images/found/g.png
  16. BIN images/found/h.png
  17. BIN images/found/i.png
  18. BIN images/found/j.png
  19. BIN images/found/k.png
  20. BIN images/found/l.png
  21. BIN images/found/m.png
  22. BIN images/found/n.png
  23. BIN images/found/o.png
  24. BIN images/found/p.png
  25. BIN images/found/q.png
  26. BIN images/found/r.png
  27. BIN images/found/s.png
  28. BIN images/found/t.png
  29. BIN images/found/u.png
  30. BIN images/found/v.png
  31. BIN images/found/w.png
  32. BIN images/found/x.png
  33. BIN images/found/y.png
  34. BIN images/found/z.png
  35. BIN images/how_to_play.png
  36. BIN images/letters/.DS_Store
  37. BIN images/letters/Thumbs.db
  38. BIN images/letters/a.png
  39. BIN images/letters/b.png
  40. BIN images/letters/c.png
  41. BIN images/letters/d.png
  42. BIN images/letters/e.png
  43. BIN images/letters/f.png
  44. BIN images/letters/g.png
  45. BIN images/letters/h.png
  46. BIN images/letters/i.png
  47. BIN images/letters/j.png
  48. BIN images/letters/k.png
  49. BIN images/letters/l.png
  50. BIN images/letters/m.png
  51. BIN images/letters/n.png
  52. BIN images/letters/o.png
  53. BIN images/letters/p.png
  54. BIN images/letters/q.png
  55. BIN images/letters/r.png
  56. BIN images/letters/s.png
  57. BIN images/letters/t.png
  58. BIN images/letters/u.png
  59. BIN images/letters/v.png
  60. BIN images/letters/w.png
  61. BIN images/letters/x.png
  62. BIN images/letters/y.png
  63. BIN images/letters/z.png
  64. +70 −0 menu/Hints.py
  65. BIN menu/Hints.pyc
  66. +280 −0 menu/Items.py
  67. BIN menu/Items.pyc
  68. 0 menu/__init__.py
  69. BIN menu/__init__.pyc
  70. 0 menu/scores.dat
  71. BIN sounds/.DS_Store
  72. BIN sounds/bonus.wav
  73. BIN sounds/buzzer.wav
  74. BIN sounds/dink.wav
  75. BIN sounds/error.wav
  76. BIN sounds/tock.wav
  77. BIN sounds/wah.wav
  78. BIN wordlists/.DS_Store
  79. +523 −0 wordlists/simple.txt
609 WordSlider.py
@@ -0,0 +1,609 @@
+#! /usr/bin/env python
+
+import os
+import re
+import sys
+import string
+import random
+import pygame
+import marshal
+import webbrowser
+
+from pygame.locals import *
+from menu.Hints import HintHeader, HintLine1, HintLine2
+from menu.Items import Bonus, Collect, EndGame, GameOver, HiScore, NewGame, SubmitScore, Timer, Word, WordsHeader
+
+FONT = os.path.join('fonts', 'nrkis.ttf')
+
+class Game:
+ def __init__(self):
+ self.game_over = 0
+
+ self.prev_x = 0
+ self.prev_y = 0
+ self.last_click = 0
+
+ file = open(os.path.join('wordlists','simple.txt'), 'r')
+ self.wordlist = file.readlines()
+
+ for i in range(len(self.wordlist)):
+ self.wordlist[i] = string.replace(self.wordlist[i], "\n", "")
+
+ self.hi_scores = []
+ self.load_scores()
+
+ def create_grid(self):
+ # This is the grid, remove 4 squares and then create it
+ positions = [
+ '0,0', '50,0', '100,0', '150,0', '200,0', '250,0', '300,0', '350,0',
+ '0,50', '50,50', '100,50', '150,50', '200,50', '250,50', '300,50', '350,50',
+ '0,100', '50,100', '100,100', '150,100', '200,100', '250,100', '300,100', '350,100',
+ '0,150', '50,150', '100,150', '150,150', '200,150', '250,150', '300,150', '350,150',
+ '0,200', '50,200', '100,200', '150,200', '200,200', '250,200', '300,200', '350,200',
+ '0,250', '50,250', '100,250', '150,250', '200,250', '250,250', '300,250', '350,250',
+ '0,300', '50,300', '100,300', '150,300', '200,300', '250,300', '300,300', '350,300',
+ '0,350', '50,350', '100,350', '150,350', '200,350', '250,350', '300,350', '350,350',
+ ]
+
+ random.shuffle(positions)
+
+ positions.pop()
+ positions.pop()
+ positions.pop()
+ positions.pop()
+ positions.pop()
+ positions.pop()
+ positions.pop()
+ positions.pop()
+
+ for i in range(2):
+ for word in self.target_words:
+ for letter in word:
+ x,y = positions.pop().split(',')
+ self.tiles.add(Tile( letter, [int(x),int(y)] ))
+
+ for pos in positions:
+ x,y = pos.split(',')
+ self.tiles.add(Tile( self.letters[ random.randrange(len(self.letters)) ], [int(x),int(y)] ))
+
+ def demo_mode(self):
+ pygame.init()
+
+ pygame.display.set_caption('Playaholics: WordSlider')
+ self.screen = pygame.display.set_mode([600,400])
+ self.background = pygame.image.load('images/how_to_play.png').convert()
+ self.screen.blit(self.background, [0, 0])
+ pygame.display.update()
+
+ sound_file = os.path.join('sounds', 'dink.wav')
+ self.sound = pygame.mixer.Sound(sound_file)
+
+ sound_file = os.path.join('sounds', 'wah.wav')
+ self.soundtrack = pygame.mixer.Sound(sound_file)
+ self.soundtrack.set_volume(0.6)
+ self.soundtrack.play(-1)
+
+ sound_file = os.path.join('sounds', 'bonus.wav')
+ self.bonus_sound = pygame.mixer.Sound(sound_file)
+ self.bonus_sound.set_volume(0.5)
+
+ sound_file = os.path.join('sounds', 'buzzer.wav')
+ self.penalty_sound = pygame.mixer.Sound(sound_file)
+ self.penalty_sound.set_volume(0.5)
+
+ sound_file = os.path.join('sounds', 'bonus.wav')
+ self.game_over_sound = pygame.mixer.Sound(sound_file)
+ self.game_over_sound.set_volume(0.5)
+
+ in_demo=1
+ while in_demo:
+ for event in pygame.event.get():
+ if event.type == QUIT:
+ #webbrowser.open("http://www.playaholics.com/")
+ sys.exit()
+
+ elif event.type == MOUSEBUTTONDOWN:
+ in_demo=0
+ self.soundtrack.fadeout(10000)
+ else:
+ pass
+
+ self.start()
+
+ def double_clicked(self,x,y):
+ time_now = pygame.time.get_ticks()
+ pause = time_now - self.last_click
+
+ if self.prev_x == x and self.prev_y == y:
+ if pause <= 300:
+ return 1
+
+ self.prev_x = x
+ self.prev_y = y
+ self.last_click = time_now
+
+ return 0
+
+ def load_scores(self):
+ self.top_scores = []
+ try:
+ scores = os.path.join('menu', 'scores.dat')
+ infile = open(scores, "rb")
+ self.top_scores = marshal.load(infile)
+ infile.close()
+ except:
+ pass
+
+ def remove_tile(self,pos):
+ """Remove each processed tile from the board at the end of a round"""
+ self.marker.rect[0] = pos[0]
+ self.marker.rect[1] = pos[1]
+ rectlist = pygame.sprite.spritecollide(self.marker,self.tiles,1)
+ self.sound.play()
+ pygame.display.update(rectlist)
+ pygame.time.wait(50)
+
+ def pick_words(self):
+ self.target_words = []
+ for i in range(4):
+ self.target_words.append(self.wordlist[random.randrange(len(self.wordlist))])
+
+ self.words_to_find = []
+ self.words_to_find.append(Word(self.target_words[0],[410,125]))
+ self.words_to_find.append(Word(self.target_words[1],[410,145]))
+ self.words_to_find.append(Word(self.target_words[2],[410,165]))
+ self.words_to_find.append(Word(self.target_words[3],[410,185]))
+
+ for word in self.words_to_find:
+ self.gamesprites.add(word)
+
+ def reset(self):
+ self.game_over = 0
+ self.bonus.reset()
+
+ self.gamesprites.remove(self.bonus)
+
+ for word in self.words_to_find:
+ self.gamesprites.remove(word)
+
+ def restart(self):
+ """Restart the game"""
+
+ self.tiles.empty()
+
+ self.reset()
+ self.timer.reset()
+ self.score.reset()
+ self.submit_score_menu.reset()
+
+ for hi_score in self.hi_scores:
+ self.menusprites.remove(hi_score)
+
+ self.gamesprites.remove(self.bonus)
+ self.menusprites.remove(self.game_over_menu)
+ self.menusprites.remove(self.submit_score_menu)
+
+ self.letters = [ 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' ]
+
+ self.run()
+
+ def run(self):
+ """Run the game"""
+
+ self.timer.start()
+ self.pick_words()
+ self.create_grid()
+ self.score.calculate(self.tiles, self.target_words) # do this now to highlight any words that are already present (yuk!)
+
+ # Restrict what events we have to deal with
+ pygame.event.set_allowed(None)
+ pygame.event.set_allowed([QUIT,MOUSEBUTTONDOWN,MOUSEMOTION,MOUSEBUTTONUP])
+
+ # Animate the tiles, scores and timers
+ start_tile = None
+ end_tile = None
+ moveable = 1
+ moved = False
+ while 1:
+ for event in pygame.event.get():
+ if event.type == QUIT:
+ #webbrowser.open("http://www.playaholics.com")
+ sys.exit()
+
+ elif event.type == MOUSEBUTTONDOWN:
+ moved = False
+ moveable = 1
+ x,y = pygame.mouse.get_pos()
+ starting_clicked_area = pygame.Rect(x,y,1,1)
+
+ # Have we clicked on a tile rather than a space?
+ for tile in self.tiles.sprites():
+ if starting_clicked_area.colliderect(tile.rect):
+ start_tile = tile
+
+ # If we've double clicked on a tile, then attempt
+ # to move in in this order - up, down, left, right
+ if self.double_clicked(x,y) and start_tile:
+ for direction in ['up','down','left','right']:
+ if not moveable:
+ break
+ if direction == 'up':
+ neighbour_x = start_tile.rect[0]
+ neighbour_y = start_tile.rect[1]-50
+ elif direction == 'down':
+ neighbour_x = start_tile.rect[0]
+ neighbour_y = start_tile.rect[1]+50
+ elif direction == 'left':
+ neighbour_x = start_tile.rect[0]-50
+ neighbour_y = start_tile.rect[1]
+ elif direction == 'right':
+ neighbour_x = start_tile.rect[0]+50
+ neighbour_y = start_tile.rect[1]
+
+ if neighbour_x < 0 or neighbour_y < 0:
+ continue
+ elif neighbour_x > 350 or neighbour_y > 350:
+ continue
+
+ neighbour = pygame.Rect(neighbour_x,neighbour_y,1,1)
+
+ for tile in self.tiles.sprites():
+ if neighbour.colliderect(tile.rect):
+ end_tile = tile
+
+ if not end_tile:
+ moveable = 0
+ start_tile.move([neighbour_x,neighbour_y])
+
+ end_tile = None
+
+ elif event.type == MOUSEMOTION:
+ try:
+ if moveable:
+ x,y = pygame.mouse.get_pos()
+ if x < 0:
+ x=0
+ if x > 350:
+ x=350
+ if y < 0:
+ y=0
+ if y > 350:
+ y=350
+ finishing_dragged_area = pygame.Rect(x,y,10,10)
+
+ # Are we over a tile? If so, we can't slide here
+ for tile in self.tiles.sprites():
+ if finishing_dragged_area.colliderect(tile.rect):
+ end_tile = tile
+ break
+
+ # Move unless we're tile skipping
+ if x > start_tile.rect[0]+75:
+ pass
+ elif y > start_tile.rect[1]+75:
+ pass
+ elif start_tile.fixed:
+ pass
+ elif start_tile and not end_tile:
+ start_tile.move([x,y])
+ moved = True
+
+ end_tile = None
+ except:
+ pass
+
+ elif event.type == MOUSEBUTTONUP:
+ # See if we've got a word in the grid now that the tile has stopped moving
+ if moved:
+ x,y = pygame.mouse.get_pos()
+ self.found_words = self.score.calculate(self.tiles, self.target_words,0)
+
+ self.collect.click_test()
+ self.end_game.click_test()
+ self.new_game.click_test()
+
+ start_tile = None
+ end_tile = None
+ moveable = 0
+
+ self.tiles.update()
+ self.score.update()
+ self.gamesprites.update()
+ self.menusprites.update()
+
+ if self.bonus.off_screen:
+ self.bonus.reset()
+ self.gamesprites.remove(self.bonus)
+
+ if self.collect.clicked and not self.game_over:
+ self.found_words = self.score.calculate(self.tiles, self.target_words)
+
+ for word in self.found_words:
+ self.timer.timer = self.timer.timer + len(word) * 2 * len(self.found_words)
+
+ words = ", ".join(self.found_words)
+
+ if len(words) > 0:
+ self.bonus.award(words)
+ self.gamesprites.add(self.bonus)
+ else:
+ self.bonus.award("-5 seconds!")
+ self.gamesprites.add(self.bonus)
+
+ if self.timer.timer > 60:
+ self.timer.timer = 60
+
+ for sprite in self.tiles.sprites():
+ self.remove_tile(sprite.rect)
+
+ for word in self.words_to_find:
+ self.gamesprites.remove(word)
+
+ for i in range(len(self.found_words)):
+ self.bonus_sound.play()
+
+ if not self.found_words:
+ self.penalty_sound.play()
+ self.timer.timer = self.timer.timer - 5
+
+ self.collect.clicked = 0
+
+ self.pick_words()
+ self.create_grid()
+ self.score.calculate(self.tiles, self.target_words)
+
+ if self.timer.time_up():
+ self.timer.stop()
+
+ for sprite in self.tiles.sprites():
+ self.remove_tile(sprite.rect)
+
+ self.submit_score_menu.score = self.score.score
+
+ if not self.game_over:
+ self.save_scores()
+
+ i = 0
+ colour = ""
+ self.hi_scores = []
+ self.hi_scores.append(HiScore(self,"Hi-Scores",[255,255,255],[150,90]))
+ for score in self.top_scores:
+ i = i + 1
+
+ if score == self.score.score:
+ colour = [255,0,0]
+ else:
+ colour = [0,0,0]
+
+ if i < 10:
+ score = " %d. %d" % (i, score)
+ else:
+ score = "%d. %d" % (i, score)
+
+ self.hi_scores.append(HiScore(self,score,colour,[150,100+20*i]))
+
+ for hi_score in self.hi_scores:
+ self.menusprites.add(hi_score)
+
+ self.game_over_sound.play()
+
+ self.game_over = 1
+
+ if not self.game_over:
+ tile_list = self.tiles.draw(self.screen)
+ pygame.display.update(tile_list)
+
+ ui_list = self.gamesprites.draw(self.screen)
+ pygame.display.update(ui_list)
+ menu_list = self.menusprites.draw(self.screen)
+ pygame.display.update(menu_list)
+
+ pygame.time.delay(10)
+ self.tiles.clear(self.screen, self.background)
+ self.gamesprites.clear(self.screen, self.background)
+ self.menusprites.clear(self.screen, self.background)
+
+ def save_scores(self):
+ if self.score.score not in self.top_scores:
+ self.top_scores.append(self.score.score)
+ self.top_scores.sort()
+ self.top_scores.reverse()
+ scores = os.path.join('menu', 'scores.dat')
+ outfile = open(scores, "wb")
+ marshal.dump(self.top_scores[0:9],outfile)
+ outfile.close()
+
+ def start(self):
+ """Initialise the game and start it running"""
+ self.screen = pygame.display.set_mode([600,400])
+ self.background = pygame.image.load(os.path.join('images','background.png')).convert()
+ self.screen.blit(self.background, [0, 0])
+ pygame.display.update()
+
+ self.marker = Tile('a',[0,0])
+
+ self.bonus = Bonus()
+ self.score = Score()
+ self.timer = Timer()
+ self.collect = Collect(self)
+
+ self.end_game = EndGame()
+ self.new_game = NewGame(self)
+ self.words_header = WordsHeader()
+ self.game_over_menu = GameOver(self)
+ self.submit_score_menu = SubmitScore()
+
+ self.tiles = pygame.sprite.RenderUpdates()
+ self.gamesprites = pygame.sprite.RenderUpdates()
+ self.menusprites = pygame.sprite.RenderUpdates()
+ self.letters = [ 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' ]
+
+ self.gamesprites.add(self.score)
+ self.gamesprites.add(self.timer)
+ self.gamesprites.add(self.words_header)
+
+ self.menusprites.add(self.collect)
+ self.menusprites.add(self.end_game)
+ self.menusprites.add(self.new_game)
+
+ self.run()
+
+class Score(pygame.sprite.Sprite):
+ def __init__(self):
+ pygame.sprite.Sprite.__init__(self)
+
+ self.score = 0
+ self.tile_groups = {}
+
+ self.font = pygame.font.Font(FONT, 32)
+ self.image = self.font.render("Score: %d" % self.score, 1, (255,255,255))
+ self.rect = self.image.get_rect()
+ self.rect = self.rect.move([410,5])
+
+ def calculate(self,board,targets,award_score=1):
+ all_words = []
+ found_words = []
+ self.word_tiles = []
+ self.found_tiles = {}
+
+ self.board = board
+ self.targets = targets
+ self.time_bonus = 0
+
+ # Left to right, right to left
+ all_words.append(self.traverse_grid(0,351,50))
+ all_words.append(self.traverse_grid(350,-1,-50))
+ # Up and down, down and up
+ all_words.append(self.traverse_grid(0,351,50,1))
+ all_words.append(self.traverse_grid(350,-1,-50,1))
+
+ regexes = []
+ for target in self.targets:
+ regexes.append(re.compile(target))
+
+ length = 0
+ tmp_word = False
+ for words in all_words:
+ for word in words:
+ if not word:
+ continue
+ for regex in regexes:
+ match = regex.search(word)
+ if match:
+ # match.group() contains the found word
+ if match.group() not in found_words and match.group() != "":
+ found_words.append(match.group())
+
+ # Now, we should be able to match up the letters of the found word
+ # with the tiles of the found word, then change the tiles and freeze them
+ tmp_word = match.group()
+ pos = word.find(tmp_word)
+ length = len(tmp_word)
+
+ for i in range(length):
+ rect = self.found_tiles[word][pos+i].rect
+ self.found_tiles[word][pos+i].image = pygame.image.load('images/found/%s.png' % self.found_tiles[word][pos+i].letter).convert()
+ self.found_tiles[word][pos+i].fixed = True
+
+ if award_score:
+ self.score = self.score+(len(word)*10)
+
+ return found_words
+
+ def reset(self):
+ self.score = 0
+
+ def traverse_grid(self,row,column,step,vertical=0):
+ # Keep track of the last tile so that we can
+ # check for spaces as word boundaries
+ if vertical:
+ prev_x = column
+ prev_y = row
+ else:
+ prev_x = row
+ prev_y = column
+
+ tile = None
+ found_words = []
+ for y in range(row,column,step):
+ word = []
+ tiles = []
+ for x in range(row,column,step):
+ if vertical:
+ current_tile = pygame.Rect(y,x,1,1)
+ else:
+ current_tile = pygame.Rect(x,y,1,1)
+
+ # Cycle through the tiles and create mostly nonsense strings
+ # in each direction. Use those strings as keys to a hash of tiles,
+ # so that we can tie up the words to tile positions later on (in calculate)
+ for sprite in self.board.sprites():
+ if current_tile.colliderect(sprite.rect):
+ tile = sprite
+ if x > (prev_x+50) or y > (prev_y+50):
+ found_words.append("".join(word))
+ self.found_tiles["".join(word)] = tiles
+ word = []
+ tiles = []
+ word.append(tile.letter)
+ tiles.append(tile)
+ elif x < (prev_x-50) or y < (prev_y-50):
+ found_words.append("".join(word))
+ self.found_tiles["".join(word)] = tiles
+ word = []
+ tiles = []
+ word.append(tile.letter)
+ tiles.append(tile)
+ else:
+ word.append(tile.letter)
+ tiles.append(tile)
+ prev_x = x
+ prev_y = y
+ found_words.append("".join(word))
+ self.found_tiles["".join(word)] = tiles
+
+ return found_words
+
+ def update(self):
+ self.image = self.font.render("Score: %d" % self.score, 1, (255,255,255))
+ self.rect = self.image.get_rect()
+ self.rect = self.rect.move([410,5])
+
+class Tile(pygame.sprite.Sprite):
+ def __init__(self,letter,pos):
+ """Initialise a tile - the basic game unit"""
+ pygame.sprite.Sprite.__init__(self)
+
+ self.fixed = False
+ self.letter = letter
+ self.image = pygame.image.load('images/letters/%s.png' % letter).convert()
+ self.rect = self.image.get_rect()
+ self.rect = self.rect.move(pos)
+
+ def move(self,pos):
+ """Only move the square if it is a direct neighbour of a blank space"""
+
+ x = pos[0] - (pos[0] % 50)
+ y = pos[1] - (pos[1] % 50)
+
+ if x > self.rect[0] or y > self.rect[1]:
+ if x > self.rect[0] + 50 or y > self.rect[1] + 50:
+ return None
+
+ if x < self.rect[0] or y < self.rect[1]:
+ if x < self.rect[0] - 50 or y < self.rect[1] - 50:
+ return None
+
+ # Diagonal movements not allowed
+ if ( x > self.rect[0] and y > self.rect[1] ) or ( x < self.rect[0] and y < self.rect[1] ):
+ return None
+
+ if ( x > self.rect[0] and y < self.rect[1] ) or ( x < self.rect[0] and y > self.rect[1] ):
+ return None
+
+ self.rect[0] = x
+ self.rect[1] = y
+
+if __name__ == '__main__':
+ Game = Game()
+ Game.demo_mode()
BIN WordSlider_Setup.exe
Binary file not shown.
BIN fonts/nrkis.ttf
Binary file not shown.
BIN images/.DS_Store
Binary file not shown.
BIN images/Thumbs.db
Binary file not shown.
BIN images/background.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN images/favicon.ico
Binary file not shown.
BIN images/found/Thumbs.db
Binary file not shown.
BIN images/found/a.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN images/found/b.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN images/found/c.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN images/found/d.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN images/found/e.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN images/found/f.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN images/found/g.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN images/found/h.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN images/found/i.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN images/found/j.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN images/found/k.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN images/found/l.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN images/found/m.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN images/found/n.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN images/found/o.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN images/found/p.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN images/found/q.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN images/found/r.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN images/found/s.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN images/found/t.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN images/found/u.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN images/found/v.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN images/found/w.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN images/found/x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN images/found/y.png
Diff not rendered.
BIN images/found/z.png
Diff not rendered.
BIN images/how_to_play.png
Diff not rendered.
BIN images/letters/.DS_Store
Binary file not shown.
BIN images/letters/Thumbs.db
Binary file not shown.
BIN images/letters/a.png
Diff not rendered.
BIN images/letters/b.png
Diff not rendered.
BIN images/letters/c.png
Diff not rendered.
BIN images/letters/d.png
Diff not rendered.
BIN images/letters/e.png
Diff not rendered.
BIN images/letters/f.png
Diff not rendered.
BIN images/letters/g.png
Diff not rendered.
BIN images/letters/h.png
Diff not rendered.
BIN images/letters/i.png
Diff not rendered.
BIN images/letters/j.png
Diff not rendered.
BIN images/letters/k.png
Diff not rendered.
BIN images/letters/l.png
Diff not rendered.
BIN images/letters/m.png
Diff not rendered.
BIN images/letters/n.png
Diff not rendered.
BIN images/letters/o.png
Diff not rendered.
BIN images/letters/p.png
Diff not rendered.
BIN images/letters/q.png
Diff not rendered.
BIN images/letters/r.png
Diff not rendered.
BIN images/letters/s.png
Diff not rendered.
BIN images/letters/t.png
Diff not rendered.
BIN images/letters/u.png
Diff not rendered.
BIN images/letters/v.png
Diff not rendered.
BIN images/letters/w.png
Diff not rendered.
BIN images/letters/x.png
Diff not rendered.
BIN images/letters/y.png
Diff not rendered.
BIN images/letters/z.png
Diff not rendered.
70 menu/Hints.py
@@ -0,0 +1,70 @@
+#! /usr/bin/env python
+
+import os
+import pygame
+from pygame.locals import *
+
+FONT = os.path.join('fonts', 'nrkis.ttf')
+
+class HintHeader(pygame.sprite.Sprite):
+ def __init__(self):
+ pygame.sprite.Sprite.__init__(self)
+
+ self.level = 1
+ self.font = pygame.font.Font(FONT, 22)
+ self.image = self.font.render("How to play:", 1, (255,255,255))
+ self.rect = self.image.get_rect()
+ self.rect = self.rect.move([410,105])
+
+ def update(self):
+ pass
+
+class HintLine1(pygame.sprite.Sprite):
+ def __init__(self):
+ pygame.sprite.Sprite.__init__(self)
+
+ self.hint = 0
+ self.font = pygame.font.Font(FONT, 16)
+ self.hint_text = { 0:"Group together 3 or more", 1:"Go edge to edge for", 2:"Clear all the tiles of one", 3:"Earn time for each chain", 4:"You can only earn up" }
+ self.image = self.font.render("%s" % self.hint_text[self.hint], 1, (255,255,255))
+ self.rect = self.image.get_rect()
+ self.rect = self.rect.move([410,130])
+
+ def next(self):
+ self.hint = self.hint+1
+ try:
+ self.image = self.font.render("%s" % self.hint_text[self.hint], 1, (255,255,255))
+ except:
+ self.hint = 0
+ self.image = self.font.render("%s" % self.hint_text[self.hint], 1, (255,255,255))
+
+ def reset(self):
+ self.level = 1
+
+ def update(self):
+ pass
+
+class HintLine2(pygame.sprite.Sprite):
+ def __init__(self):
+ pygame.sprite.Sprite.__init__(self)
+
+ self.hint = 0
+ self.font = pygame.font.Font(FONT, 16)
+ self.hint_text = { 0:"tiles to score", 1:"an extra bonus", 2:"colour for a 500 point bonus", 3:"cleared from the board", 4:"to 60 seconds of time" }
+ self.image = self.font.render("%s" % self.hint_text[self.hint], 1, (255,255,255))
+ self.rect = self.image.get_rect()
+ self.rect = self.rect.move([410,145])
+
+ def next(self):
+ self.hint = self.hint+1
+ try:
+ self.image = self.font.render("%s" % self.hint_text[self.hint], 1, (255,255,255))
+ except:
+ self.hint = 0
+ self.image = self.font.render("%s" % self.hint_text[self.hint], 1, (255,255,255))
+
+ def reset(self):
+ self.level = 1
+
+ def update(self):
+ pass
BIN menu/Hints.pyc
Binary file not shown.
280 menu/Items.py
@@ -0,0 +1,280 @@
+#! /usr/bin/env python
+
+import os
+import sys
+import time
+import pygame
+import webbrowser
+from pygame.locals import *
+
+FONT = os.path.join('fonts', 'nrkis.ttf')
+
+class Bonus(pygame.sprite.Sprite):
+ def __init__(self):
+ pygame.sprite.Sprite.__init__(self)
+
+ self.off_screen = 0
+ self.last_update = 0
+ self.colours = [ [255,255,0], [255,128,0], [255,255,0], [255,128,0], [255,255,0], [255,128,0] ]
+ self.font = pygame.font.Font(FONT, 18)
+
+ def award(self,words):
+ self.words = words
+ self.image = self.font.render("%s" % self.words, 1, [255,255,0])
+ self.rect = self.image.get_rect()
+ self.rect = self.rect.move([412,35])
+
+ def reset(self):
+ self.value = 0
+ self.off_screen = 0
+ self.colours = [ [255,255,0], [255,128,0], [255,255,0], [255,128,0], [255,255,0], [255,128,0] ]
+ self.last_update = 0
+
+ def update(self):
+ try:
+ time_now = pygame.time.get_ticks()
+ if (time_now - self.last_update) >= 125:
+ self.last_update = time_now
+ colour = self.colours.pop()
+ self.image = self.font.render("%s" % self.words, 1, colour)
+ self.rect = self.image.get_rect()
+ self.rect = self.rect.move([412,35])
+ except:
+ self.off_screen = 1
+ self.colours = [ [255,255,0], [255,128,0], [255,255,0], [255,128,0], [255,255,0], [255,128,0] ]
+
+class Collect(pygame.sprite.Sprite):
+ def __init__(self,game):
+ pygame.sprite.Sprite.__init__(self)
+
+ self.game = game
+ self.colour = [255,255,255]
+ self.clicked = 0
+ self.last_update = pygame.time.get_ticks()
+ self.font = pygame.font.Font(FONT, 22)
+ self.image = self.font.render("Collect", 1, self.colour)
+ self.rect = self.image.get_rect()
+ self.rect = self.rect.move([410,220])
+
+ def click_test(self):
+ x,y = pygame.mouse.get_pos()
+ area = pygame.Rect(x,y,1,1)
+
+ if area.colliderect(self.rect):
+ self.clicked = 1
+ else:
+ self.clicked = 0
+
+ def reset(self):
+ self.clicked = 0
+
+ def update(self):
+ x,y = pygame.mouse.get_pos()
+ area = pygame.Rect(x,y,1,1)
+
+ time_now = pygame.time.get_ticks()
+ if area.colliderect(self.rect):
+ self.colour = [255,0,0]
+ elif (time_now - self.last_update) >= 500 and self.game.timer.timer <= 10 and not self.game.timer.time_up():
+ self.last_update = time_now
+ if self.colour == [255,128,0]:
+ self.colour = [255,255,255]
+ elif self.colour == [255,255,255]:
+ self.colour = [255,128,0]
+ else:
+ if self.colour == [255,0,0]:
+ self.colour = [255,255,255]
+
+ self.image = self.font.render("Collect", 1, self.colour)
+
+class EndGame(pygame.sprite.Sprite):
+ def __init__(self):
+ pygame.sprite.Sprite.__init__(self)
+
+ self.font = pygame.font.Font(FONT, 22)
+ self.image = self.font.render("End Game", 1, (255,255,255))
+ self.rect = self.image.get_rect()
+ self.rect = self.rect.move([410,330])
+
+ def click_test(self):
+ x,y = pygame.mouse.get_pos()
+ area = pygame.Rect(x,y,1,1)
+
+ if area.colliderect(self.rect):
+ sys.exit()
+
+ def update(self):
+ x,y = pygame.mouse.get_pos()
+ area = pygame.Rect(x,y,1,1)
+
+ if area.colliderect(self.rect):
+ self.image = self.font.render("End Game", 1, (255,0,0))
+ else:
+ self.image = self.font.render("End Game", 1, (255,255,255))
+
+class GameOver(pygame.sprite.Sprite):
+ def __init__(self,game):
+ pygame.sprite.Sprite.__init__(self)
+
+ self.game = game
+ self.font = pygame.font.Font(FONT, 24)
+ self.image = self.font.render("Game Over", 1, (0,0,0))
+ self.rect = self.image.get_rect()
+ self.rect = self.rect.move([150,60])
+
+ def update(self):
+ if self.game.game_over == 1:
+ self.image = self.font.render("Game Over", 1, (0,0,0))
+
+class HiScore(pygame.sprite.Sprite):
+ def __init__(self,game,score,colour,pos):
+ pygame.sprite.Sprite.__init__(self)
+
+ self.game = game
+ self.score = str(score)
+ self.colour = colour
+ self.font = pygame.font.Font(FONT, 22)
+ self.image = self.font.render(self.score, 1, self.colour)
+ self.rect = self.image.get_rect()
+ self.rect = self.rect.move(pos)
+
+ def update(self):
+ if self.game.game_over == 1:
+ self.image = self.font.render(self.score, 1, self.colour)
+
+class NewGame(pygame.sprite.Sprite):
+ def __init__(self,game):
+ pygame.sprite.Sprite.__init__(self)
+
+ self.game = game
+ self.font = pygame.font.Font(FONT, 22)
+ self.image = self.font.render("New Game", 1, (255,255,255))
+ self.rect = self.image.get_rect()
+ self.rect = self.rect.move([410,300])
+
+ def click_test(self):
+ x,y = pygame.mouse.get_pos()
+ area = pygame.Rect(x,y,1,1)
+
+ if area.colliderect(self.rect):
+ self.game.restart()
+
+ def update(self):
+ x,y = pygame.mouse.get_pos()
+ area = pygame.Rect(x,y,1,1)
+
+ if area.colliderect(self.rect):
+ self.image = self.font.render("New Game", 1, (255,0,0))
+ else:
+ self.image = self.font.render("New Game", 1, (255,255,255))
+
+class SubmitScore(pygame.sprite.Sprite):
+ def __init__(self):
+ pygame.sprite.Sprite.__init__(self)
+
+ self.score = 0
+ self.font = pygame.font.Font(FONT, 22)
+ self.image = self.font.render("Submit your score", 1, (255,255,255))
+ self.rect = self.image.get_rect()
+ self.rect = self.rect.move([410,260])
+
+ def reset(self):
+ self.score = 0
+ self.rect = self.rect.move([410,260])
+
+ def update(self):
+ x,y = pygame.mouse.get_pos()
+ area = pygame.Rect(x,y,1,1)
+
+ if area.colliderect(self.rect):
+ self.image = self.font.render("Submit your score", 1, (255,0,0))
+ if pygame.mouse.get_pressed()[0]:
+ webbrowser.open("http://www.playaholics.com/comp_entry.php?game=Slider&developer=playaholics&score=%d" % (self.score))
+ self.image = self.font.render("",1,(255,0,0))
+ self.rect = self.image.get_rect()
+ self.rect = self.rect.move([-100,-100])
+
+ else:
+ self.image = self.font.render("Submit your score", 1, (255,255,255))
+
+class Timer(pygame.sprite.Sprite):
+ def __init__(self):
+ pygame.sprite.Sprite.__init__(self)
+
+ self.in_game = 0
+ self.time_limit = 60
+ self.last_update = 0
+ self.timer = self.time_limit
+
+ self.font = pygame.font.Font(FONT, 32)
+ self.image = self.font.render("Time: %s" % self.time_limit, 1, (255,255,255))
+ self.rect = self.image.get_rect()
+ self.rect = self.rect.move([410,55])
+ sound_file = os.path.join('sounds', 'tock.wav')
+ self.sound = pygame.mixer.Sound(sound_file)
+ self.sound.set_volume(0.15)
+
+ def reset(self):
+ """Resets the timer for the next level"""
+ self.time_limit = 60
+ self.timer = self.time_limit
+ self.start_time = int(time.time())
+ self.last_update = 0
+
+ def start(self):
+ self.in_game = 1
+ self.start_time = int(time.time())
+
+ def stop(self):
+ self.timer = 0
+ self.in_game = 0
+
+ def time_up(self):
+ """Boolean end of level check"""
+ if self.timer <= 0:
+ return 1
+ else:
+ return 0
+
+ def update(self):
+ time_now = pygame.time.get_ticks()
+ if (time_now - self.last_update) >= 1000 and self.in_game:
+ self.last_update = time_now
+ self.timer = self.timer-1
+ self.sound.play()
+ self.image = self.font.render("Time: %s" % self.timer, 1, (255,255,255))
+
+class Word(pygame.sprite.Sprite):
+ def __init__(self,word,pos):
+ pygame.sprite.Sprite.__init__(self)
+
+ self.word = word
+ self.font = pygame.font.Font(FONT, 22)
+ self.colours = [ [255,255,0], [255,128,0], [255,255,0], [255,128,0], [255,255,0], [255,128,0] ]
+ self.image = self.font.render(word, 1, [255,255,0])
+ self.rect = self.image.get_rect()
+ self.rect = self.rect.move(pos)
+
+ def update(self):
+ try:
+ time_now = pygame.time.get_ticks()
+ if (time_now - self.last_update) >= 125:
+ self.last_update = time_now
+ colour = self.colours.pop()
+ self.image = self.font.render(self.word, 1, colour)
+ self.rect = self.image.get_rect()
+ self.rect = self.rect.move([412,35])
+ except:
+ self.off_screen = 1
+
+class WordsHeader(pygame.sprite.Sprite):
+ def __init__(self):
+ pygame.sprite.Sprite.__init__(self)
+
+ self.font = pygame.font.Font(FONT, 22)
+ self.image = self.font.render("Find these words:", 1, (255,255,255))
+ self.rect = self.image.get_rect()
+ self.rect = self.rect.move([410,100])
+
+ def update(self):
+ pass
BIN menu/Items.pyc
Binary file not shown.
0 menu/__init__.py
No changes.
BIN menu/__init__.pyc
Binary file not shown.
0 menu/scores.dat
No changes.
BIN sounds/.DS_Store
Binary file not shown.
BIN sounds/bonus.wav
Binary file not shown.
BIN sounds/buzzer.wav
Binary file not shown.
BIN sounds/dink.wav
Binary file not shown.
BIN sounds/error.wav
Binary file not shown.
BIN sounds/tock.wav
Binary file not shown.
BIN sounds/wah.wav
Binary file not shown.
BIN wordlists/.DS_Store
Binary file not shown.
523 wordlists/simple.txt
@@ -0,0 +1,523 @@
+able
+about
+acid
+act
+after
+again
+air
+all
+among
+and
+angle
+angry
+ant
+any
+apple
+arch
+arm
+army
+art
+awake
+baby
+back
+bad
+bag
+ball
+band
+base
+basin
+bath
+bed
+bee
+bell
+bent
+berry
+bird
+birth
+bit
+bite
+black
+blade
+blood
+blow
+blue
+board
+boat
+body
+bone
+book
+boot
+box
+boy
+brain
+brake
+brass
+bread
+brick
+brown
+brush
+bulb
+burn
+burst
+but
+cake
+card
+care
+cart
+cat
+cause
+chain
+chalk
+cheap
+chest
+chief
+chin
+clean
+clear
+clock
+cloth
+cloud
+coal
+coat
+cold
+comb
+come
+cook
+copy
+cord
+cork
+cough
+cover
+cow
+crack
+crime
+cruel
+crush
+cry
+cup
+cup
+curve
+dark
+day
+dead
+dear
+death
+debt
+deep
+dirty
+dog
+door
+doubt
+down
+drain
+dress
+drink
+drop
+dry
+dust
+ear
+early
+earth
+east
+edge
+egg
+end
+equal
+error
+even
+event
+ever
+every
+eye
+face
+fact
+fall
+false
+far
+farm
+fat
+fear
+field
+fight
+fire
+first
+fish
+fixed
+flag
+flame
+flat
+floor
+fly
+fold
+food
+foot
+for
+force
+fork
+form
+fowl
+frame
+free
+from
+front
+fruit
+full
+get
+girl
+give
+glass
+glove
+goat
+gold
+good
+grain
+grass
+great
+green
+grey
+grip
+group
+guide
+gun
+hair
+hand
+happy
+hard
+hat
+hate
+have
+head
+hear
+heart
+heat
+help
+high
+hole
+hook
+hope
+horn
+horse
+hour
+house
+how
+ice
+idea
+ill
+ink
+iron
+jelly
+jewel
+join
+judge
+jump
+keep
+key
+kick
+kind
+kiss
+knee
+knife
+knot
+land
+last
+late
+laugh
+law
+lead
+leaf
+left
+leg
+let
+level
+lift
+light
+like
+limit
+line
+linen
+lip
+list
+lock
+long
+look
+loose
+loss
+loud
+love
+low
+make
+male
+man
+map
+mark
+mass
+match
+may
+meal
+meat
+metal
+milk
+mind
+mine
+mist
+mixed
+money
+month
+moon
+mouth
+move
+much
+music
+nail
+name
+near
+neck
+need
+nerve
+net
+new
+news
+night
+noise
+north
+nose
+not
+note
+now
+nut
+off
+offer
+oil
+old
+only
+open
+order
+other
+out
+oven
+over
+owner
+page
+pain
+paint
+paper
+part
+past
+paste
+peace
+pen
+pig
+pin
+pipe
+place
+plane
+plant
+plate
+play
+point
+poor
+pot
+power
+price
+print
+prose
+pull
+pump
+push
+put
+quick
+quiet
+quite
+rail
+rain
+range
+rat
+rate
+ray
+ready
+red
+rest
+rice
+right
+ring
+river
+road
+rod
+roll
+roof
+room
+root
+rough
+round
+rub
+rule
+run
+sad
+safe
+sail
+salt
+same
+sand
+say
+scale
+screw
+sea
+seat
+see
+seed
+seem
+self
+send
+sense
+sex
+shade
+shake
+shame
+sharp
+sheep
+shelf
+ship
+shirt
+shock
+shoe
+short
+shut
+side
+sign
+silk
+size
+skin
+skirt
+sky
+sleep
+slip
+slope
+slow
+small
+smash
+smell
+smile
+smoke
+snake
+snow
+soap
+sock
+soft
+solid
+some
+son
+song
+sort
+sound
+soup
+south
+space
+spade
+spoon
+stage
+stamp
+star
+start
+steam
+steel
+stem
+step
+stick
+stiff
+still
+stone
+stop
+store
+story
+such
+sugar
+sun
+sweet
+swim
+table
+tail
+take
+talk
+tall
+taste
+tax
+test
+than
+that
+the
+then
+there
+thick
+thin
+thing
+this
+thumb
+tight
+till
+time
+tin
+tired
+toe
+tooth
+top
+touch
+town
+trade
+train
+tray
+tree
+trick
+true
+turn
+twist
+under
+unit
+use
+value
+verse
+very
+view
+voice
+walk
+wall
+war
+warm
+wash
+waste
+watch
+water
+wave
+wax
+way
+week
+well
+west
+wet
+wheel
+when
+where
+while
+whip
+white
+who
+why
+wide
+will
+wind
+wine
+wing
+wire
+wise
+with
+woman
+wood
+wool
+word
+work
+worm
+wound
+wrong
+year
+yes
+you
+young

0 comments on commit 66ea7b0

Please sign in to comment.
Something went wrong with that request. Please try again.