else
This commit is contained in:
parent
f108b26a5f
commit
9afdfe659e
2 changed files with 41 additions and 33 deletions
|
@ -27,3 +27,5 @@
|
|||
= Prints contain the relevant Symbol to make messages clearer at a glance
|
||||
|
||||
= No hats yet
|
||||
|
||||
= Changed priority and efficiency of entity collisions
|
|
@ -1,3 +1,5 @@
|
|||
#14 October 12:33
|
||||
|
||||
import tkinter
|
||||
from tkinter import Tk, Label, Frame
|
||||
import random
|
||||
|
@ -134,16 +136,7 @@ class tgame:
|
|||
for x in range(arenasize-2):
|
||||
self.data[1:1] = [self.symbols['wall'] + self.symbols['floor']*(arenasize-2) + self.symbols['wall']]
|
||||
|
||||
for ycoord in range(len(self.data)):
|
||||
yl = self.data[ycoord]
|
||||
if ycoord == self.ypos:
|
||||
#print(ycoord)
|
||||
yl = yl[:self.xpos] + self.symbols['char'] + yl[self.xpos+1:]
|
||||
#print(yl)
|
||||
|
||||
cs = []
|
||||
for candies in self.candylist:
|
||||
if candies.y == ycoord:
|
||||
if candies.x == self.xpos and candies.y == self.ypos:
|
||||
#print('Collection')
|
||||
collect(1)
|
||||
|
@ -152,18 +145,11 @@ class tgame:
|
|||
del candies
|
||||
|
||||
for enemies in self.enemylist:
|
||||
if enemies.y == ycoord:
|
||||
if enemies.x == self.xpos and enemies.y == self.ypos:
|
||||
print('Death')
|
||||
print('[ ' + self.symbols['char'] + ' ] Death')
|
||||
self.isdeath = True
|
||||
self.datalabel.configure(fg='Red')
|
||||
|
||||
self.entlist.sort(key=lambda p: p.x)
|
||||
for entities in self.entlist:
|
||||
if entities.y == ycoord:
|
||||
yl = yl[:entities.x] + entities.symbol + yl[entities.x+1:]
|
||||
self.data[ycoord] = yl
|
||||
|
||||
if hasmoved:
|
||||
self.stepstaken += 1
|
||||
if self.stepstaken % self.candyspawnrate == 0:
|
||||
|
@ -207,9 +193,23 @@ class tgame:
|
|||
self.enemylist.remove(enemies)
|
||||
self.entlist.remove(bombs)
|
||||
self.entlist.remove(enemies)
|
||||
print('Bang')
|
||||
print('[ ' + bomb.symbol + ' ] Bang')
|
||||
mfresh()
|
||||
|
||||
|
||||
for ycoord in range(len(self.data)):
|
||||
yl = self.data[ycoord]
|
||||
if ycoord == self.ypos:
|
||||
#print(ycoord)
|
||||
yl = yl[:self.xpos] + self.symbols['char'] + yl[self.xpos+1:]
|
||||
#print(yl)
|
||||
self.entlist.sort(key=lambda p: p.x)
|
||||
for entities in self.entlist:
|
||||
if entities.y == ycoord:
|
||||
yl = yl[:entities.x] + entities.symbol + yl[entities.x+1:]
|
||||
self.data[ycoord] = yl
|
||||
|
||||
|
||||
self.datalabel.configure(text='\n'.join(self.data))
|
||||
self.stepslabel.configure(text=str(self.stepstaken) + " steps")
|
||||
self.collectlabel.configure(text=str(self.collections) + " candy")
|
||||
|
@ -228,6 +228,7 @@ class tgame:
|
|||
|
||||
event.x /= 8
|
||||
event.y /= 12
|
||||
#spawncandy(round(event.x), round(event.y))
|
||||
#print(event.x, event.y)
|
||||
xdif = event.x - self.xpos
|
||||
ydif = event.y - self.ypos
|
||||
|
@ -278,6 +279,7 @@ class tgame:
|
|||
def spawnphantom():
|
||||
goodtogo = True
|
||||
if self.collections < self.phantomcost:
|
||||
print('[ ] Not enough Candy. ' + str(self.collections) + '/' + str(self.phantomcost) + '. -' + str(self.phantomcost-self.collections))
|
||||
goodtogo = False
|
||||
if self.phantomlist != []:
|
||||
goodtogo = False
|
||||
|
@ -292,10 +294,14 @@ class tgame:
|
|||
self.entlist.append(newphantom)
|
||||
mfresh()
|
||||
|
||||
def spawncandy():
|
||||
def spawncandy(forcex=None, forcey=None):
|
||||
goodtogo = True
|
||||
if forcex == None or forcey == None:
|
||||
newx = random.randint(1, arenasize-2)
|
||||
newy = random.randint(1, arenasize-2)
|
||||
goodtogo = True
|
||||
else:
|
||||
newx = forcex
|
||||
newy = forcey
|
||||
if self.xpos == newx and self.ypos == newy:
|
||||
goodtogo = False
|
||||
if goodtogo:
|
||||
|
|
Loading…
Reference in a new issue