protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // var g = new MainGame(); var g = new Game1(); //kick off the game! SetContentView((View)g.Services.GetService(typeof(View))); g.Run(); }
protected override void OnCreate(Bundle bundle) { Console.WriteLine("In Activity"); base.OnCreate(bundle); var g = new Game1(); SetContentView((View)g.Services.GetService(typeof(View))); g.Run(); }
//TODO //pull in leaderboard and load up public override void Init(Game1 a_game) { base.Init(a_game); Console.WriteLine("game over!, checking for high score"); //Console.WriteLine("Score is: " + m_game.m_score); m_userMessage = ""; //will be set in run once in update loop ldrBrd.Init(); //opens file or populates leaderboard m_runOnce = false; m_runOnReturn = false; //userMessage = ldrBrd.DisplayLeaderBoard(); //get leaderboard string m_bgTex = m_game.Content.Load<Texture2D>("gameOver_bg"); }
//TODO //pull in leaderboard and load up public override void Init(Game1 a_game) { base.Init(a_game); Console.WriteLine("game over!"); Console.WriteLine("Score is: " + m_game.m_score); m_runCount = 0; ldrBrd.Init(); //opens file or populates leaderboard //m_userMessage = ldrBrd.DisplayLeaderBoard(); //print leaderboard to console m_userMessage += " \n You got a high score! \n please enter your name \n in the console"; m_bgTex = m_game.Content.Load<Texture2D>("gameOver_bg"); }
//public float m_radius; public override void Init(Game1 inGame, Microsoft.Xna.Framework.Graphics.SpriteBatch a_sb, CLASSID a_type) { base.Init(inGame, a_sb, a_type); //m_classID = CLASSID.CLASSID_PLANET; //m_game.Content.Load<Texture2D>("planet"); m_rot = 0.0f; m_pos = new Vector2(0, 0); m_centre = new Vector2(0,0); m_radius = -1; // m_radius = GetRadius(m_sprite.Width, m_sprite.Height); }
private Boolean lastDir; //last direction the player was moving - used to set correct idle animation orientation etc - true is left public override void Init(Game1 inGame, SpriteBatch a_sb, CLASSID a_type) { lastDir = false; base.Init(inGame, a_sb, a_type); m_classID = CLASSID.CLASSID_PLAYER; //hard set mass and friction m_mass = 50.0f; m_friction = 10.0f; m_hasCollided = false; // m_sprite = m_game.Content.Load<Texture2D>("player"); m_rot = 0.0f; // m_centre = new Vector2(m_sprite.Width / 2, m_sprite.Height / 2); m_matrix *= Matrix.CreateTranslation(new Vector3(300,300,0)); m_heading = new Vector2(0, 0); // m_pos = new Vector2(m_matrix.Translation.X, m_matrix.Translation.Y); m_pos = new Vector2(0, 0); m_planetRot = 0f; m_gravHeading = new Vector2(0, 0); m_newPlanet = false; m_killUpVelocity = false; m_isJumping = false; m_jumpStates.Add("start"); m_jumpStates.Add("loop"); m_jumpStates.Add("end"); }
static void Main() { using (var game = new Game1()) game.Run(); }
public void UpdateRes(Game1 a_game, int a_width, int a_height) { graphics.PreferredBackBufferHeight = a_height; graphics.PreferredBackBufferWidth = a_width; m_screenHeight = a_height; m_screenWidth = a_width; m_cam.UpdateRes(a_width, a_height); graphics.ApplyChanges(); }
//list of all actors in game //public List<Actor> m_actorList = new List<Actor>(); public override void Init(Game1 a_game) { base.Init(a_game); }
//XmlDocument xmlDoc = new XmlDocument(); // Create an XML document object //XElement //TODO //create global settings for platform to build to - psm, andriod etc //================================== public void Init(Game1 a_game, SpriteBatch a_sb, List<Actor> a_list, List<Actor> a_splashList) { //GOBAL SETTINGS m_globalScale = 1; //global scale will scale everything in the game //snippets from http://www.dotnetcurry.com/showarticle.aspx?ID=564 //load xml file XElement xelement = XElement.Load("content/config.xml"); // IEnumerable<XElement> planets = xelement.Elements(); // var xmlPlanets = from planets in xelement.Elements("planets") select planets; Console.WriteLine("=============== Loading XML data ==================="); //CONFIG foreach (var xConfig in xelement.Descendants("config")) { a_game.UpdateRes(a_game, Convert.ToInt32(xConfig.Element("screenX").Value), Convert.ToInt32(xConfig.Element("screenY").Value)); Actor bg = new Actor(); bg.Init(a_game, a_sb, CLASSID.CLASSID_BACKGROUND); //bg.m_spritesBackground.Add(a_game.Content.Load<Texture2D>(xConfig.Element("backgroundSprite").Value)); List<Texture2D> texture = new List<Texture2D>(); texture.Add(a_game.Content.Load<Texture2D>(xConfig.Element("backgroundSprite").Value)); bg.m_spriteManager.Cmd(SpriteManager.SpriteCommands.PUSH, "background", texture, Convert.ToInt32(xConfig.Element("frameCount").Value), Convert.ToInt32(xConfig.Element("frameWidth").Value), 0, Convert.ToInt32(xConfig.Element("frameHeight").Value), Convert.ToSingle((xConfig.Element("animSpeed").Value))); bg.m_pos = new Vector2(Convert.ToInt32(xConfig.Element("bgX").Value), Convert.ToInt32(xConfig.Element("bgY").Value)); bg.m_classID = CLASSID.CLASSID_BACKGROUND; a_list.Add(bg); m_firstState = xConfig.Element("firstGameScreen").Value; if (m_firstState == "splash") { foreach (var xSprite in xConfig.Descendants("splashSprite")) { Actor splash = new Actor(); splash.Init(a_game, a_sb, CLASSID.CLASSID_BACKGROUND); splash.m_pos = new Vector2(0, 0); List<Texture2D> Splashtexture = new List<Texture2D>(); Splashtexture.Add(a_game.Content.Load<Texture2D>(xSprite.Value)); splash.m_spriteManager.Cmd(SpriteManager.SpriteCommands.PUSH, "splash", Splashtexture, Convert.ToInt32(xConfig.Element("frameCount").Value), Convert.ToInt32(xConfig.Element("frameWidth").Value), 0, Convert.ToInt32(xConfig.Element("frameHeight").Value), Convert.ToSingle((xConfig.Element("animSpeed").Value))); splash.m_classID = CLASSID.CLASSID_BACKGROUND; a_splashList.Add(splash); } } } //================= building player Player player = new Player(); foreach (var xPlayer in xelement.Descendants("player")) { Console.WriteLine(xPlayer); //================================================================================ //================ PLAYER CONFIG //================================================================================ //There can only be only be one player player.Init(a_game, a_sb, CLASSID.CLASSID_PLAYER); //don't edit this line //set the player x and y start position //0,0 is top left //This is the actual starting position from the centre of the player player.m_pos = new Vector2(Convert.ToInt32(xPlayer.Element("posX").Value), Convert.ToInt32(xPlayer.Element("posY").Value)); float test = Convert.ToSingle(xPlayer.Element("scale").Value); //set the players local scale player.m_scale = test; //put an f at the end player.m_mass = Convert.ToSingle(xPlayer.Element("mass").Value); player.m_friction = Convert.ToSingle(xPlayer.Element("friction").Value); //sprite texture to load // player.m_sprite = a_game.Content.Load<Texture2D>(xPlayer.Element("sprite").Value); //=================== building player srpites foreach (var xSprite in xPlayer.Descendants("sprite")) { //player.m_spritesMain.Add(a_game.Content.Load<Texture2D>(xSprite.Value)); List<Texture2D> texture = new List<Texture2D>(); texture.Add(a_game.Content.Load<Texture2D>(xSprite.Value)); player.m_spriteManager.Cmd(SpriteManager.SpriteCommands.PUSH, "player", texture, Convert.ToInt32(xPlayer.Element("idleCount").Value), Convert.ToInt32(xPlayer.Element("frameWidth").Value), Convert.ToInt32(xPlayer.Element("idleStartCol").Value), Convert.ToInt32(xPlayer.Element("idleStartRow").Value), Convert.ToInt32(xPlayer.Element("frameHeight").Value), Convert.ToSingle(xPlayer.Element("animSpeed").Value), "idle"); player.m_spriteManager.Cmd(SpriteManager.SpriteCommands.PUSH, "player", texture, Convert.ToInt32(xPlayer.Element("runCount").Value), Convert.ToInt32(xPlayer.Element("frameWidth").Value), Convert.ToInt32(xPlayer.Element("runStartCol").Value), Convert.ToInt32(xPlayer.Element("runStartRow").Value), Convert.ToInt32(xPlayer.Element("frameHeight").Value), Convert.ToSingle(xPlayer.Element("animSpeed").Value), "run"); //Jumping states //jump start player.m_spriteManager.Cmd(SpriteManager.SpriteCommands.PUSH, "player", texture, Convert.ToInt32(xPlayer.Element("jumpStartCount").Value), Convert.ToInt32(xPlayer.Element("frameWidth").Value), Convert.ToInt32(xPlayer.Element("jumpStartCol").Value), Convert.ToInt32(xPlayer.Element("jumpStartRow").Value), Convert.ToInt32(xPlayer.Element("frameHeight").Value), Convert.ToSingle(xPlayer.Element("animSpeed").Value), "start"); //jump loop player.m_spriteManager.Cmd(SpriteManager.SpriteCommands.PUSH, "player", texture, Convert.ToInt32(xPlayer.Element("jumpLoopCount").Value), Convert.ToInt32(xPlayer.Element("frameWidth").Value), Convert.ToInt32(xPlayer.Element("jumpLoopCol").Value), Convert.ToInt32(xPlayer.Element("jumpLoopRow").Value), Convert.ToInt32(xPlayer.Element("frameHeight").Value), Convert.ToSingle(xPlayer.Element("animSpeed").Value), "loop"); //jump end player.m_spriteManager.Cmd(SpriteManager.SpriteCommands.PUSH, "player", texture, Convert.ToInt32(xPlayer.Element("jumpEndCount").Value), Convert.ToInt32(xPlayer.Element("frameWidth").Value), Convert.ToInt32(xPlayer.Element("jumpEndCol").Value), Convert.ToInt32(xPlayer.Element("jumpEndRow").Value), Convert.ToInt32(xPlayer.Element("frameHeight").Value), Convert.ToSingle(xPlayer.Element("animSpeed").Value), "end"); player.m_spriteManager.Cmd(SpriteManager.SpriteCommands.SWITCH,"player", "idle"); //set the initial state to idle } //center of the image, adjust as needed player.m_centre = new Vector2(Convert.ToSingle((xPlayer.Element("centreX").Value)), Convert.ToSingle(xPlayer.Element("centreY").Value)); player.m_spaceMoveSpeed = Convert.ToInt32(xPlayer.Element("spaceMoveSpeed").Value); player.m_planetMoveSpeed = Convert.ToInt32(xPlayer.Element("planetMoveSpeed").Value); player.m_jumpSpeed = Convert.ToInt32(xPlayer.Element("jumpSpeed").Value); //draw the collision circle around the player player.m_drawCollision = Convert.ToBoolean(xPlayer.Element("drawCollision").Value); player.m_width = Convert.ToSingle(xPlayer.Element("width").Value); player.m_height = Convert.ToSingle(xPlayer.Element("height").Value); //set the radius of the player //default is to get the radius based on texture player.m_radius = player.GetRadius(player.m_width, player.m_height); //add the player to the main game loop a_list.Add(player); //===================================== } //=================== building planets foreach (var xPlanet in xelement.Descendants("planet")) { Console.WriteLine(xPlanet); //start creating planet one Planet planet1 = new Planet(); //TODO - split planet based on type planet1.Init(a_game, a_sb, CLASSID.CLASSID_PLANETSPHERE); //position planet1.m_pos = new Vector2( Convert.ToInt32( xPlanet.Element("posX").Value), Convert.ToInt32( xPlanet.Element("posY").Value)); planet1.m_centre = new Vector2(Convert.ToInt32(xPlanet.Element("centreX").Value), Convert.ToInt32(xPlanet.Element("centreY").Value)); planet1.m_planetGravity = Convert.ToInt32(xPlanet.Element("gravity").Value); planet1.m_scale = Convert.ToSingle(xPlanet.Element("scale").Value); //radius of the planet for collisions planet1.m_radius = Convert.ToSingle(xPlanet.Element("collisionRadius").Value); //radius of the planet for detecting gravity effect on the player planet1.m_effectiveRadius = Convert.ToSingle(xPlanet.Element("effectiveRadius").Value); //draw the effective radius planet1.m_drawEfftiveRadius = Convert.ToBoolean(xPlanet.Element("drawCollision").Value); //draw the collision circle (good way to see radius) planet1.m_drawCollision = Convert.ToBoolean(xPlanet.Element("drawEffective").Value); //laod planet sprite //planet1.m_sprite = a_game.Content.Load<Texture2D>(xPlanet.Element("sprite").Value); //add main sprite foreach (var xSprite in xPlanet.Descendants("planetSprite")) { //Console.WriteLine(xSprite.Value); //planet1.m_spritesMain.Add(a_game.Content.Load<Texture2D>(xSprite.Value)); List<Texture2D> texture = new List<Texture2D>(); texture.Add(a_game.Content.Load<Texture2D>(xSprite.Value)); planet1.m_spriteManager.Cmd(SpriteManager.SpriteCommands.PUSH, "main", texture, Convert.ToInt32(xPlanet.Element("frameCount").Value), Convert.ToInt32(xPlanet.Element("frameWidth").Value), 0 , Convert.ToInt32(xPlanet.Element("frameHeight").Value), Convert.ToSingle(xPlanet.Element("animSpeed").Value)); } //add behind sprite elements foreach (var xSprite in xPlanet.Descendants("behindSprite")) { //Console.WriteLine(xSprite.Value); //planet1.m_spritesBehind.Add(a_game.Content.Load<Texture2D>(xSprite.Value)); List<Texture2D> texture = new List<Texture2D>(); texture.Add(a_game.Content.Load<Texture2D>(xSprite.Value)); planet1.m_spriteManager.Cmd(SpriteManager.SpriteCommands.PUSH, "behind", texture, Convert.ToInt32(xPlanet.Element("frameCount").Value), Convert.ToInt32(xPlanet.Element("frameWidth").Value), 0 , Convert.ToInt32(xPlanet.Element("frameHeight").Value), Convert.ToSingle(xPlanet.Element("animSpeed").Value)); } //add in front sprite elements foreach (var xSprite in xPlanet.Descendants("infrontSprite")) { //Console.WriteLine(xSprite.Value); //planet1.m_spritesInfront.Add(a_game.Content.Load<Texture2D>(xSprite.Value)); List<Texture2D> texture = new List<Texture2D>(); texture.Add(a_game.Content.Load<Texture2D>(xSprite.Value)); planet1.m_spriteManager.Cmd(SpriteManager.SpriteCommands.PUSH, "front", texture, Convert.ToInt32(xPlanet.Element("frameCount").Value), Convert.ToInt32(xPlanet.Element("frameWidth").Value), 0, Convert.ToInt32(xPlanet.Element("frameHeight").Value), Convert.ToSingle(xPlanet.Element("animSpeed").Value)); } //add the planet to the list a_list.Add(planet1); //================================================= //set the first planet the player is attracted to, this can be any planet but it must be set //TODO currently set to last planet added, change to be set via config player.m_curPlanet = planet1; } Console.WriteLine("============== End xml data =============="); }
/// <summary> /// clear the current game variables and rebuild the game /// </summary> /// <param name="a_game"></param> /// <param name="a_sb"></param> /// <param name="a_list"></param> public void hotReload(Game1 a_game, SpriteBatch a_sb, List<Actor> a_list, List<Actor> a_splashList) { a_list.Clear(); a_splashList.Clear(); Init(a_game, a_sb, a_list, a_splashList); Console.WriteLine("++++++++++++++++++++++++++ Hot reloading done +++++++++++++++++++++++++++++"); }
public override void Init(Game1 a_game) { base.Init(a_game); //a_game.updateCamera(new Vector2(0,0)); }
public virtual void Init(Game1 inGame, SpriteBatch a_sb, CLASSID a_type) { m_classID = a_type; m_game = inGame; m_sb = a_sb; m_spriteEffect = SpriteEffects.None; m_matrix = Matrix.Identity; m_drawCollision = true; m_scale = 1; m_lineTexture = m_game.Content.Load<Texture2D>("edge_plain"); m_classID = CLASSID.CLASSID_ACTOR; m_spriteManager = new SpriteManager(); //init the sprite manager m_spriteManager.Init(this); }
private List<StateCmd> m_cmds = new List<StateCmd>(); //list of commands to be executed during the next update public void Init(Game1 a_game) { m_game = a_game; }
public virtual void Init(Game1 a_game) { m_game = a_game; }
static void Main () { Console.WriteLine("Loading Game"); game = new Game1(); game.Run(); }