acid grow

This commit is contained in:
Frank DeMarco 2014-04-27 01:33:42 +09:00
parent 0d623ddbf7
commit 79e51e6ab1
2 changed files with 23 additions and 34 deletions

3
config
View File

@ -5,6 +5,7 @@ dimensions = 420, 700
quit = K_ESCAPE
[interpolate]
volume = C 0.0 0.0, 36.0 0.61, 120.0 1.0
scale = C 0.0 40.0, 850.0 140.0
shift = C 0.0 0.0, 500.0 3.5, 1000.0 6.0
shift-2 = C 0.0 0.0, 840.0 4.2, 2000.0 8.0
shift = C 0.0 0.0, 500.0 3.5, 1000.0 6.0

View File

@ -91,8 +91,6 @@ class Sieve(Strip):
self.vshifts = Shift(self, -1, "shift"), Shift(self, 1, "shift")
self.electric = Electric(self)
self.add_location(offset=(self.location.w, 0))
for location in self.locations:
location.bottom = self.parent.acid.ry[1]
def add_frames(self):
bar_locations = []
@ -121,32 +119,13 @@ class Sieve(Strip):
for frame in frames:
self.add_frame(frame)
def respond(self, event):
Strip.respond(self, event)
compare = self.delegate.compare
if compare(event, "up") or compare(event, "up", True):
self.vshifts[self.UP].active = not event.cancel
elif compare(event, "down") or compare(event, "down", True):
self.vshifts[self.DOWN].active = not event.cancel
def update(self):
if self.location.right < 0:
self.move(self.location.w)
if self.locations[1].left > self.display_surface.get_width():
self.move(-self.location.w)
for shift in self.vshifts:
shift.update()
if shift.time:
self.move(dy=shift.get_change())
acid = self.parent.acid
if self.location.bottom < acid.ry[0]:
self.vshifts[self.UP].time = 0
for location in self.locations:
location.bottom = acid.ry[0]
elif self.location.bottom > acid.get_level():
self.vshifts[self.DOWN].time = 0
for location in self.locations:
location.bottom = acid.get_level()
for location in self.locations:
location.bottom = self.parent.acid.get_top()
self.electric.location.centery = self.location.centery + 13
self.electric.update()
for rect in self.bar_rects:
@ -196,14 +175,14 @@ class Triangles(GameChild, list):
self.set_next_gap()
def set_next_gap(self):
self.next_gap = randint(202, 368)
self.next_gap = randint(210, 380)
def update(self):
self.populate()
if self[0].location.collidelist(self.parent.sieve.locations) != -1:
sieve = self.parent.sieve
if self[0].location.colliderect(sieve.electric.location):
print "pass"
self.parent.acid.increase()
self.remove(self[0])
else:
for br in sieve.bar_rects:
@ -221,7 +200,7 @@ class Triangle(Sprite):
def __init__(self, parent):
Sprite.__init__(self, parent)
mark = randint(72, 296)
mark = randint(96, 328)
sieve = self.parent.parent.sieve
gaps = sieve.gaps
start = randrange(0, len(gaps))
@ -246,10 +225,7 @@ class Triangle(Sprite):
self.location.centerx = self.get_display_surface().get_rect().centerx
def update(self):
acid = self.get_game().acid
ratio = 1 - (self.get_game().sieve.location.bottom - acid.ry[0]) / \
float(acid.ry[1] - acid.ry[0])
self.move(dy=4 * ratio + 2)
self.move(dy=2.45 * self.get_game().acid.get_volume() + 1.6)
for rect in self.collision_rects:
rect.bottom = self.location.bottom
Sprite.update(self)
@ -259,8 +235,20 @@ class Acid(GameChild):
def __init__(self, parent):
GameChild.__init__(self, parent)
self.ry = 160, 640
self.space = 1
self.display_surface = self.get_display_surface()
self.level_r = 80, 320
self.substance = 0
self.nodeset = self.get_game().interpolator.get_nodeset("volume")
def get_top(self):
return self.display_surface.get_height() - self.get_level()
def get_level(self):
return self.space * (self.ry[1] - self.ry[0]) + self.ry[0]
return self.get_volume() * (self.level_r[1] - self.level_r[0]) + \
self.level_r[0]
def get_volume(self):
return self.nodeset.get_y(self.substance)
def increase(self):
self.substance += 1