class action3hive(bee.frame): init_animationmanager = bee.init("animationmanager") init_soundmanager = bee.init("soundmanager") init_animationmanager.add_animation("swim", "splash-animation") init_soundmanager.add_sound("swim", "splash.wav") init_animationmanager.add_animation("crouch", "crouching") init_soundmanager.add_sound("crouch", "crouch.wav")
class action1hive(bee.frame): adict = bee.init("animdict") sdict = bee.init("sounddict") adict["walk"] = "walk-animation" sdict["walk"] = "walking.wav" adict["jump"] = "jump-animation" sdict["jump"] = "jmp.wav"
class action2hive(bee.frame): actiondict = dragonfly.logic.dictionary("CharacterAction")() actionplay = antenna(actiondict.inkey) action = dragonfly.blocks.block("CharacterAction")() set_action = dragonfly.blocks.setter("CharacterAction")() connect(set_action, action) connect(actiondict.outvalue, set_action._set) get_action = dragonfly.blocks.getter("CharacterAction")() connect(action, get_action) transistor_2 = transistor("str")() transistor_3 = transistor("str")() connect(get_action.animation, transistor_2) connect(get_action.soundfile, transistor_3) connect(set_action.on_set, transistor_2) connect(set_action.on_set, transistor_3) play_animation = play_animation() play_sound = play_sound() connect(transistor_2, play_animation) connect(transistor_3, play_sound) d = bee.init("actiondict") d["run"] = CharacterAction( animation="running.animation", soundfile="run.wav", ) #or: d["run"] = CharacterAction("running.animation", "run.wav") d["shoot"] = CharacterAction( animation="shooting.animation", soundfile="shoot.wav", )
class myscene(dragonfly.pandahive.spyderframe): pandaicon_ = bee.get_parameter("pandaicon") a = Spyder.AxisSystem() a *= 0.25 a.origin += (-8, 42, 0) env = Spyder.Model3D("models/environment", "egg", a) a = Spyder.AxisSystem() a *= 0.005 mypanda = Spyder.Actor3D("models/panda-model", "egg", [("walk", "models/panda-walk4", "egg")], a, entityname="mypanda") a = Spyder.AxisSystem() a *= 0.005 pandaclass = Spyder.ActorClass3D("models/panda-model", "egg", [("walk", "models/panda-walk4", "egg")], a, actorclassname="pandaclass") box = box2d(50, 470, 96, 96) params = parameters() params.transparency = True args = canvasargs("pandaicon.png", pandaicon_, box, params) plugin = plugin_single_required(args) pattern = ("canvas", "draw", "init", ("object", "image")) d1 = dummydrone(plugindict={pattern: plugin}) i1 = bee.init("mousearea") i1.register(pandaicon_, box) del a, box, params, args, plugin, pattern
class myhive(dragonfly.pandahive.pandahive): pandaname = "mypanda" pandaname_ = bee.attribute("pandaname") pandaclassname = "pandaclass" pandaclassname_ = bee.attribute("pandaclassname") canvas = dragonfly.pandahive.pandacanvas() mousearea = dragonfly.canvas.mousearea() raiser = bee.raiser() connect("evexc", raiser) z_pandawalk = pandawalkbind().worker() pandaid = dragonfly.std.variable("id")(pandaname_) connect(pandaid, z_pandawalk.bindname) camerabind = camerabind().worker() camcenter = dragonfly.std.variable("id")("camcenter") connect(camcenter, camerabind.bindname) startsensor = dragonfly.sys.startsensor() cam = dragonfly.scene.get_camera() camparent = dragonfly.scene.unbound.parent() connect(cam, camparent.entityname) connect(camcenter, camparent.entityparentname) connect(startsensor, camparent) cphide = dragonfly.scene.unbound.hide() connect(camcenter, cphide) connect(startsensor, cphide) pandaspawn = dragonfly.scene.spawn_actor() v_panda = dragonfly.std.variable("id")(pandaclassname_) connect(v_panda, pandaspawn) panda_id = dragonfly.std.generator("id", id_generator)() random_matrix = dragonfly.std.generator(("object", "matrix"), random_matrix_generator)() w_spawn = dragonfly.std.weaver(("id", ("object", "matrix")))() connect(panda_id, w_spawn.inp1) connect(random_matrix, w_spawn.inp2) do_spawn = dragonfly.std.transistor(("id", ("object", "matrix")))() connect(w_spawn, do_spawn) connect(do_spawn, pandaspawn.spawn_matrix) key_z = dragonfly.io.keyboardsensor_trigger("Z") connect(key_z, do_spawn) pandaicon_click = dragonfly.io.mouseareasensor("pandaicon") connect(pandaicon_click, do_spawn) myscene = myscene( scene="scene", canvas=canvas, mousearea=mousearea, ) wininit = bee.init("window") wininit.camera.setPos(0, 45, 25) wininit.camera.setHpr(180, -20, 0)
class action3hive(bee.frame): animationmanager = animationmanager() soundmanager = soundmanager() init_animationmanager = bee.init(animationmanager) init_soundmanager = bee.init(soundmanager) init_animationmanager.add_animation("swim", "splash-animation") init_soundmanager.add_sound("swim", "splash.wav") init_animationmanager.add_animation("crouch", "crouching") init_soundmanager.add_sound("crouch", "crouch.wav") action3_play_animation_1 = action3_play_animation() action3_play_sound_1 = action3_play_sound() animplay = antenna(action3_play_animation_1.inp) soundplay = antenna(action3_play_sound_1.inp)
class action1hive(bee.frame): animdict = dragonfly.logic.dictionary("str")() play_animation = play_animation() connect(animdict.outvalue, play_animation) sounddict = dragonfly.logic.dictionary("str")() play_sound = play_sound() connect(sounddict.outvalue, play_sound) adict = bee.init(animdict) sdict = bee.init(sounddict) adict["walk"] = "walk-animation" sdict["walk"] = "walking.wav" adict["jump"] = "jump-animation" sdict["jump"] = "jmp.wav" animplay = antenna(animdict.inkey) soundplay = antenna(sounddict.inkey)
class action2hive(bee.frame): d = bee.init("dictionary") d["run"] = CharacterAction( animation="running.animation", soundfile="run.wav", ) # or: d["run"] = CharacterAction("running.animation", "run.wav") d["shoot"] = CharacterAction( animation="shooting.animation", soundfile="shoot.wav", )
class myscene(bee.frame): pandaclassname_ = bee.get_parameter("pandaclassname") pandaname_ = bee.get_parameter("pandaname") pandaicon_ = bee.get_parameter("pandaicon") c1 = bee.configure("scene") c1.import_mesh_EGG("models/environment") a = NodePath("") a.setScale(0.25) a.setPos(-8, 42, 0) mat = a.getMat() m = (mat.getRow3(3), mat.getRow3(0), mat.getRow3(1), mat.getRow3(2)) c1.add_model_MATRIX(matrix=m) c2 = bee.configure("scene") c2.import_mesh_EGG("models/panda-model") a = NodePath("") a.setScale(0.005) mat = a.getMat() m = (mat.getRow3(3), mat.getRow3(0), mat.getRow3(1), mat.getRow3(2)) c2.add_actor_MATRIX(matrix=m, entityname=pandaname_) c2.import_mesh_EGG("models/panda-walk4") c2.add_animation("walk") c3 = bee.configure("scene") c3.import_mesh_EGG("models/panda-model") a = NodePath("") a.setScale(0.005) mat = a.getMat() m = (mat.getRow3(3), mat.getRow3(0), mat.getRow3(1), mat.getRow3(2)) c3.add_actorclass_MATRIX(matrix=m, actorclassname=pandaclassname_) c3.import_mesh_EGG("models/panda-walk4") c3.add_animation("walk") box = box2d(50, 470, 96, 96) params = parameters() params.transparency = True args = canvasargs("pandaicon.png", pandaicon_, box, params) plugin = plugin_single_required(args) pattern = ("canvas", "draw", "init", ("object", "image")) d1 = dummydrone(plugindict={pattern: plugin}) i1 = bee.init("mousearea") i1.register(pandaicon_, box) del a, m, mat, box, params, args, plugin, pattern
class myscene(bee.frame): pandaclassname_ = bee.get_parameter("pandaclassname") pandaname_ = bee.get_parameter("pandaname") pandaicon_ = bee.get_parameter("pandaicon") c1 = bee.configure("scene") c1.import_mesh_EGG("models/environment") a = Spyder.AxisSystem() a *= 0.25 a.origin += (-8, 42, 0) c1.add_model_SPYDER(axissystem=a) c2 = bee.configure("scene") c2.import_mesh_EGG("models/panda-model") a = Spyder.AxisSystem() a *= 0.005 c2.add_actor_SPYDER(axissystem=a, entityname=pandaname_) c2.import_mesh_EGG("models/panda-walk4") c2.add_animation("walk") c3 = bee.configure("scene") c3.import_mesh_EGG("models/panda-model") a = Spyder.AxisSystem() a *= 0.005 c3.add_actorclass_SPYDER(axissystem=a, actorclassname=pandaclassname_) c3.import_mesh_EGG("models/panda-walk4") c3.add_animation("walk") box = box2d(50, 470, 96, 96) params = parameters() params.transparency = True args = canvasargs("pandaicon.png", pandaicon_, box, params) plugin = plugin_single_required(args) pattern = ("canvas", "draw", "init", ("object", "image")) d1 = dummydrone(plugindict={pattern: plugin}) i1 = bee.init("mousearea") i1.register(pandaicon_, box) del a, box, params, args, plugin, pattern
class myhive(dragonfly.pandahive.pandahive): pandaclassname = "pandaclass" pandaclassname_ = bee.attribute("pandaclassname") canvas = dragonfly.pandahive.pandacanvas() mousearea = dragonfly.canvas.mousearea() raiser = bee.raiser() connect("evexc", raiser) camerabind = camerabind().worker() camcenter = dragonfly.std.variable("id")("camcenter") connect(camcenter, camerabind.bindname) startsensor = dragonfly.sys.startsensor() cam = dragonfly.scene.get_camera() camparent = dragonfly.scene.unbound.parent() connect(cam, camparent.entityname) connect(camcenter, camparent.entityparentname) connect(startsensor, camparent) cphide = dragonfly.scene.unbound.hide() connect(camcenter, cphide) connect(startsensor, cphide) v_marker = dragonfly.std.variable("id")("marker") hide_marker = dragonfly.scene.unbound.hide() connect(v_marker, hide_marker) show_marker = dragonfly.scene.unbound.show() connect(v_marker, show_marker) parent_marker = dragonfly.scene.unbound.parent() connect(v_marker, parent_marker.entityname) connect(startsensor, hide_marker) pandaspawn = dragonfly.scene.spawn_actor() v_panda = dragonfly.std.variable("id")(pandaclassname_) connect(v_panda, pandaspawn) panda_id_gen = dragonfly.std.generator("id", id_generator)() panda_id = dragonfly.std.variable("id")("") t_panda_id_gen = dragonfly.std.transistor("id")() connect(panda_id_gen, t_panda_id_gen) connect(t_panda_id_gen, panda_id) random_matrix = dragonfly.std.generator(("object", "matrix"), random_matrix_generator)() w_spawn = dragonfly.std.weaver(("id", ("object", "matrix")))() connect(panda_id, w_spawn.inp1) connect(random_matrix, w_spawn.inp2) hivereg = dragonfly.bind.hiveregister() c_hivereg = bee.configure("hivereg") c_hivereg.register_hive("pandawalk", pandawalkhive) pandabinder = pandabind().worker() v_hivename = dragonfly.std.variable("id")("pandawalk") w_bind = dragonfly.std.weaver(("id", "id"))() connect(panda_id, w_bind.inp1) connect(v_hivename, w_bind.inp2) t_bind = dragonfly.std.transistor("id")() connect(panda_id, t_bind) t_bind2 = dragonfly.std.transistor(("id", "id"))() connect(w_bind, t_bind2) connect(t_bind2, pandabinder.bind) sel = dragonfly.logic.selector() connect(t_bind, sel.register_and_select) selected = dragonfly.std.variable("id")("") connect(t_bind, selected) t_get_selected = dragonfly.logic.filter("trigger")() connect(sel.empty, t_get_selected) tt_get_selected = dragonfly.std.transistor("id")() do_select = dragonfly.std.pushconnector("trigger")() connect(t_get_selected.false, do_select) connect(do_select, tt_get_selected) connect(sel.selected, tt_get_selected) connect(tt_get_selected, selected) disp_sel = dragonfly.io.display("id")("Selected: ") connect(tt_get_selected, disp_sel) connect(selected, parent_marker.entityparentname) connect(do_select, show_marker) connect(do_select, parent_marker) key_tab = dragonfly.io.keyboardsensor_trigger("TAB") connect(key_tab, sel.select_next) connect(key_tab, t_get_selected) key_bsp = dragonfly.io.keyboardsensor_trigger("BACKSPACE") connect(key_bsp, sel.select_prev) connect(key_bsp, t_get_selected) kill = dragonfly.std.pushconnector("trigger")() t_kill = dragonfly.std.transistor("id")() connect(selected, t_kill) connect(t_kill, pandabinder.stop) remove = dragonfly.scene.unbound.remove_actor_or_entity() connect(t_kill, remove) disp_kill = dragonfly.io.display("id")("Killed: ") connect(t_kill, disp_kill) connect(kill, t_kill) connect(kill, sel.unregister) connect(kill, hide_marker) connect(kill, t_get_selected) testkill = dragonfly.logic.filter("trigger")() connect(sel.empty, testkill) connect(testkill.false, kill) key_k = dragonfly.io.keyboardsensor_trigger("K") connect(key_k, testkill) do_spawn = dragonfly.std.transistor(("id", ("object", "matrix")))() connect(w_spawn, do_spawn) connect(do_spawn, pandaspawn.spawn_matrix) trig_spawn = dragonfly.std.pushconnector("trigger")() connect(trig_spawn, t_panda_id_gen) connect(trig_spawn, do_spawn) connect(trig_spawn, t_bind) connect(trig_spawn, t_bind2) connect(trig_spawn, do_select) key_z = dragonfly.io.keyboardsensor_trigger("Z") connect(key_z, trig_spawn) pandaicon_click = dragonfly.io.mouseareasensor("pandaicon") connect(pandaicon_click, trig_spawn) myscene = myscene( scene="scene", canvas=canvas, mousearea=mousearea, ) wininit = bee.init("window") wininit.camera.setPos(0, 45, 25) wininit.camera.setHpr(180, -20, 0) keyboardevents = dragonfly.event.sensor_match_leader("keyboard") add_head = dragonfly.event.add_head() head = dragonfly.convert.pull.duck("id", "event")() connect(selected, head) connect(keyboardevents, add_head) connect(head, add_head) connect(add_head, pandabinder.event)
def insert_sound_item(sounditem): initbee = bee.init("sounddict") initbee[sounditem.identifier] = sounditem.soundfile return initbee
def insert_animation_item(animationitem): initbee = bee.init("animdict") initbee[animationitem.identifier] = animationitem.animation return initbee
def insert_sound_item(sounditem): initbee = bee.init("soundmanager") initbee.add_sound(sounditem.identifier, sounditem.soundfile) return initbee
def insert_animation_item(animationitem): initbee = bee.init("animationmanager") initbee.add_animation(animationitem.identifier, animationitem.animation) return initbee
def show_mousearea(i): i1 = bee.init("mousearea") b = i.box box = box2d(b.x, b.y, b.sizex, b.sizey, b.mode) i1.register(i.identifier, box) return i1