changeset 372:90abd39e6c3c 1.0.x

Merge in post-pyweek fixes (r359:371).
author Simon Cross <hodgestar@gmail.com>
date Tue, 13 Oct 2009 20:28:48 +0000
parents c39e7d33ac82
children c14a6d640507
files README.txt TODO gamelib/animal.py gamelib/engine.py gamelib/gameboard.py gamelib/sound.py screenshots/r359-paranoid-battle-stations.png screenshots/r359-paranoid-on-parade.png
diffstat 8 files changed, 194 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/README.txt	Tue Oct 13 20:12:06 2009 +0000
+++ b/README.txt	Tue Oct 13 20:28:48 2009 +0000
@@ -74,6 +74,8 @@
   PyGame:                   http://www.pygame.org/
   Python Game Utilities:    http://code.google.com/p/pgu 
 
+Fox Assault requires python 2.5 or later, pygame 1.8 or later and
+pgu 0.12.3.
 
 LICENSE
 =======
--- a/TODO	Tue Oct 13 20:12:06 2009 +0000
+++ b/TODO	Tue Oct 13 20:28:48 2009 +0000
@@ -9,6 +9,9 @@
 * Persistent high scores 
 
 * Better fox move logic
+  - Tweak weighting of free chickens
+  - Foxes should eat the chickens immediately when they move onto the
+    occupied square - avoid the fox drawn on top of chicken thing.
 
 * More game levels / progression of difficulty
 
@@ -17,3 +20,168 @@
 * Improve Fullscreen mode (on the fly scaling)
 
 * Investigate using infinity symbol instead of dash for unlimited mode
