Skip to content

Commit 4cf0b77

Browse files
committed
Added trunk without history. svnsync failed... so no history!
See svn://www.imitationpickles.org/pyweek2 for history.
0 parents  commit 4cf0b77

File tree

299 files changed

+17629
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

299 files changed

+17629
-0
lines changed

BUGS.txt

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
2+
3+
4+
Crash BUGS:
5+
********************
6+
7+
8+
9+
10+
********************
11+
Game play bugs.
12+
13+
- when a cannon ball hits a wall it does not do an area of affect explosion. Which means if a peasant is nearby it will kill them. Same if it hits a cannon tower.
14+
15+
- upgrades between levels.
16+
if you play a level and get some upgrades
17+
<philhassey> and then you press escape on the map to "quit" the game
18+
<philhassey> and then go back to the map to start a new game and start playing a level, you still have your upgrades.
19+
<philhassey> you probably need to add a line of code to main.py:reset() so that it resets the castle...
20+
<philhassey> data_reset() that is
21+
22+
- level select.
23+
- when all levels on bottom are done, and all but far right on second level are done it doesn't work.
24+
25+
26+
27+
28+
********************
29+
Graphic bugs.
30+
31+
- pink around cannon ball.
32+
- pink around bottom of castle.
33+
34+
- need a normal mouse cursor graphic. because of set_visible bugs.
35+
36+
37+
38+
********************
39+
Sound bugs.
40+
41+
42+
43+

CHANGES.txt

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
============================================
2+
- build truck bot
3+
x - clouds that can move with you
4+
- cannon explosions
5+
- effects need to go "around" objects when you walk upwards, or whatever, not get
6+
sucked into the floor, each effect should remember its Z position, somehow...
7+
8+
==========================================
9+
- make coal, water, rubble into tiles
10+
- make cities into sprites
11+
- make isovid.set() smartly make changes to .slayer and other magic
12+
astar layers
13+
14+
15+
2006-03-26========================
16+
- the player sprite is not put in the area where the codes are placed.
17+
- seems to be a miss match between the code coordinates and the levels.
18+
19+
- the sprites are shown below the levels.
20+
21+
- need to remove the yes/no question after picking up coal. How do you remove gui elements?
22+
23+
24+
25+
==========================================
26+
- added TODO.txt, BUGS.txt, CHANGES.txt, LICENSE.txt

LICENSE.txt

+340
Large diffs are not rendered by default.

