public GameSession(Game game) : base(game) { backgroundTexture = new Texture("resources/background.png"); Texture gameTexture = new Texture("resources/blocks.png"); Texture[] textures = CreateBlockTextures(gameTexture); GameBlock[] regularBlocks = CreateColoredBlocks(textures, regularBlockColors, false); GameBlock[] hardBlocks = CreateColoredBlocks(textures, hardBlockColors, true); barTexture = gameTexture.Slice(6, 88, 243, 66); gameOverTexture = gameTexture.Slice(5, 166, 238, 45); leftPane = new GamePane(this, regularBlocks, hardBlocks, 40.0f, 30.0f); rightPane = new GamePane(this, regularBlocks, hardBlocks, 430.0f, 30.0f); running = true; }
public GameSession(Game game) : base(game) { backgroundTexture = new Texture("resources/background.png"); Texture gameTexture = new Texture("resources/blocks.png"); Texture[] textures = CreateBlockTextures(gameTexture); GameBlock[] regularBlocks = CreateColoredBlocks(textures, regularBlockColors, false); GameBlock[] hardBlocks = CreateColoredBlocks(textures, hardBlockColors, true); barTexture = gameTexture.Slice(6, 88, 243, 66); gameOverTexture = gameTexture.Slice(5, 166, 238, 45); leftPane = new GamePane(this, regularBlocks, hardBlocks, 40.0f, 30.0f); rightPane = new GamePane(this, regularBlocks, hardBlocks, 430.0f, 30.0f); running = true; }
/// <summary> /// Internal helper for registering a new menu item. /// </summary> protected void AddMenuItem(int x1, int y1, int x2, int y2, MainMenuItem.TriggerDelegate trigger) { int width = x2 - x1; int height = y2 - y1; menuItems.Add(new MainMenuItem(trigger, menuTexture.Slice(x1, y1, width, height), 630 - width / 2, 310 + menuItems.Count * 60, width, height)); }
protected Texture[] CreateBlockTextures(Texture gameTexture) { List <Texture> blockTextures = new List <Texture>(); for (int row = 0; row < 2; row++) { for (int column = 0; column < 6; column++) { blockTextures.Add(gameTexture.Slice(5 + column * 40, 5 + row * 40, 34, 34)); } } return(blockTextures.ToArray()); }
protected Texture[] CreateBlockTextures(Texture gameTexture) { List<Texture> blockTextures = new List<Texture>(); for (int row = 0; row < 2; row++) for (int column = 0; column < 6; column++) blockTextures.Add(gameTexture.Slice(5 + column * 40, 5 + row * 40, 34, 34)); return blockTextures.ToArray(); }