+
+== ISSUES ==
+
+23:26 <@Derakon> Jerith: http://paste.ubuntu.com/266865/
+23:26 <@Derakon> That's with the OSX .dmg.
+
+From the pastebin URL above: """
+dyld: lazy symbol binding failed: Symbol not found: _pthread_cond_init$UNIX2003
+  Referenced from: /Volumes/Operation Fox Assault/Operation Fox Assault.app/Contents/Frameworks/libpython2.5.dylib
+  Expected in: /usr/lib/libSystem.B.dylib
+
+dyld: Symbol not found: _pthread_cond_init$UNIX2003
+  Referenced from: /Volumes/Operation Fox Assault/Operation Fox Assault.app/Contents/Frameworks/libpython2.5.dylib
+  Expected in: /usr/lib/libSystem.B.dylib
+
+Sep  7 14:25:21 Kleine crashdump[402]: Operation Fox Assault crashed
+Sep  7 14:25:21 Kleine crashdump[402]: crash report written to: /Users/chriswei/Library/Logs/CrashReporter/Operation Fox Assault.crash.log
+"""
+
+pygame event queue full bug.
+Sep 10 22:01: <eltigre> one IndexError and one pygame event overflow
+...
+Sep 10 23:15: <eltigre> Hodgestar, jerith : http://dpaste.com/91590/
+
+From pastebin:
+"""
+Traceback (most recent call last):
+  File "run_game.py", line 4, in <module>
+    main.main()
+  File "/home/andi/projekte/pyweek/Rinkhals/foxassault-1.0.0/gamelib/main.py", line 38, in main
+    engine.run(MainMenuState(engine), screen)
+  File "/home/andi/projekte/pyweek/Rinkhals/foxassault-1.0.0/pgu/engine.py", line 104, in run
+    self.loop()
+  File "/home/andi/projekte/pyweek/Rinkhals/foxassault-1.0.0/pgu/engine.py", line 123, in loop
+    if self.fnc('event',e): return
+  File "/home/andi/projekte/pyweek/Rinkhals/foxassault-1.0.0/pgu/engine.py", line 79, in fnc
+    if v != None: r = f(v)
+  File "/home/andi/projekte/pyweek/Rinkhals/foxassault-1.0.0/gamelib/engine.py", line 229, in event
+    return pygame.event.post(START_DAY)
+pygame.error: Event queue full
+"""
+ - r370 disables timer events while processing the fox movements and
+   chicken attacks. This should make this bug harder to trigger.
+
+
+Leaking weakref objects bug (reported by tumbleweed):
+ - this is probably http://pygame.motherhamster.org/bugzilla/show_bug.cgi?id=30
+
+
+== COMMENTS ==
+
+Farmer's weekly (daily?) -- egg/chicken/fox report thing. (Yay Marc!)
+
+23:41 <@Derakon> The instructions could also be more detailed, but the game's pretty intuitive once you realize that it's not realtime.
+00:03 < Rhamphoryncus> hrm.  Instructions need work.. yup, that got said, heh
+
+00:10 <@Derakon> An auto-repair fences command would be handy.
+00:12 <@Derakon> Man, fence repair is nuking my budget.
+00:13 <@AnnoDomini> Fences made of wood are overrated.
+00:13 <@AnnoDomini> I make a fence of elite fighting fowl.
+00:13  * Derakon nods.
+00:15 <@Derakon> Suddenly the game gets much easier~
+
+00:28 <@Derakon> I want a faster way to sell eggs. ._.
+00:29 <@Derakon> Some way to say "Keep enough eggs to mature the maximum number of chickens as quickly as possible; sell the rest."
+00:33 <@jerith> Derakon: Superfluous eggs autosell.
+00:34 <@jerith> A chicken lays some number of eggs. On of those eggs will hatch, the rest will sell.
+00:34 <@Derakon> Oooh.
+00:34 <@Derakon> Okay, then I can stop bothering to click so much. Thanks.
+
+00:38 <@AnnoDomini> Needs an 'evict all' button.
+
+00:40 <@Derakon> And a way to drag-clear trees, drag-sell chickens (or auto-sell naked outdoor chickens).
+00:42 <@Derakon> So...much...clicking... ;.;
+
+00:50 <@AnnoDomini> http://i30.tinypic.com/sx15k1.jpg
+
+01:19 < Rhamphoryncus> Do you know what watch towers are for?
+01:20 <@Derakon> I think the watchtowers might make riflehens more effective somehow.
+01:20 <@Derakon> Or maybe they're bunkers.
+
+01:24 < Rhamphoryncus> And I have no idea what my income is from
+01:24 <@Derakon> Killing foxes and selling stuff.
+01:25 < Rhamphoryncus> I have spare room around my  henhouses, so autosell isn't happening.  It must be from killing foxes
+01:27 <@AnnoDomini> Rhamphoryncus: I expect you get eggs sold. Hens lay eggs every turn, but incubate for two. So you get N*5 cash for each hen in a henhouse/hendominium per turn.
+
+01:31 < Rhamphoryncus> It seems like, long term, you want to pack hendominiums in with no space around them
+01:32 < Rhamphoryncus> As you fill a grid like that you'll still have exposed edges, producing tons of chickens
+01:32 <@AnnoDomini> Aren't overflow chickens autokilled, rather the eggs never hatching and being sold?
+01:33 <@Derakon> No idea.
+01:33 <@AnnoDomini> That's what I read in the instructions.
+01:33 < Rhamphoryncus> I thought they were autosold.  I may have been confusing with the egg autosell though
+01:33 <@AnnoDomini> Eggs autosell if there's no room. Chickens die.
+
+05:41 <@Derakon> 2x2 pods of knifehens are almost invincible.
+05:57 <@Derakon> Oh, hey, the 2x2 pod of knifehens is not invulnerable. The foxes finally killed one after losing some 1500 of their own.
+
+05:45  * Vornicus-Latens thinks this game needs less shouty graphics.
+
+08:37 < Rhamphoryncus> jerith: feature request: automatically switch to an offset breeding schedule.  IOW, a henhouse should only do 3/day and a hendemonium should only do 6/day
+
+08:50 < Rhamphoryncus> and if I go and sell an egg in a henhouse/hendominium, is it supposed to take multiple clicks?
+[ed: He didn't know it was multiple eggs.]
+
+09:12 < Reivthia> Jerith: UI improvement: *Please* let us click&drag.
+09:12 < Reivthia> I want to be able to not have to click every single chicken/tree seperately when I have five thousand cash :P
+
+09:12 < Rhamphoryncus> My huts get ignored
+09:12 < Reivthia> Rham: I thought mine were too, until they got occasionally pounced.
+09:12 < Reivthia> Very, very occasionally
+
+
+And here's me rapid-fire rambling at #ctpug after finishing my first long game. (Unedited.)
+
+20:34 < jerith> Nitwit: Had some ideas while playing just now.
+20:34 <&Nitwit> ?
+20:35 < jerith> I want a "sell all naked outdoor chickens" button.
+20:35 < jerith> And a "sell all superfluous eggs" button.
+20:35 < jerith> Also, chickens should hatch into squares at the corners of the henhouses.
+20:36 <&Nitwit> We're either going to have to expand the game window, or somehow compress the other menu options
+20:37 < superfly> Nitwit: use a smaller font?
+20:37 -!- confluence [confluence@atrum-A04B64E5.telkomadsl.co.za] has joined #ctpug
+20:37 -!- mode/#ctpug [+ao confluence confluence] by ChanServ
+20:37 < jerith> I'd be happy with an "advanced" menu.
+20:37 < jerith> Hey confluence.
+20:37 <&Nitwit> I've been toying with the idea of unifying the buildings into a "buy building" button and "select building" dialog - that will free up a couple of 
+                buttons & give us space to put building prices
+20:37 <&confluence> Hello
+20:37 < jerith> Also, we need to do a proper toolbar thing.
+20:37 < jerith> That will save us space.
+20:37 < jerith> Nitwit: That also works.
+20:38 <&Nitwit> I don't want to do the same for equipment though, as I find I use those buttons much more often
+20:38 < jerith> If possible, I'd like to make the "right click cancels current thing" global.
+20:39 < jerith> Oh, there's a cursor display bug when moving chickens into and out of buildings.
+20:39 < jerith> Also when deslecting a chicken to move.
+20:40 < jerith> Then there are some nice-to-haves.
+20:41 < jerith> Generating the gameboard instead of using a template.
+20:41 < jerith> Being able to select groups of chickens to work with.
+20:41 < jerith> Possibly even customisable ones.
+20:41 < jerith> That makes no sense outside my head.
+20:42 < jerith> Okay, two things.
+20:42 <&Nitwit> I like the idea of being able to have pre-determined maps 
+20:42 < jerith> Select a group of chickens and say "put these over there".
+20:42 < jerith> Also, select a group of chickens and say "these are soldiers, re-equip them every turn if necessary".
+20:43 < jerith> So chicken classes, in other words.
+20:44 < jerith> If you sell a chicken with eggs, are you supposed to get paid out for the eggs too?
+20:44 < jerith> I think I tried it and didn't.
+20:44 < jerith> But I could be wrong.
+20:45 < jerith> We need some settings -- sound on/off at the least.
+20:45 < jerith> Why is resizing things in Windows a problem, by the way?
+20:46 < jerith> I seem to be throwing stuff into this channel at an alarming rate. Remind me to look at the logs when I have a moment or three.
+20:46 <&Nitwit> jerith: Not getting the money for the eggs probably a bug 
+20:47 < jerith> Wishlist for buildings: opening a building opens a dialog you can move around with little chicken slots in it.
+20:48 < jerith> That'll be hard in pgu, though.
+20:49 < jerith> We need some harder foxes.
+20:49 < jerith> Maybe foxes that hit harder and/or are tougher.
+20:49 < jerith> We can have them triggered by the killed foxes count.
+20:49 < jerith> Thus, you get harder baddies as you get better at killing baddies.
+20:50 < jerith> Saving and loading games would be great, especially for the longer games.
+20:51 < jerith> Also different game scenarios -- one where you start off with lots of money and only a week, but foxes come faster, for example.
+20:51 < jerith> And alternate win conditions, as confluence mentioned.
+20:52 < jerith> Maybe reachaing a certain cash level.
+20:52 < jerith> Also bigger game boards once we can scroll, although that getts difficult in night mode.
+20:52 < jerith> Forests should give foxes a stealth bonus.
+
--- a/gamelib/animal.py	Tue Oct 13 20:12:06 2009 +0000
+++ b/gamelib/animal.py	Tue Oct 13 20:28:48 2009 +0000
@@ -349,7 +349,9 @@
             for chicken in gameboard.chickens:
                 dist = chicken.pos.dist(self.pos)
                 if chicken.abode:
-                    dist += 10 # Prefer free-ranging chickens
+                    dist += 5 # Prefer free-ranging chickens
+                if len(chicken.weapons()) > 0:
+                    dist += 5 # Prefer unarmed chickens
                 if dist < min_dist:
                     min_dist = dist
                     self.closest = chicken
--- a/gamelib/engine.py	Tue Oct 13 20:12:06 2009 +0000
+++ b/gamelib/engine.py	Tue Oct 13 20:28:48 2009 +0000
@@ -216,9 +216,12 @@
         elif e.type is ANIM_ID:
             self.game.gameboard.run_animations()
         elif e.type is MOVE_FOX_ID:
-            # Timer aren't nessecairly ordered, so we make sure
-            # we don't get a ANIM event until at least cycle after this
-            pygame.time.set_timer(ANIM_ID, self.cycle_time)
+            # ensure no timers trigger while we're running
+            pygame.time.set_timer(ANIM_ID, 0)
+            pygame.time.set_timer(MOVE_FOX_ID, 0)
+            # Clear any queued timer events, so we don't full the queue
+            pygame.event.clear(ANIM_ID)
+            pygame.event.clear(MOVE_FOX_ID)
             # Ensure any outstanding animitions get cleaned up
             self.game.gameboard.run_animations()
             self.cycle_count += 1
@@ -227,6 +230,9 @@
             if self.game.gameboard.move_foxes():
                 # All foxes are gone/safe, so dawn happens
                 return pygame.event.post(START_DAY)
+            # Re-enable timers
+            pygame.time.set_timer(ANIM_ID, self.cycle_time)
+            pygame.time.set_timer(MOVE_FOX_ID, 4*self.cycle_time)
         elif e.type is not QUIT:
             self.game.main_app.event(e)
 
--- a/gamelib/gameboard.py	Tue Oct 13 20:12:06 2009 +0000
+++ b/gamelib/gameboard.py	Tue Oct 13 20:28:48 2009 +0000
@@ -271,8 +271,11 @@
         us = []
         x, y = self.vid.view.x, self.vid.view.y
         for anim in self.gameboard.animations[:]:
-            if anim.updated or anim.removed:
+            if (anim.updated or anim.removed) and \
+                    self.gameboard.in_bounds(anim.pos):
                 # We flag that we need to redraw stuff undeneath the animation
+                anim.irect.x = anim.rect.x - anim.shape.x
+                anim.irect.y = anim.rect.y - anim.shape.y
                 us.append(pygame.Rect(anim.irect.x - x, anim.irect.y - y,
                     anim.irect.width, anim.irect.height))
                 self.vid.alayer[anim.pos.y][anim.pos.x]=1
@@ -282,15 +285,12 @@
                 self.gameboard.animations.remove(anim)
         us.extend(self.vid.update(surface))
         for anim in self.gameboard.animations:
-            if anim.updated: 
-                anim.fix_pos(self.vid)
+            if anim.updated:
                 # setimage has happened, so redraw
-                anim.irect.x = anim.rect.x - anim.shape.x
-                anim.irect.y = anim.rect.y - anim.shape.y
-                surface.blit(anim.image, (anim.irect.x - x, anim.irect.y - y))
                 anim.updated = 0
-                us.append(pygame.Rect(anim.irect.x - x, anim.irect.y - y,
-                    anim.irect.width, anim.irect.height))
+                anim.fix_pos(self.vid)
+                if self.gameboard.in_bounds(anim.pos): 
+                    surface.blit(anim.image, (anim.irect.x - x, anim.irect.y - y))
                 # This is enough, because sprite changes happen disjoint
                 # from the animation sequence, so we don't need to worry
                 # other changes forcing us to redraw the animation frame.
@@ -737,6 +737,8 @@
 
         def do_equip(chicken, update_button=None):
             # Try to equip the chicken
+            if self.cash < equipment.buy_price():
+                return False
             if equipment.place(chicken):
                 self.add_cash(-equipment.buy_price())
                 chicken.equip(equipment)
@@ -745,8 +747,6 @@
             return False
 
         chicken = self.get_outside_chicken(tile_pos)
-        if self.cash < equipment.buy_price():
-            return
         if chicken is None:
             building = self.get_building(tile_pos)
             if building is None:
--- a/gamelib/sound.py	Tue Oct 13 20:12:06 2009 +0000
+++ b/gamelib/sound.py	Tue Oct 13 20:28:48 2009 +0000
@@ -35,6 +35,8 @@
 def stop_background_music():
     """stops any playing background music"""
     global CURRENT_MUSIC_FILE
+    if not SOUND_INITIALIZED:
+        return
     CURRENT_MUSIC_FILE = None
     # TODO: fadeout in a background thread
     pygame.mixer.music.stop()
Binary file screenshots/r359-paranoid-battle-stations.png has changed
Binary file screenshots/r359-paranoid-on-parade.png has changed