README.txt

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Zanthor!
2+
3+
http://www.imitationpickles.org/pyweek2/
4+
5+
main.py
6+
7+
KEYBOARD: arrows or wasd - to move. F10 pause. f/space/ctrl to fire.
8+
MOUSE: button one move. button two fire.
9+
JOYSTICK: game pad move. button 1 fire.
10+
11+
We love you.
12+
13+
Thank you for downloading.
14+
15+
' ' . Thank you for installing.
16+
.' '
17+
!"' Thank you for clicking.
18+
'
19+
`' Thank you for loading.
20+
\
21+
_()()__ Thank you for playing.
22+
| |
23+
| | Thank you for quiting.
24+
//\_____/\\
25+
// \ / \\ Thank you uninstalling.
26+
|| | | ||
27+
// | \ Thank you for deleting.
28+
29+
30+
Sanity is as overrated as a nuclear bomb.
31+

TODO.txt

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
3+
EFFECTS:
4+
- variables for effects (size, etc)
5+
- combo effects (cannon
6+
- explosion should look better, inner should turn red towards end of blast
7+
8+
9+
10+
INTERFACE:
11+
- load and draw background images for each section of interface.
12+
- load in different castle illistrations.
13+
- load in images for equipment.
14+
- load button images.
15+
16+
- put call in to update the castles stats.
17+
- draw the different amounts of coal, water, health, steam.
18+
- draw the message box text.
19+
- draw the buttons load, save, quit,
20+
21+
22+
front screen.
23+
- start game.
24+
- select level.
25+
- news.
26+
- load.
27+
- save.
28+
- download levels.
29+
30+
31+
32+

_effects.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# q = parts[(n+1)%l]
2+
# dx,dy = q.x-p.x, q.y-p.y
3+
# dist = (abs(dx)+abs(dy))
4+
# d2 = dist*dist
5+
# f, f2 = 16, 16*16
6+
# if d2 > f2:
7+
# cx,cy = (q.x+p.x)/2,(q.y+p.y)/2
8+
# p.x,p.y = cx - dx*f/dist,cy - dy*f/dist
9+
# q.x,q.y = cx + dx*f/dist,cy + dy*f/dist
10+
#
11+
12+

algo.py

+135
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
"""Some handy algorithms for use in games, etc.
2+
3+
<p>please note that this file is alpha, and is subject to modification in
4+
future versions of pgu!</p>
5+
"""
6+
print 'pgu.algo','This module is alpha, and is subject to change.'
7+
8+
#def dist(a,b):
9+
# return abs(a[0]-b[0]) + abs(a[1]-b[1])
10+
11+
class node:
12+
def __init__(self,prev,pos,dest):
13+
self.prev,self.pos,self.dest = prev,pos,dest
14+
if self.prev == None: self.g = 0
15+
else: self.g = self.prev.g + 1
16+
self.h = dist(pos,dest)
17+
self.f = self.g+self.h
18+
19+
20+
def astar(start,end,layer,_dist):
21+
"""uses the a* algorithm to find a path
22+
23+
<pre>astar(start,end,layer,dist): return [list of positions]</pre>
24+
25+
<dl>
26+
<dt>start<dd>start position
27+
<dt>end<dd>end position
28+
<dt>layer<dd>a grid where zero cells are open and non-zero cells are walls
29+
<dt>dist<dd>a distance function dist(a,b)
30+
</dl>
31+
32+
<p>returns a list of positions from start to end</p>
33+
"""
34+
global dist
35+
dist = _dist
36+
if layer[start[1]][start[0]]: return [] #start is blocked
37+
if layer[end[1]][end[0]]: return [] #end is blocked
38+
w,h = len(layer[0]),len(layer)
39+
if start[0] < 0 or start[1] < 0 or start[0] >= w or start[1] >= h: return [] #start outside of layer
40+
if end[0] < 0 or end[1] < 0 or end[0] >= w or end[1] >= h: return [] #end outside of layer
41+
42+
opens = []
43+
open = {}
44+
closed = {}
45+
cur = node(None,start,end)
46+
open[cur.pos] = cur
47+
opens.append(cur)
48+
while len(open):
49+
cur = opens.pop(0)
50+
if cur.pos not in open: continue
51+
del open[cur.pos]
52+
closed[cur.pos] = cur
53+
if cur.pos == end: break
54+
for dx,dy in [(0,-1),(1,0),(0,1),(-1,0),(-1,-1),(1,-1),(-1,1),(1,1)]:
55+
x,y = pos = cur.pos[0]+dx,cur.pos[1]+dy
56+
if layer[y][x]: continue
57+
#check for blocks of diagonals
58+
if layer[cur.pos[1]+dy][cur.pos[0]]: continue
59+
if layer[cur.pos[1]][cur.pos[0]+dx]: continue
60+
new = node(cur,pos,end)
61+
if pos in open and new.f >= open[pos].f: continue
62+
if pos in closed and new.f >= closed[pos].f: continue
63+
if pos in open: del open[pos]
64+
if pos in closed: del closed[pos]
65+
open[pos] = new
66+
lo = 0
67+
hi = len(opens)
68+
while lo < hi:
69+
mid = (lo+hi)/2
70+
if new.f < opens[mid].f: hi = mid
71+
else: lo = mid + 1
72+
opens.insert(lo,new)
73+
74+
if cur.pos != end:
75+
return []
76+
77+
path = []
78+
while cur.prev != None:
79+
path.append(cur.pos)
80+
cur = cur.prev
81+
path.reverse()
82+
return path
83+
84+
85+
def getline(a,b):
86+
"""returns a path of points from a to b
87+
88+
<pre>getline(a,b): return [list of points]</pre>
89+
90+
<dl>
91+
<dt>a<dd>starting point
92+
<dt>b<dd>ending point
93+
</dl>
94+
95+
<p>returns a list of points from a to b</p>
96+
"""
97+
98+
path = []
99+
100+
x1,y1 = a
101+
x2,y2 = b
102+
dx,dy = abs(x2-x1),abs(y2-y1)
103+
104+
if x2 >= x1: xi1,xi2 = 1,1
105+
else: xi1,xi2 = -1,-1
106+
107+
if y2 >= y1: yi1,yi2 = 1,1
108+
else: yi1,yi2 = -1,-1
109+
110+
if dx >= dy:
111+
xi1,yi2 = 0,0
112+
d = dx
113+
n = dx/2
114+
a = dy
115+
p = dx
116+
else:
117+
xi2,yi1 = 0,0
118+
d = dy
119+
n = dy/2
120+
a = dx
121+
p = dy
122+
123+
x,y = x1,y1
124+
c = 0
125+
while c <= p:
126+
path.append((x,y))
127+
n += a
128+
if n > d:
129+
n -= d
130+
x += xi1
131+
y += yi1
132+
x += xi2
133+
y += yi2
134+
c += 1
135+
return path

cannon.py

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
import isovid
2+
import random
3+
4+
from const import *
5+
6+
from units import CannonTower
7+
8+
import states
9+
import sound_info
10+
11+
12+
def cannon_new(g,t,v):
13+
g.clayer[t.ty][t.tx] = 0
14+
s = isovid.Sprite(g.images['cannon'],t.rect)
15+
16+
s.frame = random.randrange(0,FPS*3)
17+
18+
g.sprites.append(s)
19+
s.loop = cannon_loop
20+
s.hit = cannon_hit
21+
s.groups = g.string2groups("cannon")
22+
#s.agroups =g.string2groups("castle")
23+
24+
s.unit = CannonTower()
25+
26+
27+
28+
def cannon_loop(g,s):
29+
s.unit.loop()
30+
31+
tw,th = g.iso_w,g.iso_h
32+
if s.frame%(FPS*3) == 0:
33+
sx,sy = s.rect.centerx/tw,s.rect.centery/th
34+
p = g.castle
35+
px,py = p.rect.centerx/tw,p.rect.centery/th
36+
dx,dy = px-sx,py-sy
37+
if (dx*dx+dy*dy)**0.5 < 12: #only shoot if they are reachable
38+
# try and use some steam to fire.
39+
if s.unit.try_fire():
40+
cball_new(g,(s.rect.centerx,s.rect.centery), s.unit.stats['Damage'])
41+
42+
43+
s.frame += 1
44+
45+
46+
def cannon_hit(g,a,b):
47+
pass
48+
49+
50+
def cball_new(g,pos, damage = 1.0):
51+
g.level.game.sm.Play("cannon")
52+
53+
s = isovid.Sprite(g.images['cball'],pos)
54+
55+
s.frame = 0
56+
57+
g.sprites.append(s)
58+
s.loop = cball_loop
59+
s.hit = cball_hit
60+
#s.groups = g.string2groups("cball")
61+
s.agroups =g.string2groups("castle")
62+
63+
#s.rect, s._rect
64+
65+
dx,dy = g.castle.rect.x-s.rect.x,g.castle.rect.y-s.rect.y
66+
dist = (dx*dx+dy*dy)**0.5
67+
v = 16
68+
s.vx, s.vy = dx*v/dist,dy*v/dist
69+
s.vz = -8
70+
s.z = 0
71+
s.damage = damage
72+
73+
74+
75+
def cball_loop(g,s):
76+
77+
s.rect.x += s.vx
78+
s.rect.y += s.vy
79+
s.z += s.vz
80+
s.vz += 1
81+
if s.vz == 8:
82+
g.sprites.remove(s)
83+
#print s.rect
84+
s.frame += 1
85+
86+
87+
def cball_hit(g,a,b):
88+
print "BANG!"
89+
g.level.game.sm.Play(sound_info.ushit.nextone())
90+
91+
if b.unit.hit(a.damage):
92+
#raise "game over, you got killed!"
93+
#b.reset_castle()
94+
g.level.game.state = states.GameOver(g.level.game) #, g.level.game.state)
95+
96+
97+
98+
99+
pass
100+

0 commit comments

Comments
 (0)