From e74fd9c9793c7f6a2e4d6ce09b33f2b803a35ab1 Mon Sep 17 00:00:00 2001 From: Voussoir Date: Tue, 14 Oct 2014 23:22:24 -0700 Subject: [PATCH] else --- Dodgy/README.md | 2 -- Dodgy/changelog.md | 8 ++++- Dodgy/dodgy.py | 78 +++++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 81 insertions(+), 7 deletions(-) diff --git a/Dodgy/README.md b/Dodgy/README.md index f545b87..24b6b37 100644 --- a/Dodgy/README.md +++ b/Dodgy/README.md @@ -15,8 +15,6 @@ Ideas for later: Smokescreen pickup: Exclamators cannot detect player. Will wander randomly for 5-10 steps -Gold candy: Special candy which gives quadruple points. Is invisible, flashes every 5 steps, relocates if not found fast enough - Hats. Enemies move faster as the game goes on diff --git a/Dodgy/changelog.md b/Dodgy/changelog.md index 9a49a4b..a8bc92a 100644 --- a/Dodgy/changelog.md +++ b/Dodgy/changelog.md @@ -28,4 +28,10 @@ = No hats yet -= Changed priority and efficiency of entity collisions \ No newline at end of file += Changed priority and efficiency of entity collisions + + +###14 October 2014 + +\+ Added Gold candy. Has randomized chance of spawning. Looks like normal candy except it flashes differently every few steps + diff --git a/Dodgy/dodgy.py b/Dodgy/dodgy.py index bd24be3..90817cf 100644 --- a/Dodgy/dodgy.py +++ b/Dodgy/dodgy.py @@ -1,4 +1,4 @@ -#14 October 12:33 +#14 October 12:47 import tkinter from tkinter import Tk, Label, Frame @@ -63,6 +63,7 @@ class tgame: self.enemylist = [] self.bomblist = [] self.phantomlist = [] + self.goldcandylist = [] self.entlist = [] self.symbols = {'char':'H', 'wall':'#', 'floor':' '} self.stepstaken = 0 @@ -70,15 +71,19 @@ class tgame: self.bombs = 0 self.enemyspawnrate = 50 - self.enemyspawnmindist = 6 + self.enemyspawnmindist = 9 self.enemydocollide = False self.candyspawnrate = 4 self.isdeath = False self.bombcost = 4 - self.phantomcost = 100 + self.phantomcost = 60 self.helplabelindex = -1 + self.goldcandyflashrate = 8 + self.goldcandyspawnrate = 40 + self.goldcandyspawnrand = 4 + self.helplabeltexts = [ "=Movement =Bomb =Phantom =Restart ->", "=Movement =Bomb =Phantom =Restart ->", @@ -144,6 +149,13 @@ class tgame: self.entlist.remove(candies) del candies + for goldcandies in self.goldcandylist: + if goldcandies.x == self.xpos and goldcandies.y == self.ypos: + print('[ ' + goldcandy.symbol + ' ] Gold collection with ' + str(goldcandies.lifespan) + ' remaining') + collect(5) + self.goldcandylist.remove(goldcandies) + self.entlist.remove(goldcandies) + for enemies in self.enemylist: if enemies.x == self.xpos and enemies.y == self.ypos: print('[ ' + self.symbols['char'] + ' ] Death') @@ -154,6 +166,11 @@ class tgame: self.stepstaken += 1 if self.stepstaken % self.candyspawnrate == 0: spawncandy() + + goldchance = random.randint(self.stepstaken-self.goldcandyspawnrand, self.stepstaken+self.goldcandyspawnrand) + #print(goldchance) + if goldchance % self.goldcandyspawnrate == 0: + spawngoldcandy() if self.stepstaken % self.enemyspawnrate == 0: spawnenemy() for x in range(self.stepstaken // 200): @@ -186,6 +203,13 @@ class tgame: en.y = arenasize-2 mfresh() + for goldcandies in self.goldcandylist: + goldcandies.tick(self.goldcandyflashrate) + if goldcandies.lifespan <= 0: + self.goldcandylist.remove(goldcandies) + self.entlist.remove(goldcandies) + del goldcandies + for bombs in self.bomblist: for enemies in self.enemylist: if enemies.x == bombs.x and enemies.y == bombs.y: @@ -315,6 +339,38 @@ class tgame: self.entlist.append(newcan) mfresh() + + def spawngoldcandy(forcex=None, forcey=None): + goodtogo = True + if forcex == None or forcey == None: + newx = random.randint(1, arenasize-2) + newy = random.randint(1, arenasize-2) + spawntries = 0 + while (dist(self.xpos, self.ypos, newx, newy) < self.enemyspawnmindist): + newx = random.randint(1, arenasize-2) + newy = random.randint(1, arenasize-2) + spawntries += 1 + #print('Rerolling from', newx, newy) + if spawntries == 20: + #print('Could not spawn enemy') + goodtogo = False + break + else: + newx = forcex + newy = forcey + if goodtogo: + for entity in self.entlist: + if entity.x == newx and entity.y == newy: + goodtogo = False + if goodtogo: + lifespan= dist(self.xpos, self.ypos, newx, newy) + lifespan *= 2 + print('[ ' + goldcandy.symbol + ' ] New gold candy') + newcan = goldcandy(newx, newy, lifespan) + self.goldcandylist.append(newcan) + self.entlist.append(newcan) + mfresh() + def spawnenemy(): newx = random.randint(1, arenasize-2) newy = random.randint(1, arenasize-2) @@ -324,7 +380,7 @@ class tgame: newx = random.randint(1, arenasize-2) newy = random.randint(1, arenasize-2) spawntries += 1 - print('Rerolling from', newx, newy) + #print('Rerolling from', newx, newy) if spawntries == 10: print('Could not spawn enemy') goodtogo = False @@ -431,4 +487,18 @@ class phantom: self.lifespan = lifespan self.symbol = phantom.symbol +class goldcandy: + symbol = "$" + def __init__(self, x, y, lifespan): + self.x = x + self.y = y + self.lifespan = lifespan + self.symbol = goldcandy.symbol + def tick(self, flashrate): + self.lifespan -= 1 + if self.lifespan % flashrate == 0 or self.lifespan % flashrate == 1: + self.symbol = goldcandy.symbol + else: + self.symbol = candy.symbol + t = tgame() \ No newline at end of file