This commit is contained in:
Voussoir 2014-10-14 00:34:59 -07:00
parent f108b26a5f
commit 9afdfe659e
2 changed files with 41 additions and 33 deletions

View file

@ -26,4 +26,6 @@
= Prints contain the relevant Symbol to make messages clearer at a glance = Prints contain the relevant Symbol to make messages clearer at a glance
= No hats yet = No hats yet
= Changed priority and efficiency of entity collisions

View file

@ -1,3 +1,5 @@
#14 October 12:33
import tkinter import tkinter
from tkinter import Tk, Label, Frame from tkinter import Tk, Label, Frame
import random import random
@ -134,35 +136,19 @@ class tgame:
for x in range(arenasize-2): for x in range(arenasize-2):
self.data[1:1] = [self.symbols['wall'] + self.symbols['floor']*(arenasize-2) + self.symbols['wall']] self.data[1:1] = [self.symbols['wall'] + self.symbols['floor']*(arenasize-2) + self.symbols['wall']]
for ycoord in range(len(self.data)): for candies in self.candylist:
yl = self.data[ycoord] if candies.x == self.xpos and candies.y == self.ypos:
if ycoord == self.ypos: #print('Collection')
#print(ycoord) collect(1)
yl = yl[:self.xpos] + self.symbols['char'] + yl[self.xpos+1:] self.candylist.remove(candies)
#print(yl) self.entlist.remove(candies)
del candies
cs = [] for enemies in self.enemylist:
for candies in self.candylist: if enemies.x == self.xpos and enemies.y == self.ypos:
if candies.y == ycoord: print('[ ' + self.symbols['char'] + ' ] Death')
if candies.x == self.xpos and candies.y == self.ypos: self.isdeath = True
#print('Collection') self.datalabel.configure(fg='Red')
collect(1)
self.candylist.remove(candies)
self.entlist.remove(candies)
del candies
for enemies in self.enemylist:
if enemies.y == ycoord:
if enemies.x == self.xpos and enemies.y == self.ypos:
print('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: if hasmoved:
self.stepstaken += 1 self.stepstaken += 1
@ -207,9 +193,23 @@ class tgame:
self.enemylist.remove(enemies) self.enemylist.remove(enemies)
self.entlist.remove(bombs) self.entlist.remove(bombs)
self.entlist.remove(enemies) self.entlist.remove(enemies)
print('Bang') print('[ ' + bomb.symbol + ' ] Bang')
mfresh() 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.datalabel.configure(text='\n'.join(self.data))
self.stepslabel.configure(text=str(self.stepstaken) + " steps") self.stepslabel.configure(text=str(self.stepstaken) + " steps")
self.collectlabel.configure(text=str(self.collections) + " candy") self.collectlabel.configure(text=str(self.collections) + " candy")
@ -228,6 +228,7 @@ class tgame:
event.x /= 8 event.x /= 8
event.y /= 12 event.y /= 12
#spawncandy(round(event.x), round(event.y))
#print(event.x, event.y) #print(event.x, event.y)
xdif = event.x - self.xpos xdif = event.x - self.xpos
ydif = event.y - self.ypos ydif = event.y - self.ypos
@ -278,6 +279,7 @@ class tgame:
def spawnphantom(): def spawnphantom():
goodtogo = True goodtogo = True
if self.collections < self.phantomcost: if self.collections < self.phantomcost:
print('[ ] Not enough Candy. ' + str(self.collections) + '/' + str(self.phantomcost) + '. -' + str(self.phantomcost-self.collections))
goodtogo = False goodtogo = False
if self.phantomlist != []: if self.phantomlist != []:
goodtogo = False goodtogo = False
@ -292,10 +294,14 @@ class tgame:
self.entlist.append(newphantom) self.entlist.append(newphantom)
mfresh() mfresh()
def spawncandy(): def spawncandy(forcex=None, forcey=None):
newx = random.randint(1, arenasize-2)
newy = random.randint(1, arenasize-2)
goodtogo = True goodtogo = True
if forcex == None or forcey == None:
newx = random.randint(1, arenasize-2)
newy = random.randint(1, arenasize-2)
else:
newx = forcex
newy = forcey
if self.xpos == newx and self.ypos == newy: if self.xpos == newx and self.ypos == newy:
goodtogo = False goodtogo = False
if goodtogo: if goodtogo: