public Controls(Game1 game,GlassesUI glasses) { this.game = game; this.glasses = glasses; speed = new Vector2(PLAYERBASESPEED,0); direction = new Vector2(0,0); }
public Map(ArrayList objects, ArrayList dynamicObjects,int width,Game1 game) { staticObject = objects; dynamicObject = dynamicObjects; mapWidth = width; this.game = game; }
/// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { using (Game1 game = new Game1()) { game.Run(); } }
protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); Game1.Activity = this; var g = new Game1(); SetContentView(g.Window); g.Run(); }
public override void FinishedLaunching(UIApplication app) { // Fun begins.. using (Game1 game = new Game1()) { game.Run(); } }
/// <summary> /// Initializes a new instance of the <see cref="RenderTarget2DSample.Player"/> class. /// </summary> /// <param name='game'> /// Game. /// </param> /// public Player(Game1 game) { this.game = game; screenPosition.X = 0; screenPosition.Y = 0; mapPosition.X = 0; mapPosition.Y = 0; direction = 0; }
public Sprite(Game game, Texture2D tileSheet, SpriteBatch Batch, Vector2 pos, MapLoader.TileType t, bool dynamicObject = false) : base(game) { Position = pos; Tile = t; spriteBatch = Batch; TileSheet = tileSheet; theGame = (Game1)game; }
/// <summary> /// Initalise the specified game, playerTexture, spriteBatch and screenPosition. /// </summary> /// <param name='game'> /// Game. /// </param> /// <param name='playerTexture'> /// Player texture. /// </param> /// <param name='spriteBatch'> /// Sprite batch. /// </param> /// <param name='screenPosition'> /// Screen position. /// </param> public void Initalise(Game1 game, Texture2D playerTexture, SpriteBatch spriteBatch, Vector2 screenPosition) { this.origin = new Vector2 (playerTexture.Width / 2, playerTexture.Height / 2); this.screenPosition = screenPosition; this.sprite = new AnimatedSprite (game, playerTexture, spriteBatch, screenPosition, MapLoader.TileType.Player); this.overlaySprite = new Sprite (game, playerTexture, spriteBatch, screenPosition, MapLoader.TileType.Glasses); }
public static Map ReadFile(string filename, Texture2D TileSheet,Texture2D AnimatedTileSheet, Game1 game) { Int32 x = 0; Int32 y = 0; int largestWidth = 0; ArrayList tmp = new ArrayList(); ArrayList tmp2 = new ArrayList(); using (StreamReader sReader = new StreamReader(filename)) { while (sReader.Peek() >= 0) { x = 0; foreach (char c in sReader.ReadLine()) { switch (c) { case '#': tmp2.Add(new Sprite(game,TileSheet,game.GetSpriteBatch(),new Vector2(x*32, y*32), TileType.Ground)); break; case '$': tmp2.Add(new Sprite(game,TileSheet, game.GetSpriteBatch(), new Vector2(x*32, y*32), TileType.Water)); break; case '&': tmp2.Add(new Sprite(game, TileSheet, game.GetSpriteBatch(), new Vector2(x * 32, y * 32), TileType.Goo)); break; case '%': tmp2.Add(new Sprite(game, TileSheet, game.GetSpriteBatch(), new Vector2(x * 32, y * 32), TileType.Rocks)); break; case '^': tmp2.Add(new Sprite(game, TileSheet, game.GetSpriteBatch(), new Vector2(x * 32, y * 32), TileType.Spikes)); break; case '2': tmp2.Add(new Sprite(game, TileSheet, game.GetSpriteBatch(), new Vector2(x * 32, y * 32), TileType.Life)); break; case '1': tmp2.Add(new Sprite(game, TileSheet, game.GetSpriteBatch(), new Vector2(x * 32, y * 32), TileType.Key)); break; case '3': tmp.Add(new AnimatedSprite(game, AnimatedTileSheet, game.GetSpriteBatch(), new Vector2(x * 32, y * 32), TileType.NPC_ground)); break; case '4': tmp.Add(new AnimatedSprite(game, AnimatedTileSheet, game.GetSpriteBatch(), new Vector2(x * 32, y * 32), TileType.NPC_Flyer)); break; case '\t': x += 7; break; default: // Char is whitespace or non recognised tile, ignore. break; } x += 1; } if (x > largestWidth) { largestWidth = x; } y += 1; } } Map tempMap = new Map(tmp2,tmp,largestWidth * 32,game); return tempMap; }
static void Main() { game = new Game1(); game.Run(); }
public Background(Game1 game) { this.game = game; }
public void Collision(GameTime gameTime,Vector2 changeVector, Game1 game) { Vector2 playerVect = ((Game1)this.Game).GetPlayer().Position; if (RenderTarget2DSample.Collision.CornerDetection( (int)(Position.X + changeVector.X), (int)(Position.Y - changeVector.Y), 32, 32, (int)playerVect.X + 5 , (int)playerVect.Y + 2, 22, 60)) { // ---------------------------------------------------------------------------------- // Detect for going down if (RenderTarget2DSample.Collision.CornerDetection( (int)(Position.X + changeVector.X), (int)(Position.Y - changeVector.Y), 32, 32, (int)(playerVect.X + 12), (int)(playerVect.Y + 55), 8, 3)) { game.GetPlayer().collisionInDirection.downColliding = true; game.GetPlayer().CanJump = true; } else { game.GetPlayer().collisionInDirection.downColliding = game.GetPlayer().collisionInDirection.downColliding | false; } // ----------------------------------------------------------------------------------- // Detect for going Left if (RenderTarget2DSample.Collision.CornerDetection( (int)(Position.X + changeVector.X), (int)(Position.Y - changeVector.Y), 32, 32, (int)(playerVect.X), (int)(playerVect.Y + 20), 4, 24)) { game.GetPlayer().collisionInDirection.leftColliding = true; } else { game.GetPlayer().collisionInDirection.leftColliding = game.GetPlayer().collisionInDirection.leftColliding | false; } // ----------------------------------------------------------------------------------- // Detect for going right if (RenderTarget2DSample.Collision.CornerDetection( (int)(Position.X + changeVector.X), (int)(Position.Y - changeVector.Y), 32, 32, (int)(playerVect.X + 28), (int)(playerVect.Y + 20), 4, 24)) { game.GetPlayer().collisionInDirection.rightColliding = true; } else { game.GetPlayer().collisionInDirection.rightColliding = game.GetPlayer().collisionInDirection.rightColliding | false; } // ----------------------------------------------------------------------------------- // Detect for going up if (RenderTarget2DSample.Collision.CornerDetection( (int)(Position.X + changeVector.X), (int)(Position.Y - changeVector.Y), 32, 32, (int)(playerVect.X + 5), (int)(playerVect.Y), 22, 5)) { game.GetPlayer().collisionInDirection.upColliding = true; } else { game.GetPlayer().collisionInDirection.upColliding = game.GetPlayer().collisionInDirection.upColliding | false; } } else { // No Collision at all } }
public override void FinishedLaunching (MonoMac.Foundation.NSObject notification) { game = new Game1 (); game.Run (); }