Migration from GitHub
This commit is contained in:
@@ -0,0 +1,182 @@
|
||||
##################################
|
||||
#
|
||||
# Sight Words - For Kids by Kids
|
||||
#
|
||||
##################################
|
||||
# TODO:
|
||||
# - Add Scene to Pick Wordlists
|
||||
# - Create CheckBox Object
|
||||
# - Add Image to main screen
|
||||
# - Add Image to Word Game
|
||||
# - Make the Colors easier to change
|
||||
# - Add Delay 'animation' to word changing
|
||||
# - Add alphabet list
|
||||
|
||||
|
||||
import random
|
||||
import pygame
|
||||
import pygame.freetype
|
||||
import os
|
||||
|
||||
FONT = "resources/fonts/iosevka-regular.ttf"
|
||||
HEIGHT = 600
|
||||
WIDTH = 800
|
||||
DISPLAY = (WIDTH, HEIGHT)
|
||||
DEPTH = 0
|
||||
FLAGS = 0
|
||||
|
||||
CORRECT = 0
|
||||
MISSED = 0
|
||||
|
||||
class Scene(object):
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def render(self, screen):
|
||||
raise NotImplementedError
|
||||
|
||||
def update(self):
|
||||
raise NotImplementedError
|
||||
|
||||
def handle_events(self, events):
|
||||
raise NotImplementedError
|
||||
|
||||
class GameScene(object):
|
||||
def next_word(self):
|
||||
return self.words[random.randint(0,len(self.words)-1)]
|
||||
|
||||
def write_word(self, screen, text):
|
||||
# blank the word area
|
||||
pygame.draw.rect(screen,
|
||||
(20,20,20),
|
||||
(0,0,WIDTH*0.75, HEIGHT),
|
||||
0
|
||||
)
|
||||
|
||||
# Write the current word
|
||||
text_surface, _ = self.font.render(text, pygame.Color("DeepPink"))
|
||||
text_rect = text_surface.get_rect(center=((WIDTH//8)*3, HEIGHT//2))
|
||||
screen.blit(text_surface, text_rect)
|
||||
pygame.display.update()
|
||||
|
||||
def __init__(self):
|
||||
super(GameScene, self).__init__()
|
||||
self.font = pygame.freetype.Font(FONT, 72)
|
||||
self.sfont = pygame.freetype.Font(FONT, 24)
|
||||
self.sound_correct = pygame.mixer.Sound('resources/sounds/MENU A_Select.wav')
|
||||
self.sound_missed = pygame.mixer.Sound('resources/sounds/ALERT_Error.wav')
|
||||
self.CORRECT = 0
|
||||
self.MISSED = 0
|
||||
self.updating = False
|
||||
self.words = []
|
||||
|
||||
# Load all the words in the wordlists
|
||||
path = "resources/wordlists/"
|
||||
filelist = os.listdir(path)
|
||||
for wordlistf in filelist:
|
||||
with open(path+wordlistf) as f:
|
||||
for line in f:
|
||||
self.words.append(line.rstrip())
|
||||
print(self.words)
|
||||
self.current_word = self.next_word()
|
||||
pass
|
||||
|
||||
def render(self, screen):
|
||||
# Blank the Screen
|
||||
screen.fill((20,20,20))
|
||||
|
||||
if self.updating:
|
||||
self.write_word(screen, "...")
|
||||
pygame.time.wait(200)
|
||||
self.updating = False
|
||||
|
||||
self.write_word(screen, self.current_word)
|
||||
|
||||
# Write the Correct Score
|
||||
yes_surface, _ = self.font.render(str(self.CORRECT), pygame.Color("Green"))
|
||||
yes_rect = yes_surface.get_rect(center=((WIDTH//8)*7, (HEIGHT//3)))
|
||||
screen.blit(yes_surface, yes_rect)
|
||||
|
||||
# Write the Missed Score
|
||||
no_surface, _ = self.font.render(str(self.MISSED), pygame.Color("Red"))
|
||||
no_rect = no_surface.get_rect(center=((WIDTH//8)*7, (HEIGHT//3)*2))
|
||||
screen.blit(no_surface, no_rect)
|
||||
|
||||
def update(self):
|
||||
pass
|
||||
|
||||
def handle_events(self, events):
|
||||
for e in events:
|
||||
if e.type == pygame.KEYDOWN:
|
||||
if e.key == pygame.K_q:
|
||||
pygame.quit()
|
||||
elif e.key == pygame.K_m:
|
||||
self.current_word = self.next_word()
|
||||
pygame.mixer.Sound.play(self.sound_correct)
|
||||
self.CORRECT += 1
|
||||
self.updating = True
|
||||
elif e.key == pygame.K_z:
|
||||
self.current_word = self.next_word()
|
||||
pygame.mixer.Sound.play(self.sound_missed)
|
||||
self.MISSED += 1
|
||||
self.updating = True
|
||||
|
||||
class TitleScene(object):
|
||||
|
||||
def __init__(self):
|
||||
super(TitleScene, self).__init__()
|
||||
self.font = pygame.freetype.Font(FONT, 72)
|
||||
self.sfont = pygame.freetype.Font(FONT, 24)
|
||||
|
||||
def render(self, screen):
|
||||
# beware: ugly!
|
||||
screen.fill((20, 20, 20))
|
||||
text1, _ = self.font.render('Sight Words', pygame.Color("DeepPink"))
|
||||
text1_rect = text1.get_rect(center=(WIDTH//2,HEIGHT//2))
|
||||
screen.blit(text1, text1_rect)
|
||||
|
||||
text2, _ = self.sfont.render('> press space to start <', pygame.Color("Purple"))
|
||||
text2_rect = text2.get_rect(center=(WIDTH//2,(HEIGHT - 50)))
|
||||
screen.blit(text2, text2_rect)
|
||||
|
||||
def update(self):
|
||||
pass
|
||||
|
||||
def handle_events(self, events):
|
||||
for e in events:
|
||||
if e.type == pygame.KEYDOWN and e.key == pygame.K_SPACE:
|
||||
self.manager.go_to(GameScene())
|
||||
#pygame.quit()
|
||||
|
||||
|
||||
class SceneMananger(object):
|
||||
def __init__(self):
|
||||
self.go_to(TitleScene())
|
||||
|
||||
def go_to(self, scene):
|
||||
self.scene = scene
|
||||
self.scene.manager = self
|
||||
|
||||
def main():
|
||||
pygame.init()
|
||||
screen = pygame.display.set_mode(DISPLAY, FLAGS, DEPTH)
|
||||
pygame.display.set_caption("Sight Words - For Kids By Kids")
|
||||
clock = pygame.time.Clock()
|
||||
running = True
|
||||
|
||||
manager = SceneMananger()
|
||||
|
||||
while running:
|
||||
clock.tick(30)
|
||||
|
||||
if pygame.event.get(pygame.QUIT):
|
||||
running = False
|
||||
return
|
||||
manager.scene.handle_events(pygame.event.get())
|
||||
manager.scene.update()
|
||||
manager.scene.render(screen)
|
||||
pygame.display.flip()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1 @@
|
||||
pygame==2.0.0
|
||||
Binary file not shown.
@@ -0,0 +1,39 @@
|
||||
then
|
||||
big
|
||||
my
|
||||
me
|
||||
as
|
||||
then
|
||||
some
|
||||
the
|
||||
two
|
||||
and
|
||||
of
|
||||
a
|
||||
I
|
||||
you
|
||||
your
|
||||
his
|
||||
her
|
||||
hers
|
||||
him
|
||||
it
|
||||
in
|
||||
said
|
||||
had
|
||||
for
|
||||
up
|
||||
we
|
||||
is
|
||||
look
|
||||
go
|
||||
can
|
||||
down
|
||||
little
|
||||
some
|
||||
big
|
||||
one
|
||||
two
|
||||
see
|
||||
not
|
||||
as
|
||||
@@ -0,0 +1,20 @@
|
||||
my
|
||||
me
|
||||
big
|
||||
then
|
||||
come
|
||||
blue
|
||||
red
|
||||
could
|
||||
where
|
||||
jump
|
||||
away
|
||||
when
|
||||
here
|
||||
help
|
||||
make
|
||||
were
|
||||
yellow
|
||||
to
|
||||
play
|
||||
them
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,19 @@
|
||||
Title: UI Sound Pack 1
|
||||
Artist: ViRiX (David Mckee)
|
||||
Creation: 2012
|
||||
|
||||
There are eleven user interface sounds in this pack at 44.1 KHZ in .wav format. Keep in mind though that just because it says UI doesn't mean you HAVE to use them for UI sounds.
|
||||
|
||||
They can be used in any project, commercial or noncommercial. The only thing I ask is that you put the following in the credits.
|
||||
|
||||
"Some of the sounds in this project were created by David McKee (ViRiX)
|
||||
soundcloud.com/virix"
|
||||
|
||||
If you'd like me to do some custom sounds or music for you, just contact me.
|
||||
|
||||
email: dmckee1009@gmail.com
|
||||
facebook: facebook.com/virixcore
|
||||
Page: www.soundcloud.com/virix
|
||||
|
||||
Thanks and enjoy.
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
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
|
||||
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
|
||||
Reference in New Issue
Block a user