Permalink
Browse files

unusable. client/server migration.

  • Loading branch information...
1 parent b440e83 commit eace8925c6dab8231b67aff2d8e2eae5422311d5 @bitcraft committed May 17, 2012
View
11 README
@@ -2,13 +2,20 @@ this is a ongoing project for some sort of multiplayer adventure game.
a world of warning, this repository is generally not stable, and may not run. there is a stable version under the downloads section.
-python/pygame adventure game library
+server:
+ network support coming soon with twisted integration
native support for tiled maps
supports keyboard and joystick movement
save game and persistence for all objects
+
+client:
scrolling map for large areas
animated sprites
- network support coming soon with twisted integration
+
+goals are:
+ generic server and client
+ resources from the server can be pushed to the client
+ framework for multiplayer games
started during pyweek sept '11, has slowly morphed into something else.
View
@@ -1,203 +0,0 @@
-"""
-Game world for "mh"
-
-this will create a pickle that can be read by the library
-"""
-
-from lib2d.area import AbstractArea, Area, createAreaFromTMX
-from lib2d.avatar import Avatar, Animation, StaticAnimation
-from lib2d.objects import AvatarObject
-from lib2d import res, tmxloader
-from lib.rpg import Hero, NPC
-
-from collections import defaultdict
-
-
-
-# build the initial environment
-uni = AbstractArea()
-uni.name = 'MH'
-uni.setGUID(0)
-
-# build our avatars and heros
-avatar = Avatar()
-ani = Animation("warrior-male-stand.png", "stand", 1, 4)
-avatar.add(ani)
-ani = Animation("warrior-male-walk.png", "walk", [0,1,2,1], 4)
-avatar.add(ani)
-ani = Animation("warrior-male-attack.png", "attack", 4, 4, 60)
-avatar.add(ani)
-avatar.play("walk")
-npc = Hero()
-npc.setName("Rat")
-npc.setAvatar(avatar)
-npc.setGUID(1)
-uni.add(npc)
-
-
-avatar = Avatar()
-ani = Animation("townfolk-male-walk.png", "walk", [0,1,2,1], 4)
-avatar.add(ani)
-npc = NPC()
-npc.setName("Mayor")
-npc.setAvatar(avatar)
-npc.setGUID(2)
-uni.add(npc)
-
-
-avatar = Avatar()
-ani = Animation("ranger-male-walk.png", "walk", [0,1,2,1], 4)
-avatar.add(ani)
-npc = NPC()
-npc.setName("Bolt")
-npc.setAvatar(avatar)
-npc.setGUID(3)
-uni.add(npc)
-
-
-avatar = Avatar()
-ani = Animation("healer-male-walk.png", "walk", [0,1,2,1], 4)
-avatar.add(ani)
-npc = NPC()
-npc.setName("Ax")
-npc.setAvatar(avatar)
-npc.setGUID(4)
-uni.add(npc)
-
-
-avatar = Avatar()
-ani = Animation("healer-female-walk.png", "walk", [0,1,2,1], 4)
-avatar.add(ani)
-npc = NPC()
-npc.setName("Tooth")
-npc.setAvatar(avatar)
-npc.setGUID(5)
-uni.add(npc)
-
-
-avatar = Avatar()
-ani = Animation("magician-male-walk.png", "walk", [0,1,2,1], 4)
-avatar.add(ani)
-npc = NPC()
-npc.setName("Nail")
-npc.setAvatar(avatar)
-npc.setGUID(6)
-uni.add(npc)
-
-
-avatar = Avatar()
-ani = StaticAnimation("16x16-forest-town.png", "barrel", (9,1), (16,16))
-avatar.add(ani)
-item = AvatarObject()
-item.pushable = True
-item.setName("Barrel")
-item.setAvatar(avatar)
-item.setGUID(513)
-uni.add(item)
-
-avatar = Avatar()
-ani = StaticAnimation("16x16-forest-town.png", "sign", (11,1), (16,16))
-avatar.add(ani)
-item = AvatarObject()
-item.pushable = False
-item.setName("Sign")
-item.setAvatar(avatar)
-item.setGUID(514)
-uni.add(item)
-
-avatar = Avatar()
-ani = StaticAnimation("16x16-forest-town.png", "rock", (8,9), (16,16))
-avatar.add(ani)
-item = AvatarObject()
-item.pushable = True
-item.setName("Rock")
-item.setAvatar(avatar)
-item.setGUID(515)
-uni.add(item)
-
-avatar = Avatar()
-ani = StaticAnimation("16x16-forest-town.png", "stump", (8,7), (16,16))
-avatar.add(ani)
-item = AvatarObject()
-item.pushable = False
-item.setName("Stump")
-item.setAvatar(avatar)
-item.setGUID(516)
-uni.add(item)
-
-avatar = Avatar()
-ani = StaticAnimation("16x16-forest-town.png", "stump", (8,7), (16,16))
-avatar.add(ani)
-item = AvatarObject()
-item.pushable = False
-item.setName("Stump")
-item.setAvatar(avatar)
-item.setGUID(517)
-uni.add(item)
-
-avatar = Avatar()
-ani = StaticAnimation("16x16-forest-town.png", "stump", (8,7), (16,16))
-avatar.add(ani)
-item = AvatarObject()
-item.pushable = False
-item.setName("Stump")
-item.setAvatar(avatar)
-item.setGUID(518)
-uni.add(item)
-
-avatar = Avatar()
-ani = StaticAnimation("16x16-forest-town.png", "stump", (8,7), (16,16))
-avatar.add(ani)
-item = AvatarObject()
-item.pushable = False
-item.setName("Stump")
-item.setAvatar(avatar)
-item.setGUID(519)
-uni.add(item)
-
-avatar = Avatar()
-ani = StaticAnimation("16x16-forest-town.png", "stump", (8,7), (16,16))
-avatar.add(ani)
-item = AvatarObject()
-item.pushable = False
-item.setName("Stump")
-item.setAvatar(avatar)
-item.setGUID(520)
-uni.add(item)
-
-
-
-# build the areas to explore
-
-village = createAreaFromTMX(uni, "village.tmx")
-village.setName("Village")
-village.setGUID(1001)
-
-
-home = createAreaFromTMX(uni, "building0.tmx")
-home.setName("Building0")
-home.setGUID(1002)
-
-
-# finialize exits by adding the needed references
-
-allAreas = [ i for i in uni.getChildren() if isinstance(i, Area) ]
-allExits = defaultdict(list)
-
-# make table of all exits
-for area in allAreas:
- for guid in area.exits.keys():
- allExits[guid].append(area)
- print guid, area
-
-# set the exits properly
-for guid, areaList in allExits.items():
- if len(areaList) == 2:
- areaList[0].exits[guid] = (areaList[0].exits[guid][0], areaList[1].guid)
- areaList[1].exits[guid] = (areaList[1].exits[guid][0], areaList[0].guid)
-
- print areaList[0], areaList[0].exits
- print areaList[1], areaList[1].exits
-
-
-uni.save("mh")
View
@@ -1,8 +0,0 @@
-# resize the "700+ icon set to usable sizes"
-
-# remove the border of each image
-mogrify -shave 14x14
-
-# make the tilemap, thing...
-montage -geometry 64x64 -tile 25x32 *.png iconset.png
-
View
@@ -132,3 +132,9 @@ the use of signals may be lost now, i will see where that will go once i get the
achievements should be built into the game. this means that all state changes should be run through a achievement checker and then applied to the player's 'account'.
if all state changes, and actions tracked, then that will cover 90% of achievements.
+
+Quadtree:
+ + Fast collision detection
+ + Great for static geometry
+ - Slow add/remove of nodes
+
View
@@ -1,7 +1,7 @@
-from lib2d.gamestate import GameState
-from lib2d.buttons import *
-from lib2d.statedriver import driver as sd
-from lib2d import res
+from lib2d.client.gamestate import GameState
+from lib2d.client.buttons import *
+from lib2d.client.statedriver import driver as sd
+from lib2d.common import res
import pygame
from dialog import TextDialog
View
@@ -1,7 +1,8 @@
-from lib2d.buttons import *
-from lib2d.gamestate import GameState
-from lib2d.statedriver import driver as sd
-from lib2d import res, gui
+from lib2d.client.buttons import *
+from lib2d.client.gamestate import GameState
+from lib2d.client.statedriver import driver as sd
+from lib2d.client import gui
+from lib2d.common import res
from pygame.locals import *
from pygame.surface import Surface
View
@@ -1,5 +1,5 @@
-from lib2d.tilemap import BufferedTilemapRenderer
-from lib2d.objects import AvatarObject
+from lib2d.client.tilemap import BufferedTilemapRenderer
+from lib2d.common.objects import AvatarObject
from pygame.rect import Rect
View
@@ -1,5 +1,5 @@
-from lib2d.objects import AvatarObject
-from lib2d.buttons import *
+from lib2d.common.objects import AvatarObject
+from lib2d.client.buttons import *
from conditions import *
from math import cos, sin, degrees
View
@@ -1,17 +1,18 @@
-from lib2d.gamestate import GameState
-from lib2d.cmenu import cMenu
-from lib2d.tilemap import BufferedTilemapRenderer
-from lib2d.statedriver import driver as sd
-from lib2d.banner import TextBanner
-from lib2d.subpixelsurface import SubPixelSurface
-from lib2d.objects import loadObject
-from lib2d import res
+from lib2d.client.gamestate import GameState
+from lib2d.client.cmenu import cMenu
+from lib2d.client.tilemap import BufferedTilemapRenderer
+from lib2d.client.statedriver import driver as sd
+from lib2d.client.banner import TextBanner
+from lib2d.client.subpixelsurface import SubPixelSurface
+from lib2d.common.objects import loadObject
+from lib2d.common import res
from pygame import Rect, Surface
import pygame
from worldstate import WorldState
from cutscene import Cutscene
+import world
from collections import deque
from random import randint, random, uniform
@@ -32,10 +33,12 @@ def __init__(self, inQueue, outQueue):
Thread.__init__(self)
self.inQueue = inQueue
self.outQueue = outQueue
+ self.running = True
+ self.done = False
def run(self):
- while 1:
+ while self.running:
try:
surface = self.inQueue.get(0)
@@ -46,6 +49,8 @@ def run(self):
self.outQueue.put(subpix)
self.inQueue.task_done()
+ if not self.running: self.done = True
+
class TitleScreen(GameState):
"""
@@ -62,7 +67,7 @@ def activate(self):
res.fadeoutMusic()
self.maps = []
- self.change_delay = 8000 # seconds until map moves to next point
+ self.change_delay = 2000 # seconds until map moves to next point
self.map_fadeout = 60.0 # must be a float
self.last_update = 0
self.surfaceQueue = queue()
@@ -75,11 +80,13 @@ def activate(self):
self.menu = cMenu(Rect((42,20), sd.get_size()),
20, 5, 'vertical', 100,
[('New Game', self.new_game),
- ('Battle Test', self.continue_game),
+ ('Load Game', self.load_game),
('Introduction', self.show_intro),
('Quit Game', self.quit_game)],
font="northwoodhigh.ttf", font_size=24)
+ self.game = None
+
self.menu.ready()
self.change_map()
@@ -157,12 +164,22 @@ def draw(self, surface):
def new_game(self):
- uni = loadObject("mh")
- village = uni.getChildByGUID(1001)
+ res.fadeoutMusic(1000)
+ self.game = world.build()
+ village = self.game.getChildByGUID(5001)
sd.start_restart(WorldState(village))
- def continue_game(self):
- sd.start_restart(BattleState(None, None))
+
+ def load_game(self):
+ res.fadeoutMusic(1000)
+ try:
+ path = os.path.join("resources", "saves", "save")
+ self.game = loadObject(path)
+ except IOError:
+ return self.new_game()
+
+ level = self.game.getChildByGUID(5001)
+ sd.start(WorldState(level))
def show_intro(self):
@@ -171,5 +188,8 @@ def show_intro(self):
def quit_game(self):
- sd.done()
+ self.thread.running = False
+ while not self.thread.done:
+ pass
+ sd.done()
Oops, something went wrong.

0 comments on commit eace892

Please sign in to comment.