public Grid(Game1 g, String s) { //Get input from the imported file streamReader = new StreamReader(s); //Allow access to the Game1 object for screen sizes and ContentPipline this.g = g; //Get the size of the screen gridHeight = g.GraphicsDevice.Viewport.Bounds.Height; gridWidth = g.GraphicsDevice.Viewport.Bounds.Width; //Calc the number of cells long and wide numCellsLong = int.Parse(streamReader.ReadLine()); numCellsHigh = int.Parse(streamReader.ReadLine()); //Calc the width and height of each cell cellWidth = (double)gridWidth / numCellsLong; cellHeight = (double)gridHeight / numCellsHigh; //Initialze the grid array grid = new bool[numCellsHigh, numCellsLong]; charGrid = new char[numCellsHigh, numCellsLong]; //Initialize the grid initGrid(); }
/// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { using (Game1 game = new Game1()) { game.Run(); } }
public Screen(Game1 g, String bg, String f) { background = g.Content.Load<Texture2D>(bg); font = g.Content.Load<SpriteFont>(f); selection = 0; numOfLinks = 0; }
protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); var g = new Game1 (); SetContentView (g.Services.GetService<View> ()); g.Run (); }
//Constructor public Snake(Game1 game, Grid grid) { //Get the game this.game = game; //Get the current grid this.grid = grid; //Set the starting direction direction = 'R'; //Init the body size bodyRow = new int[grid.numCellsHigh * grid.numCellsLong]; bodyCol = new int[grid.numCellsHigh * grid.numCellsLong]; //Init the snake size snakeLength = 6; curLength = 1; for (int i = 0; i < bodyRow.Length; i++) { bodyRow[i] = 0; bodyCol[i] = 0; } //Find the body for (int i = 0; i < grid.numCellsHigh; i++) { for (int j = 0; j < grid.numCellsLong; j++) { if (grid.charGrid[i, j] == 's') { bodyRow[0] = i; bodyCol[0] = j; startRow = i; startCol = j; } } } //Init the speed and timer speed = 5; currentTick = 0; //Init the state of the game lost = false; //Init the powerup EnablePowerups(); powerUpEnabled = true; }
public Grid(Game1 g, int numCellsHigh, int numCellsLong) { //Allow access to the Game1 object for screen sizes and ContentPipline this.g = g; //Get the size of the screen gridHeight = g.GraphicsDevice.Viewport.Bounds.Height; gridWidth = g.GraphicsDevice.Viewport.Bounds.Width; //Store te number of cells wide and high this.numCellsHigh = numCellsHigh; this.numCellsLong = numCellsLong; //Calc the width and height of each cell cellWidth = (double)gridWidth / numCellsLong; cellHeight = (double)gridHeight / numCellsHigh; //Initialze the grid array grid = new bool[numCellsHigh, numCellsLong]; charGrid = new char[numCellsHigh, numCellsLong]; //Initialze the grid initGrid(); }
//We will need references to the paddles for collision detection, and //our Game1 contains these references, our ball should have the //reference to the Game1 public Ball(Game1 g, String texture) { //set the game1 object game1 = g; //set the texture of the ball this.texture = game1.Content.Load<Texture2D>(texture); //we use a random object when randomly setting the balls direction rand = new Random(); //the ball should start near at the center of the screen //use a size of 20x20 ball = new Rectangle( game1.GraphicsDevice.Viewport.Bounds.Width / 2 - ball.Width / 2, game1.GraphicsDevice.Viewport.Bounds.Height / 2 - ball.Height / 2, 20, 20); reset(); //Initialize the score font = game1.Content.Load<SpriteFont>(@"ScoreFont"); }
public Page() { InitializeComponent(); game = new Game1(); game.Attach(LayoutRoot); }
static void Main() { using (var game = new Game1()) game.Run(); }