icecream
icecream

Reputation: 155

How to match the width to the actual screen

enter image description here

How can I maximize the width of this program that I get on someone's tutorial.

here's the code:

protected void onSizeChanged(int w, int h, int oldw, int oldh) {
    width = (w < h)?w:h;
    height = width;         //for now square mazes
    lineWidth = 1;          //for now 1 pixel wide walls
    cellWidth = (width - ((float)mazeSizeX*lineWidth)) / mazeSizeX;
    totalCellWidth = cellWidth+lineWidth;
    cellHeight = (height - ((float)mazeSizeY*lineWidth)) / mazeSizeY;
    totalCellHeight = cellHeight+lineWidth;
    gold.setTextSize(cellHeight*0.75f);
    super.onSizeChanged(w, h, oldw, oldh);

any answers will be appreciated thanks !

Upvotes: 1

Views: 50

Answers (2)

icecream
icecream

Reputation: 155

I just got an answer to this one :)

//new value
    height = width+(width/2);

Upvotes: 1

kablu
kablu

Reputation: 669

You can try like this.

int width = GraphicsDevice.DisplayMode.Width;
int height = GraphicsDevice.DisplayMode.Height;
this.graphics.PreferredBackBufferWidth = width;
this.graphics.PreferredBackBufferHeight = height;
this.graphics.IsFullScreen = true;
this.graphics.ApplyChanges();

it is my given answer proved by question's man. thanks

Reference: Maximizing the width and height of the Screen.

Upvotes: 0

Related Questions