else
This commit is contained in:
parent
9afdfe659e
commit
e74fd9c979
3 changed files with 81 additions and 7 deletions
|
@ -15,8 +15,6 @@ Ideas for later:
|
||||||
|
|
||||||
Smokescreen pickup: Exclamators cannot detect player. Will wander randomly for 5-10 steps
|
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.
|
Hats.
|
||||||
|
|
||||||
Enemies move faster as the game goes on
|
Enemies move faster as the game goes on
|
||||||
|
|
|
@ -28,4 +28,10 @@
|
||||||
|
|
||||||
= No hats yet
|
= No hats yet
|
||||||
|
|
||||||
= Changed priority and efficiency of entity collisions
|
= 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
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#14 October 12:33
|
#14 October 12:47
|
||||||
|
|
||||||
import tkinter
|
import tkinter
|
||||||
from tkinter import Tk, Label, Frame
|
from tkinter import Tk, Label, Frame
|
||||||
|
@ -63,6 +63,7 @@ class tgame:
|
||||||
self.enemylist = []
|
self.enemylist = []
|
||||||
self.bomblist = []
|
self.bomblist = []
|
||||||
self.phantomlist = []
|
self.phantomlist = []
|
||||||
|
self.goldcandylist = []
|
||||||
self.entlist = []
|
self.entlist = []
|
||||||
self.symbols = {'char':'H', 'wall':'#', 'floor':' '}
|
self.symbols = {'char':'H', 'wall':'#', 'floor':' '}
|
||||||
self.stepstaken = 0
|
self.stepstaken = 0
|
||||||
|
@ -70,15 +71,19 @@ class tgame:
|
||||||
self.bombs = 0
|
self.bombs = 0
|
||||||
|
|
||||||
self.enemyspawnrate = 50
|
self.enemyspawnrate = 50
|
||||||
self.enemyspawnmindist = 6
|
self.enemyspawnmindist = 9
|
||||||
self.enemydocollide = False
|
self.enemydocollide = False
|
||||||
self.candyspawnrate = 4
|
self.candyspawnrate = 4
|
||||||
|
|
||||||
self.isdeath = False
|
self.isdeath = False
|
||||||
self.bombcost = 4
|
self.bombcost = 4
|
||||||
self.phantomcost = 100
|
self.phantomcost = 60
|
||||||
self.helplabelindex = -1
|
self.helplabelindex = -1
|
||||||
|
|
||||||
|
self.goldcandyflashrate = 8
|
||||||
|
self.goldcandyspawnrate = 40
|
||||||
|
self.goldcandyspawnrand = 4
|
||||||
|
|
||||||
self.helplabeltexts = [
|
self.helplabeltexts = [
|
||||||
"<WASD>=Movement <J>=Bomb <K>=Phantom <R>=Restart ->",
|
"<WASD>=Movement <J>=Bomb <K>=Phantom <R>=Restart ->",
|
||||||
"<UDLR>=Movement <Z>=Bomb <X>=Phantom <R>=Restart ->",
|
"<UDLR>=Movement <Z>=Bomb <X>=Phantom <R>=Restart ->",
|
||||||
|
@ -144,6 +149,13 @@ class tgame:
|
||||||
self.entlist.remove(candies)
|
self.entlist.remove(candies)
|
||||||
del 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:
|
for enemies in self.enemylist:
|
||||||
if enemies.x == self.xpos and enemies.y == self.ypos:
|
if enemies.x == self.xpos and enemies.y == self.ypos:
|
||||||
print('[ ' + self.symbols['char'] + ' ] Death')
|
print('[ ' + self.symbols['char'] + ' ] Death')
|
||||||
|
@ -154,6 +166,11 @@ class tgame:
|
||||||
self.stepstaken += 1
|
self.stepstaken += 1
|
||||||
if self.stepstaken % self.candyspawnrate == 0:
|
if self.stepstaken % self.candyspawnrate == 0:
|
||||||
spawncandy()
|
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:
|
if self.stepstaken % self.enemyspawnrate == 0:
|
||||||
spawnenemy()
|
spawnenemy()
|
||||||
for x in range(self.stepstaken // 200):
|
for x in range(self.stepstaken // 200):
|
||||||
|
@ -186,6 +203,13 @@ class tgame:
|
||||||
en.y = arenasize-2
|
en.y = arenasize-2
|
||||||
mfresh()
|
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 bombs in self.bomblist:
|
||||||
for enemies in self.enemylist:
|
for enemies in self.enemylist:
|
||||||
if enemies.x == bombs.x and enemies.y == bombs.y:
|
if enemies.x == bombs.x and enemies.y == bombs.y:
|
||||||
|
@ -315,6 +339,38 @@ class tgame:
|
||||||
self.entlist.append(newcan)
|
self.entlist.append(newcan)
|
||||||
mfresh()
|
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():
|
def spawnenemy():
|
||||||
newx = random.randint(1, arenasize-2)
|
newx = random.randint(1, arenasize-2)
|
||||||
newy = random.randint(1, arenasize-2)
|
newy = random.randint(1, arenasize-2)
|
||||||
|
@ -324,7 +380,7 @@ class tgame:
|
||||||
newx = random.randint(1, arenasize-2)
|
newx = random.randint(1, arenasize-2)
|
||||||
newy = random.randint(1, arenasize-2)
|
newy = random.randint(1, arenasize-2)
|
||||||
spawntries += 1
|
spawntries += 1
|
||||||
print('Rerolling from', newx, newy)
|
#print('Rerolling from', newx, newy)
|
||||||
if spawntries == 10:
|
if spawntries == 10:
|
||||||
print('Could not spawn enemy')
|
print('Could not spawn enemy')
|
||||||
goodtogo = False
|
goodtogo = False
|
||||||
|
@ -431,4 +487,18 @@ class phantom:
|
||||||
self.lifespan = lifespan
|
self.lifespan = lifespan
|
||||||
self.symbol = phantom.symbol
|
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()
|
t = tgame()
|
Loading…
Reference in a new issue