def build(): res.defaults.colorkey = True # build the initial environment uni = AbstractArea() uni.name = 'universe' uni.setGUID(0) # ========================================================================= # our charming hero avatar = Avatar([ Animation('idle', Image('hero-idle.png'), range(9), 1, 100), Animation('brake', Image('hero-brake.png'), range(6), 1, 30), Animation('walk', Image('hero-walk.png'), range(10), 1, 70), Animation('crouch', Image('hero-crouch.png'), range(5), 1, 30), Animation('uncrouch', Image('hero-uncrouch.png'), range(5), 1, 30), Animation('run', Image('hero-run.png'), range(16), 1, 30), Animation('sprint', Image('hero-sprint.png'), range(17), 1, 20), Animation('wait', Image('hero-wait.png'), range(6), 1, 100), Animation('jump', Image('hero-jump.png'), range(4), 1, 20), Animation('die', Image('hero-die.png'), range(3), 1, 85), StaticAnimation('falling', ImageTile('hero-die.png', (0,0), (32,32))), StaticAnimation('roll', Image('hero-roll.png')), #range(8), 1, 30), ]) npc = Entity( avatar, [], Image('face0.png') ) npc.setName("Brahbrah") npc.setGUID(1) npc.size = (16,12,32) npc.move_speed = 1 #.025 npc.jump_strength = 400 uni.add(npc) # ========================================================================= # some keys # red #avatar = Avatar([ # StaticAnimation( # Image('red-key.png', colorkey=True), # 'stand') #]) avatar = Avatar([ Animation('stand', Image('red-key-spinning.png'), range(12), 1, 100) ]) red_key = Key(avatar) red_key.setName('Red Key') red_key.setGUID(513) uni.add(red_key) # green avatar = Avatar([ StaticAnimation('stand', Image('green-key.png')) ]) green_key = Key(avatar) green_key.setName('Green Key') green_key.setGUID(514) uni.add(green_key) # blue avatar = Avatar([ StaticAnimation('stand', Image('blue-key.png')) ]) blue_key = Key(avatar) blue_key.setName('Blue Key') blue_key.setGUID(515) uni.add(blue_key) # floating security bot # ========================================================================= avatar = Avatar([ StaticAnimation('fall', Image('bot0-idle-0001.png')), StaticAnimation('hover', Image('bot0-hover-0001.png')), ]) npc = HoverBot( avatar, [], Image('face0.png') ) npc.setName("bot0") npc.setGUID(516) npc.size = (16,16,16) npc.move_speed = .5 #.025 npc.jump_strength = .5 uni.add(npc) # ========================================================================= # levels level = fromTMX(uni, "level2.tmx") level.setName("Level 1") level.setGUID(5001) #level = Area() #level.setGUID(5001) #uni.add(level) return uni
def build(): res.defaults.colorkey = True # build the initial environment # the name is not important, but the GUID should always be 0 uni = AbstractArea(guid=0) uni.name = 'universe' # ========================================================================= # our charming hero avatar = Avatar([ Animation('idle', Image('hero-idle.png'), range(9), 1, .1), Animation('brake', Image('hero-brake.png'), range(6), 1, .03), Animation('unbrake', Image('hero-brake.png'), range(5,-1,-1), 1, .03), Animation('walk', Image('hero-walk.png'), range(10), 1, .07), Animation('crouch', Image('hero-crouch.png'), range(5), 1, .03), Animation('uncrouch', Image('hero-uncrouch.png'), range(5), 1, .03), Animation('run', Image('hero-run.png'), range(16), 1, .03), Animation('sprint', Image('hero-sprint.png'), range(17), 1, .02), Animation('wait', Image('hero-wait.png'), range(6), 1, .1), Animation('die', Image('hero-die.png'), range(3), 1, .85), StaticAnimation('jumping', ImageTile('hero-jump.png', (2,0), (32,32))), StaticAnimation('falling', ImageTile('hero-die.png', (0,0), (32,32))), StaticAnimation('roll', Image('hero-roll.png'))], axis_offset = (8,0) ) npc = Entity( ( avatar, Sound('stop.wav'), ), guid=1 ) npc.name = "Brahbrah" npc.size = (16,32) npc.jump_strength = 800 uni.add(npc) # ========================================================================= # some keys # red #avatar = Avatar([ # StaticAnimation( # Image('red-key.png', colorkey=True), # 'stand') #]) avatar = Avatar([ Animation('stand', Image('red-key-spinning.png'), range(12), 1, 100) ]) red_key = Key(avatar, guid=513) red_key.name = 'Red Key' uni.add(red_key) # green avatar = Avatar([ StaticAnimation('stand', Image('green-key.png')) ]) green_key = Key(avatar, guid=514) green_key.name = 'Green Key' uni.add(green_key) # blue avatar = Avatar([ StaticAnimation('stand', Image('blue-key.png')) ]) blue_key = Key(avatar, guid=515) blue_key.name = 'Blue Key' uni.add(blue_key) # ========================================================================= # walking laser robot avatar = Avatar([ StaticAnimation('idle', Image('robot-stand.png')), Animation('shoot', Image('robot-shoot.png'), range(4), 1, 85)], axis_offset = (8,0) ) npc = LaserRobot(avatar) npc.guid = 1025 uni.add(npc) # ========================================================================= # floating security bot avatar = Avatar([ StaticAnimation('idle', Image('bot0-idle-0001.png')), StaticAnimation('hover', Image('bot0-hover-0001.png')), ]) npc = HoverBot((avatar, Sound('Hover0.wav'))) npc.name = "bot0" npc.guid = 1026 npc.size = (16,32,16) npc.move_speed = .5 #.025 npc.jump_strength = 50 uni.add(npc) # ========================================================================= # levels level = fromTMX(uni, "level4.tmx") level.name = 'Level 1' level.guid = 5001 #level = Area() #level.setGUID(5001) #uni.add(level) return uni
def build(): # build the initial environment uni = GameObject() 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 = fromTMX(uni, "village.tmx") village.setName("Village") village.setGUID(5001) return uni home = FromTMX(uni, "building0.tmx") home.setName("Building0") home.setGUID(5002) # finialize exits by adding the needed references allAreas = [i for i in uni.getChildren() if isinstance(i, AbstractArea)] allExits = defaultdict(list) # make table of all exits for area in allAreas: for guid in area.exits.keys(): allExits[guid].append(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) return uni
def build(): # build the initial environment uni = GameObject() 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 = fromTMX(uni, "village.tmx") village.setName("Village") village.setGUID(5001) return uni home = FromTMX(uni, "building0.tmx") home.setName("Building0") home.setGUID(5002) # finialize exits by adding the needed references allAreas = [ i for i in uni.getChildren() if isinstance(i, AbstractArea) ] allExits = defaultdict(list) # make table of all exits for area in allAreas: for guid in area.exits.keys(): allExits[guid].append(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) return uni