diff --git a/.idea/vcs.xml b/.idea/vcs.xml
index def6a6a..c80f219 100644
--- a/.idea/vcs.xml
+++ b/.idea/vcs.xml
@@ -1,7 +1,7 @@
-
+
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index e4f578e..886d1e1 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -1,11 +1,15 @@
-
-
+
-
+
+
+
+
+
+
@@ -26,30 +30,69 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
-
+
@@ -90,21 +133,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -119,13 +148,146 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $PROJECT_DIR$/tulnukas_paremale1suurem.png
+ $PROJECT_DIR$/tulnukas_paremale2suurem.png
+ $PROJECT_DIR$/tulnukas_paremale3suurem.png
+ $PROJECT_DIR$/tulnukas_vasakule1suurem.png
+ $PROJECT_DIR$/tulnukas_vasakule2suurem.png
+ $PROJECT_DIR$/tulnukas_vasakule3suurem.png
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -204,6 +366,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -325,18 +507,20 @@
-
+
+
-
-
+
+
-
-
+
+
+
@@ -350,29 +534,55 @@
1417879138834
1417879138834
+
+ 1418295980145
+ 1418295980145
+
+
+ 1418314420642
+ 1418314420642
+
+
+ 1418316997347
+ 1418316997347
+
+
+ 1418333574226
+ 1418333574226
+
+
+ 1418333697524
+ 1418333697524
+
+
+ 1418337927498
+ 1418337927498
+
+
-
-
+
+
+
-
-
+
+
-
-
-
+
+
+
-
+
-
+
@@ -390,99 +600,144 @@
+
+
+
+
-
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
-
+
+
+
+
+
+
+
+
+
+
-
+
-
-
+
+
+
-
+
-
-
-
+
+
+
+
+
+
+
+
+
+
-
+
-
-
+
+
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
-
+
-
-
+
+
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
+
-
-
+
+
+
-
+
-
-
-
+
+
@@ -511,99 +766,118 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
-
+
+
+
+
+
-
-
-
+
+
+
+
+
-
-
-
+
+
+
+
+
-
+
-
+
-
-
-
+
+
+
+
+
+
-
+
-
+
-
+
-
+
-
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Storm, Earth and Fire.mp3 b/Storm, Earth and Fire.mp3
new file mode 100644
index 0000000..60e1162
Binary files /dev/null and b/Storm, Earth and Fire.mp3 differ
diff --git a/__pycache__/constants.cpython-34.pyc b/__pycache__/constants.cpython-34.pyc
index 8e02daf..a80270f 100644
Binary files a/__pycache__/constants.cpython-34.pyc and b/__pycache__/constants.cpython-34.pyc differ
diff --git a/background1.jpg b/background1.jpg
deleted file mode 100644
index d342b30..0000000
Binary files a/background1.jpg and /dev/null differ
diff --git a/background2.jpg b/background2.jpg
deleted file mode 100644
index 3630cc1..0000000
Binary files a/background2.jpg and /dev/null differ
diff --git a/background3.jpg b/background3.jpg
deleted file mode 100644
index 8f6d630..0000000
Binary files a/background3.jpg and /dev/null differ
diff --git a/constants.py b/constants.py
index 10b3579..737890e 100644
--- a/constants.py
+++ b/constants.py
@@ -1,3 +1,6 @@
+
+
+#VARIABLES
DISPLAY_WIDTH = 1280
DISPLAY_HEIGHT = 720
@@ -9,6 +12,16 @@
black = (0,0,0)
bright_green = (0,255,0)
bright_red = (255,0,0)
+AQUA = (0,255,255)
+
+## DIRECTIONS
+UP = "UP"
+DOWN = "DOWN"
+LEFT = "LEFT"
+RIGHT = "RIGHT"
+
+## GAME DATA VARIABLES
+GRAVITY = 10
## IMAGES
seisab = "seisab.png"
@@ -18,18 +31,36 @@
liigubparemale1 = "jookseb_paremale_1.png"
liigubparemale2 = "jookseb_paremale_2.png"
liigubparemale3 = "jookseb_paremale_3.png"
-hüppabparemale1 = "hüppab_paremale_1.png"
-hüppabvasakule1 = "hüppab_vasakule_1.png"
-mollingusse_p = "mollingusse_paremale.png"
-mollingusse_v = "mollingusse_vasakule.png"
-jalaga_p = "jalaga_paremalt.png"
-jalaga_v = "jalaga_vasakult.png"
+hyppabparemale = "hyppab_paremale.png"
+hyppabvasakule = "hyppab_vasakule.png"
+mollingusse_paremale1 = "mollingusse_paremale1.png"
+mollingusse_paremale2 = "mollingusse_paremale2.png"
+mollingusse_paremale3 = "mollingusse_paremale3.png"
+mollingusse_vasakule1 = "mollingusse_vasakule1.png"
+mollingusse_vasakule2 = "mollingusse_vasakule2.png"
+mollingusse_vasakule3 = "mollingusse_vasakule3.png"
+mollingusse_paremale = [mollingusse_paremale1, mollingusse_paremale2, mollingusse_paremale3]
+mollingusse_vasakule = [mollingusse_vasakule1, mollingusse_vasakule2, mollingusse_vasakule3]
+mollingusse = {"RIGHT": mollingusse_paremale, "LEFT": mollingusse_vasakule}
+jalaga_mollingusse_paremale = "jalaga_paremalt.png"
+jalaga_mollingusse_vasakule = "jalaga_vasakult.png"
+mehike_liigub_vasemale = [liigubvasemale1, liigubvasemale2, liigubvasemale3]
+mehike_liigub_paremale = [liigubparemale1, liigubparemale2, liigubparemale3]
+mehike_hyppab_paremale = [hyppabparemale]
+mehike_hyppab_vasemale = [hyppabvasakule]
+mehike_seisab = [seisab]
+mehike_jookseb = {"LEFT": mehike_liigub_vasemale, "RIGHT": mehike_liigub_paremale, "DOWN": mehike_seisab, "UP": mehike_seisab}
+mehike_hyppab = {"LEFT": mehike_hyppab_vasemale, "RIGHT": mehike_hyppab_paremale, "DOWN": mehike_seisab, "UP": mehike_seisab}
beebiparemale1 = "beebi_paremale1.png"
beebiparemale2 = "beebi_paremale2.png"
beebiparemale3 = "beebi_paremale3.png"
beebivasemale1 = "beebi_vasakule1.png"
beebivasemale2 = "beebi_vasakule2.png"
beebivasemale3 = "beebi_vasakule3.png"
+beebi_seisab = [beebivasemale2]
+beebi_liigub_paremale = [beebiparemale1, beebiparemale2, beebiparemale3]
+beebi_liigub_vasakule = [beebivasemale1, beebivasemale2, beebivasemale3]
+beebi_jookseb = {LEFT: beebi_liigub_vasakule, RIGHT: beebi_liigub_paremale, UP: beebi_seisab, DOWN: beebi_seisab}
tulnukasparemale1 = "tulnukas_paremale1.png"
tulnukasparemale2 = "tulnukas_paremale2.png"
tulnukasparemale3 = "tulnukas_paremale3.png"
@@ -39,10 +70,13 @@
taust1 = "background1.png"
taust2 = "background2.png"
taust3 = "background3.png"
+backgrounds = [taust1, taust2, taust3]
##tiles and stuff
-gray_brick = "texture_grass_uus.jpg"
+gray_brick = "block64.png"
+grass_brick = "texture_grass.jpg"
+bricks = [gray_brick, grass_brick]
#platvormi võimalikud pealmised ruudud
diff --git a/hyppab_paremale.png b/hyppab_paremale.png
new file mode 100644
index 0000000..2d3a45c
Binary files /dev/null and b/hyppab_paremale.png differ
diff --git a/hyppab_vasakule.png b/hyppab_vasakule.png
new file mode 100644
index 0000000..3e002f5
Binary files /dev/null and b/hyppab_vasakule.png differ
diff --git "a/h\303\274ppab_paremale.png" "b/h\303\274ppab_paremale.png"
deleted file mode 100644
index 286d984..0000000
Binary files "a/h\303\274ppab_paremale.png" and /dev/null differ
diff --git "a/h\303\274ppab_paremale_uus.png" "b/h\303\274ppab_paremale_uus.png"
deleted file mode 100644
index cbac730..0000000
Binary files "a/h\303\274ppab_paremale_uus.png" and /dev/null differ
diff --git "a/h\303\274ppab_paremale_vana.png" "b/h\303\274ppab_paremale_vana.png"
deleted file mode 100644
index 91fcb49..0000000
Binary files "a/h\303\274ppab_paremale_vana.png" and /dev/null differ
diff --git "a/h\303\274ppab_vasakule.png" "b/h\303\274ppab_vasakule.png"
deleted file mode 100644
index b8d805e..0000000
Binary files "a/h\303\274ppab_vasakule.png" and /dev/null differ
diff --git "a/h\303\274ppab_vasakule_uus.png" "b/h\303\274ppab_vasakule_uus.png"
deleted file mode 100644
index 1f3a724..0000000
Binary files "a/h\303\274ppab_vasakule_uus.png" and /dev/null differ
diff --git "a/h\303\274ppab_vasakule_vana.png" "b/h\303\274ppab_vasakule_vana.png"
deleted file mode 100644
index 5bd24cb..0000000
Binary files "a/h\303\274ppab_vasakule_vana.png" and /dev/null differ
diff --git a/jalaga_paremalt.png b/jalaga_paremalt.png
index 7010e29..91a4492 100644
Binary files a/jalaga_paremalt.png and b/jalaga_paremalt.png differ
diff --git a/jalaga_vasakult.png b/jalaga_vasakult.png
index f47174c..49fa777 100644
Binary files a/jalaga_vasakult.png and b/jalaga_vasakult.png differ
diff --git a/moller.py b/moller.py
new file mode 100644
index 0000000..877bacf
--- /dev/null
+++ b/moller.py
@@ -0,0 +1,455 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import random
+from constants import *
+import pygame
+from pygame.locals import *
+all_sprites_list = pygame.sprite.Group()
+enemies_sprites_list = pygame.sprite.Group()
+to_add_enemies_sprites_list = pygame.sprite.Group()
+platform_sprites_list = pygame.sprite.Group()
+score = 0
+
+## ABIFUNKTSIOONID
+
+def loadImage(imagepath):
+ return pygame.image.load(imagepath)
+
+class Block(pygame.sprite.Sprite ):
+ def __init__(self, x=0, y=0, brick=grass_brick):
+ super().__init__()
+ #brick is not used
+ self.image = pygame.image.load(grass_brick)
+ self.rect = self.image.get_rect()
+ self.image.set_colorkey(WHITE)
+ self.rect.x = x
+ self.rect.y = y
+
+class Platform(Block):
+ floortiles = pygame.sprite.Group()
+ floortiletype = pygame.image.load(random.choice(bricks))
+ def __init__(self, x=0, y=0, generate=False):
+ super().__init__()
+ if generate:
+ self.generate()
+ def generate(self):
+ self.generate_floor()
+ self.generate_platforms(5)
+ def generate_floor(self, x=0, y=DISPLAY_HEIGHT):
+ for i in range(int(x), int(DISPLAY_WIDTH), self.image.get_size()[0]):
+ tile = Block(x=i, y= y - self.image.get_size()[1], brick=self.floortiletype)
+ self.floortiles.add(tile)
+ def generate_platforms(self, n=1):
+ for i in range(n):
+ position = random.randint(2,18) *64
+ obstacle = random.choice(OBSTACLES)
+ for coordinates in obstacle:
+ X = coordinates[0] + position
+ Y = coordinates[1] + DISPLAY_HEIGHT-128
+ tile = Block(x= X, y= Y, brick=self.floortiletype)
+ self.floortiles.add(tile)
+class Character(pygame.sprite.Sprite):
+ ## Textures go here
+ jooks_tekstuurid = []
+ hyppamine_tekstuurid = []
+ seismine_tekstuurid = []
+ ###################
+ isJumping = False
+ isPunching = False
+ jumpingClock = pygame.time.Clock()
+ jumpingTimer = jumpingClock.get_time()
+ jumpLength = 500
+ direction = UP
+ animationClock = pygame.time.Clock()
+ animationTimer = animationClock.get_time()
+ animationLength = 120
+ imageType = 0 # either 0, 1 or 2
+
+ kiirus = 10
+ liikumine = [0,0]
+
+ def __init__(self):
+ super().__init__()
+ self.animationClock.tick()
+ self.jumpingClock.tick()
+
+ ###LIIKUMINE
+
+ def dogravity(self):
+ self.rect.y += GRAVITY
+ if pygame.sprite.spritecollide(self, platform_sprites_list, False):
+ self.rect.y -= GRAVITY
+ self.isJumping = False # to stop jump when collision with ground
+
+ def liiguvasemale(self):
+ self.liikumine[0] += -self.kiirus
+ if self.rect.x < 0:
+ self.liikumine[0] += self.kiirus
+ self.direction = LEFT
+ def liiguparemale(self):
+ self.liikumine[0] += self.kiirus
+ self.direction = RIGHT
+ def liiguülesse(self):
+ self.liikumine[1] -= self.kiirus*2
+ def liigualla(self):
+ self.liikumine[1] += self.kiirus
+ self.direction = DOWN
+
+ def liigu(self):
+ x, y = self.liikumine[0], self.liikumine[1]
+ self.rect.x += x
+ self.rect.y += y
+ # print(x,y)
+ if(x == 0 and y == 0):
+ self.direction = DOWN
+ def hyppa(self):
+ if self.isJumping == False:
+ self.jumpingTimer = 0
+ self.isJumping = True
+
+ def check_hyppamine(self):
+ self.jumpingTimer += self.jumpingClock.tick()
+ if self.jumpingTimer <= self.jumpLength and self.isJumping:
+ self.liiguülesse()
+ elif self.isJumping == False and self.jumpingTimer != 0:
+ self.jumpingTimer = 0
+
+ ###ANIMATION RELATED
+ def assignImage(self, direction):
+ if self.isJumping:
+ image = loadImage(self.getImage(self.hyppamine_tekstuurid[direction]))
+ if self.isPunching:
+ if direction == RIGHT:
+ image = loadImage(jalaga_mollingusse_paremale)
+ elif direction == LEFT:
+ image = loadImage(jalaga_mollingusse_vasakule)
+ elif not self.isJumping:
+ image = loadImage(self.getImage(self.jooks_tekstuurid[direction]))
+ if self.isPunching:
+ if direction == RIGHT:
+ image = loadImage(self.getImage(mollingusse[direction]))
+ if direction == LEFT:
+ image = loadImage(self.getImage(mollingusse[direction]))
+ self.image = image
+
+ def getImage(self, image_list):
+ imageType = self.imageType
+ while len(image_list) <= imageType:
+ imageType -= 1
+ return image_list[imageType]
+
+ def updateAnimationType(self):
+ self.animationTimer += self.animationClock.tick()
+ if(self.animationTimer <= self.animationLength*1):
+ self.imageType = 0
+ elif(self.animationTimer <= self.animationLength*2):
+ self.imageType = 1
+ elif(self.animationTimer <= self.animationLength*3):
+ self.imageType = 2
+ if(self.animationTimer > self.animationLength*3):
+ self.animationTimer = 0
+
+ def peksmine(self):
+ self.isPunching = True
+ #####################
+
+ def check_collision(self):
+ if pygame.sprite.spritecollide(self, platform_sprites_list, False):
+ self.liikumine[0] = -self.liikumine[0]
+ self.liikumine[1] = -self.liikumine[1]
+ self.liigu()
+ self.liikumine[0], self.liikumine[1] = 0, 0
+
+ def update(self):
+ self.updateAnimationType()
+ self.check_hyppamine()
+ self.liigu()
+ self.check_collision()
+ self.assignImage(self.direction)
+ self.isPunching = False
+
+ self.dogravity()
+
+class AI(Character):
+ def __init__(self):
+ super().__init__()
+ self.kiirus = 5
+
+ def getPlayerPos(self, playerobj):
+ x = playerobj.rect.x
+ y = playerobj.rect.y
+ return [x, y]
+
+ def getMovement(self, playercords):
+ player_x, player_y = playercords[0], playercords[1]
+ ai_x, ai_y = self.rect.x, self.rect.y
+ if (ai_x - player_x > 0):
+ self.direction = LEFT
+ return [-self.kiirus, 0]
+ elif (ai_x - player_x < 0):
+ self.direction = RIGHT
+ return [self.kiirus, 0]
+ else:
+ return [0, 0]
+
+ def setLiikumine(self, newliikumine):
+ self.liikumine[0], self.liikumine[1] = newliikumine[0], newliikumine[1]
+
+class Titt(AI):
+ def __init__(self):
+ super().__init__()
+ self.image = pygame.image.load(beebi_seisab[0])
+ self.image.set_colorkey(WHITE)
+ self.rect = self.image.get_rect()
+ self.rect.x = (DISPLAY_WIDTH * 0.75)
+ self.rect.y = (DISPLAY_HEIGHT * 0.5)
+
+ ## tekstuurid
+ self.jooks_tekstuurid = beebi_jookseb
+ self.hyppamine_tekstuurid = beebi_jookseb
+ self.seismine_tekstuurid = beebi_seisab
+
+ self.animationLength = 10
+ def check_collision(self, playerobj):
+ if pygame.sprite.spritecollide(self, platform_sprites_list, False):
+ self.liikumine[0] = -self.liikumine[0]-1
+ self.liikumine[1] = -self.liikumine[1]-10
+ self.liigu()
+ self.liikumine[0], self.liikumine[1] = 0, 0
+
+ def update(self, playerobj):
+ self.setLiikumine(self.getMovement(self.getPlayerPos(playerobj)))
+ self.updateAnimationType()
+ self.liigu()
+ self.check_collision(playerobj)
+ self.check_hyppamine()
+ self.dogravity()
+ self.assignImage(self.direction)
+
+class Player(Character):
+ stamina = 100
+ staminaLength = 0
+ staminaReplenishRate = 2
+ staminaBurnRate = 5
+
+ def __init__(self):
+ super().__init__()
+ self.image = pygame.image.load(liigubparemale1)
+ self.image.set_colorkey(WHITE)
+ self.rect = self.image.get_rect()
+ self.rect.x = (DISPLAY_WIDTH * 0.05)
+ self.rect.y = (DISPLAY_HEIGHT * 0.5)
+
+ ## laeb mehikese tekstuurid
+ self.jooks_tekstuurid = mehike_jookseb
+ self.hyppamine_tekstuurid = mehike_hyppab
+ self.seismine_tekstuurid = mehike_seisab
+ def check_collision(self):
+ if pygame.sprite.spritecollide(self, platform_sprites_list, False):
+ self.liikumine[0] = -self.liikumine[0]
+ self.liikumine[1] = -self.liikumine[1]
+ self.liigu()
+ if pygame.sprite.spritecollide(self, enemies_sprites_list, False):
+ if not self.isPunching:
+ game_over()
+ if self.isPunching:
+ global score
+ score += 1
+ for sprite in enemies_sprites_list:
+ sprite.kill()
+ self.liikumine[0], self.liikumine[1] = 0, 0
+
+ def update_stamina(self):
+ if self.isPunching and self.stamina > 0:
+ self.depleteStamina()
+ if not self.isPunching and self.stamina < 100:
+ self.replenishStamina()
+
+ def check_stamina(self):
+ if self.stamina > self.staminaBurnRate:
+ return True
+ else:
+ return False
+
+ def depleteStamina(self):
+ self.stamina -= self.staminaBurnRate
+ def replenishStamina(self):
+ self.stamina += self.staminaReplenishRate
+
+ def drawStaminaRect(self, surface):
+ width = self.stamina*2
+ height = 50
+ pygame.draw.rect(surface, AQUA, (50, 50, self.stamina*2, height), 0)
+ pygame.draw.rect(surface, BLACK, (49, 49, width, height+2), 2)
+
+ def peksmine(self):
+ if self.check_stamina():
+ self.isPunching = True
+ else:
+ self.isPunching = False
+
+ def update(self):
+ self.updateAnimationType()
+ self.check_hyppamine()
+ self.liigu()
+ self.check_collision()
+ self.assignImage(self.direction)
+ self.update_stamina()
+ print(self.stamina)
+ self.isPunching = False
+ self.dogravity()
+ self.drawStaminaRect(gameDisplay)
+
+
+
+def nupp(msg,x,y,laius,kõrgus,värv1,värv2,action=None):
+ font = pygame.font.Font(None, 100)
+ mouse = pygame.mouse.get_pos()
+ click = pygame.mouse.get_pressed()
+ if x+laius > mouse[0] > x and y+kõrgus > mouse[1] > y:
+ pygame.draw.rect(gameDisplay, värv2, (x,y,laius,kõrgus))
+ if click[0] == 1 and action != None:
+ action()
+ else:
+ pygame.draw.rect(gameDisplay, värv1, (x,y,laius,kõrgus))
+ smallText = font.render(msg,1,black)
+## textSurf, textRect = text_objects(msg, smallText)
+## textRect.center = ((x+(w/2)), (y+(h/2)))
+ gameDisplay.blit(smallText, (x, y+50))
+
+def skoori_number(score):
+ font = pygame.font.Font(None, 40)
+ pygame.event.pump()
+ key = pygame.key.get_pressed()
+ score = str(score)
+ score_text = font.render(score,1,black)
+ gameDisplay.blit(score_text, (90, 0))
+
+def skooritabel(msg,x,y,laius,kõrgus,värv):
+ font = pygame.font.Font(None, 40)
+ text = font.render(msg,1,black)
+ gameDisplay.blit(text, (x, y))
+
+def clear_callback(surf, rect):
+ color = 255, 0, 0
+ surf.fill(color, rect)
+
+def uus_level():
+ for sprite in all_sprites_list:
+ sprite.kill()
+ for sprite in enemies_sprites_list:
+ sprite.kill()
+ for sprite in platform_sprites_list:
+ sprite.kill()
+ all_sprites_list.empty()
+ platform_sprites_list.empty()
+ to_add_enemies_sprites_list.add(Titt())
+ game_loop()
+
+
+def game_over():
+ font = pygame.font.Font(None, 280)
+ text = font.render("Game Over",1,black)
+ game_over = True
+ global score
+ score = 0
+ background = pygame.image.load(random.choice(backgrounds)).convert()
+ while game_over:
+ for event in pygame.event.get():
+ if event.type == pygame.QUIT:
+ pygame.quit()
+ quit()
+ gameDisplay.blit(background, (0,0))
+ gameDisplay.blit(text, (100, 200))
+ nupp("Play again",150,450,350,200,green,bright_green,uus_level)
+ nupp("Quit Game!",750,450,400,200,red,bright_red,quit)
+ pygame.display.update()
+ clock.tick(15)
+
+def game_intro():
+ background = pygame.image.load("background2.png").convert()
+ pygame.mixer.music.set_volume(0.5)
+ intro = True
+ while intro:
+ for event in pygame.event.get():
+ if event.type == pygame.QUIT:
+ pygame.quit()
+ quit()
+
+ gameDisplay.blit(background, (0,0))
+ nupp("Start Game!",150,450,400,200,green,bright_green,game)
+ nupp("Quit Game!",750,450,400,200,red,bright_red,quit)
+ pygame.display.update()
+ clock.tick(15)
+
+gameDisplay = pygame.display.set_mode((DISPLAY_WIDTH, DISPLAY_HEIGHT))
+
+
+clock = pygame.time.Clock()
+
+x = (DISPLAY_WIDTH * 0.25)
+y = (DISPLAY_HEIGHT * 0.5)
+
+
+def game():
+
+ pygame.mixer.music.set_volume(0.1)
+ pygame.display.set_caption("Koduvägivald")
+ pygame.key.set_repeat()
+ if not game_loop():
+ return False
+
+def game_loop():
+ titt = Titt()
+ player = Player()
+ põrand = Platform(generate=True)
+ print(põrand)
+ all_sprites_list.add(player, põrand.floortiles, titt) #+to_add_enemies_sprite_list
+ platform_sprites_list.add(põrand.floortiles)
+ enemies_sprites_list.add(titt) #+to_add_enemies_sprite_list
+ background = pygame.image.load(random.choice(backgrounds)).convert()
+ game = True
+ while game:
+ gameDisplay.blit(background, (0,0))
+ skooritabel("Score:",0,0,100,20,black)
+ skoori_number(score)
+ for event in pygame.event.get():
+ if event.type == pygame.QUIT:
+ game = False
+ #Kui läheb paremalt välja, siis teeb uue maailma
+
+ pygame.event.pump()
+ key = pygame.key.get_pressed()
+ if key[K_UP]:
+ player.hyppa()
+ if key[K_DOWN]:
+ player.liigualla()
+ if key[K_LEFT]:
+ player.liiguvasemale()
+ if key[K_RIGHT]:
+ player.liiguparemale()
+ if key[K_SPACE]:
+ player.peksmine()
+ if key[K_ESCAPE]:
+ game_over()
+
+ player.update()
+ titt.update(player)
+ all_sprites_list.draw(gameDisplay)
+ pygame.display.update()
+ clock.tick(30)
+ if player.rect.x >= DISPLAY_WIDTH:
+ newLevel = True
+ break
+
+ if newLevel:
+ uus_level()
+pygame.init()
+#Muusika
+pygame.mixer.music.load("Storm, Earth and Fire.mp3")
+pygame.mixer.music.play(-1,0.0)
+#Intro screen
+game_intro()
+pygame.quit()
+quit()
diff --git a/mollingusse_paremale.png b/mollingusse_paremale.png
deleted file mode 100644
index fdf852a..0000000
Binary files a/mollingusse_paremale.png and /dev/null differ
diff --git a/mollingusse_paremale1.png b/mollingusse_paremale1.png
new file mode 100644
index 0000000..b68970c
Binary files /dev/null and b/mollingusse_paremale1.png differ
diff --git a/mollingusse_paremale2.png b/mollingusse_paremale2.png
new file mode 100644
index 0000000..a59c6cb
Binary files /dev/null and b/mollingusse_paremale2.png differ
diff --git a/mollingusse_paremale3.png b/mollingusse_paremale3.png
new file mode 100644
index 0000000..df6b3af
Binary files /dev/null and b/mollingusse_paremale3.png differ
diff --git a/mollingusse_vasakule.png b/mollingusse_vasakule.png
deleted file mode 100644
index d9517ef..0000000
Binary files a/mollingusse_vasakule.png and /dev/null differ
diff --git a/mollingusse_vasakule1.png b/mollingusse_vasakule1.png
new file mode 100644
index 0000000..53b0218
Binary files /dev/null and b/mollingusse_vasakule1.png differ
diff --git a/mollingusse_vasakule2.png b/mollingusse_vasakule2.png
new file mode 100644
index 0000000..f085aae
Binary files /dev/null and b/mollingusse_vasakule2.png differ
diff --git a/mollingusse_vasakule3.png b/mollingusse_vasakule3.png
new file mode 100644
index 0000000..d9f9570
Binary files /dev/null and b/mollingusse_vasakule3.png differ
diff --git "a/m\303\244ller.py" "b/m\303\244ller.py"
deleted file mode 100644
index 863b4b3..0000000
--- "a/m\303\244ller.py"
+++ /dev/null
@@ -1,193 +0,0 @@
-import pygame
-import random
-from constants import *
-
-all_sprites_list = pygame.sprite.Group()
-platform_sprites_list = pygame.sprite.Group()
-
-class Block(pygame.sprite.Sprite):
- def __init__(self, x=0, y=0):
- super().__init__()
- self.image = pygame.image.load(gray_brick)
- self.rect = self.image.get_rect()
- self.image.set_colorkey(WHITE)
- self.rect.x = x
- self.rect.y = y
-
-class Platform(Block):
- floortiles = []
- def __init__(self, x=0, y=0, generate=False):
- super().__init__()
- if generate:
- self.generate()
- def generate(self):
- self.generate_floor()
- self.generate_on_floor(5)
- def generate_floor(self, x=0, y=DISPLAY_HEIGHT):
- for i in range(int(x), int(DISPLAY_WIDTH), self.image.get_size()[0]):
- tile = Block(x=i, y= y - self.image.get_size()[1])
- self.floortiles.append(tile)
- def generate_on_floor(self, n=1):
- for i in range(n):
- position = random.randint(2,18) *64
- obstacle = random.choice(OBSTACLES)
- for coordinates in obstacle:
- X = coordinates[0] + position
- Y = coordinates[1] + DISPLAY_HEIGHT-128
- tile = Block(x= X, y= Y)
- self.floortiles.append(tile)
-
-class Character(pygame.sprite.Sprite):
- def __init__(self):
- super().__init__()
-
-class Player(Character):
- #pilt_liigubvasemale = []
- #pilt_liigubparemale = []
- #pilt_hüppabvasemale = []
- #pilt_hüppabparemale = []
- kiirus = 10
-
- def __init__(self):
- super().__init__()
- self.image = pygame.image.load(liigubparemale1).convert_alpha()
- self.image.set_colorkey(WHITE)
- self.rect = self.image.get_rect()
-
- def hüppa(self):
- ...
-
- def mollingusse(self):
- self.image = pygame.image.load(mollingusse_p)
-
- def liiguvasemale(self):
- self.rect.x -= self.kiirus
- if pygame.sprite.spritecollide(self, platform_sprites_list, False):
- self.rect.x += self.kiirus
- else:
- # X = self.rect.x
- # Y = self.rect.y
- self.image = pygame.image.load(liigubvasemale1)
- # self.rect.x = X
- # self.rect.y = Y
- def liiguparemale(self):
- self.rect.x += self.kiirus
- if pygame.sprite.spritecollide(self, platform_sprites_list, False):
- self.rect.x -= self.kiirus
- else:
- self.image = pygame.image.load(liigubparemale1)
-
- # X = self.rect.x
- # Y = self.rect.y
- #self.image = pygame.image.load(liigubparemale1)
- #jooksebparemale.play()
- # self.rect = self.image.get_rect()
- # self.rect.x = X
- # self.rect.y = Y
- def liiguülesse(self):
- self.rect.y -= self.kiirus*2
- if pygame.sprite.spritecollide(self, platform_sprites_list, False):
- self.rect.y += self.kiirus
- else:
- # X, Y = self.rect.x, self.rect.y
- self.image = pygame.image.load(seisab)
- # self.rect = self.image.get_rect()
- # # self.rect.x = X
- # self.rect.y = Y
- def liigualla(self):
- self.rect.y += self.kiirus
- if pygame.sprite.spritecollide(self, platform_sprites_list, False):
- self.rect.y -= self.kiirus
- else:
- # X, Y = self.rect.x, self.rect.y
- self.image = pygame.image.load(seisab)
- # self.rect = self.image.get_rect()
- # self.rect.x = X
- # self.rect.y = Y
-
- def dogravity(self):
- self.rect.y += 10
- if pygame.sprite.spritecollide(self, platform_sprites_list, False):
- self.rect.y -= 10
-
-def nupp(msg,x,y,laius,kõrgus,värv1,värv2,action=None):
- font = pygame.font.Font(None, 100)
- mouse = pygame.mouse.get_pos()
- click = pygame.mouse.get_pressed()
- if x+laius > mouse[0] > x and y+kõrgus > mouse[1] > y:
- pygame.draw.rect(gameDisplay, värv2, (x,y,laius,kõrgus))
- if click[0] == 1 and action != None:
- action()
- else:
- pygame.draw.rect(gameDisplay, värv1, (x,y,laius,kõrgus))
- smallText = font.render(msg,1,black)
-## textSurf, textRect = text_objects(msg, smallText)
-## textRect.center = ((x+(w/2)), (y+(h/2)))
- gameDisplay.blit(smallText, (x, y+50))
-
-def game_intro():
- intro = True
- pygame.event.pump()
- key = pygame.key.get_pressed()
- while intro:
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- pygame.quit()
- quit()
-
- gameDisplay.blit(background, (0,0))
- nupp("Start Game!",150,450,400,200,green,bright_green,game_loop)
- nupp("Quit Game!",750,450,400,200,red,bright_red,quit)
- pygame.display.update()
- clock.tick(15)
-
-
-gameDisplay = pygame.display.set_mode((DISPLAY_WIDTH, DISPLAY_HEIGHT))
-
-background = pygame.image.load("background1.png").convert()
-clock = pygame.time.Clock()
-
-x = (DISPLAY_WIDTH * 0.25)
-y = (DISPLAY_HEIGHT * 0.5)
-
-def game_loop():
- pygame.display.set_caption("Maskantje")
- crashed = False
-
- player = Player()
- põrand = Platform(generate=True)
- all_sprites_list.add(player, põrand.floortiles)
- platform_sprites_list.add(põrand.floortiles)
- player.rect.x = x
- player.rect.y = y
-
- while not crashed:
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- crashed = True
- gameDisplay.blit(background, (0,0))
-
- pygame.event.pump()
- key = pygame.key.get_pressed()
- if key[pygame.K_UP]:
- player.liiguülesse()
- if key[pygame.K_DOWN]:
- player.liigualla()
- if key[pygame.K_LEFT]:
- player.liiguvasemale()
- if key[pygame.K_RIGHT]:
- player.liiguparemale()
-
- player.dogravity()
-
- if key[pygame.K_ESCAPE]:
- crashed = True
-
- all_sprites_list.draw(gameDisplay)
- pygame.display.update()
- clock.tick(30)
-
-pygame.init()
-game_intro()
-pygame.quit()
-quit()
diff --git "a/m\303\244ng_muudetud.py" "b/m\303\244ng_muudetud.py"
deleted file mode 100644
index 863b4b3..0000000
--- "a/m\303\244ng_muudetud.py"
+++ /dev/null
@@ -1,193 +0,0 @@
-import pygame
-import random
-from constants import *
-
-all_sprites_list = pygame.sprite.Group()
-platform_sprites_list = pygame.sprite.Group()
-
-class Block(pygame.sprite.Sprite):
- def __init__(self, x=0, y=0):
- super().__init__()
- self.image = pygame.image.load(gray_brick)
- self.rect = self.image.get_rect()
- self.image.set_colorkey(WHITE)
- self.rect.x = x
- self.rect.y = y
-
-class Platform(Block):
- floortiles = []
- def __init__(self, x=0, y=0, generate=False):
- super().__init__()
- if generate:
- self.generate()
- def generate(self):
- self.generate_floor()
- self.generate_on_floor(5)
- def generate_floor(self, x=0, y=DISPLAY_HEIGHT):
- for i in range(int(x), int(DISPLAY_WIDTH), self.image.get_size()[0]):
- tile = Block(x=i, y= y - self.image.get_size()[1])
- self.floortiles.append(tile)
- def generate_on_floor(self, n=1):
- for i in range(n):
- position = random.randint(2,18) *64
- obstacle = random.choice(OBSTACLES)
- for coordinates in obstacle:
- X = coordinates[0] + position
- Y = coordinates[1] + DISPLAY_HEIGHT-128
- tile = Block(x= X, y= Y)
- self.floortiles.append(tile)
-
-class Character(pygame.sprite.Sprite):
- def __init__(self):
- super().__init__()
-
-class Player(Character):
- #pilt_liigubvasemale = []
- #pilt_liigubparemale = []
- #pilt_hüppabvasemale = []
- #pilt_hüppabparemale = []
- kiirus = 10
-
- def __init__(self):
- super().__init__()
- self.image = pygame.image.load(liigubparemale1).convert_alpha()
- self.image.set_colorkey(WHITE)
- self.rect = self.image.get_rect()
-
- def hüppa(self):
- ...
-
- def mollingusse(self):
- self.image = pygame.image.load(mollingusse_p)
-
- def liiguvasemale(self):
- self.rect.x -= self.kiirus
- if pygame.sprite.spritecollide(self, platform_sprites_list, False):
- self.rect.x += self.kiirus
- else:
- # X = self.rect.x
- # Y = self.rect.y
- self.image = pygame.image.load(liigubvasemale1)
- # self.rect.x = X
- # self.rect.y = Y
- def liiguparemale(self):
- self.rect.x += self.kiirus
- if pygame.sprite.spritecollide(self, platform_sprites_list, False):
- self.rect.x -= self.kiirus
- else:
- self.image = pygame.image.load(liigubparemale1)
-
- # X = self.rect.x
- # Y = self.rect.y
- #self.image = pygame.image.load(liigubparemale1)
- #jooksebparemale.play()
- # self.rect = self.image.get_rect()
- # self.rect.x = X
- # self.rect.y = Y
- def liiguülesse(self):
- self.rect.y -= self.kiirus*2
- if pygame.sprite.spritecollide(self, platform_sprites_list, False):
- self.rect.y += self.kiirus
- else:
- # X, Y = self.rect.x, self.rect.y
- self.image = pygame.image.load(seisab)
- # self.rect = self.image.get_rect()
- # # self.rect.x = X
- # self.rect.y = Y
- def liigualla(self):
- self.rect.y += self.kiirus
- if pygame.sprite.spritecollide(self, platform_sprites_list, False):
- self.rect.y -= self.kiirus
- else:
- # X, Y = self.rect.x, self.rect.y
- self.image = pygame.image.load(seisab)
- # self.rect = self.image.get_rect()
- # self.rect.x = X
- # self.rect.y = Y
-
- def dogravity(self):
- self.rect.y += 10
- if pygame.sprite.spritecollide(self, platform_sprites_list, False):
- self.rect.y -= 10
-
-def nupp(msg,x,y,laius,kõrgus,värv1,värv2,action=None):
- font = pygame.font.Font(None, 100)
- mouse = pygame.mouse.get_pos()
- click = pygame.mouse.get_pressed()
- if x+laius > mouse[0] > x and y+kõrgus > mouse[1] > y:
- pygame.draw.rect(gameDisplay, värv2, (x,y,laius,kõrgus))
- if click[0] == 1 and action != None:
- action()
- else:
- pygame.draw.rect(gameDisplay, värv1, (x,y,laius,kõrgus))
- smallText = font.render(msg,1,black)
-## textSurf, textRect = text_objects(msg, smallText)
-## textRect.center = ((x+(w/2)), (y+(h/2)))
- gameDisplay.blit(smallText, (x, y+50))
-
-def game_intro():
- intro = True
- pygame.event.pump()
- key = pygame.key.get_pressed()
- while intro:
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- pygame.quit()
- quit()
-
- gameDisplay.blit(background, (0,0))
- nupp("Start Game!",150,450,400,200,green,bright_green,game_loop)
- nupp("Quit Game!",750,450,400,200,red,bright_red,quit)
- pygame.display.update()
- clock.tick(15)
-
-
-gameDisplay = pygame.display.set_mode((DISPLAY_WIDTH, DISPLAY_HEIGHT))
-
-background = pygame.image.load("background1.png").convert()
-clock = pygame.time.Clock()
-
-x = (DISPLAY_WIDTH * 0.25)
-y = (DISPLAY_HEIGHT * 0.5)
-
-def game_loop():
- pygame.display.set_caption("Maskantje")
- crashed = False
-
- player = Player()
- põrand = Platform(generate=True)
- all_sprites_list.add(player, põrand.floortiles)
- platform_sprites_list.add(põrand.floortiles)
- player.rect.x = x
- player.rect.y = y
-
- while not crashed:
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- crashed = True
- gameDisplay.blit(background, (0,0))
-
- pygame.event.pump()
- key = pygame.key.get_pressed()
- if key[pygame.K_UP]:
- player.liiguülesse()
- if key[pygame.K_DOWN]:
- player.liigualla()
- if key[pygame.K_LEFT]:
- player.liiguvasemale()
- if key[pygame.K_RIGHT]:
- player.liiguparemale()
-
- player.dogravity()
-
- if key[pygame.K_ESCAPE]:
- crashed = True
-
- all_sprites_list.draw(gameDisplay)
- pygame.display.update()
- clock.tick(30)
-
-pygame.init()
-game_intro()
-pygame.quit()
-quit()
diff --git a/screenshot03.jpg b/screenshot03.jpg
deleted file mode 100644
index 8f6d630..0000000
Binary files a/screenshot03.jpg and /dev/null differ
diff --git a/smiley3.png b/smiley3.png
deleted file mode 100644
index d627de5..0000000
Binary files a/smiley3.png and /dev/null differ
diff --git a/spritesheet.py b/spritesheet.py
deleted file mode 100644
index c68d1d3..0000000
--- a/spritesheet.py
+++ /dev/null
@@ -1,32 +0,0 @@
-# Taken from http://www.pygame.org/wiki/Spritesheet?parent=CookBook
-
-import pygame
-
-class spritesheet(object):
- def __init__(self, filename):
- try:
- self.sheet = pygame.image.load(filename).convert()
- except pygame.error, message:
- print 'Unable to load spritesheet image:', filename
- raise SystemExit, message
- # Load a specific image from a specific rectangle
- def image_at(self, rectangle, colorkey = None):
- "Loads image from x,y,x+offset,y+offset"
- rect = pygame.Rect(rectangle)
- image = pygame.Surface(rect.size).convert()
- image.blit(self.sheet, (0, 0), rect)
- if colorkey is not None:
- if colorkey is -1:
- colorkey = image.get_at((0,0))
- image.set_colorkey(colorkey, pygame.RLEACCEL)
- return image
- # Load a whole bunch of images and return them as a list
- def images_at(self, rects, colorkey = None):
- "Loads multiple images, supply a list of coordinates"
- return [self.image_at(rect, colorkey) for rect in rects]
- # Load a whole strip of images
- def load_strip(self, rect, image_count, colorkey = None):
- "Loads a strip of images and returns them as a list"
- tups = [(rect[0]+rect[2]*x, rect[1], rect[2], rect[3])
- for x in range(image_count)]
- return self.images_at(tups, colorkey)
diff --git a/texture.png b/texture.png
deleted file mode 100644
index cb1ba05..0000000
Binary files a/texture.png and /dev/null differ
diff --git a/texture_grass_uus.jpg b/texture_grass.jpg
similarity index 100%
rename from texture_grass_uus.jpg
rename to texture_grass.jpg
diff --git a/texture_grass1.jpg b/texture_grass1.jpg
deleted file mode 100644
index 5cf122c..0000000
Binary files a/texture_grass1.jpg and /dev/null differ
diff --git a/texture_grass2.jpg b/texture_grass2.jpg
deleted file mode 100644
index 451ca8a..0000000
Binary files a/texture_grass2.jpg and /dev/null differ
diff --git a/texture_top.png b/texture_top.png
deleted file mode 100644
index a665e3d..0000000
Binary files a/texture_top.png and /dev/null differ
diff --git a/tile6.png b/tile6.png
deleted file mode 100644
index 4462c43..0000000
Binary files a/tile6.png and /dev/null differ
diff --git a/tulnukas_paremale1suurem.png b/tulnukas_paremale1suurem.png
new file mode 100644
index 0000000..f2db150
Binary files /dev/null and b/tulnukas_paremale1suurem.png differ
diff --git a/tulnukas_paremale2suurem.png b/tulnukas_paremale2suurem.png
new file mode 100644
index 0000000..d8faa3d
Binary files /dev/null and b/tulnukas_paremale2suurem.png differ
diff --git a/tulnukas_paremale3suurem.png b/tulnukas_paremale3suurem.png
new file mode 100644
index 0000000..4df5224
Binary files /dev/null and b/tulnukas_paremale3suurem.png differ
diff --git a/tulnukas_vasakule1suurem.png b/tulnukas_vasakule1suurem.png
new file mode 100644
index 0000000..3542cd2
Binary files /dev/null and b/tulnukas_vasakule1suurem.png differ
diff --git a/tulnukas_vasakule2suurem.png b/tulnukas_vasakule2suurem.png
new file mode 100644
index 0000000..dd97d36
Binary files /dev/null and b/tulnukas_vasakule2suurem.png differ
diff --git a/tulnukas_vasakule3suurem.png b/tulnukas_vasakule3suurem.png
new file mode 100644
index 0000000..b30164d
Binary files /dev/null and b/tulnukas_vasakule3suurem.png differ