Created
July 22, 2012 14:27
-
-
Save Bocom/3159855 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public dynamic CreateFromFile(string filename, string name, params object[] parameters) | |
| { | |
| ScriptSource source = engine.CreateScriptSourceFromFile(filename, Encoding.UTF8, SourceCodeKind.File); | |
| CompiledCode code; | |
| try | |
| { | |
| code = source.Compile(); | |
| source.Execute(scope); | |
| } | |
| catch (Exception e) | |
| { | |
| ExceptionOperations eo; | |
| eo = engine.GetService<ExceptionOperations>(); | |
| string error = eo.FormatException(e); | |
| throw new Exception(error); | |
| } | |
| dynamic output = engine.Operations.Invoke(scope.GetVariable(name), parameters); | |
| return output; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import clr | |
| clr.AddReference("Wanderful") | |
| clr.AddReference("WanderfulEngine") | |
| clr.AddReference("Microsoft.Xna.Framework") | |
| import Wanderful | |
| from WanderfulEngine import InputManager | |
| from Microsoft.Xna.Framework import Vector2 | |
| from Microsoft.Xna.Framework.Input import Keys | |
| class TestMonster(Wanderful.MonsterBase): | |
| def Initialize(self): | |
| self.speed = 100 | |
| def LoadContent(self, content): | |
| self.LoadAnimations(content, "mariomonster.json") | |
| self.PlayAnimation("idle-down") | |
| def HandleInput(self): | |
| m_x = 0 | |
| m_y = 0 | |
| if InputManager.IsKeyPressed(Keys.W): | |
| m_y = -1 | |
| elif InputManager.IsKeyPressed(Keys.S): | |
| m_y = 1 | |
| if InputManager.IsKeyPressed(Keys.A): | |
| m_x = -1 | |
| elif InputManager.IsKeyPressed(Keys.D): | |
| m_x = 1 | |
| self.movement = Vector2(m_x, m_y) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment